summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-01-20 10:08:00 +0100
committerHaru <haru@dotalux.com>2020-02-09 23:46:56 +0100
commit38a504a04a2c864938ef3e105d0ce22332ff0b7a (patch)
tree1da723d240928039361e0c4f89e810ae2c93cc73 /src/map
parent1098b588625774ca2cf4e05527b00fd4d0187919 (diff)
downloadhercules-38a504a04a2c864938ef3e105d0ce22332ff0b7a.tar.gz
hercules-38a504a04a2c864938ef3e105d0ce22332ff0b7a.tar.bz2
hercules-38a504a04a2c864938ef3e105d0ce22332ff0b7a.tar.xz
hercules-38a504a04a2c864938ef3e105d0ce22332ff0b7a.zip
Added a new option flag to itemskill() script command, to be able to cast a skill without cast time.
Diffstat (limited to 'src/map')
-rw-r--r--src/map/pc.h3
-rw-r--r--src/map/script.c3
-rw-r--r--src/map/script.h1
-rw-r--r--src/map/unit.c13
4 files changed, 18 insertions, 2 deletions
diff --git a/src/map/pc.h b/src/map/pc.h
index 4d7a7eef0..1540482c3 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -242,6 +242,7 @@ struct map_session_data {
unsigned int lapine_ui : 1;
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.
} state;
struct {
unsigned char no_weapon_damage, no_magic_damage, no_misc_damage;
@@ -647,7 +648,7 @@ END_ZEROED_BLOCK;
VECTOR_DECL(int) title_ids;
/*
- * itemskill_conditions_checked/itemskill_no_conditions abuse prevention.
+ * itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime 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 470ad9408..acf9fb9ff 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 abuse prevention.
+ /// itemskill_conditions_checked/itemskill_no_conditions/itemskill_no_casttime 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;
@@ -11012,6 +11012,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.
if (sd->state.itemskill_no_conditions == 0) {
if (skill->check_condition_castbegin(sd, id, lv) == 0 || skill->check_condition_castend(sd, id, lv) == 0)
diff --git a/src/map/script.h b/src/map/script.h
index c981a895d..8167a9efd 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -570,6 +570,7 @@ enum mado_type {
enum itemskill_flag {
ISF_NONE = 0x00,
ISF_IGNORECONDITIONS = 0x01, // Ignore skill conditions and don't consume them.
+ ISF_INSTANTCAST = 0x02, // Cast skill instantaneously.
};
/**
diff --git a/src/map/unit.c b/src/map/unit.c
index 923438d78..ee721bb64 100644
--- a/src/map/unit.c
+++ b/src/map/unit.c
@@ -1051,6 +1051,7 @@ static int unit_skilluse_id(struct block_list *src, int target_id, uint16 skill_
sd->itemskill_lv = 0;
sd->state.itemskill_conditions_checked = 0;
sd->state.itemskill_no_conditions = 0;
+ sd->state.itemskill_no_casttime = 0;
}
return ret;
@@ -1610,6 +1611,11 @@ static int unit_skilluse_id2(struct block_list *src, int target_id, uint16 skill
if (!ud->state.running) //need TK_RUN or WUGDASH handler to be done before that, see bugreport:6026
unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);// even though this is not how official works but this will do the trick. bugreport:6829
+ if (sd != NULL && sd->state.itemskill_no_casttime == 1 && sd->itemskill_id == sd->skillitem
+ && sd->itemskill_lv == sd->skillitemlv) {
+ casttime = 0;
+ }
+
// in official this is triggered even if no cast time.
clif->useskill(src, src->id, target_id, 0,0, skill_id, skill_lv, casttime);
if( casttime > 0 || temp )
@@ -1689,6 +1695,7 @@ static int unit_skilluse_pos(struct block_list *src, short skill_x, short skill_
sd->itemskill_lv = 0;
sd->state.itemskill_conditions_checked = 0;
sd->state.itemskill_no_conditions = 0;
+ sd->state.itemskill_no_casttime = 0;
}
return ret;
@@ -1816,6 +1823,12 @@ static int unit_skilluse_pos2(struct block_list *src, short skill_x, short skill
}
unit->stop_walking(src, STOPWALKING_FLAG_FIXPOS);
+
+ if (sd != NULL && sd->state.itemskill_no_casttime == 1 && sd->itemskill_id == sd->skillitem
+ && sd->itemskill_lv == sd->skillitemlv) {
+ casttime = 0;
+ }
+
// in official this is triggered even if no cast time.
clif->useskill(src, src->id, 0, skill_x, skill_y, skill_id, skill_lv, casttime);
if( casttime > 0 ) {