Skip to content

Commit

Permalink
Added 'OnPCStatCalcEvent' trigger. (tid:77230, credits: @QQfoolsorell…
Browse files Browse the repository at this point in the history
…ina, 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>
  • Loading branch information
euphyy committed Feb 15, 2014
1 parent f3777cc commit 27a0f3f
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
13 changes: 10 additions & 3 deletions doc/script_commands.txt
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions src/map/npc.c
Expand Up @@ -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++)
Expand Down
1 change: 1 addition & 0 deletions src/map/npc.h
Expand Up @@ -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_);
Expand Down
1 change: 1 addition & 0 deletions src/map/script.c
Expand Up @@ -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)
};
Expand Down
1 change: 1 addition & 0 deletions src/map/script.h
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/map/status.c
Expand Up @@ -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]
Expand Down

0 comments on commit 27a0f3f

Please sign in to comment.