summaryrefslogtreecommitdiff
path: root/src/map/script.c
diff options
context:
space:
mode:
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