summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-01-20 10:30:03 +0100
committerHaru <haru@dotalux.com>2020-02-09 23:46:56 +0100
commita67dddb0c21be9c6ceeb174db023d3b9db4a9db9 (patch)
tree670ad532f64967f2c6ace1ba678c4e6f57a4c1d2 /src
parent38a504a04a2c864938ef3e105d0ce22332ff0b7a (diff)
downloadhercules-a67dddb0c21be9c6ceeb174db023d3b9db4a9db9.tar.gz
hercules-a67dddb0c21be9c6ceeb174db023d3b9db4a9db9.tar.bz2
hercules-a67dddb0c21be9c6ceeb174db023d3b9db4a9db9.tar.xz
hercules-a67dddb0c21be9c6ceeb174db023d3b9db4a9db9.zip
Added a new option flag to itemskill() script command to be able to forcefully cast skill on on invoking character.
Diffstat (limited to 'src')
-rw-r--r--src/map/clif.c8
-rw-r--r--src/map/pc.h3
-rw-r--r--src/map/script.c5
-rw-r--r--src/map/script.h1
-rw-r--r--src/map/unit.c2
5 files changed, 15 insertions, 4 deletions
diff --git a/src/map/clif.c b/src/map/clif.c
index 868117a96..50b81d25d 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -6759,10 +6759,16 @@ static void clif_item_skill(struct map_session_data *sd, uint16 skill_id, uint16
nullpo_retv(sd);
fd=sd->fd;
+
+ int type = skill->get_inf(skill_id);
+
+ if (sd->state.itemskill_castonself == 1 && sd->itemskill_id == sd->skillitem && sd->itemskill_lv == sd->skillitemlv)
+ type = INF_SELF_SKILL;
+
WFIFOHEAD(fd,packet_len(0x147));
WFIFOW(fd, 0)=0x147;
WFIFOW(fd, 2)=skill_id;
- WFIFOL(fd, 4)=skill->get_inf(skill_id);
+ WFIFOL(fd, 4) = type;
WFIFOW(fd, 8)=skill_lv;
WFIFOW(fd,10)=skill->get_sp(skill_id,skill_lv);
WFIFOW(fd,12)=skill->get_range2(&sd->bl, skill_id,skill_lv);
diff --git a/src/map/pc.h b/src/map/pc.h
index 1540482c3..26e33a400 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -243,6 +243,7 @@ struct map_session_data {
unsigned int itemskill_conditions_checked : 1; // Used by itemskill() script command, to prevent second check of conditions after target was selected.
unsigned int itemskill_no_conditions : 1; // Used by itemskill() script command, to ignore skill conditions and don't consume them.
unsigned int itemskill_no_casttime : 1; // Used by itemskill() script command, to cast skill instantaneously.
+ unsigned int itemskill_castonself : 1; // Used by itemskill() script command, to forcefully cast skill on invoking character.
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@@ -648,7 +649,7 @@ END_ZEROED_BLOCK;
VECTOR_DECL(int) title_ids;
/*
- * itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime abuse prevention.
+ * itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime/itemskill_castonself abuse prevention.
* If a skill, casted by itemskill() script command, is aborted while target selection,
* the map server gets no notification where these states could be unset.
* Thus we need this helper variables to prevent abusing these states for next skill cast.
diff --git a/src/map/script.c b/src/map/script.c
index acf9fb9ff..b51c1a915 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -11003,7 +11003,7 @@ static BUILDIN(itemskill)
sd->skillitem=id;
sd->skillitemlv=lv;
- /// itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime abuse prevention.
+ /// itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime/itemskill_castonself abuse prevention.
/// Unset in unit_skilluse_id()/unit_skilluse_pos() if skill was not aborted while target selection.
sd->itemskill_id = id;
sd->itemskill_lv = lv;
@@ -11013,6 +11013,7 @@ static BUILDIN(itemskill)
sd->state.itemskill_conditions_checked = 0; /// Skill casting items will check the conditions prior to the target selection in AEGIS. Thus we need a flag to prevent checking them twice.
sd->state.itemskill_no_conditions = ((flag & ISF_IGNORECONDITIONS) == ISF_IGNORECONDITIONS) ? 1 : 0; /// Unset in unit_skilluse_id()/unit_skilluse_pos() if skill was not aborted while target selection.
sd->state.itemskill_no_casttime = ((flag & ISF_INSTANTCAST) == ISF_INSTANTCAST) ? 1 : 0; /// /// Unset in unit_skilluse_id()/unit_skilluse_pos() if skill was not aborted while target selection.
+ sd->state.itemskill_castonself = ((flag & ISF_CASTONSELF) == ISF_CASTONSELF) ? 1 : 0; /// Unset in unit_skilluse_id()/unit_skilluse_pos() if skill was not aborted while target selection.
if (sd->state.itemskill_no_conditions == 0) {
if (skill->check_condition_castbegin(sd, id, lv) == 0 || skill->check_condition_castend(sd, id, lv) == 0)
@@ -11021,7 +11022,7 @@ static BUILDIN(itemskill)
sd->state.itemskill_conditions_checked = 1; /// Unset in unit_skilluse_id()/unit_skilluse_pos() if skill was not aborted while target selection.
}
- clif->item_skill(sd,id,lv);
+ clif->item_skill(sd, id, lv);
return true;
}
/*==========================================
diff --git a/src/map/script.h b/src/map/script.h
index 8167a9efd..857d22c61 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -571,6 +571,7 @@ enum itemskill_flag {
ISF_NONE = 0x00,
ISF_IGNORECONDITIONS = 0x01, // Ignore skill conditions and don't consume them.
ISF_INSTANTCAST = 0x02, // Cast skill instantaneously.
+ ISF_CASTONSELF = 0x04, // Forcefully cast skill on invoking character without showing the target selection cursor.
};
/**
diff --git a/src/map/unit.c b/src/map/unit.c
index ee721bb64..3ad94d20a 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1052,6 +1052,7 @@ static int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_
sd->state.itemskill_conditions_checked = 0;
sd->state.itemskill_no_conditions = 0;
sd->state.itemskill_no_casttime = 0;
+ sd->state.itemskill_castonself = 0;
}
return ret;
@@ -1696,6 +1697,7 @@ static int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_
sd->state.itemskill_conditions_checked = 0;
sd->state.itemskill_no_conditions = 0;
sd->state.itemskill_no_casttime = 0;
+ sd->state.itemskill_castonself = 0;
}
return ret;