From 53b6e99c8d8e27bfb1d7d22ed32013005b4c7469 Mon Sep 17 00:00:00 2001 From: skotlex Date: Fri, 2 Jun 2006 02:51:34 +0000 Subject: - Altered status_calc_pc so that equipment scripts are ran before card-scripts. - Fixed pc_bonus to not underflow/overflow when adjusting def/mdef. - These two together, should fix Tao Gunka Card. - npc_debug_warps() will now be invoked if warp_point_debug is set. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@6925 54d463be-8e91-2dee-dedb-b68131a5f0ec --- Changelog-Trunk.txt | 7 +++ conf-tmpl/battle/misc.conf | 2 + src/map/npc.c | 4 +- src/map/pc.c | 20 ++++-- src/map/status.c | 151 ++++++++++++++++++++++----------------------- 5 files changed, 101 insertions(+), 83 deletions(-) diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index d997c0c43..41ec5cb4e 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -7,6 +7,13 @@ IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. * [Fixed] - Yet another compilation warning. [Lance] 2006/06/01 + * Altered status_calc_pc so that equipment scripts are ran before + card-scripts. [Skotlex] + * Fixed pc_bonus to not underflow/overflow when adjusting def/mdef. + [Skotlex] + - These two together, should fix Tao Gunka Card. + * npc_debug_warps() will now be invoked if warp_point_debug is set. + [Skotlex] * Updated item_db.sql/mob_db.sql to current. [Skotlex] * Fixed NPC_SELFDESTRUCTION not showing nor dealing damage. [Skotlex] * NPC_TRANSFORMATION/NPC_METAMORPHOSIS will now preserve the original mob diff --git a/conf-tmpl/battle/misc.conf b/conf-tmpl/battle/misc.conf index 2534f1ac8..eb21bfbbd 100644 --- a/conf-tmpl/battle/misc.conf +++ b/conf-tmpl/battle/misc.conf @@ -94,6 +94,8 @@ skill_sp_override_grffile: no cardillust_read_grffile: yes // Do you want to debug warp points? If set to yes, warp points will appear as flags.(Note 1) +// It will also run on start-up a warp-check to print out which warp points lead directly on +// top of on-touch npcs (which can lead to infinite loopback warping situations) warp_point_debug: no // Choose if server begin with night (yes) or day (no) diff --git a/src/map/npc.c b/src/map/npc.c index 9dc5d0357..870a94390 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -2934,8 +2934,8 @@ int do_init_npc(void) memset(script_event, 0, sizeof(script_event)); npc_read_event_script(); //Debug function to locate all endless loop warps. -// Warps debugging removed by request of Playtester. [Skotlex] -// npc_debug_warps(); + if (battle_config.warp_point_debug) + npc_debug_warps(); add_timer_func_list(npc_event_timer,"npc_event_timer"); add_timer_func_list(npc_event_do_clock,"npc_event_do_clock"); diff --git a/src/map/pc.c b/src/map/pc.c index 9c42dee1c..cca92aff5 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -1245,8 +1245,14 @@ int pc_bonus(struct map_session_data *sd,int type,int val) } break; case SP_DEF1: - if(sd->state.lr_flag != 2) - status->def+=val; + if(sd->state.lr_flag != 2) { + if (val < 0 && status->def < -val) + status->def = 0; + else if (val > 0 && val > UCHAR_MAX - status->def) + status->def = UCHAR_MAX; + else + status->def+=val; + } break; case SP_DEF2: if(sd->state.lr_flag != 2) @@ -1257,8 +1263,14 @@ int pc_bonus(struct map_session_data *sd,int type,int val) status->mdef+=val; break; case SP_MDEF2: - if(sd->state.lr_flag != 2) - status->mdef+=val; + if(sd->state.lr_flag != 2) { + if (val < 0 && status->mdef < -val) + status->mdef = 0; + else if (val > 0 && val > UCHAR_MAX - status->mdef) + status->mdef = UCHAR_MAX; + else + status->mdef+=val; + } break; case SP_HIT: if(sd->state.lr_flag != 2) diff --git a/src/map/status.c b/src/map/status.c index 89b1f0592..da8492bdc 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -1367,7 +1367,6 @@ int status_calc_pc(struct map_session_data* sd,int first) struct skill b_skill[MAX_SKILL]; int b_weight,b_max_weight; - int b_paramcard[6]; int i,index; int skill,refinedef=0; @@ -1551,73 +1550,7 @@ int status_calc_pc(struct map_session_data* sd,int first) + sizeof(sd->add_mdmg_count) ); - for(i=0;i<10;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] - if(index < 0) - continue; - if(i == 9 && sd->equip_index[8] == index) - continue; - if(i == 5 && sd->equip_index[4] == index) - continue; - if(i == 6 && (sd->equip_index[5] == index || sd->equip_index[4] == index)) - continue; - - if(sd->inventory_data[index]) { - int j,c; - struct item_data *data; - - //Card script execution. - if(sd->status.inventory[index].card[0]==0x00ff || - sd->status.inventory[index].card[0]==0x00fe || - sd->status.inventory[index].card[0]==(short)0xff00) - continue; - for(j=0;jinventory_data[index]->slot;j++){ - current_equip_card_id= c= sd->status.inventory[index].card[j]; - if(!c) - continue; - data = itemdb_exists(c); - if(!data) - continue; - if(first&1 && data->equip_script) - { //Execute equip-script on login - run_script(data->equip_script,0,sd->bl.id,0); - if (!calculating) - return 1; - } - if(!data->script) - continue; - if(data->flag.no_equip) { //Card restriction checks. - if(map[sd->bl.m].flag.restricted && data->flag.no_equip&map[sd->bl.m].zone) - continue; - if(map[sd->bl.m].flag.pvp && data->flag.no_equip&1) - continue; - if(map_flag_gvg(sd->bl.m) && data->flag.no_equip&2) - continue; - } - if(i == 8 && sd->status.inventory[index].equip == 0x20) - { //Left hand status. - sd->state.lr_flag = 1; - run_script(data->script,0,sd->bl.id,0); - sd->state.lr_flag = 0; - } else - run_script(data->script,0,sd->bl.id,0); - if (!calculating) //Abort, run_script his function. [Skotlex] - return 1; - } - } - } - - if(sd->status.pet_id > 0 && battle_config.pet_status_support && sd->pet.intimate > 0) - { // Pet - struct pet_data *pd=sd->pd; - if(pd && (!battle_config.pet_equip_required || pd->equip > 0) && - pd->state.skillbonus == 1 && pd->bonus) //Skotlex: Readjusted for pets - pc_bonus(sd,pd->bonus->type, pd->bonus->val); - } - memcpy(b_paramcard,sd->param_bonus,sizeof(b_paramcard)); - memset(sd->param_bonus, 0, sizeof(sd->param_bonus)); - - // ?備品によるステ?タス?化はここで?行 + // Parse equipment. for(i=0;i<10;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] if(index < 0) @@ -1704,12 +1637,76 @@ int status_calc_pc(struct map_session_data* sd,int first) //Store equipment script bonuses memcpy(sd->param_equip,sd->param_bonus,sizeof(sd->param_equip)); - //We store card bonuses here because Improve Concentration is the only SC - //that will not take it into consideration when buffing you up. - memcpy(sd->param_bonus, b_paramcard, sizeof(sd->param_bonus)); + memset(sd->param_bonus, 0, sizeof(sd->param_bonus)); status->def += (refinedef+50)/100; + //Parse Cards + for(i=0;i<10;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] + if(index < 0) + continue; + if(i == 9 && sd->equip_index[8] == index) + continue; + if(i == 5 && sd->equip_index[4] == index) + continue; + if(i == 6 && (sd->equip_index[5] == index || sd->equip_index[4] == index)) + continue; + + if(sd->inventory_data[index]) { + int j,c; + struct item_data *data; + + //Card script execution. + if(sd->status.inventory[index].card[0]==0x00ff || + sd->status.inventory[index].card[0]==0x00fe || + sd->status.inventory[index].card[0]==(short)0xff00) + continue; + for(j=0;jinventory_data[index]->slot;j++){ + current_equip_card_id= c= sd->status.inventory[index].card[j]; + if(!c) + continue; + data = itemdb_exists(c); + if(!data) + continue; + if(first&1 && data->equip_script) + { //Execute equip-script on login + run_script(data->equip_script,0,sd->bl.id,0); + if (!calculating) + return 1; + } + if(!data->script) + continue; + if(data->flag.no_equip) { //Card restriction checks. + if(map[sd->bl.m].flag.restricted && data->flag.no_equip&map[sd->bl.m].zone) + continue; + if(map[sd->bl.m].flag.pvp && data->flag.no_equip&1) + continue; + if(map_flag_gvg(sd->bl.m) && data->flag.no_equip&2) + continue; + } + if(i == 8 && sd->status.inventory[index].equip == 0x20) + { //Left hand status. + sd->state.lr_flag = 1; + run_script(data->script,0,sd->bl.id,0); + sd->state.lr_flag = 0; + } else + run_script(data->script,0,sd->bl.id,0); + if (!calculating) //Abort, run_script his function. [Skotlex] + return 1; + } + } + } + + if(sd->status.pet_id > 0 && battle_config.pet_status_support && sd->pet.intimate > 0) + { // Pet + struct pet_data *pd=sd->pd; + if(pd && (!battle_config.pet_equip_required || pd->equip > 0) && + pd->state.skillbonus == 1 && pd->bonus) //Skotlex: Readjusted for pets + pc_bonus(sd,pd->bonus->type, pd->bonus->val); + } + //param_bonus now holds card bonuses. + if(status->rhw.range < 1) status->rhw.range = 1; if(status->lhw->range < 1) status->lhw->range = 1; if(status->rhw.range < status->lhw->range) @@ -1778,17 +1775,17 @@ int status_calc_pc(struct map_session_data* sd,int first) status->dex += skill; // Bonuses from cards and equipment as well as base stat, remember to avoid overflows. - i = status->str + sd->status.str + b_paramcard[0] + sd->param_equip[0]; + i = status->str + sd->status.str + sd->param_bonus[0] + sd->param_equip[0]; status->str = i<0?0:(i>USHRT_MAX?USHRT_MAX:i); - i = status->agi + sd->status.agi + b_paramcard[1] + sd->param_equip[1]; + i = status->agi + sd->status.agi + sd->param_bonus[1] + sd->param_equip[1]; status->agi = i<0?0:(i>USHRT_MAX?USHRT_MAX:i); - i = status->vit + sd->status.vit + b_paramcard[2] + sd->param_equip[2]; + i = status->vit + sd->status.vit + sd->param_bonus[2] + sd->param_equip[2]; status->vit = i<0?0:(i>USHRT_MAX?USHRT_MAX:i); - i = status->int_+ sd->status.int_+ b_paramcard[3] + sd->param_equip[3]; + i = status->int_+ sd->status.int_+ sd->param_bonus[3] + sd->param_equip[3]; status->int_ = i<0?0:(i>USHRT_MAX?USHRT_MAX:i); - i = status->dex + sd->status.dex + b_paramcard[4] + sd->param_equip[4]; + i = status->dex + sd->status.dex + sd->param_bonus[4] + sd->param_equip[4]; status->dex = i<0?0:(i>USHRT_MAX?USHRT_MAX:i); - i = status->luk + sd->status.luk + b_paramcard[5] + sd->param_equip[5]; + i = status->luk + sd->status.luk + sd->param_bonus[5] + sd->param_equip[5]; status->luk = i<0?0:(i>USHRT_MAX?USHRT_MAX:i); // ------ BASE ATTACK CALCULATION ------ -- cgit v1.2.3-70-g09d2