summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-19 20:31:57 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2007-10-19 20:31:57 +0000
commit9a83b5ad626f8bfd4011277173e8bf385e4971fe (patch)
treefac179a5bb93199cf5f0314ff21e935d7da47b72 /src/map/script.c
parentca003ef941f7a039a4251f28d0a60b61de66f186 (diff)
downloadhercules-9a83b5ad626f8bfd4011277173e8bf385e4971fe.tar.gz
hercules-9a83b5ad626f8bfd4011277173e8bf385e4971fe.tar.bz2
hercules-9a83b5ad626f8bfd4011277173e8bf385e4971fe.tar.xz
hercules-9a83b5ad626f8bfd4011277173e8bf385e4971fe.zip
- Added bonusautoscript and bonusautoscript2. These are used to attach a script to a player which gets executed on attack (or when attacked). Required for several of the more recent items.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@11519 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/script.c')
-rw-r--r--src/map/script.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c
index 458f57fb3..e1e3a02cf 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -3802,6 +3802,8 @@ BUILDIN_FUNC(bonus2);
BUILDIN_FUNC(bonus3);
BUILDIN_FUNC(bonus4);
BUILDIN_FUNC(bonus5);
+BUILDIN_FUNC(bonusautoscript);
+BUILDIN_FUNC(bonusautoscript2);
BUILDIN_FUNC(skill);
BUILDIN_FUNC(addtoskill); // [Valaris]
BUILDIN_FUNC(guildskill);
@@ -4134,6 +4136,8 @@ struct script_function buildin_func[] = {
BUILDIN_DEF2(bonus,"bonus3","iiii"),
BUILDIN_DEF2(bonus,"bonus4","iiiii"),
BUILDIN_DEF2(bonus,"bonus5","iiiiii"),
+ BUILDIN_DEF(bonusautoscript,"si?"),
+ BUILDIN_DEF(bonusautoscript2,"si?"),
BUILDIN_DEF(skill,"ii?"),
BUILDIN_DEF(addtoskill,"ii?"), // [Valaris]
BUILDIN_DEF(guildskill,"ii"),
@@ -7192,6 +7196,59 @@ BUILDIN_FUNC(bonus)
return 0;
}
+/// Bonus script that has a chance of being executed on attack.
+BUILDIN_FUNC(bonusautoscript)
+{
+ int rate, flag = 0;
+ const char *str;
+ struct script_code *script;
+ TBL_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 1;// no player attached, report source
+
+ str = script_getstr(st,2);
+ rate = script_getnum(st,3);
+ if( script_hasdata(st,4) )
+ flag = script_getnum(st,4);
+ script = parse_script(str, "autoscript bonus", 0, 0);
+ if (!script)
+ return 1;
+ if (!pc_autoscript_add(sd->autoscript, ARRAYLENGTH(sd->autoscript), rate, flag, script))
+ {
+ script_free_code(script);
+ return 1;
+ }
+ return 0;
+}
+/// Bonus script that has a chance of being executed when attacked.
+BUILDIN_FUNC(bonusautoscript2)
+{
+ int rate, flag = 0;
+ const char *str;
+ struct script_code *script;
+ TBL_PC* sd;
+
+ sd = script_rid2sd(st);
+ if( sd == NULL )
+ return 1;// no player attached, report source
+
+ str = script_getstr(st,2);
+ rate = script_getnum(st,3);
+ if( script_hasdata(st,4) )
+ flag = script_getnum(st,4);
+ script = parse_script(str, "autoscript2 bonus", 0, 0);
+ if (!script)
+ return 1;
+ if (!pc_autoscript_add(sd->autoscript2, ARRAYLENGTH(sd->autoscript2), rate, flag, script))
+ {
+ script_free_code(script);
+ return 1;
+ }
+ return 0;
+}
+
/// Changes the level of a player skill.
/// <flag> defaults to 1
/// <flag>=0 : set the level of the skill