summaryrefslogtreecommitdiff
path: root/src/map/pc.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/pc.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/pc.c')
-rw-r--r--src/map/pc.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/map/pc.c b/src/map/pc.c
index f039f8318..733f31d0a 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1219,6 +1219,36 @@ int pc_disguise(struct map_session_data *sd, int class_)
return 1;
}
+int pc_autoscript_add(struct s_autoscript *scripts, int max, short rate, short flag, struct script_code *script)
+{
+ int i;
+ ARR_FIND(0, max, i, scripts[i].script == NULL);
+ if (i == max) {
+ if (battle_config.error_log)
+ ShowWarning("pc_autoscript_bonus: Reached max (%d) number of autoscripts per character!\n", max);
+ return 0;
+ }
+ scripts[i].script = script;
+ scripts[i].rate = rate;
+ //Auto-update flag value.
+ if (!(flag&BF_RANGEMASK)) flag|=BF_SHORT|BF_LONG; //No range defined? Use both.
+ if (!(flag&BF_WEAPONMASK)) flag|=BF_WEAPON; //No attack type defined? Use weapon.
+ if (!(flag&BF_SKILLMASK)) {
+ if (flag&(BF_MAGIC|BF_MISC)) flag|=BF_SKILL; //These two would never trigger without BF_SKILL
+ if (flag&BF_WEAPON) flag|=BF_NORMAL;
+ }
+ scripts[i].flag = flag;
+ return 1;
+}
+
+void pc_autoscript_clear(struct s_autoscript *scripts, int max)
+{
+ int i;
+ for (i = 0; i < max && scripts[i].script; i++)
+ script_free_code(scripts[i].script);
+ memset(scripts, 0, i*sizeof(struct s_autoscript));
+}
+
static int pc_bonus_autospell_del(struct s_autospell *spell, int max, short id, short lv, short rate, short card_id)
{
int i, j;