diff options
Diffstat (limited to 'src/map/status.c')
-rw-r--r-- | src/map/status.c | 92 |
1 files changed, 51 insertions, 41 deletions
diff --git a/src/map/status.c b/src/map/status.c index 5d1b92a51..746ca51e2 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -6311,9 +6311,12 @@ void status_change_init(struct block_list *bl) { memset(sc, 0, sizeof (struct status_change)); } -//Applies SC defense to a given status change. -//Returns the adjusted duration based on flag values. -//the flag values are the same as in status->change_start. +/** + * Applies SC defense to a given status change. + * + * @see status_change_start for the expected parameters. + * @return the adjusted duration based on flag values. + */ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int tick, int flag) { //Percentual resistance: 10000 = 100% Resist //Example: 50% -> sc_def=5000 -> 25%; 5000ms -> tick_def=5000 -> 2500ms @@ -6606,7 +6609,7 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ tick_def = sc_def; //Natural resistance - if (!(flag&8)) { + if (!(flag&SCFLAG_FIXEDRATE)) { rate -= rate*sc_def/10000; rate -= sc_def2; @@ -6640,7 +6643,7 @@ int status_get_sc_def(struct block_list *src, struct block_list *bl, enum sc_typ if (tick < 1) return 1; //Rate reduction - if (flag&2) + if (flag&SCFLAG_FIXEDTICK) return tick; tick -= tick*tick_def/10000; @@ -6727,18 +6730,23 @@ void status_display_remove(struct map_session_data *sd, enum sc_type type) { } } } -/*========================================== -* Starts a status change. -* 'type' = type, 'val1~4' depend on the type. -* 'rate' = base success rate. 10000 = 100% -* 'tick' is base duration -* 'flag': -* &1 : Cannot be avoided (it has to start) -* &2 : Tick should not be reduced (by vit, luk, lv, etc) -* &4 : sc_data loaded, no value has to be altered. -* &8 : rate should not be reduced (not evaluated here, but in some calls to other functions) -* &16: Status icon (SI) should not be send -*------------------------------------------*/ +/** + * Starts a status change. + * + * @param src Status change source bl. + * @param bl Status change target bl. + * @param type Status change type. + * @param rate Base success rate. 1 means 0.01%, 10000 means 100%. + * @param val1 Additional value (meaning depends on type). + * @param val2 Additional value (meaning depends on type). + * @param val3 Additional value (meaning depends on type). + * @param val4 Additional value (meaning depends on type). + * @param tick Base duration (milliseconds). + * @param flag Special flags (@see enum scstart_flag). + * + * @retval 0 if no status change happened. + * @retval 1 if the status change was successfully applied. + */ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_type type, int rate, int val1, int val2, int val3, int val4, int tick, int flag) { struct map_session_data *sd = NULL; struct status_change* sc; @@ -6841,7 +6849,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t sd = BL_CAST(BL_PC, bl); //Adjust tick according to status resistances - if( !(flag&(1|4)) ) { + if( !(flag&(SCFLAG_NOAVOID|SCFLAG_LOADED)) ) { tick = status->get_sc_def(src, bl, type, rate, tick, flag); if( !tick ) return 0; } @@ -6871,7 +6879,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t return 0; case SC_FREEZE: //Undead are immune to Freeze/Stone - if (undead_flag && !(flag&1)) + if (undead_flag && !(flag&SCFLAG_NOAVOID)) return 0; case SC_SLEEP: case SC_STUN: @@ -6980,7 +6988,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t break; //Strip skills, need to divest something or it fails. case SC_NOEQUIPWEAPON: - if (sd && !(flag&4)) { //apply sc anyway if loading saved sc_data + if (sd && !(flag&SCFLAG_LOADED)) { //apply sc anyway if loading saved sc_data int i; opt_flag = 0; //Reuse to check success condition. if(sd->bonus.unstripable_equip&EQP_WEAPON) @@ -6998,7 +7006,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t case SC_NOEQUIPSHIELD: if( val2 == 1 ) val2 = 0; //GX effect. Do not take shield off.. else - if (sd && !(flag&4)) { + if (sd && !(flag&SCFLAG_LOADED)) { int i; if(sd->bonus.unstripable_equip&EQP_SHIELD) return 0; @@ -7010,7 +7018,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC break; case SC_NOEQUIPARMOR: - if (sd && !(flag&4)) { + if (sd && !(flag&SCFLAG_LOADED)) { int i; if(sd->bonus.unstripable_equip&EQP_ARMOR) return 0; @@ -7022,7 +7030,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t if (tick == 1) return 1; //Minimal duration: Only strip without causing the SC break; case SC_NOEQUIPHELM: - if (sd && !(flag&4)) { + if (sd && !(flag&SCFLAG_LOADED)) { int i; if(sd->bonus.unstripable_equip&EQP_HELM) return 0; @@ -7135,7 +7143,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t } //Check for BOSS resistances - if(st->mode&MD_BOSS && !(flag&1)) { + if(st->mode&MD_BOSS && !(flag&SCFLAG_NOAVOID)) { if (type>=SC_COMMON_MIN && type <= SC_COMMON_MAX) return 0; switch (type) { @@ -7533,7 +7541,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t vd = status->get_viewdata(bl); calc_flag = status->ChangeFlagTable[type]; - if(!(flag&4)) { //&4 - Do not parse val settings when loading SCs + if(!(flag&SCFLAG_LOADED)) { // Do not parse val settings when loading SCs switch(type) { case SC_ADORAMUS: sc_start(src,bl,SC_BLIND,100,val1,skill->get_time(status->sc2skill(type),val1)); @@ -7544,16 +7552,16 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t break; case SC_ENDURE: val2 = 7; // Hit-count [Celest] - if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground && !val4 ) { + if( !(flag&SCFLAG_NOAVOID) && (bl->type&(BL_PC|BL_MER)) && !map_flag_gvg(bl->m) && !map->list[bl->m].flag.battleground && !val4 ) { struct map_session_data *tsd; if( sd ) { int i; for( i = 0; i < 5; i++ ) { if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) - status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, 17); + status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, SCFLAG_ALL); } } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) - status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, 17); + status->change_start(bl, &tsd->bl, type, 10000, val1, val2, val3, val4, tick, SCFLAG_ALL); } //val4 signals infinite endure (if val4 == 2 it is infinite endure from Berserk) if( val4 ) @@ -7641,16 +7649,16 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t break; case SC_REFLECTSHIELD: val2=10+val1*3; // %Dmg reflected - if( !(flag&1) && (bl->type&(BL_PC|BL_MER)) ) { + if( !(flag&SCFLAG_NOAVOID) && (bl->type&(BL_PC|BL_MER)) ) { struct map_session_data *tsd; if( sd ) { int i; for( i = 0; i < 5; i++ ) { if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) - status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 17); + status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL); } } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) - status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 17); + status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL); } break; case SC_NOEQUIPWEAPON: @@ -7893,7 +7901,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t break; case SC_AUTOGUARD: - if( !(flag&1) ) { + if( !(flag&SCFLAG_NOAVOID) ) { struct map_session_data *tsd; int i,t; for( i = val2 = 0; i < val1; i++) { @@ -7905,17 +7913,17 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t if( sd ) { for( i = 0; i < 5; i++ ) { if( sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i])) ) - status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 17); + status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL); } } else if( bl->type == BL_MER && ((TBL_MER*)bl)->devotion_flag && (tsd = ((TBL_MER*)bl)->master) ) - status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, 17); + status->change_start(bl, &tsd->bl, type, 10000, val1, val2, 0, 0, tick, SCFLAG_ALL); } } break; case SC_DEFENDER: - if (!(flag&1)) { + if (!(flag&SCFLAG_NOAVOID)) { val2 = 5 + 15*val1; //Damage reduction val3 = 0; // unused, previously speed adjustment val4 = 250 - 50*val1; //Aspd adjustment @@ -7926,7 +7934,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t for (i = 0; i < 5; i++) { //See if there are devoted characters, and pass the status to them. [Skotlex] if (sd->devotion[i] && (tsd = map->id2sd(sd->devotion[i]))) - status->change_start(bl, &tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,1); + status->change_start(bl, &tsd->bl,type,10000,val1,5+val1*5,val3,val4,tick,SCFLAG_NOAVOID); } } } @@ -8053,7 +8061,9 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t while( i >= 0 ) { type2 = types[i]; if( d_sc->data[type2] ) - status->change_start(bl, bl, type2, 10000, d_sc->data[type2]->val1, 0, 0, 0, skill->get_time(status->sc2skill(type2),d_sc->data[type2]->val1), (type2 != SC_DEFENDER) ? 16 : 0); + status->change_start(bl, bl, type2, 10000, d_sc->data[type2]->val1, 0, 0, 0, + skill->get_time(status->sc2skill(type2),d_sc->data[type2]->val1), + (type2 != SC_DEFENDER) ? SCFLAG_NOICON : SCFLAG_NONE); i--; } } @@ -8452,7 +8462,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t tick_time = 4000; // [GodLesZ] tick time break; case SC_PYREXIA: - status->change_start(src, bl,SC_BLIND,10000,val1,0,0,0,30000,11); // Blind status that last for 30 seconds + status->change_start(src, bl,SC_BLIND,10000,val1,0,0,0,30000,SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); // Blind status that last for 30 seconds val4 = tick / 3000; tick_time = 3000; // [GodLesZ] tick time break; @@ -9050,7 +9060,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t } } - /* values that must be set regardless of flag&4 e.g. val_flag */ + /* values that must be set regardless of SCFLAG_LOADED e.g. val_flag */ switch(type) { case SC_FIGHTINGSPIRIT: val_flag |= 1|2; @@ -9462,7 +9472,7 @@ int status_change_start(struct block_list *src, struct block_list *bl, enum sc_t calc_flag&=~SCB_DYE; } - if(!(flag&16) && !(flag&4 && status->DisplayType[type])) + if(!(flag&SCFLAG_NOICON) && !(flag&SCFLAG_LOADED && status->DisplayType[type])) clif->status_change(bl,status->IconChangeTable[type],1,tick,(val_flag&1)?val1:1,(val_flag&2)?val2:0,(val_flag&4)?val3:0); /** @@ -11655,7 +11665,7 @@ int status_change_spread( struct block_list *src, struct block_list *bl ) { data.val2 = sc->data[i]->val2; data.val3 = sc->data[i]->val3; data.val4 = sc->data[i]->val4; - status->change_start(src,bl,(sc_type)i,10000,data.val1,data.val2,data.val3,data.val4,data.tick,1|2|8); + status->change_start(src,bl,(sc_type)i,10000,data.val1,data.val2,data.val3,data.val4,data.tick,SCFLAG_NOAVOID|SCFLAG_FIXEDTICK|SCFLAG_FIXEDRATE); flag = 1; } } |