summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Changelog-Trunk.txt5
-rw-r--r--src/common/mmo.h2
-rw-r--r--src/map/clif.c145
-rw-r--r--src/map/clif.h4
-rw-r--r--src/map/skill.c383
-rw-r--r--src/map/skill.h18
-rw-r--r--src/map/status.c166
-rw-r--r--src/map/unit.c4
8 files changed, 283 insertions, 444 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt
index f5b5cdd8c..c461854ee 100644
--- a/Changelog-Trunk.txt
+++ b/Changelog-Trunk.txt
@@ -4,6 +4,11 @@ AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO
IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK.
2007/10/03
+ * Cleaned up parts of skill.c related to skill units [ultramage]
+ - removed some nonsense code in skill_dance_switch() (from r8876)
+ - removed 'security system to prevent forgetting timer removal' (r1213)
+ - renamed some skill-related data structs (had same name as variables)
+ - commented out custom Venom Splasher countdown messaging code
* Bosses now can use teleport on Land Protector [Playtester]
2007/10/01
* Fixed various trading/vending glitches [ultramage]
diff --git a/src/common/mmo.h b/src/common/mmo.h
index 6e136c2ae..4858a1667 100644
--- a/src/common/mmo.h
+++ b/src/common/mmo.h
@@ -366,6 +366,8 @@ struct guild_castle {
int id;
} guardian[MAX_GUARDIANS]; //New simplified structure. [Skotlex]
};
+
+// for Brandish Spear calculations
struct square {
int val1[5];
int val2[5];
diff --git a/src/map/clif.c b/src/map/clif.c
index 6303552d2..e48714c4e 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -3923,17 +3923,13 @@ void clif_getareachar_item(struct map_session_data* sd,struct flooritem_data* fi
/*==========================================
* 場所スキルエフェクトが視界に入る
*------------------------------------------*/
-int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *unit)
+static void clif_getareachar_skillunit(struct map_session_data *sd, struct skill_unit *unit)
{
- int fd;
- struct block_list *bl;
+ int fd = sd->fd;
- fd=sd->fd;
- bl=map_id2bl(unit->group->src_id);
#if PACKETVER >= 3
if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
WFIFOHEAD(fd,packet_len(0x1c9));
- memset(WFIFOP(fd,0),0,packet_len(0x1c9));
WFIFOW(fd, 0)=0x1c9;
WFIFOL(fd, 2)=unit->bl.id;
WFIFOL(fd, 6)=unit->group->src_id;
@@ -3942,21 +3938,19 @@ int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *un
WFIFOB(fd,14)=unit->group->unit_id;
WFIFOB(fd,15)=1;
WFIFOB(fd,16)=1;
- memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
+ safestrncpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
WFIFOSET(fd,packet_len(0x1c9));
- return 0;
+ return;
}
#endif
WFIFOHEAD(fd,packet_len(0x11f));
- memset(WFIFOP(fd,0),0,packet_len(0x11f));
WFIFOW(fd, 0)=0x11f;
WFIFOL(fd, 2)=unit->bl.id;
WFIFOL(fd, 6)=unit->group->src_id;
WFIFOW(fd,10)=unit->bl.x;
WFIFOW(fd,12)=unit->bl.y;
- //Use invisible unit id for traps.
if (battle_config.traps_setting&1 && skill_get_inf2(unit->group->skill_id)&INF2_TRAP)
- WFIFOB(fd,14)=UNT_ATTACK_SKILLS;
+ WFIFOB(fd,14)=UNT_ATTACK_SKILLS; //Use invisible unit id for traps.
else
WFIFOB(fd,14)=unit->group->unit_id;
WFIFOB(fd,15)=0;
@@ -3964,69 +3958,22 @@ int clif_getareachar_skillunit(struct map_session_data *sd,struct skill_unit *un
if(unit->group->skill_id == WZ_ICEWALL)
clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
- return 0;
-/* Previous implementation guess of packet 0x1c9, who can understand what all those fields are for? [Skotlex]
- WFIFOHEAD(fd,packet_len(0x1c9));
- memset(WFIFOP(fd,0),0,packet_len(0x1c9));
- WFIFOW(fd, 0)=0x1c9;
- WFIFOL(fd, 2)=unit->bl.id;
- WFIFOL(fd, 6)=unit->group->src_id;
- WFIFOW(fd,10)=unit->bl.x;
- WFIFOW(fd,12)=unit->bl.y;
- WFIFOB(fd,14)=unit->group->unit_id;
- WFIFOB(fd,15)=1;
- if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- WFIFOB(fd,16)=1;
- memcpy(WFIFOP(fd,17),unit->group->valstr,MESSAGE_SIZE);
- } else {
- WFIFOL(fd,15+1)=0; //1-4調べた限り固定
- WFIFOL(fd,15+5)=0; //5-8調べた限り固定
- //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
- WFIFOL(fd,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
- WFIFOL(fd,15+17)=0x004f37dd; //17-20調べた限り固定
- WFIFOL(fd,15+21)=0x0012f674; //21-24調べた限り固定
- WFIFOL(fd,15+25)=0x0012f664; //25-28調べた限り固定
- WFIFOL(fd,15+29)=0x0012f654; //29-32調べた限り固定
- WFIFOL(fd,15+33)=0x77527bbc; //33-36調べた限り固定
- //37-39
- WFIFOB(fd,15+40)=0x2d; //40調べた限り固定
- WFIFOL(fd,15+41)=0; //41-44調べた限り0固定
- WFIFOL(fd,15+45)=0; //45-48調べた限り0固定
- WFIFOL(fd,15+49)=0; //49-52調べた限り0固定
- WFIFOL(fd,15+53)=0x0048d919; //53-56調べた限り固定
- WFIFOL(fd,15+57)=0x0000003e; //57-60調べた限り固定
- WFIFOL(fd,15+61)=0x0012f66c; //61-64調べた限り固定
- //65-68
- //69-72
- if(bl) WFIFOL(fd,15+73)=bl->y; //73-76術者のY座標
- WFIFOL(fd,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
- WFIFOB(fd,15+81)=0xaa; //81終端文字0xaa
- }
-
- WFIFOSET(fd,packet_len(0x1c9));
-#endif
- if(unit->group->skill_id == WZ_ICEWALL)
- clif_set0192(fd,unit->bl.m,unit->bl.x,unit->bl.y,5);
-
- return 0;
-*/
}
/*==========================================
* 場所スキルエフェクトが視界から消える
*------------------------------------------*/
-int clif_clearchar_skillunit(struct skill_unit *unit,int fd)
+static void clif_clearchar_skillunit(struct skill_unit *unit, int fd)
{
- nullpo_retr(0, unit);
+ nullpo_retv(unit);
WFIFOHEAD(fd,packet_len(0x120));
WFIFOW(fd, 0)=0x120;
WFIFOL(fd, 2)=unit->bl.id;
WFIFOSET(fd,packet_len(0x120));
+
if(unit->group && unit->group->skill_id == WZ_ICEWALL)
clif_changemapcell(fd,unit->bl.m,unit->bl.x,unit->bl.y,unit->val2);
-
- return 0;
}
/*==========================================
@@ -4573,110 +4520,52 @@ int clif_skill_poseffect(struct block_list *src,int skill_id,int val,int x,int y
/*==========================================
* 場所スキルエフェクト表示
*------------------------------------------*/
-int clif_skill_setunit(struct skill_unit *unit)
+void clif_skill_setunit(struct skill_unit *unit)
{
unsigned char buf[128];
- struct block_list *bl;
-
- nullpo_retr(0, unit);
- bl=map_id2bl(unit->group->src_id);
+ nullpo_retv(unit);
-// These are invisible client-side, but are necessary because
-// otherwise the client will not know who caused the attack.
-// if (unit->group->unit_id == UNT_ATTACK_SKILLS)
-// return 0;
-
#if PACKETVER >= 3
if(unit->group->unit_id==UNT_GRAFFITI) { // Graffiti [Valaris]
- memset(WBUFP(buf, 0),0,packet_len(0x1c9));
WBUFW(buf, 0)=0x1c9;
WBUFL(buf, 2)=unit->bl.id;
WBUFL(buf, 6)=unit->group->src_id;
WBUFW(buf,10)=unit->bl.x;
WBUFW(buf,12)=unit->bl.y;
- if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
- WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
- } else {
- WBUFB(buf,14)=unit->group->unit_id;
- }
+ WBUFB(buf,14)=unit->group->unit_id;
WBUFB(buf,15)=1;
WBUFB(buf,16)=1;
- memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
+ safestrncpy((char*)WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
clif_send(buf,packet_len(0x1c9),&unit->bl,AREA);
- return 0;
+ return;
}
#endif
- memset(WBUFP(buf, 0),0,packet_len(0x11f));
WBUFW(buf, 0)=0x11f;
WBUFL(buf, 2)=unit->bl.id;
WBUFL(buf, 6)=unit->group->src_id;
WBUFW(buf,10)=unit->bl.x;
WBUFW(buf,12)=unit->bl.y;
- if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) {
+ if (unit->group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE)
WBUFB(buf,14)=unit->val2&UF_SONG?UNT_DISSONANCE:UNT_UGLYDANCE;
- } else {
+ else
WBUFB(buf,14)=unit->group->unit_id;
- }
WBUFB(buf,15)=0;
clif_send(buf,packet_len(0x11f),&unit->bl,AREA);
- return 0;
-
-/* Previous mysterious implementation noone really understands. [Skotlex]
- memset(WBUFP(buf, 0),0,packet_len(0x1c9));
- WBUFW(buf, 0)=0x1c9;
- WBUFL(buf, 2)=unit->bl.id;
- WBUFL(buf, 6)=unit->group->src_id;
- WBUFW(buf,10)=unit->bl.x;
- WBUFW(buf,12)=unit->bl.y;
- WBUFB(buf,14)=unit->group->unit_id;
- WBUFB(buf,15)=1;
- if(unit->group->unit_id==0xb0) { // Graffiti [Valaris]
- WBUFB(buf,16)=1;
- memcpy(WBUFP(buf,17),unit->group->valstr,MESSAGE_SIZE);
- } else {
- WBUFL(buf,15+1)=0; //1-4調べた限り固定
- WBUFL(buf,15+5)=0; //5-8調べた限り固定
- //9-12マップごとで一定の77-80とはまた違う4バイトのかなり大きな数字
- WBUFL(buf,15+13)=unit->bl.y - 0x12; //13-16ユニットのY座標-18っぽい(Y:17でFF FF FF FF)
- WBUFL(buf,15+17)=0x004f37dd; //17-20調べた限り固定(0x1b2で0x004fdbddだった)
- WBUFL(buf,15+21)=0x0012f674; //21-24調べた限り固定
- WBUFL(buf,15+25)=0x0012f664; //25-28調べた限り固定
- WBUFL(buf,15+29)=0x0012f654; //29-32調べた限り固定
- WBUFL(buf,15+33)=0x77527bbc; //33-36調べた限り固定
- //37-39
- WBUFB(buf,15+40)=0x2d; //40調べた限り固定
- WBUFL(buf,15+41)=0; //41-44調べた限り0固定
- WBUFL(buf,15+45)=0; //45-48調べた限り0固定
- WBUFL(buf,15+49)=0; //49-52調べた限り0固定
- WBUFL(buf,15+53)=0x0048d919; //53-56調べた限り固定(0x01b2で0x00495119だった)
- WBUFL(buf,15+57)=0x0000003e; //57-60調べた限り固定
- WBUFL(buf,15+61)=0x0012f66c; //61-64調べた限り固定
- //65-68
- //69-72
- if(bl) WBUFL(buf,15+73)=bl->y; //73-76術者のY座標
- WBUFL(buf,15+77)=unit->bl.m; //77-80マップIDかなぁ?かなり2バイトで足りそうな数字
- WBUFB(buf,15+81)=0xaa; //81終端文字0xaa
- }
- clif_send(buf,packet_len(0x1c9),&unit->bl,AREA);
-#endif
- return 0;
-*/
}
/*==========================================
* 場所スキルエフェクト削除
*------------------------------------------*/
-int clif_skill_delunit(struct skill_unit *unit)
+void clif_skill_delunit(struct skill_unit *unit)
{
unsigned char buf[16];
- nullpo_retr(0, unit);
+ nullpo_retv(unit);
WBUFW(buf, 0)=0x120;
WBUFL(buf, 2)=unit->bl.id;
clif_send(buf,packet_len(0x120),&unit->bl,AREA);
- return 0;
}
/*==========================================
diff --git a/src/map/clif.h b/src/map/clif.h
index 0e0667503..4361c1895 100644
--- a/src/map/clif.h
+++ b/src/map/clif.h
@@ -218,8 +218,8 @@ int clif_skill_produce_mix_list(struct map_session_data *sd, int trigger);
int clif_produceeffect(struct map_session_data* sd,int flag,int nameid);
-int clif_skill_setunit(struct skill_unit *unit);
-int clif_skill_delunit(struct skill_unit *unit);
+void clif_skill_setunit(struct skill_unit *unit);
+void clif_skill_delunit(struct skill_unit *unit);
int clif_01ac(struct block_list *bl);
diff --git a/src/map/skill.c b/src/map/skill.c
index 6343f98d6..8541bc01c 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -663,12 +663,12 @@ const struct skill_name_db skill_names[] = {
static struct eri *skill_unit_ers = NULL; //For handling skill_unit's [Skotlex]
static struct eri *skill_timer_ers = NULL; //For handling skill_timerskills [Skotlex]
-struct skill_db skill_db[MAX_SKILL_DB];
-struct skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB];
-struct skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB];
-struct skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB];
+struct s_skill_db skill_db[MAX_SKILL_DB];
+struct s_skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB];
+struct s_skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB];
+struct s_skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB];
-struct skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT];
+struct s_skill_unit_layout skill_unit_layout[MAX_SKILL_UNIT_LAYOUT];
int firewall_unit_pos;
int icewall_unit_pos;
@@ -995,7 +995,7 @@ int skillnotok_hom (int skillid, struct homun_data *hd)
return skillnotok(skillid, hd->master);
}
-struct skill_unit_layout* skill_get_unit_layout (int skillid, int skilllv, struct block_list* src, int x, int y)
+struct s_skill_unit_layout* skill_get_unit_layout (int skillid, int skilllv, struct block_list* src, int x, int y)
{
int pos = skill_get_unit_layout_type(skillid,skilllv);
int dir;
@@ -6106,11 +6106,11 @@ int skill_castend_pos (int tid, unsigned int tick, int id, int data)
/*==========================================
*
*------------------------------------------*/
-int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, int skilllv, unsigned int tick, int flag)
+int skill_castend_pos2(struct block_list* src, int x, int y, int skillid, int skilllv, unsigned int tick, int flag)
{
- struct map_session_data *sd=NULL;
- struct status_change *sc;
- struct skill_unit_group *sg;
+ struct map_session_data* sd;
+ struct status_change* sc;
+ struct skill_unit_group* sg;
int i,type;
//if(skilllv <= 0) return 0;
@@ -6121,12 +6121,9 @@ int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, int s
if(status_isdead(src))
return 0;
- if(src->type==BL_PC)
- sd=(struct map_session_data *)src;
+ BL_CAST(BL_PC, src, sd);
sc = status_get_sc(src);
- if (sc && !sc->count)
- sc = NULL; //Unneeded.
type = SkillStatusChangeTable(skillid);
switch (skillid) { //Skill effect.
@@ -6141,6 +6138,7 @@ int skill_castend_pos2 (struct block_list *src, int x, int y, int skillid, int s
else
clif_skill_poseffect(src,skillid,skilllv,x,y,tick);
}
+
switch(skillid)
{
case PR_BENEDICTIO:
@@ -6611,92 +6609,92 @@ int skill_castend_map (struct map_session_data *sd, int skill_num, const char *m
#undef skill_failed
}
-static int skill_dance_overlap_sub(struct block_list *bl, va_list ap)
+/// transforms 'target' skill unit into dissonance (if conditions are met)
+static int skill_dance_overlap_sub(struct block_list* bl, va_list ap)
{
- struct skill_unit *target = (struct skill_unit*)bl,
- *src = va_arg(ap, struct skill_unit*);
+ struct skill_unit* target = (struct skill_unit*)bl;
+ struct skill_unit* src = va_arg(ap, struct skill_unit*);
int flag = va_arg(ap, int);
+
if (src == target)
return 0;
if (!target->group || !(target->group->state.song_dance&0x1))
return 0;
if (!(target->val2 & src->val2 & ~UF_ENSEMBLE)) //They don't match (song + dance) is valid.
return 0;
+
if (flag) //Set dissonance
target->val2 |= UF_ENSEMBLE; //Add ensemble to signal this unit is overlapping.
else //Remove dissonance
target->val2 &= ~UF_ENSEMBLE;
+
clif_skill_setunit(target); //Update look of affected cell.
+
return 1;
}
//Does the song/dance overlapping -> dissonance check. [Skotlex]
//When flag is 0, this unit is about to be removed, cancel the dissonance effect
//When 1, this unit has been positioned, so start the cancel effect.
-int skill_dance_overlap(struct skill_unit *unit, int flag)
+int skill_dance_overlap(struct skill_unit* unit, int flag)
{
if (!unit || !unit->group || !(unit->group->state.song_dance&0x1))
return 0;
if (!flag && !(unit->val2&UF_ENSEMBLE))
return 0; //Nothing to remove, this unit is not overlapped.
+
if (unit->val1 != unit->group->skill_id)
{ //Reset state
unit->val1 = unit->group->skill_id;
unit->val2 &= ~UF_ENSEMBLE;
}
- return map_foreachincell(skill_dance_overlap_sub,
- unit->bl.m,unit->bl.x,unit->bl.y,BL_SKILL,unit,flag);
+
+ return map_foreachincell(skill_dance_overlap_sub, unit->bl.m,unit->bl.x,unit->bl.y,BL_SKILL, unit,flag);
}
/*==========================================
- * Converts this group information so that it is handled
- * as a Dissonance or Ugly Dance cell.
- * Flag: 0 - Convert, 1 - Revert, 2 - Initialize.
+ * Converts this group information so that it is handled as a Dissonance or Ugly Dance cell.
+ * Flag: 0 - Convert, 1 - Revert.
*------------------------------------------*/
-#define skill_dance_switch(unit, group, flag) (((group)->state.song_dance&0x1 && (unit)->val2&UF_ENSEMBLE)?skill_dance_switch_sub(unit, group, flag):0)
-static int skill_dance_switch_sub(struct skill_unit *unit, struct skill_unit_group *group, int flag)
+static int skill_dance_switch(struct skill_unit* unit, struct skill_unit_group* group, int flag)
{
- static struct skill_unit_group original, dissonance, uglydance, *group2;
-
- if (flag&2) { //initialize
- memset(&dissonance, 0, sizeof(dissonance));
- memset(&uglydance, 0, sizeof(uglydance));
- group2 = &dissonance;
- group2->skill_id = BA_DISSONANCE;
- group2->skill_lv = 1;
- group2->unit_id = skill_get_unit_id(group2->skill_id,0);
- group2->target_flag = skill_get_unit_target(group2->skill_id);
- group2->bl_flag= skill_get_unit_bl_target(group2->skill_id);
- group2->interval = skill_get_unit_interval(group2->skill_id);
-
- group2 = &uglydance;
- group2->skill_id = DC_UGLYDANCE;
- group2->skill_lv = 1;
- group2->unit_id = skill_get_unit_id(group2->skill_id,0);
- group2->target_flag = skill_get_unit_target(group2->skill_id);
- group2->bl_flag= skill_get_unit_bl_target(group2->skill_id);
- group2->interval = skill_get_unit_interval(group2->skill_id);
+ static struct skill_unit_group backup;
+
+ //TODO: add protection against attempts to read an empty backup / write to a full backup
+
+ if ( !(group->state.song_dance&0x1 && unit->val2&UF_ENSEMBLE) )
return 0;
- }
- if (!flag)
+ if( !flag )
{ //Transform
- memcpy(&original, group, sizeof(struct skill_unit_group)); //Backup
- group2 = unit->val2&UF_SONG?&dissonance:&uglydance;
- group->skill_id = group2->skill_id;
- group->skill_lv = group2->skill_lv;
- group->unit_id = group2->unit_id;
- group->target_flag = group2->target_flag;
- group->bl_flag= group2->bl_flag;
- group->interval = group2->interval;
- } else { //Restore only relevant values (should the backup be 5 ints rather than the whole structure?)
- group->skill_id = original.skill_id;
- group->skill_lv = original.skill_lv;
- group->unit_id = original.unit_id;
- group->target_flag = original.target_flag;
- group->bl_flag = original.bl_flag;
- group->interval = original.interval;
+ int skillid = unit->val2&UF_SONG ? BA_DISSONANCE : DC_UGLYDANCE;
+
+ // backup
+ backup.skill_id = group->skill_id;
+ backup.skill_lv = group->skill_lv;
+ backup.unit_id = group->unit_id;
+ backup.target_flag = group->target_flag;
+ backup.bl_flag = group->bl_flag;
+ backup.interval = group->interval;
+
+ // replace
+ group->skill_id = skillid;
+ group->skill_lv = 1;
+ group->unit_id = skill_get_unit_id(skillid,0);
+ group->target_flag = skill_get_unit_target(skillid);
+ group->bl_flag = skill_get_unit_bl_target(skillid);
+ group->interval = skill_get_unit_interval(skillid);
+ }
+ else
+ { //Restore
+ group->skill_id = backup.skill_id;
+ group->skill_lv = backup.skill_lv;
+ group->unit_id = backup.unit_id;
+ group->target_flag = backup.target_flag;
+ group->bl_flag = backup.bl_flag;
+ group->interval = backup.interval;
}
+
return 1;
}
@@ -6710,7 +6708,7 @@ struct skill_unit_group *skill_unitsetting (struct block_list *src, int skillid,
struct skill_unit_group *group;
int i,limit,val1=0,val2=0,val3=0;
int target,interval,range,unit_flag;
- struct skill_unit_layout *layout;
+ struct s_skill_unit_layout *layout;
struct map_session_data *sd;
struct status_data *status;
struct status_change *sc;
@@ -7187,7 +7185,7 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
if (sc && sc->data[type].timer==-1)
sc_start4(bl,type,100,sg->skill_lv,0,BCT_ENEMY,sg->group_id,sg->limit);
break;
-
+
case UNT_ICEWALL: //Destroy the cell. [Skotlex]
src->val1 = 0;
if(src->limit + sg->tick > tick + 700)
@@ -7195,8 +7193,8 @@ int skill_unit_onplace (struct skill_unit *src, struct block_list *bl, unsigned
break;
case UNT_MOONLIT:
- //Knockback out of area if affected char isn't in Moonlit effect
- if (sc && sc->data[SC_DANCING].timer!=-1 && (sc->data[SC_DANCING].val1&0xFFFF) == CG_MOONLIT)
+ //Knockback out of area if affected char isn't in Moonlit effect
+ if (sc && sc->data[SC_DANCING].timer != -1 && (sc->data[SC_DANCING].val1&0xFFFF) == CG_MOONLIT)
break;
if (ss == bl) //Also needed to prevent infinite loop crash.
break;
@@ -7652,9 +7650,6 @@ int skill_unit_onout (struct skill_unit *src, struct block_list *bl, unsigned in
nullpo_retr(0, bl);
nullpo_retr(0, sg=src->group);
sc = status_get_sc(bl);
- if (sc && !sc->count)
- sc = NULL;
-
type = SkillStatusChangeTable(sg->skill_id);
if (bl->prev==NULL || !src->alive || //Need to delete the trap if the source died.
@@ -7785,48 +7780,45 @@ static int skill_unit_onleft (int skill_id, struct block_list *bl, unsigned int
* flag&1: Invoke onplace function (otherwise invoke onout)
* flag&4: Invoke a onleft call (the unit might be scheduled for deletion)
*------------------------------------------*/
-int skill_unit_effect (struct block_list *bl, va_list ap)
+int skill_unit_effect (struct block_list* bl, va_list ap)
{
- struct skill_unit *unit;
- struct skill_unit_group *group;
- int flag,skill_id;
- unsigned int tick;
-
- unit=va_arg(ap,struct skill_unit*);
- tick = va_arg(ap,unsigned int);
- flag = va_arg(ap,unsigned int);
+ struct skill_unit* unit = va_arg(ap,struct skill_unit*);
+ struct skill_unit_group* group = unit->group;
+ unsigned int flag = va_arg(ap,unsigned int);
+ unsigned int tick = va_arg(ap,unsigned int);
+ int skill_id;
- if (!unit->alive || bl->prev==NULL)
+ if( !unit->alive || bl->prev == NULL )
return 0;
- nullpo_retr(0, group=unit->group);
+ nullpo_retr(0, group);
- if (skill_dance_switch(unit, group, 0))
+ if( skill_dance_switch(unit, group, 0) )
flag|=64; //Converted cell, remember to restore it.
//Necessary in case the group is deleted after calling on_place/on_out [Skotlex]
skill_id = group->skill_id;
//Target-type check.
- if(!(group->bl_flag&bl->type && battle_check_target(&unit->bl,bl,group->target_flag)>0))
+ if( !(group->bl_flag&bl->type && battle_check_target(&unit->bl,bl,group->target_flag)>0) )
{
- if (flag&4 && group->src_id == bl->id && group->state.song_dance&0x2)
+ if( flag&4 && group->src_id == bl->id && group->state.song_dance&0x2 )
skill_unit_onleft(skill_id, bl, tick);//Ensemble check to terminate it.
- if (flag&64)
- skill_dance_switch(unit, group, 1);
- return 0;
}
-
- if (flag&1)
- skill_unit_onplace(unit,bl,tick);
else
- skill_unit_onout(unit,bl,tick);
+ {
+ if( flag&1 )
+ skill_unit_onplace(unit,bl,tick);
+ else
+ skill_unit_onout(unit,bl,tick);
- if (flag&4)
- skill_unit_onleft(skill_id, bl, tick);
+ if( flag&4 )
+ skill_unit_onleft(skill_id, bl, tick);
+ }
- if (flag&64)
+ if( flag&64 )
skill_dance_switch(unit, group, 1);
+
return 0;
}
@@ -9061,29 +9053,23 @@ void skill_brandishspear_first (struct square *tc, int dir, int x, int y)
/*=========================================
*
*-----------------------------------------*/
-void skill_brandishspear_dir (struct square *tc, int dir, int are)
+void skill_brandishspear_dir (struct square* tc, int dir, int are)
{
int c;
-
nullpo_retv(tc);
- for(c=0;c<5;c++){
- if(dir==0){
- tc->val2[c]+=are;
- }else if(dir==1){
- tc->val1[c]-=are; tc->val2[c]+=are;
- }else if(dir==2){
- tc->val1[c]-=are;
- }else if(dir==3){
- tc->val1[c]-=are; tc->val2[c]-=are;
- }else if(dir==4){
- tc->val2[c]-=are;
- }else if(dir==5){
- tc->val1[c]+=are; tc->val2[c]-=are;
- }else if(dir==6){
- tc->val1[c]+=are;
- }else if(dir==7){
- tc->val1[c]+=are; tc->val2[c]+=are;
+ for( c = 0; c < 5; c++ )
+ {
+ switch( dir )
+ {
+ case 0: tc->val2[c]+=are; break;
+ case 1: tc->val1[c]-=are; tc->val2[c]+=are; break;
+ case 2: tc->val1[c]-=are; break;
+ case 3: tc->val1[c]-=are; tc->val2[c]-=are; break;
+ case 4: tc->val2[c]-=are; break;
+ case 5: tc->val1[c]+=are; tc->val2[c]-=are; break;
+ case 6: tc->val1[c]+=are; break;
+ case 7: tc->val1[c]+=are; tc->val2[c]+=are; break;
}
}
}
@@ -10131,6 +10117,7 @@ int skill_clear_unitgroup (struct block_list *src)
while (ud->skillunit[0])
skill_delunitgroup(src, ud->skillunit[0], 1);
+
return 1;
}
@@ -10180,70 +10167,67 @@ struct skill_unit_group_tickset *skill_unitgrouptickset_search (struct block_lis
/*==========================================
*
*------------------------------------------*/
-int skill_unit_timer_sub_onplace (struct block_list *bl, va_list ap)
+int skill_unit_timer_sub_onplace (struct block_list* bl, va_list ap)
{
- struct skill_unit *unit;
- struct skill_unit_group *group;
- unsigned int tick;
-
- unit = va_arg(ap,struct skill_unit *);
- tick = va_arg(ap,unsigned int);
+ struct skill_unit* unit = va_arg(ap,struct skill_unit *);
+ struct skill_unit_group* group = unit->group;
+ unsigned int tick = va_arg(ap,unsigned int);
- if (!unit->alive || bl->prev==NULL)
+ if( !unit->alive || bl->prev == NULL )
return 0;
- nullpo_retr(0, group=unit->group);
+ nullpo_retr(0, group);
- if (!(skill_get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP))
- && map_getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR))
+ if( !(skill_get_inf2(group->skill_id)&(INF2_SONG_DANCE|INF2_TRAP)) && map_getcell(bl->m, bl->x, bl->y, CELL_CHKLANDPROTECTOR) )
return 0; //AoE skills are ineffective. [Skotlex]
- if (battle_check_target(&unit->bl,bl,group->target_flag)<=0)
+ if( battle_check_target(&unit->bl,bl,group->target_flag) <= 0 )
return 0;
skill_unit_onplace_timer(unit,bl,tick);
+
return 1;
}
/*==========================================
*
*------------------------------------------*/
-int skill_unit_timer_sub (struct block_list *bl, va_list ap)
+int skill_unit_timer_sub (struct block_list* bl, va_list ap)
{
- struct skill_unit *unit;
- struct skill_unit_group *group;
- unsigned int tick;
+ struct skill_unit* unit = (struct skill_unit *)bl;
+ struct skill_unit_group* group = unit->group;
+ unsigned int tick = va_arg(ap,unsigned int);
int flag;
- unit=(struct skill_unit *)bl;
- tick=va_arg(ap,unsigned int);
-
- if(!unit->alive)
+ if( !unit->alive )
return 0;
- group=unit->group;
nullpo_retr(0, group);
flag = skill_dance_switch(unit, group, 0);
- if (unit->range>=0 && group->interval!=-1)
+ if( unit->range >= 0 && group->interval != -1 )
{
- if (battle_config.skill_wall_check)
+ if( battle_config.skill_wall_check )
map_foreachinshootrange(skill_unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick);
else
map_foreachinrange(skill_unit_timer_sub_onplace, bl, unit->range, group->bl_flag, bl,tick);
- if (!unit->alive)
+ if( !unit->alive )
{
- if (flag)
+ if( flag )
skill_dance_switch(unit, group, 1);
+
return 0;
}
}
+
if (flag)
skill_dance_switch(unit, group, 1);
- if((DIFF_TICK(tick,group->tick)>=group->limit || DIFF_TICK(tick,group->tick)>=unit->limit))
+ // check for expiration
+ if( (DIFF_TICK(tick,group->tick) >= group->limit || DIFF_TICK(tick,group->tick) >= unit->limit) )
{
- switch(group->unit_id){
+ switch( group->unit_id )
+ {
case UNT_BLASTMINE:
case UNT_GROUNDDRIFT_WIND:
case UNT_GROUNDDRIFT_DARK:
@@ -10265,9 +10249,10 @@ int skill_unit_timer_sub (struct block_list *bl, va_list ap)
case UNT_CLAYMORETRAP:
case UNT_TALKIEBOX:
{
- struct block_list *src=map_id2bl(group->src_id);
- if(src && src->type==BL_PC && !group->state.into_abyss)
- { //Avoid generating trap items when it did not cost to create them. [Skotlex]
+ struct block_list* src = map_id2bl(group->src_id);
+ // revert unit back into a trap
+ if( src && src->type == BL_PC && !group->state.into_abyss ) // but only when it cost a trap to deploy it
+ {
struct item item_tmp;
memset(&item_tmp,0,sizeof(item_tmp));
item_tmp.nameid=1065;
@@ -10281,21 +10266,27 @@ int skill_unit_timer_sub (struct block_list *bl, va_list ap)
skill_delunit(unit, 0);
}
}
-
- if(group->unit_id == UNT_ICEWALL)
- {
- unit->val1 -= 5;
- if(unit->val1 <= 0 && unit->limit + group->tick > tick + 700)
- unit->limit = DIFF_TICK(tick+700,group->tick);
- }
else
- if (group->unit_id == UNT_TATAMIGAESHI && unit->range>=0)
- { //Disable processed cell.
- unit->range = -1;
- if (--group->val1 <= 0)
- { //All tiles were processed, disable skill.
- group->target_flag=BCT_NOONE;
- group->bl_flag= BL_NUL;
+ {
+ switch( group->unit_id )
+ {
+ case UNT_ICEWALL:
+ // icewall loses 50 hp every second (and this executes every 100ms, so...)
+ unit->val1 -= 5; // trap's hp
+ if( unit->val1 <= 0 && unit->limit + group->tick > tick + 700 )
+ unit->limit = DIFF_TICK(tick+700,group->tick);
+ break;
+ case UNT_TATAMIGAESHI:
+ if( unit->range >= 0 )
+ { //Disable processed cell.
+ unit->range = -1;
+ if (--group->val1 <= 0) // number of live cells
+ { //All tiles were processed, disable skill.
+ group->target_flag=BCT_NOONE;
+ group->bl_flag= BL_NUL;
+ }
+ }
+ break;
}
}
@@ -10318,91 +10309,91 @@ int skill_unit_timer (int tid, unsigned int tick, int id, int data)
/*==========================================
*
*------------------------------------------*/
-int skill_unit_move_sub (struct block_list *bl, va_list ap)
+int skill_unit_move_sub (struct block_list* bl, va_list ap)
{
- struct skill_unit *unit = (struct skill_unit *)bl;
- struct skill_unit_group *group;
- struct block_list *target;
- unsigned int tick,flag,result;
- int skill_id;
+ struct skill_unit* unit = (struct skill_unit *)bl;
+ struct skill_unit_group* group = unit->group;
+
+ struct block_list* target = va_arg(ap,struct block_list*);
+ unsigned int tick = va_arg(ap,unsigned int);
+ int flag = va_arg(ap,int);
- target=va_arg(ap,struct block_list*);
- tick = va_arg(ap,unsigned int);
- flag = va_arg(ap,int);
+ int skill_id;
- nullpo_retr(0, group=unit->group);
+ nullpo_retr(0, group);
- if (!unit->alive || target->prev==NULL)
+ if( !unit->alive || target->prev == NULL )
return 0;
- if (skill_dance_switch(unit, group, 0))
+ if( skill_dance_switch(unit, group, 0) )
flag|=64; //Signal to remember to restore it.
//Necessary in case the group is deleted after calling on_place/on_out [Skotlex]
skill_id = unit->group->skill_id;
- if (unit->group->interval!=-1 &&
- !(skill_get_unit_flag(skill_id)&UF_DUALMODE))
+ if( unit->group->interval!=-1 && !(skill_get_unit_flag(skill_id)&UF_DUALMODE) )
{ //Skills in dual mode have to trigger both. [Skotlex]
- if (flag&64)
+ if( flag&64 )
skill_dance_switch(unit, group, 1);
+
return 0;
}
//Target-type check.
- if(!(group->bl_flag&target->type && battle_check_target(&unit->bl,target,group->target_flag)>0))
+ if( !(group->bl_flag&target->type && battle_check_target(&unit->bl,target,group->target_flag) > 0) )
{
- if(group->src_id == target->id && group->state.song_dance&0x2)
+ if( group->src_id == target->id && group->state.song_dance&0x2 )
{ //Ensemble check to see if they went out/in of the area [Skotlex]
- if (flag&1)
+ if( flag&1 )
{
- if (flag&2)
+ if( flag&2 )
{ //Clear skill ids we have stored in onout.
int i;
- for(i=0; i < (sizeof(skill_unit_temp)/sizeof(int)) &&
- skill_unit_temp[i]!=skill_id; i++);
- if (i < (sizeof(skill_unit_temp)/sizeof(int)))
+ ARR_FIND(0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == skill_id );
+ if( i < ARRAYLENGTH(skill_unit_temp) )
skill_unit_temp[i] = 0;
}
}
else
{
- if (flag&2) { //Store this unit id.
- if (skill_unit_index < (sizeof(skill_unit_temp)/sizeof(int)))
+ if( flag&2 )
+ { //Store this unit id.
+ if( skill_unit_index < ARRAYLENGTH(skill_unit_temp) )
skill_unit_temp[skill_unit_index++] = skill_id;
- else if (battle_config.error_log)
+ else if( battle_config.error_log )
ShowError("skill_unit_move_sub: Reached limit of unit objects per cell!\n");
}
}
- if (flag&4)
+ if( flag&4 )
skill_unit_onleft(skill_id,target,tick);
}
- if (flag&64)
+ if( flag&64 )
skill_dance_switch(unit, group, 1);
+
return 0;
}
- if (flag&1)
+ if( flag&1 )
{
- result = skill_unit_onplace(unit,target,tick);
- if (flag&2 && result)
+ unsigned int result = skill_unit_onplace(unit,target,tick);
+ if( flag&2 && result )
{ //Clear skill ids we have stored in onout.
int i;
- for(i=0; i < (sizeof(skill_unit_temp)/sizeof(int)) &&
- skill_unit_temp[i]!=result; i++);
- if (i < (sizeof(skill_unit_temp)/sizeof(int)))
+ ARR_FIND(0, ARRAYLENGTH(skill_unit_temp), i, skill_unit_temp[i] == result );
+ if( i < ARRAYLENGTH(skill_unit_temp) )
skill_unit_temp[i] = 0;
}
}
else
{
- result = skill_unit_onout(unit,target,tick);
- if (flag&2 && result) { //Store this unit id.
- if (skill_unit_index < (sizeof(skill_unit_temp)/sizeof(int)))
+ unsigned int result = skill_unit_onout(unit,target,tick);
+ if( flag&2 && result )
+ { //Store this unit id.
+ if( skill_unit_index < ARRAYLENGTH(skill_unit_temp) )
skill_unit_temp[skill_unit_index++] = result;
- else if (battle_config.error_log)
+ else if( battle_config.error_log )
ShowError("skill_unit_move_sub: Reached limit of unit objects per cell!\n");
}
}
@@ -10410,11 +10401,12 @@ int skill_unit_move_sub (struct block_list *bl, va_list ap)
//TODO: Normally, this is dangerous since the unit and group could be freed
//inside the onout/onplace functions. Currently it is safe because we know song/dance
//cells do not get deleted within them. [Skotlex]
- if (flag&64)
+ if( flag&64 )
skill_dance_switch(unit, group, 1);
- if (flag&4)
+ if( flag&4 )
skill_unit_onleft(skill_id,target,tick);
+
return 1;
}
@@ -11794,7 +11786,6 @@ void skill_reload (void)
int do_init_skill (void)
{
skill_readdb();
- skill_dance_switch_sub(NULL, NULL, 2); //Initialize Song/Dance overlap switch code.
skill_unit_ers = ers_new(sizeof(struct skill_unit_group));
skill_timer_ers = ers_new(sizeof(struct skill_timerskill));
diff --git a/src/map/skill.h b/src/map/skill.h
index 3f3420628..857c7a313 100644
--- a/src/map/skill.h
+++ b/src/map/skill.h
@@ -58,7 +58,7 @@
#define SD_ANIMATION 0x2000
// スキルデ?タベ?ス
-struct skill_db {
+struct s_skill_db {
char *name;
char *desc;
int range[MAX_SKILL_LEVEL],hit,inf,pl[MAX_SKILL_LEVEL],nk,splash[MAX_SKILL_LEVEL],max;
@@ -80,7 +80,7 @@ struct skill_db {
int unit_target;
int unit_flag;
};
-extern struct skill_db skill_db[MAX_SKILL_DB];
+extern struct s_skill_db skill_db[MAX_SKILL_DB];
struct skill_name_db {
int id; // skill id
@@ -91,7 +91,7 @@ struct skill_name_db {
#define MAX_SKILL_UNIT_LAYOUT 50
#define MAX_SQUARE_LAYOUT 5 // 11*11のユニット配置が最大
#define MAX_SKILL_UNIT_COUNT ((MAX_SQUARE_LAYOUT*2+1)*(MAX_SQUARE_LAYOUT*2+1))
-struct skill_unit_layout {
+struct s_skill_unit_layout {
int count;
int dx[MAX_SKILL_UNIT_COUNT];
int dy[MAX_SKILL_UNIT_COUNT];
@@ -112,27 +112,27 @@ enum {
};
// アイテム作成デ?タベ?ス
-struct skill_produce_db {
+struct s_skill_produce_db {
int nameid, trigger;
int req_skill,req_skill_lv,itemlv;
int mat_id[MAX_PRODUCE_RESOURCE],mat_amount[MAX_PRODUCE_RESOURCE];
};
-extern struct skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB];
+extern struct s_skill_produce_db skill_produce_db[MAX_SKILL_PRODUCE_DB];
// 矢作成デ?タベ?ス
-struct skill_arrow_db {
+struct s_skill_arrow_db {
int nameid, trigger;
int cre_id[5],cre_amount[5];
};
-extern struct skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB];
+extern struct s_skill_arrow_db skill_arrow_db[MAX_SKILL_ARROW_DB];
// アブラカダブラデ?タベ?ス
-struct skill_abra_db {
+struct s_skill_abra_db {
int nameid;
int req_lv;
int per;
};
-extern struct skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB];
+extern struct s_skill_abra_db skill_abra_db[MAX_SKILL_ABRA_DB];
extern int enchant_eff[5];
extern int deluge_eff[5];
diff --git a/src/map/status.c b/src/map/status.c
index 5d07ea59b..9c892818f 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -183,7 +183,7 @@ void initChangeTables(void)
add_sc(HT_SANDMAN, SC_SLEEP);
add_sc(HT_FLASHER, SC_BLIND);
add_sc(HT_FREEZINGTRAP, SC_FREEZE);
- set_sc(AS_CLOAKING, SC_CLOAKING, SI_CLOAKING, SCB_CRI|SCB_SPEED);
+ set_sc(AS_CLOAKING, SC_CLOAKING, SI_CLOAKING, SCB_CRI|SCB_SPEED);
add_sc(AS_SONICBLOW, SC_STUN);
set_sc(AS_GRIMTOOTH, SC_SLOWDOWN, SI_BLANK, SCB_SPEED);
set_sc(AS_ENCHANTPOISON, SC_ENCPOISON, SI_ENCPOISON, SCB_ATK_ELE);
@@ -6581,47 +6581,36 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
{
int type = data;
struct block_list *bl;
- struct map_session_data *sd=NULL;
+ struct map_session_data *sd;
struct status_data *status;
struct status_change *sc;
-// security system to prevent forgetting timer removal
- int temp_timerid;
-
- bl=map_id2bl(id);
-#ifndef _WIN32
- nullpo_retr_f(0, bl, "id=%d data=%d",id,data);
-#endif
- sc=status_get_sc(bl);
+ bl = map_id2bl(id);
+ sc = status_get_sc(bl);
status = status_get_status_data(bl);
- if (!sc || !status)
- { //Temporal debug until case is resolved. [Skotlex]
+ if( !bl || !sc || !status )
+ {
ShowDebug("status_change_timer: Null pointer id: %d data: %d bl-type: %d\n", id, data, bl?bl->type:-1);
return 0;
}
- if(bl->type==BL_PC)
- sd=(struct map_session_data *)bl;
-
- if(sc->data[type].timer != tid) {
+ if( sc->data[type].timer != tid )
+ {
if(battle_config.error_log)
ShowError("status_change_timer: Mismatch for type %d: %d != %d (bl id %d)\n",type,tid,sc->data[type].timer, bl->id);
return 0;
}
- // security system to prevent forgetting timer removal
- // you shouldn't be that careless inside the switch here
- temp_timerid = sc->data[type].timer;
- sc->data[type].timer = -1;
+ BL_CAST(BL_PC, bl, sd);
- switch(type){ /* 特殊な?理になる場合 */
- case SC_MAXIMIZEPOWER: /* マキシマイズパワ? */
+ switch(type)
+ {
+ case SC_MAXIMIZEPOWER:
case SC_CLOAKING:
if(!status_charge(bl, 0, 1))
break; //Not enough SP to continue.
- sc->data[type].timer=add_timer(
- sc->data[type].val2+tick, status_change_timer, bl->id, data);
+ sc->data[type].timer = add_timer(sc->data[type].val2+tick, status_change_timer, bl->id, data);
return 0;
case SC_CHASEWALK:
@@ -6633,17 +6622,14 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
(sc->data[SC_SPIRIT].timer != -1 && sc->data[SC_SPIRIT].val2 == SL_ROGUE?10:1) //SL bonus -> x10 duration
*skill_get_time2(StatusSkillChangeTable[type],sc->data[type].val1));
}
- sc->data[type].timer = add_timer(
- sc->data[type].val2+tick, status_change_timer, bl->id, data);
+ sc->data[type].timer = add_timer(sc->data[type].val2+tick, status_change_timer, bl->id, data);
return 0;
break;
case SC_SKA:
if((--sc->data[type].val2)>0){
sc->data[type].val3 = rand()%100; //Random defense.
- sc->data[type].timer=add_timer(
- 1000+tick, status_change_timer,
- bl->id, data);
+ sc->data[type].timer = add_timer(1000+tick, status_change_timer,bl->id, data);
return 0;
}
break;
@@ -6654,9 +6640,7 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
if(sc->data[type].val2 % sc->data[type].val4 == 0 &&!status_charge(bl, 0, 1))
break; //Fail if it's time to substract SP and there isn't.
- sc->data[type].timer=add_timer(
- 1000+tick, status_change_timer,
- bl->id, data);
+ sc->data[type].timer = add_timer(1000+tick, status_change_timer,bl->id, data);
return 0;
}
break;
@@ -6664,29 +6648,24 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
case SC_SIGHT:
case SC_RUWACH:
case SC_SIGHTBLASTER:
- {
- map_foreachinrange( status_change_timer_sub, bl,
- sc->data[type].val3, BL_CHAR, bl,sc,type,tick);
+ map_foreachinrange( status_change_timer_sub, bl, sc->data[type].val3, BL_CHAR, bl,sc,type,tick);
- if( (--sc->data[type].val2)>0 ){
- sc->data[type].timer=add_timer( /* タイマ?再設定 */
- 250+tick, status_change_timer,
- bl->id, data);
- return 0;
- }
+ if( (--sc->data[type].val2)>0 ){
+ sc->data[type].timer = add_timer(250+tick, status_change_timer, bl->id, data);
+ return 0;
}
break;
case SC_PROVOKE:
if(sc->data[type].val2) { //Auto-provoke (it is ended in status_heal)
- sc->data[type].timer=add_timer(1000*60+tick,status_change_timer, bl->id, data );
+ sc->data[type].timer = add_timer(1000*60+tick,status_change_timer, bl->id, data );
return 0;
}
break;
case SC_ENDURE:
if(sc->data[type].val4) { //Infinite Endure.
- sc->data[type].timer=add_timer(1000*60+tick,status_change_timer, bl->id, data);
+ sc->data[type].timer = add_timer(1000*60+tick,status_change_timer, bl->id, data);
return 0;
}
break;
@@ -6697,14 +6676,14 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
unit_stop_walking(bl,1);
sc->opt1 = OPT1_STONE;
clif_changeoption(bl);
- sc->data[type].timer=add_timer(1000+tick,status_change_timer, bl->id, data );
+ sc->data[type].timer = add_timer(1000+tick,status_change_timer, bl->id, data );
status_calc_bl(bl, StatusChangeFlagTable[type]);
return 0;
}
if((--sc->data[type].val3) > 0) {
- if((++sc->data[type].val4)%5 == 0 && status->hp > status->max_hp>>2)
+ if((++sc->data[type].val4)%5 == 0 && status->hp > status->max_hp/4)
status_zap(bl, sc->data[type].val2, 0);
- sc->data[type].timer=add_timer(1000+tick,status_change_timer, bl->id, data );
+ sc->data[type].timer = add_timer(1000+tick,status_change_timer, bl->id, data );
return 0;
}
break;
@@ -6719,25 +6698,19 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
if (status_isdead(bl))
break;
}
- sc->data[type].timer = add_timer (1000 + tick, status_change_timer, bl->id, data );
+ sc->data[type].timer = add_timer(1000 + tick, status_change_timer, bl->id, data );
return 0;
}
break;
case SC_TENSIONRELAX:
if(status->max_hp > status->hp && (--sc->data[type].val3) > 0){
- sc->data[type].timer=add_timer(
- sc->data[type].val4+tick, status_change_timer,
- bl->id, data);
+ sc->data[type].timer = add_timer(sc->data[type].val4+tick, status_change_timer, bl->id, data);
return 0;
}
break;
- case SC_BLEEDING: // [celest]
- // i hope i haven't interpreted it wrong.. which i might ^^;
- // Source:
- // - 10ゥェエェネェヒHPェャハ盒
- // - ェホェ゙ェ゙ォオ?ォミケヤムェ茘ォォーェキェニェ?ヘェマ眈ェィェハェ、
- // To-do: bleeding effect increases damage taken?
+
+ case SC_BLEEDING:
if ((--sc->data[type].val4) >= 0) {
status_fix_damage(NULL, bl, rand()%600 + 200, 0);
if (status_isdead(bl))
@@ -6748,12 +6721,10 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
break;
case SC_KNOWLEDGE:
- if (sd) {
- if(bl->m != sd->feel_map[0].m
- && bl->m != sd->feel_map[1].m
- && bl->m != sd->feel_map[2].m)
- break; //End it
- } //Otherwise continue.
+ if (sd) {
+ if(bl->m != sd->feel_map[0].m && bl->m != sd->feel_map[1].m && bl->m != sd->feel_map[2].m)
+ break; //End it
+ } //Otherwise continue.
// Status changes that don't have a time limit
case SC_AETERNA:
case SC_TRICKDEAD:
@@ -6772,9 +6743,9 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
case SC_READYCOUNTER:
case SC_RUN:
case SC_DODGE:
- case SC_AUTOBERSERK: //continues until triggered off manually. [Skotlex]
- case SC_SIGNUMCRUCIS: /* シグナムクルシス */
- sc->data[type].timer=add_timer( 1000*600+tick,status_change_timer, bl->id, data );
+ case SC_AUTOBERSERK:
+ case SC_SIGNUMCRUCIS:
+ sc->data[type].timer = add_timer( 1000*600+tick,status_change_timer, bl->id, data );
return 0;
case SC_DANCING: //ダンススキルの時間SP消費
@@ -6821,15 +6792,14 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
s=10;
break;
}
- if (s && (counter%s == 0)) {
+ if (s && (counter%s == 0))
+ {
if (sc->data[SC_LONGING].timer != -1)
sp*= 3;
if (!status_charge(bl, 0, sp))
break;
}
- sc->data[type].timer=add_timer(
- 1000+tick, status_change_timer,
- bl->id, data);
+ sc->data[type].timer = add_timer(1000+tick, status_change_timer, bl->id, data);
return 0;
}
break;
@@ -6847,40 +6817,35 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
break;
case SC_BERSERK:
- //The damage below should be made aware that Berserk is active.
- sc->data[type].timer = temp_timerid;
// 5% every 10 seconds [DracoRPG]
if((--sc->data[type].val3)>0 && status_charge(bl, sc->data[type].val2, 0))
{
- sc->data[type].timer = add_timer(
- sc->data[type].val4+tick, status_change_timer,
- bl->id, data);
+ sc->data[type].timer = add_timer(sc->data[type].val4+tick, status_change_timer, bl->id, data);
return 0;
}
break;
+
case SC_NOCHAT:
if(sd){
sd->status.manner++;
clif_updatestatus(sd,SP_MANNER);
if (sd->status.manner < 0)
{ //Every 60 seconds your manner goes up by 1 until it gets back to 0.
- sc->data[type].timer=add_timer(60000+tick, status_change_timer, bl->id, data);
+ sc->data[type].timer = add_timer(60000+tick, status_change_timer, bl->id, data);
return 0;
}
}
break;
case SC_SPLASHER:
- if (sc->data[type].val4 % 1000 == 0) {
- char timer[10];
- snprintf (timer, 10, "%d", sc->data[type].val4/1000);
- clif_message(bl, timer);
- }
+ //if (sc->data[type].val4 % 1000 == 0) {
+ // char timer[10];
+ // snprintf (timer, 10, "%d", sc->data[type].val4/1000);
+ // clif_message(bl, timer);
+ //}
if((sc->data[type].val4 -= 500) > 0) {
- sc->data[type].timer = add_timer(
- 500 + tick, status_change_timer,
- bl->id, data);
- return 0;
+ sc->data[type].timer = add_timer(500 + tick, status_change_timer, bl->id, data);
+ return 0;
}
break;
@@ -6890,10 +6855,8 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
struct block_list *pbl = map_id2bl(sc->data[type].val1);
if (pbl && check_distance_bl(bl, pbl, 7) && (sc->data[type].val2--)>0)
{
- sc->data[type].timer = add_timer(
- 1000 + tick, status_change_timer,
- bl->id, data);
- return 0;
+ sc->data[type].timer = add_timer(1000 + tick, status_change_timer, bl->id, data);
+ return 0;
}
}
break;
@@ -6906,9 +6869,7 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
sp = (sc->data[type].val1 > 5) ? 35 : 20;
if(!status_charge(bl, hp, sp))
break;
- sc->data[type].timer = add_timer(
- 10000+tick, status_change_timer,
- bl->id, data);
+ sc->data[type].timer = add_timer(10000+tick, status_change_timer, bl->id, data);
return 0;
}
break;
@@ -6918,39 +6879,30 @@ int status_change_timer(int tid, unsigned int tick, int id, int data)
struct block_list *tbl = map_id2bl(sc->data[type].val2);
if (tbl && battle_check_range(bl, tbl, 2)){
- sc->data[type].timer = add_timer(
- 1000 + tick, status_change_timer,
- bl->id, data);
- return 0;
+ sc->data[type].timer = add_timer(1000 + tick, status_change_timer, bl->id, data);
+ return 0;
}
}
break;
+
case SC_JAILED:
if(sc->data[type].val1 == INT_MAX || --sc->data[type].val1 > 0)
{
- sc->data[type].timer=add_timer(
- 60000+tick, status_change_timer, bl->id,data);
+ sc->data[type].timer = add_timer(60000+tick, status_change_timer, bl->id,data);
return 0;
}
break;
+
case SC_BLIND:
if(sc->data[SC_FOGWALL].timer!= -1)
{ //Blind lasts forever while you are standing on the fog.
- sc->data[type].timer=add_timer(
- 5000+tick, status_change_timer,
- bl->id, data);
+ sc->data[type].timer = add_timer(5000+tick, status_change_timer, bl->id, data);
return 0;
}
break;
}
- // default for all non-handled control paths
- // security system to prevent forgetting timer removal
-
- // if we reach this point we need the timer for the next call,
- // so restore it to have status_change_end handle a valid timer
- sc->data[type].timer = temp_timerid;
-
+ // default for all non-handled control paths is to end the status
return status_change_end( bl,type,tid );
}
diff --git a/src/map/unit.c b/src/map/unit.c
index 812dc0b47..17d9581f1 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -274,8 +274,8 @@ static int unit_delay_walktoxy_timer(int tid, unsigned int tick, int id, int dat
//&4 -> Delay walking if the reason you can't walk is the canwalk delay
int unit_walktoxy( struct block_list *bl, int x, int y, int flag)
{
- struct unit_data *ud = NULL;
- struct status_change *sc = NULL;
+ struct unit_data* ud = NULL;
+ struct status_change* sc = NULL;
nullpo_retr(0, bl);