diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/mob.c | 35 | ||||
-rw-r--r-- | src/map/status.c | 12 | ||||
-rw-r--r-- | src/map/status.h | 2 |
3 files changed, 35 insertions, 14 deletions
diff --git a/src/map/mob.c b/src/map/mob.c index 87b4377ef..f03b9ac9d 100644 --- a/src/map/mob.c +++ b/src/map/mob.c @@ -498,11 +498,28 @@ int mob_once_spawn_area(struct map_session_data* sd,int m,int x0,int y0,int x1,i /*========================================== * Barricades [Zephyrus] *------------------------------------------*/ +void mob_barricade_nextxy(short x, short y, short dir, int pos, short *x1, short *y1) +{ // Calculates Next X-Y Position + if( dir == 0 || dir == 4 ) + *x1 = x; // Keep X + else if( dir > 0 && dir < 4 ) + *x1 = x - pos; // Going left + else + *x1 = x + pos; // Going right + + if( dir == 2 || dir == 6 ) + *y1 = y; + else if( dir > 2 && dir < 6 ) + *y1 = y - pos; + else + *y1 = y + pos; +} + short mob_barricade_build(short m, short x, short y, short count, short dir, bool killable, const char* event) { int i, j; - short x1 = dir ? x + count - 1 : x; - short y1 = dir ? y : y + count - 1; + short x1; + short y1; struct mob_data *md; struct barricade_data *barricade; @@ -531,8 +548,7 @@ short mob_barricade_build(short m, short x, short y, short count, short dir, boo for( i = 0; i < count; i++ ) { - x1 = dir ? x + i : x; - y1 = dir ? y : y + i; + mob_barricade_nextxy(x, y, dir, i, &x1, &y1); if( map_getcell(m, x1, y1, CELL_CHKNOREACH) ) break; // Collision @@ -576,8 +592,7 @@ void mob_barricade_get(struct map_session_data *sd) for( i = 0; i < barricade->count; i++ ) { - x1 = barricade->dir ? barricade->x + i : barricade->x; - y1 = barricade->dir ? barricade->y : barricade->y + i; + mob_barricade_nextxy(barricade->x, barricade->y, barricade->dir, i, &x1, &y1); clif_changemapcell(sd->fd, barricade->m, x1, y1, (barricade->killable ? 5 : 1), SELF); } } @@ -597,9 +612,7 @@ static void mob_barricade_break(struct barricade_data *barricade) for( i = 0; i < barricade->count; i++ ) { - x1 = barricade->dir ? barricade->x + i : barricade->x; - y1 = barricade->dir ? barricade->y : barricade->y + i; - + mob_barricade_nextxy(barricade->x, barricade->y, barricade->dir, i, &x1, &y1); map_setgatcell(barricade->m, x1, y1, 0); clif_changemapcell(0, barricade->m, x1, y1, 0, ALL_SAMEMAP); } @@ -645,9 +658,7 @@ void mod_barricade_clearall(void) { for( i = 0; i < barricade->count; i++ ) { - x1 = barricade->dir ? barricade->x + i : barricade->x; - y1 = barricade->dir ? barricade->y : barricade->y + i; - + mob_barricade_nextxy(barricade->x, barricade->y, barricade->dir, i, &x1, &y1); map_setgatcell(barricade->m, x1, y1, 0); clif_changemapcell(0, barricade->m, x1, y1, 0, ALL_SAMEMAP); } diff --git a/src/map/status.c b/src/map/status.c index adcfc726d..7ba331591 100644 --- a/src/map/status.c +++ b/src/map/status.c @@ -507,6 +507,7 @@ void initChangeTables(void) StatusChangeFlagTable[SC_MATKFOOD] |= SCB_MATK; StatusChangeFlagTable[SC_ARMOR_ELEMENT] |= SCB_PC; StatusChangeFlagTable[SC_ARMOR_RESIST] |= SCB_PC; + StatusChangeFlagTable[SC_SPCOST_RATE] |= SCB_PC; if (!battle_config.display_hallucination) //Disable Hallucination. StatusIconChangeTable[SC_HALLUCINATION] = SI_BLANK; @@ -2289,6 +2290,9 @@ int status_calc_pc(struct map_session_data* sd,int first) if(sc->data[SC_SERVICE4U]) sd->dsprate -= sc->data[SC_SERVICE4U]->val3; + if(sc->data[SC_SPCOST_RATE]) + sd->dsprate -= sc->data[SC_SPCOST_RATE]->val1; + //Underflow protections. if(sd->dsprate < 0) sd->dsprate = 0; @@ -4575,9 +4579,13 @@ int status_get_sc_def(struct block_list *bl, enum sc_type type, int rate, int ti rate -= rate*sc_def/100; //Item resistance (only applies to rate%) - if(sd && SC_COMMON_MIN<=type && type<=SC_COMMON_MAX - && sd->reseff[type-SC_COMMON_MIN] > 0) + if(sd && SC_COMMON_MIN <= type && type <= SC_COMMON_MAX) + { + if( sd->reseff[type-SC_COMMON_MIN] > 0 ) rate -= rate*sd->reseff[type-SC_COMMON_MIN]/10000; + if( sd->sc.data[SC_COMMONSC_RESIST] ) + rate -= rate*sd->sc.data[SC_COMMONSC_RESIST]->val1; + } } if (!(rand()%10000 < rate)) return 0; diff --git a/src/map/status.h b/src/map/status.h index 80ce484c1..75b558d79 100644 --- a/src/map/status.h +++ b/src/map/status.h @@ -287,6 +287,8 @@ enum sc_type { SC_AUTOTRADE, SC_KSPROTECTED, SC_ARMOR_RESIST, + SC_SPCOST_RATE, + SC_COMMONSC_RESIST, SC_MAX, //Automatically updated max, used in for's to check we are within bounds. }; int SkillStatusChangeTable(int skill); |