Aisha Posted August 16, 2017 Share Posted August 16, 2017 (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 August 16, 2017 by Aisha Quote Link to comment Share on other sites More sharing options...
1 Technoken Posted August 16, 2017 Share Posted August 16, 2017 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; 1 Quote Link to comment Share on other sites More sharing options...
0 Aisha Posted August 16, 2017 Author Share Posted August 16, 2017 Hi, can you tell me where you manage to get this variable? .GID = [email protected][0]; Thank you for your reply. Quote Link to comment Share on other sites More sharing options...
0 Technoken Posted August 16, 2017 Share Posted August 16, 2017 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 Quote Link to comment Share on other sites More sharing options...
0 Aisha Posted August 16, 2017 Author Share Posted August 16, 2017 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? Quote Link to comment Share on other sites More sharing options...
0 Emistry Posted August 17, 2017 Share Posted August 17, 2017 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. Quote Link to comment Share on other sites More sharing options...
0 Aisha Posted August 17, 2017 Author Share Posted August 17, 2017 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? Quote Link to comment Share on other sites More sharing options...
0 ToiletMaster Posted August 19, 2017 Share Posted August 19, 2017 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 Quote Link to comment Share on other sites More sharing options...
0 Aisha Posted August 21, 2017 Author Share Posted August 21, 2017 Thanks, I found a more efficient way of doing it. Thanks for the reply. Quote Link to comment Share on other sites More sharing options...
0 Moooooon-Aisha Posted September 9, 2017 Share Posted September 9, 2017 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+"]"); } Quote Link to comment Share on other sites More sharing options...
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 AishaLink to comment
Share on other sites