Browse Source

Added 'OnPCStatCalcEvent' trigger. (tid:77230, credits: @QQfoolsorellina, AnnieRuru)
This label triggers whenever a player's stats are recalculated.
http://rathena.org/board/topic/77230-onpcstatcalcevent/

Signed-off-by: Euphy <euphy.raliel@rathena.org>

Euphy 11 years ago
parent
commit
27a0f3f88e
6 changed files with 16 additions and 3 deletions
  1. 10 3
      doc/script_commands.txt
  2. 1 0
      src/map/npc.c
  3. 1 0
      src/map/npc.h
  4. 1 0
      src/map/script.c
  5. 1 0
      src/map/script.h
  6. 2 0
      src/map/status.c

+ 10 - 3
doc/script_commands.txt

@@ -3,7 +3,7 @@
 //===== By: ==================================================
 //= rAthena Dev Team
 //===== Last Updated: ========================================
-//= 20140211
+//= 20140215
 //===== Description: =========================================
 //= A reference manual for the rAthena scripting language.
 //= Commands are sorted depending on their functionality.
@@ -945,12 +945,19 @@ This special label triggers when a player kills a monster. The variable
 
 OnPCLoadMapEvent:
 
-This special label will trigger once a player steps in a map marked with the 
-'loadevent' mapflag and attach its RID. The fact that this label requires a 
+This special label triggers when a player steps in a map marked with the 
+'loadevent' mapflag and attaches its RID. The fact that this label requires a 
 mapflag for it to work is because, otherwise, it'd be server-wide and trigger
 every time a player would change maps. Imagine the server load with 1,000 players
 (oh the pain...)
 
+OnPCStatCalcEvent:
+
+This special label triggers when a player's stats are recalculated, such as when
+changing stats, equipment, or maps, as well as when logging in, leveling up, and
+mounting a job mount. This can be used to grant additional item bonuses to certain
+player groups, for instance.
+
 Only the special labels which are not associated with any script command are 
 listed here. There are other kinds of labels which may be triggered in a similar 
 manner, but they are described with their associated commands.

+ 1 - 0
src/map/npc.c

@@ -3946,6 +3946,7 @@ void npc_read_event_script(void)
 		{"Die Event",script_config.die_event_name},
 		{"Kill PC Event",script_config.kill_pc_event_name},
 		{"Kill NPC Event",script_config.kill_mob_event_name},
+		{"Stat Calc Event",script_config.stat_calc_event_name},
 	};
 
 	for (i = 0; i < NPCE_MAX; i++)

+ 1 - 0
src/map/npc.h

@@ -112,6 +112,7 @@ enum npce_event {
 	NPCE_DIE,
 	NPCE_KILLPC,
 	NPCE_KILLNPC,
+	NPCE_STATCALC,
 	NPCE_MAX
 };
 struct view_data* npc_get_viewdata(int class_);

+ 1 - 0
src/map/script.c

@@ -256,6 +256,7 @@ struct Script_Config script_config = {
 	"OnPCLoadMapEvent", //loadmap_event_name
 	"OnPCBaseLvUpEvent", //baselvup_event_name
 	"OnPCJobLvUpEvent", //joblvup_event_name
+	"OnPCStatCalcEvent", //stat_calc_event_name
 	"OnTouch_",	//ontouch_name (runs on first visible char to enter area, picks another char if the first char leaves)
 	"OnTouch",	//ontouch2_name (run whenever a char walks into the OnTouch area)
 };

+ 1 - 0
src/map/script.h

@@ -28,6 +28,7 @@ extern struct Script_Config {
 	const char *loadmap_event_name;
 	const char *baselvup_event_name;
 	const char *joblvup_event_name;
+	const char *stat_calc_event_name;
 
 	const char* ontouch_name;
 	const char* ontouch2_name;

+ 2 - 0
src/map/status.c

@@ -2852,6 +2852,8 @@ int status_calc_pc_(struct map_session_data* sd, bool first)
 	pc_delautobonus(sd,sd->autobonus2,ARRAYLENGTH(sd->autobonus2),true);
 	pc_delautobonus(sd,sd->autobonus3,ARRAYLENGTH(sd->autobonus3),true);
 
+	npc_script_event(sd, NPCE_STATCALC);
+
 	// Parse equipment
 	for(i=0;i<EQI_MAX;i++) {
 		current_equip_item_index = index = sd->equip_index[i]; // We pass INDEX to current_equip_item_index - for EQUIP_SCRIPT (new cards solution) [Lupus]