summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/clif.c6
-rw-r--r--src/map/mob.c174
-rw-r--r--src/map/skill.c26
-rw-r--r--src/map/status.c2
4 files changed, 103 insertions, 105 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index a06857834..b2d70f55e 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -9670,6 +9670,7 @@ void clif_parse_UseSkillToId(int fd, struct map_session_data *sd) {
if (sd->menuskill_id == SA_TAMINGMONSTER)
sd->menuskill_id = sd->menuskill_lv = 0; //Cancel pet capture.
else
+ if (sd->menuskill_id != SA_AUTOSPELL)
return; //Can't use skills while a menu is open.
}
if (sd->skillitem == skillnum) {
@@ -9774,6 +9775,7 @@ void clif_parse_UseSkillToPosSub(int fd, struct map_session_data *sd, int skilll
if (sd->menuskill_id == SA_TAMINGMONSTER)
sd->menuskill_id = sd->menuskill_lv = 0; //Cancel pet capture.
else
+ if (sd->menuskill_id != SA_AUTOSPELL)
return; //Can't use skills while a menu is open.
}
@@ -9841,7 +9843,9 @@ void clif_parse_UseSkillMap(int fd,struct map_session_data *sd)
if(sd->sc.option&(OPTION_WEDDING|OPTION_XMAS))
return;
- if(sd->menuskill_id && sd->menuskill_id != RFIFOW(fd,2))
+ if(sd->menuskill_id &&
+ sd->menuskill_id != RFIFOW(fd,2) &&
+ sd->menuskill_id != SA_AUTOSPELL)
return; //Can't use skills while a menu is open.
pc_delinvincibletimer(sd);
diff --git a/src/map/mob.c b/src/map/mob.c
index c56e4362f..fa23e1b7b 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -2675,8 +2675,9 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
{
struct mob_skill *ms;
struct block_list *fbl = NULL; //Friend bl, which can either be a BL_PC or BL_MOB depending on the situation. [Skotlex]
+ struct block_list *bl;
struct mob_data *fmd = NULL;
- int i,n;
+ int i,j,n;
nullpo_retr (0, md);
nullpo_retr (0, ms = md->db->skill);
@@ -2734,7 +2735,6 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
if (!md->sc.count) {
flag = 0;
} else if (ms[i].cond2 == -1) {
- int j;
for (j = SC_COMMON_MIN; j <= SC_COMMON_MAX; j++)
if ((flag = (md->sc.data[j].timer != -1)) != 0)
break;
@@ -2778,103 +2778,95 @@ int mobskill_use(struct mob_data *md, unsigned int tick, int event)
//Execute skill
if (skill_get_casttype(ms[i].skill_id) == CAST_GROUND)
- {
- struct block_list *bl = NULL;
- short x = 0, y = 0;
- if (ms[i].target <= MST_AROUND) {
- switch (ms[i].target) {
- case MST_RANDOM: //Pick a random enemy within skill range.
- bl = battle_getenemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
- skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
- break;
- case MST_TARGET:
- case MST_AROUND5:
- case MST_AROUND6:
- case MST_AROUND7:
- case MST_AROUND8:
- bl = map_id2bl(md->target_id);
- break;
- case MST_MASTER:
- bl = &md->bl;
- if (md->master_id)
- bl = map_id2bl(md->master_id);
- if (bl) //Otherwise, fall through.
- break;
- case MST_FRIEND:
- if (fbl)
- {
- bl = fbl;
- break;
- } else if (fmd) {
- bl= &fmd->bl;
- break;
- } // else fall through
- default:
- bl = &md->bl;
+ { //Ground skill.
+ short x, y;
+ switch (ms[i].target) {
+ case MST_RANDOM: //Pick a random enemy within skill range.
+ bl = battle_getenemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
+ skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
+ break;
+ case MST_TARGET:
+ case MST_AROUND5:
+ case MST_AROUND6:
+ case MST_AROUND7:
+ case MST_AROUND8:
+ bl = map_id2bl(md->target_id);
+ break;
+ case MST_MASTER:
+ bl = &md->bl;
+ if (md->master_id)
+ bl = map_id2bl(md->master_id);
+ if (bl) //Otherwise, fall through.
break;
- }
- if (bl != NULL) {
- x = bl->x; y=bl->y;
- }
+ case MST_FRIEND:
+ bl = fbl?fbl:(fmd?&fmd->bl:&md->bl);
+ break;
+ default:
+ bl = &md->bl;
+ break;
}
- if (x <= 0 || y <= 0)
- continue;
+ if (!bl) continue;
+ x = bl->x;
+ y = bl->y;
// Look for an area to cast the spell around...
if (ms[i].target >= MST_AROUND1 || ms[i].target >= MST_AROUND5) {
- int r = ms[i].target >= MST_AROUND1?
+ j = ms[i].target >= MST_AROUND1?
(ms[i].target-MST_AROUND1) +1:
(ms[i].target-MST_AROUND5) +1;
- map_search_freecell(&md->bl, md->bl.m, &x, &y, r, r, 3);
+ map_search_freecell(&md->bl, md->bl.m, &x, &y, j, j, 3);
}
md->skillidx = i;
flag = unit_skilluse_pos2(&md->bl, x, y, ms[i].skill_id, ms[i].skill_lv,
ms[i].casttime, ms[i].cancel);
- if (!flag) md->skillidx = -1; //Skill failed.
- return flag;
} else {
- if (ms[i].target <= MST_MASTER) {
- struct block_list *bl;
- switch (ms[i].target) {
- case MST_RANDOM: //Pick a random enemy within skill range.
- bl = battle_getenemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
- skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
+ //Targetted skill
+ switch (ms[i].target) {
+ case MST_RANDOM: //Pick a random enemy within skill range.
+ bl = battle_getenemy(&md->bl, DEFAULT_ENEMY_TYPE(md),
+ skill_get_range2(&md->bl, ms[i].skill_id, ms[i].skill_lv));
+ break;
+ case MST_TARGET:
+ bl = map_id2bl(md->target_id);
+ break;
+ case MST_MASTER:
+ bl = &md->bl;
+ if (md->master_id)
+ bl = map_id2bl(md->master_id);
+ if (bl) //Otherwise, fall through.
break;
- case MST_TARGET:
- bl = map_id2bl(md->target_id);
+ case MST_FRIEND:
+ if (fbl) {
+ bl = fbl;
break;
- case MST_MASTER:
- bl = &md->bl;
- if (md->master_id)
- bl = map_id2bl(md->master_id);
- if (bl) //Otherwise, fall through.
- break;
- case MST_FRIEND:
- if (fbl) {
- bl = fbl;
- break;
- } else if (fmd) {
- bl = &fmd->bl;
- break;
- } // else fall through
- default:
- bl = &md->bl;
+ } else if (fmd) {
+ bl = &fmd->bl;
break;
- }
- md->skillidx = i;
- flag = (bl && unit_skilluse_id2(&md->bl, bl->id, ms[i].skill_id, ms[i].skill_lv,
- ms[i].casttime, ms[i].cancel));
- if (!flag) md->skillidx = -1;
- return flag;
- } else {
- if (battle_config.error_log)
- ShowWarning("Wrong mob skill target 'around' for non-ground skill %d (%s). Mob %d - %s\n",
- ms[i].skill_id, skill_get_name(ms[i].skill_id), md->class_, md->db->sprite);
- continue;
+ } // else fall through
+ default:
+ bl = &md->bl;
+ break;
}
+ if (!bl) continue;
+ md->skillidx = i;
+ flag = unit_skilluse_id2(&md->bl, bl->id, ms[i].skill_id, ms[i].skill_lv,
+ ms[i].casttime, ms[i].cancel);
+ }
+ //Skill used. Post-setups...
+ if (!flag)
+ { //Skill failed.
+ md->skillidx = -1;
+ return 0;
}
+ if(battle_config.mob_ai&0x200)
+ { //pass on delay to same skill.
+ for (j = 0; j < md->db->maxskill; j++)
+ if (md->db->skill[j].skill_id == ms[i].skill_id)
+ md->skilldelay[j]=tick;
+ } else
+ md->skilldelay[i]=tick;
return 1;
}
-
+ //No skill was used.
return 0;
}
/*==========================================
@@ -3827,6 +3819,26 @@ static int mob_readskilldb(void)
if( strcmp(sp[9],target[j].str)==0)
ms->target=target[j].id;
}
+
+ //Check that the target condition is right for the skill type. [Skotlex]
+ if (skill_get_casttype(ms->skill_id) == CAST_GROUND)
+ { //Ground skill.
+ if (ms->target > MST_AROUND)
+ {
+ if (battle_config.error_log)
+ ShowWarning("Wrong mob skill target for ground skill %d (%s) for %s\n",
+ ms->skill_id, skill_get_name(ms[i].skill_id),
+ mob_id < 0?"all mobs":mob_db_data[mob_id]->sprite);
+ ms->target = MST_TARGET;
+ }
+ } else if (ms[i].target > MST_MASTER) {
+ if (battle_config.error_log)
+ ShowWarning("Wrong mob skill target 'around' for non-ground skill %d (%s). for %s\n",
+ ms[i].skill_id, skill_get_name(ms[i].skill_id),
+ mob_id < 0?"all mobs":mob_db_data[mob_id]->sprite);
+ ms->target = MST_TARGET;
+ }
+
ms->cond1=-1;
tmp = sizeof(cond1)/sizeof(cond1[0]);
for(j=0;j<tmp && strcmp(sp[10],cond1[j].str);j++);
diff --git a/src/map/skill.c b/src/map/skill.c
index 66b923a62..91c7b327f 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -5678,17 +5678,8 @@ int skill_castend_id (int tid, unsigned int tick, int id, int data)
md->last_thinktime=tick +md->status.amotion;
else
md->last_thinktime=tick +md->status.adelay;
- if(battle_config.mob_ai&0x200) { //pass on delay to same skill.
- int i;
- for (i = 0; i < md->db->maxskill; i++)
- if (md->db->skill[i].skill_id == ud->skillid)
- md->skilldelay[i]=tick;
- } else
- if(md->skillidx >= 0) {
- md->skilldelay[md->skillidx]=tick;
- if (md->db->skill[md->skillidx].emotion >= 0)
- clif_emotion(src, md->db->skill[md->skillidx].emotion);
- }
+ if(md->skillidx >= 0 && md->db->skill[md->skillidx].emotion >= 0)
+ clif_emotion(src, md->db->skill[md->skillidx].emotion);
}
if(src != target && battle_config.skill_add_range &&
@@ -5864,17 +5855,8 @@ int skill_castend_pos (int tid, unsigned int tick, int id, int data)
md->last_thinktime=tick +md->status.amotion;
else
md->last_thinktime=tick +md->status.adelay;
- if(battle_config.mob_ai&0x200) { //pass on delay to same skill.
- int i;
- for (i = 0; i < md->db->maxskill; i++)
- if (md->db->skill[i].skill_id == ud->skillid)
- md->skilldelay[i]=tick;
- } else
- if(md->skillidx >= 0) {
- md->skilldelay[md->skillidx]=tick;
- if (md->db->skill[md->skillidx].emotion >= 0)
- clif_emotion(src, md->db->skill[md->skillidx].emotion);
- }
+ if(md->skillidx >= 0 && md->db->skill[md->skillidx].emotion >= 0)
+ clif_emotion(src, md->db->skill[md->skillidx].emotion);
}
if(battle_config.skill_log && battle_config.skill_log&src->type)
diff --git a/src/map/status.c b/src/map/status.c
index 2e1c45833..e0375bfad 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -428,7 +428,7 @@ void initChangeTables(void) {
StatusIconChangeTable[SC_INTFOOD] = SI_FOODINT;
StatusIconChangeTable[SC_DEXFOOD] = SI_FOODDEX;
StatusIconChangeTable[SC_LUKFOOD] = SI_FOODLUK;
- StatusIconChangeTable[SC_FLEEFOOD] = SI_FOODFLEE;
+ StatusIconChangeTable[SC_FLEEFOOD]= SI_FOODFLEE;
StatusIconChangeTable[SC_HITFOOD] = SI_FOODHIT;
//Other SC which are not necessarily associated to skills.
StatusChangeFlagTable[SC_ASPDPOTION0] = SCB_ASPD;