Jump to content
  • 0
Aisha

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

Question

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

You can try to use setunitdata and getunitdata.
 

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

 

  • MVP 1
Link to comment
Share on other sites

  • 0
19 minutes ago, Aisha said:

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

.GID = [email protected][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 [email protected][].

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

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
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

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
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

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 [email protected],0;[email protected] < .monster_count; [email protected]++){
		setarray [email protected][[email protected]],[email protected][[email protected]];
		setunitdata [email protected][[email protected]],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...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.