Jump to content
  • 0

Mob HP - How to "save" current mob HP**


Aisha

Question


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   2
  • Joined:  06/27/17
  • Last Seen:  

I am trying to have a "max hp" of mob and "current hp" of mob, does anyone have any idea how to get current hp of mob?

I can only see getmonsterinfo but is not gonna work since it only look max hp

**Fixed "title" to be more informative

Edited by Aisha
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 1

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

You can try to use setunitdata and getunitdata.
 

monster "prontera",149,190,"Poring",1002,1;
.GID = $@mobid[0];
getunitdata .GID,.@por_arr;
unittalk .GID,"Max HP: "+.@por_arr[UMOB_MAXHP];
unittalk .GID,"Current HP: "+.@por_arr[UMOB_HP];
sleep 10000; // Try to do some damage after 10 seconds
getunitdata .GID,.@por_arr;
unittalk .GID,"Current HP: "+.@por_arr[UMOB_HP];
end;

 

  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   2
  • Joined:  06/27/17
  • Last Seen:  

Hi, can you tell me where you manage to get this variable?

.GID = $@mobid[0];

Thank you for your reply.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  505
  • Reputation:   126
  • Joined:  04/04/16
  • Last Seen:  

19 minutes ago, Aisha said:

Hi, can you tell me where you manage to get this variable?


.GID = $@mobid[0];

Thank you for your reply.

Quote

// - Keep in mind, when the 'monster' script command is used,
// - all the spawned monster GID's are stored in an array
// - called $@mobid[].

For more info you can check it here https://github.com/rathena/rathena/blob/master/doc/script_commands.txt#L7488-L7790

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   2
  • Joined:  06/27/17
  • Last Seen:  

Thanks, this is good enough, thank you. I will share the script I make out of this in a form of showcase soon.

 

As a follow up question. What is the most efficient way of checking mob HP. Would a timer suffice? Sleep perhaps? OnClock or something similar, or a do..while loop wherein the condition is if the mob is still alive?

For instance, I only wish to check the hp of the monster every 30 minutes, would a do-while loop be better, or would an OnClock/OnTimer be better?

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10015
  • Reputation:   2348
  • Joined:  10/28/11
  • Last Seen:  

18 hours ago, Aisha said:

For instance, I only wish to check the hp of the monster every 30 minutes, would a do-while loop be better, or would an OnClock/OnTimer be better?

OnTimer - if you want precision in interval time for checking....

OnClock are acceptable, but the interval time for checking aren't precise.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   2
  • Joined:  06/27/17
  • Last Seen:  

I was hoping to save the HP information every 30 minutes or maybe every hour as long as the monster is alive. So I think it is best to have OnClock then? Because I am not sure as to how initnpctimer and stopnpcimer works, it say "pause" the time, so if I stop at one time, and resume at the other, it will resume at the previous timer correct, not back to 0 time?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

On 8/17/2017 at 6:38 PM, Aisha said:

I was hoping to save the HP information every 30 minutes or maybe every hour as long as the monster is alive. So I think it is best to have OnClock then? Because I am not sure as to how initnpctimer and stopnpcimer works, it say "pause" the time, so if I stop at one time, and resume at the other, it will resume at the previous timer correct, not back to 0 time?

initnpctimer will set the timer back to 0

however if you stopnpctimer and then startnpctimer, it'll resume where it stopped

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   2
  • Joined:  06/27/17
  • Last Seen:  

Thanks, I found a more efficient way of doing it. Thanks for the reply.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  23
  • Topics Per Day:  0.01
  • Content Count:  116
  • Reputation:   18
  • Joined:  09/08/17
  • Last Seen:  

Trying this script. Somehow the mob is not registering the initial HP.

setunitdata .gid,UMOB_MAXHP,.hp;

I managed to make a previous script work, almost same as above using dynamic method, but the one above is not working properly

dynamic method: (old script)

	for(set .@i,0;.@i < .monster_count; .@i++){
		setarray .@GID[.@i],$@mobid[.@i];
		setunitdata .@GID[.@i],UMOB_MAXHP,getd(".mob_hp"+.rand+"["+.round+"]");
	}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...