Explorar el Código

Script level up events from atcommands

Based on @Emistry's pull request HerculesWS/Hercules#1396:
Added a configuration to enable the atcommands baselevel and joblevel to trigger their respective npc events.
This will help you guys with testing your custom scripts that are listening to OnPCBaseLvUpEvent or OnPCJobLvUpEvent.
For safety reasons we only trigger the events on level increase.
Lemongrass3110 hace 8 años
padre
commit
9157318ee9
Se han modificado 4 ficheros con 16 adiciones y 0 borrados
  1. 5 0
      conf/battle/gm.conf
  2. 9 0
      src/map/atcommand.c
  3. 1 0
      src/map/battle.c
  4. 1 0
      src/map/battle.h

+ 5 - 0
conf/battle/gm.conf

@@ -27,3 +27,8 @@ ban_hack_trade: 5
 // modifies @iteminfo to not display the minimum item drop rate (since it can't tell the mob level)
 // modifies @whodrops to display the users' real drop rate as per renewal_drop formula
 atcommand_mobinfo_type: 1
+
+// Should atcommands trigger level up events for NPCs? (Note 1)
+// This option is for @baselevelup and @joblevelup
+// Default: no
+atcommand_levelup_events: no

+ 9 - 0
src/map/atcommand.c

@@ -1435,6 +1435,7 @@ ACMD_FUNC(baselevelup)
 		sd->status.base_level -= (unsigned int)level;
 		clif_displaymessage(fd, msg_txt(sd,22)); // Base level lowered.
 		status_calc_pc(sd, SCO_FORCE);
+		level*=-1;
 	}
 	sd->status.base_exp = 0;
 	clif_updatestatus(sd, SP_STATUSPOINT);
@@ -1444,6 +1445,10 @@ ACMD_FUNC(baselevelup)
 	pc_baselevelchanged(sd);
 	if(sd->status.party_id)
 		party_send_levelup(sd);
+
+	if( level > 0 && battle_config.atcommand_levelup_events )
+		npc_script_event(sd,NPCE_BASELVUP);
+
 	return 0;
 }
 
@@ -1488,6 +1493,7 @@ ACMD_FUNC(joblevelup)
 		else
 			sd->status.skill_point -= level;
 		clif_displaymessage(fd, msg_txt(sd,25)); // Job level lowered.
+		level *=-1;
 	}
 	sd->status.job_exp = 0;
 	clif_updatestatus(sd, SP_JOBLEVEL);
@@ -1496,6 +1502,9 @@ ACMD_FUNC(joblevelup)
 	clif_updatestatus(sd, SP_SKILLPOINT);
 	status_calc_pc(sd, SCO_FORCE);
 
+	if( level > 0 && battle_config.atcommand_levelup_events )
+		npc_script_event(sd,NPCE_JOBLVUP);
+
 	return 0;
 }
 

+ 1 - 0
src/map/battle.c

@@ -8329,6 +8329,7 @@ static const struct _battle_data {
 	{ "exp_cost_inspiration",               &battle_config.exp_cost_inspiration,            1,      0,      100,            },
 	{ "mvp_exp_reward_message",             &battle_config.mvp_exp_reward_message,          0,      0,      1,              },
 	{ "can_damage_skill",                   &battle_config.can_damage_skill,                1,      0,      BL_ALL,         },
+	{ "atcommand_levelup_events",			&battle_config.atcommand_levelup_events,		0,		0,		1,				},
 
 #include "../custom/battle_config_init.inc"
 };

+ 1 - 0
src/map/battle.h

@@ -610,6 +610,7 @@ extern struct Battle_Config
 	int exp_cost_inspiration;
 	int mvp_exp_reward_message;
 	int can_damage_skill; //Which BL types can damage traps
+	int atcommand_levelup_events;
 
 #include "../custom/battle_config_struct.inc"
 } battle_config;