xJhay Posted September 20, 2020 Posted September 20, 2020 Hello Rathena, I needed some help about adding a timer for dead/bloody branch. If the mob doesn't been hit for 5mins after spawning, they were automatically die without loot (like @killmonster2). Quote
0 AnnieRuru Posted September 22, 2020 Posted September 22, 2020 can only be done with source edits src/map/mob.cpp | 9 +++++++++ src/map/mob.hpp | 1 + src/map/unit.cpp | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 3e0b54f37..686c30ac1 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -708,6 +708,15 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const //"I understand the "Aggressive" part, but the "Can Move" and "Can Attack" is just stupid" - Poki#3 sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE|MD_CANATTACK|MD_CANMOVE|MD_ANGRY, 0, 60000); } + + if (md != NULL) { + if (mob_id < 0) { + md->special_state.deadbranch = 1; + md->deletetimer = add_timer(gettick()+5000,mob_timer_delete,md->bl.id,0); + } + else + md->special_state.deadbranch = 0; + } return (md) ? md->bl.id : 0; // id of last spawned mob } diff --git a/src/map/mob.hpp b/src/map/mob.hpp index 5b47b8c6f..37921599c 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -189,6 +189,7 @@ struct mob_data { unsigned int size : 2; //Small/Big monsters. enum mob_ai ai; //Special ai for summoned monsters. unsigned int clone : 1;/* is clone? 1:0 */ + unsigned int deadbranch : 1; /* summon from branch */ } special_state; //Special mob information that does not needs to be zero'ed on mob respawn. struct s_MobState { unsigned int aggressive : 1; //Signals whether the mob AI is in aggressive mode or reactive mode. [Skotlex] diff --git a/src/map/unit.cpp b/src/map/unit.cpp index 15632f201..b42668a1d 100644 --- a/src/map/unit.cpp +++ b/src/map/unit.cpp @@ -2420,6 +2420,17 @@ int unit_attack(struct block_list *src,int target_id,int continuous) if(ud->attacktimer != INVALID_TIMER) return 0; + if (target_id != 0) { + struct block_list *target_bl = map_id2bl(target_id); + if (target_bl->type == BL_MOB) { + struct mob_data *md = map_id2md(target_id); + if (md->special_state.deadbranch == 1 && md->deletetimer != INVALID_TIMER) { + delete_timer(md->deletetimer, mob_timer_delete); + md->deletetimer = add_timer(gettick() + 5000, mob_timer_delete, md->bl.id, 0); + } + } + } + // New action request received, delete previous action request if not executed yet if(ud->stepaction || ud->steptimer != INVALID_TIMER) unit_stop_stepaction(src); I tested with 5000 = 5 seconds, change them into 60000 2 Quote
1 AnnieRuru Posted October 4, 2020 Posted October 4, 2020 (edited) hmm, it seems unit_attack function only trigger when 1st click on the monster if do a continues attack (/nc) it doesn't reset the timer try battle_check_target thenhttps://github.com/AnnieRuru/Release/blob/master/plugins/deadbranch_timerdelete/deadbranch_timerdelete_0.2.diff @Bringer Edit for below -> @Bringer I've made the script according to the request of the topic starter, and has been mark solved what you want is If the mob doesn't been hit OR didn't attack a player for 5mins you are requesting additional feature, you should open a new topic in fact this message is consider backseat moderating, and I should get a warning =/ Edited October 5, 2020 by AnnieRuru 1 Quote
0 Bringer Posted October 4, 2020 Posted October 4, 2020 On 9/23/2020 at 1:58 AM, AnnieRuru said: can only be done with source edits src/map/mob.cpp | 9 +++++++++ src/map/mob.hpp | 1 + src/map/unit.cpp | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/map/mob.cpp b/src/map/mob.cpp index 3e0b54f37..686c30ac1 100644 --- a/src/map/mob.cpp +++ b/src/map/mob.cpp @@ -708,6 +708,15 @@ int mob_once_spawn(struct map_session_data* sd, int16 m, int16 x, int16 y, const //"I understand the "Aggressive" part, but the "Can Move" and "Can Attack" is just stupid" - Poki#3 sc_start4(NULL,&md->bl, SC_MODECHANGE, 100, 1, 0, MD_AGGRESSIVE|MD_CANATTACK|MD_CANMOVE|MD_ANGRY, 0, 60000); } + + if (md != NULL) { + if (mob_id < 0) { + md->special_state.deadbranch = 1; + md->deletetimer = add_timer(gettick()+5000,mob_timer_delete,md->bl.id,0); + } + else + md->special_state.deadbranch = 0; + } return (md) ? md->bl.id : 0; // id of last spawned mob } diff --git a/src/map/mob.hpp b/src/map/mob.hpp index 5b47b8c6f..37921599c 100644 --- a/src/map/mob.hpp +++ b/src/map/mob.hpp @@ -189,6 +189,7 @@ struct mob_data { unsigned int size : 2; //Small/Big monsters. enum mob_ai ai; //Special ai for summoned monsters. unsigned int clone : 1;/* is clone? 1:0 */ + unsigned int deadbranch : 1; /* summon from branch */ } special_state; //Special mob information that does not needs to be zero'ed on mob respawn. struct s_MobState { unsigned int aggressive : 1; //Signals whether the mob AI is in aggressive mode or reactive mode. [Skotlex] diff --git a/src/map/unit.cpp b/src/map/unit.cpp index 15632f201..b42668a1d 100644 --- a/src/map/unit.cpp +++ b/src/map/unit.cpp @@ -2420,6 +2420,17 @@ int unit_attack(struct block_list *src,int target_id,int continuous) if(ud->attacktimer != INVALID_TIMER) return 0; + if (target_id != 0) { + struct block_list *target_bl = map_id2bl(target_id); + if (target_bl->type == BL_MOB) { + struct mob_data *md = map_id2md(target_id); + if (md->special_state.deadbranch == 1 && md->deletetimer != INVALID_TIMER) { + delete_timer(md->deletetimer, mob_timer_delete); + md->deletetimer = add_timer(gettick() + 5000, mob_timer_delete, md->bl.id, 0); + } + } + } + // New action request received, delete previous action request if not executed yet if(ud->stepaction || ud->steptimer != INVALID_TIMER) unit_stop_stepaction(src); I tested with 5000 = 5 seconds, change them into 60000 i test it but even the monster got hit they gone / teleport 1 Quote
0 Bringer Posted October 5, 2020 Posted October 5, 2020 (edited) @AnnieRuru even the monster attack you still monster deleted Edited October 5, 2020 by Bringer Quote
Question
xJhay
Hello Rathena, I needed some help about adding a timer for dead/bloody branch. If the mob doesn't been hit for 5mins after spawning, they were automatically die without loot (like @killmonster2).
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.