Skip to content

Commit

Permalink
Script level up events from atcommands
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Lemongrass3110 committed Aug 12, 2016
1 parent f560da8 commit 9157318
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions conf/battle/gm.conf
Expand Up @@ -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 changes: 9 additions & 0 deletions src/map/atcommand.c
Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down Expand Up @@ -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);
Expand All @@ -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;
}

Expand Down
1 change: 1 addition & 0 deletions src/map/battle.c
Expand Up @@ -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"
};
Expand Down
1 change: 1 addition & 0 deletions src/map/battle.h
Expand Up @@ -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;
Expand Down

0 comments on commit 9157318

Please sign in to comment.