summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenpachi Developer <Kenpachi.Developer@gmx.de>2020-01-20 11:22:12 +0100
committerHaru <haru@dotalux.com>2020-02-09 23:51:31 +0100
commit9e8369e0daa596a93934dece1543af2c0a17412c (patch)
tree7c11b66323c7a2b61810c2bf8d22fa6f5f208c81
parent5000729333105107994d67c639f408beb8055f89 (diff)
downloadhercules-9e8369e0daa596a93934dece1543af2c0a17412c.tar.gz
hercules-9e8369e0daa596a93934dece1543af2c0a17412c.tar.bz2
hercules-9e8369e0daa596a93934dece1543af2c0a17412c.tar.xz
hercules-9e8369e0daa596a93934dece1543af2c0a17412c.zip
Applied code style to BUILDIN(itemskill).
-rw-r--r--src/map/script.c52
1 files changed, 29 insertions, 23 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 08a05004f..b87a46785 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10985,46 +10985,52 @@ static BUILDIN(guildopenstorage)
return true;
}
-/*==========================================
- * Make player use a skill trought item usage
- *------------------------------------------*/
-/// itemskill <skill id>,<level>{,flag
-/// itemskill "<skill name>",<level>{,flag
+/**
+ * Makes the attached character use a skill by using an item.
+ *
+ * @code{.herc}
+ * itemskill(<skill id>, <skill level>{, <flag>});
+ * itemskill("<skill name>", <skill level>{, <flag>});
+ * @endcode
+ *
+ */
static BUILDIN(itemskill)
{
- int id;
- int lv;
struct map_session_data *sd = script->rid2sd(st);
+
if (sd == NULL || sd->ud.skilltimer != INVALID_TIMER)
return true;
- id = ( script_isstringtype(st,2) ? skill->name2id(script_getstr(st,2)) : script_getnum(st,2) );
- lv = script_getnum(st,3);
- sd->skillitem=id;
- sd->skillitemlv=lv;
-
- /// 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;
+ sd->skillitem = script_isstringtype(st, 2) ? skill->name2id(script_getstr(st, 2)) : script_getnum(st, 2);
+ sd->skillitemlv = script_getnum(st, 3);
+ 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.
int flag = script_hasdata(st, 4) ? script_getnum(st, 4) : ISF_NONE;
- 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.
+ 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.
if (sd->state.itemskill_no_conditions == 0) {
- if (skill->check_condition_castbegin(sd, id, lv) == 0 || skill->check_condition_castend(sd, id, lv) == 0)
+ if (skill->check_condition_castbegin(sd, sd->skillitem, sd->skillitemlv) == 0
+ || skill->check_condition_castend(sd, sd->skillitem, sd->skillitemlv) == 0) {
return true;
+ }
- sd->state.itemskill_conditions_checked = 1; /// Unset in unit_skilluse_id()/unit_skilluse_pos() if skill was not aborted while target selection.
+ 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);
+ 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.
+
+ // 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 = sd->skillitem;
+ sd->itemskill_lv = sd->skillitemlv;
+
+ clif->item_skill(sd, sd->skillitem, sd->skillitemlv);
+
return true;
}
+
/*==========================================
* Attempt to create an item
*------------------------------------------*/