Jump to content
  • 0

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


Question

Posted (edited)

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

9 answers to this question

Recommended Posts

  • 1
Posted

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
  • 0
Posted
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

  • 0
Posted

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?

  • 0
Posted
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.

  • 0
Posted

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?

  • 0
Posted
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

  • 0
Posted

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+"]");
	}

 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...