honestly, status_calc_pc should have split into multiple functions ...
if we have follow the
Linux Kernel Coding Style
in my opinion, status_calc_pc_additional function shouldn't even exist ...
parse equipment, should has its own function, parse card, its own function
so we can just post-hook to that function, instead of having a function doing nothing out in the middle of it =/
ok let me try code this
bAddMaxWeight, that has been in our repo and turn it as a plugin
#include "common/hercules.h"#include <stdio.h>#include <stdlib.h>#include <string.h>#include "map/pc.h"#include "map/map.h"#include "common/nullpo.h"#include "common/HPMDataCheck.h"HPExport struct hplugin_info pinfo = { "baddweight", SERVER_TYPE_MAP, ">.<", HPM_VERSION,};int SP_ADDWEIGHT = 0;int pc_bonus_pre( struct map_session_data *sd, int *type, int *val ) { nullpo_ret(sd); if ( *type == SP_ADDWEIGHT ) { if ( sd->state.lr_flag != 2 ) { sd->max_weight += *val; hookStop(); } } return 0;}HPExport void plugin_init (void) { SP_ADDWEIGHT = map->get_new_bonus_id(); script->set_constant( "baddweight", SP_ADDWEIGHT, false ); addHookPre( "pc->bonus", pc_bonus_pre );}
Code:
- script dfbskfh -1,{OnPCStatCalcEvent: bonus baddweight, 10000000;}
hmmm ... totally possible,I just noticed there is a map->get_new_bonus_id() in our repo, somebody must have use this stuff before already
so don't have to add whatever function anymore
.
.
and for the topic,
I rather say there are 2 problems with it
1. bonus bAddMaxWaight, 1000;
I think the bonus command, the 1st field should always be a constant
this kind of typo makes the script engine read the bAddMaxWaight as a player variable
and currently our script engine 'i' type cannot differentiate integer, constant or player variable
maybe we can add a 'c' type, to enforce a check that field only accept constant
BUILDIN_DEF(bonus,"cv"),however, this is still a run-time check, our script engine still suxbut the script->report_data function will able to print the variable name out
I can pull request this soon
2. and to actually having to print where the error come from, item ? pet ? combo ?
perhaps the run_script function should have an optional field 'flag' and 'line',
so the 'pc_bonus' and 'status_change_start' function can tell where the error come from
this kind of stuffs should be done in the new script engine update though
I kinda lost interest in this, better left this to Haru