Jump to content
  • 0

Dead/Bloody Branch Timer


xJhay

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.01
  • Content Count:  38
  • Reputation:   0
  • Joined:  11/22/16
  • Last Seen:  

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

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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

  • Upvote 2
Link to comment
Share on other sites

  • 1

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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 then
https://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 by AnnieRuru
  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  737
  • Reputation:   47
  • Joined:  03/12/14
  • Last Seen:  

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

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  162
  • Topics Per Day:  0.04
  • Content Count:  737
  • Reputation:   47
  • Joined:  03/12/14
  • Last Seen:  

@AnnieRuru even the monster attack you still monster deleted
 

 

Edited by Bringer
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...