summaryrefslogtreecommitdiff
path: root/src/map/battle.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-04 04:48:30 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2006-03-04 04:48:30 +0000
commite27cd1c1b31aa3cecf2006de64f2b95f90bcd7cb (patch)
treee5f666a82c5a0f2c5a366c40c3f05f5d1da55953 /src/map/battle.c
parent4f44cd846049aa506f3c8c43fb25d78343e71551 (diff)
downloadhercules-e27cd1c1b31aa3cecf2006de64f2b95f90bcd7cb.tar.gz
hercules-e27cd1c1b31aa3cecf2006de64f2b95f90bcd7cb.tar.bz2
hercules-e27cd1c1b31aa3cecf2006de64f2b95f90bcd7cb.tar.xz
hercules-e27cd1c1b31aa3cecf2006de64f2b95f90bcd7cb.zip
- Fixed missing baby-dancer job in exp2.txt
- Added function battle_set_walkdelay in charge of updating walkdelays of characters based on two criterias: when the delay is induced by damage, if the current walk delay isn't over yet, do not update it. If the delay is instead caused by a skill, then the current walk delay cannot be decreased, only increased. - Removed the canmove tick reset on skill cast cancel; likewise it isn't updated on begin casting. pc_can_move uses a skilltimer check to know whether you can move or not. - Added GrandCross's can't move delay of 900ms to skill_cast_db - Added Finger Offensive's can't move delay of 200ms/lv to skill_cast_db git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@5457 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/battle.c')
-rw-r--r--src/map/battle.c84
1 files changed, 39 insertions, 45 deletions
diff --git a/src/map/battle.c b/src/map/battle.c
index d205034d4..79ec8bc68 100644
--- a/src/map/battle.c
+++ b/src/map/battle.c
@@ -439,34 +439,52 @@ int battle_attr_fix(struct block_list *src, struct block_list *target, int damag
return damage*ratio/100;
}
-static int battle_walkdelay_sub(int tid, unsigned int tick, int id, int data)
+/*==========================================
+ * Applies walk delay to character, considering that
+ * if type is 0, this is a damage induced delay: if previous delay is active, do not change it.
+ * if type is 1, this is a skill induced delay: walk-delay may only be increased, not decreased.
+ *------------------------------------------
+ */
+int battle_set_walkdelay(struct block_list *bl, unsigned int tick, int delay, int type)
{
- struct block_list *bl = map_id2bl(id);
- if (!bl || status_isdead(bl))
- return 0;
+ unsigned int *canmove_tick=NULL;
+ if (delay <= 0) return 0;
switch (bl->type) {
case BL_PC:
- {
- struct map_session_data *sd = (struct map_session_data*)bl;
- if (sd->walktimer != -1)
- pc_stop_walking (sd,3);
- if (sd->canmove_tick < tick)
- sd->canmove_tick = tick + data;
- }
+ canmove_tick = &((TBL_PC*)bl)->canmove_tick;
break;
case BL_MOB:
- {
- struct mob_data *md = (struct mob_data*)bl;
- if (md->state.state == MS_WALK)
- mob_stop_walking(md,3);
- if (md->canmove_tick < tick)
- md->canmove_tick = tick + data;
- }
+ canmove_tick = &((TBL_MOB*)bl)->canmove_tick;
break;
+ case BL_NPC:
+ canmove_tick = &((TBL_NPC*)bl)->canmove_tick;
+ break;
+ }
+ if (!canmove_tick)
+ return 0;
+ if (type) {
+ if (DIFF_TICK(*canmove_tick, tick+delay) > 0)
+ return 0;
+ } else {
+ if (DIFF_TICK(*canmove_tick, tick) > 0)
+ return 0;
}
+ *canmove_tick = tick + delay;
+ return 1;
+}
+
+static int battle_walkdelay_sub(int tid, unsigned int tick, int id, int data)
+{
+ struct block_list *bl = map_id2bl(id);
+ if (!bl || status_isdead(bl))
+ return 0;
+
+ if (battle_set_walkdelay(bl, tick, data, 0))
+ battle_stopwalking(bl,3);
return 0;
}
+
/*==========================================
* Applies walk delay based on attack type. [Skotlex]
*------------------------------------------
@@ -489,31 +507,10 @@ int battle_walkdelay(struct block_list *bl, unsigned int tick, int adelay, int d
if (delay <= 0)
return 0;
- //See if it makes sense to set this trigger.
- switch (bl->type) {
- case BL_PC:
- {
- struct map_session_data *sd = (struct map_session_data*)bl;
- if (DIFF_TICK(sd->canmove_tick, tick+adelay) > 0)
- return 0;
- if (!adelay) //No need of timer.
- sd->canmove_tick = tick + delay;
- break;
- }
- case BL_MOB:
- {
- struct mob_data *md = (struct mob_data*)bl;
- if (DIFF_TICK(md->canmove_tick, tick+adelay) > 0)
- return 0;
- if (!adelay) //No need of timer.
- md->canmove_tick = tick + delay;
- break;
- }
- default:
- return 0;
- }
if (adelay > 0)
add_timer(tick+adelay, battle_walkdelay_sub, bl->id, delay);
+ else
+ battle_set_walkdelay(bl, tick, delay, 0);
return 1;
}
@@ -580,10 +577,7 @@ int battle_calc_damage(struct block_list *src,struct block_list *bl,int damage,i
delay = 200;
else
delay = 100;
- if(sd)
- sd->canmove_tick = gettick() + delay;
- else if(md)
- md->canmove_tick = gettick() + delay;
+ battle_set_walkdelay(bl, gettick(), delay, 1);
if(sc->data[SC_SHRINK].timer != -1 && rand()%100<5*sc->data[SC_AUTOGUARD].val1)
skill_blown(bl,src,skill_get_blewcount(CR_SHRINK,1));