summaryrefslogtreecommitdiff
path: root/world/map/npc/magic
diff options
context:
space:
mode:
Diffstat (limited to 'world/map/npc/magic')
-rw-r--r--world/map/npc/magic/_import.txt2
-rw-r--r--world/map/npc/magic/_procedures.txt1
-rw-r--r--world/map/npc/magic/level0-antiprotect.txt26
-rw-r--r--world/map/npc/magic/level0-discharge.txt18
-rw-r--r--world/map/npc/magic/level0-wand.txt68
-rw-r--r--world/map/npc/magic/level1-aggravate.txt8
-rw-r--r--world/map/npc/magic/level1-flare-dart.txt9
-rw-r--r--world/map/npc/magic/level1-lesser-heal.txt8
-rw-r--r--world/map/npc/magic/level1-magic-blade.txt9
-rw-r--r--world/map/npc/magic/level2-arrow-hail.txt20
-rw-r--r--world/map/npc/magic/level2-barrier.txt9
-rw-r--r--world/map/npc/magic/level2-flying-backpack.txt3
-rw-r--r--world/map/npc/magic/level2-happy-curse.txt5
-rw-r--r--world/map/npc/magic/level2-hide.txt3
-rw-r--r--world/map/npc/magic/level2-lay-on-hands.txt6
-rw-r--r--world/map/npc/magic/level2-lightning-strike.txt11
-rw-r--r--world/map/npc/magic/level2-magic-knuckles.txt9
-rw-r--r--world/map/npc/magic/level2-protect.txt15
-rw-r--r--world/map/npc/magic/level2-rain.txt12
-rw-r--r--world/map/npc/magic/level2-shear.txt14
-rw-r--r--world/map/npc/magic/level2-toxic-dart.txt9
-rw-r--r--world/map/npc/magic/level3-necromancy.txt3
22 files changed, 182 insertions, 86 deletions
diff --git a/world/map/npc/magic/_import.txt b/world/map/npc/magic/_import.txt
index 2ef595af..e5d40947 100644
--- a/world/map/npc/magic/_import.txt
+++ b/world/map/npc/magic/_import.txt
@@ -1,4 +1,6 @@
npc: npc/magic/_procedures.txt
+npc: npc/magic/level0-antiprotect.txt
+npc: npc/magic/level0-discharge.txt
npc: npc/magic/level0-wand.txt
npc: npc/magic/level1-aggravate.txt
npc: npc/magic/level1-experience.txt
diff --git a/world/map/npc/magic/_procedures.txt b/world/map/npc/magic/_procedures.txt
index aa59905b..bdeb6140 100644
--- a/world/map/npc/magic/_procedures.txt
+++ b/world/map/npc/magic/_procedures.txt
@@ -30,6 +30,7 @@ function|script|magic_checks
if(HIDDEN) set .@r, 1; // can not cast with @hide
if(@_M_BLOCK) set .@r, 2; // check if last debuff ended
if(Hp < 1) set .@r, 3; // can not cast when dead
+ if (MATK1 < 1) set .@r, 4; // can not cast with a grey mana bar
if (.@r)
smsg SMSG_FAILURE, "Magic: Impossible to cast right now.";
return .@r;
diff --git a/world/map/npc/magic/level0-antiprotect.txt b/world/map/npc/magic/level0-antiprotect.txt
new file mode 100644
index 00000000..8e9b700c
--- /dev/null
+++ b/world/map/npc/magic/level0-antiprotect.txt
@@ -0,0 +1,26 @@
+-|script|antiprotect|32767
+{
+ if(call("magic_checks")) end;
+ callfunc "magic_exp";
+
+ if (@antiprotect)
+ goto L_Disable;
+
+ sc_end SC_PHYS_SHIELD;
+ message strcharinfo(0), "Shield : You are now protected against betsanc until you cast detsanc again or logout.";
+ set @antiprotect, 1;
+ end;
+
+L_Disable:
+ message strcharinfo(0), "Shield : You are no longer protected against betsanc.";
+ set @antiprotect, 0;
+ end;
+
+OnInit:
+ set .school, SKILL_MAGIC_NATURE;
+ set .invocation$, chr(MAGIC_SYMBOL) + "detsanc"; // used in npcs that refer to this spell
+ void call("magic_register");
+ set .level, 0;
+ set .exp_gain, 0;
+ end;
+}
diff --git a/world/map/npc/magic/level0-discharge.txt b/world/map/npc/magic/level0-discharge.txt
new file mode 100644
index 00000000..7b2cfa8c
--- /dev/null
+++ b/world/map/npc/magic/level0-discharge.txt
@@ -0,0 +1,18 @@
+-|script|discharge spell|32767
+{
+ if(call("magic_checks")) end;
+ callfunc "magic_exp";
+
+ // tell the spells they were discharged
+ // XXX: maybe we could make it do area damage when you discharge (release your energy all of a sudden)
+ addtimer 0, "::OnDischarge"; // seeks OnDischarge in ALL npcs
+ end;
+
+OnInit:
+ set .school, SKILL_MAGIC;
+ set .invocation$, chr(MAGIC_SYMBOL) + "discharge"; // used in npcs that refer to this spell
+ void call("magic_register");
+ set .level, 0;
+ set .exp_gain, 0;
+ end;
+}
diff --git a/world/map/npc/magic/level0-wand.txt b/world/map/npc/magic/level0-wand.txt
index 07fbb025..00934806 100644
--- a/world/map/npc/magic/level0-wand.txt
+++ b/world/map/npc/magic/level0-wand.txt
@@ -1,62 +1,70 @@
-|script|spell-wand|32767
{
if(call("magic_checks")) goto L_Failed;
- callsub S_CheckWand;
- if(@WandAttack != 1) goto L_Failed;
+ set @wandspell[0], 0; // reset state
+ callfunc "adjust_spellpower";
+ callsub S_Loop; // set up wand
+ if(@wandspell[0] < 1) goto L_Failed;
// here we install
set @_M_BLOCK, 1; // block casting, until the timer clears it
addtimer 500, "Magic Timer::OnClear"; // set the new debuff
- callfunc "adjust_spellpower";
misceffect FX_MAGIC_GENERIC, strcharinfo(0);
- set .@delay, (((200 - Agi) * 1200) / 200);
- overrideattack (@Wand + (@spellpower / 10)), .@delay, 3, ATTACK_ICON_GENERIC, @WandID, strnpcinfo(0)+"::OnAttack";
+
callfunc "magic_exp";
+ goto L_FreeRecast;
+
+L_FreeRecast:
+ if (@wandspell[4] > 0)
+ addtimer 0, strnpcinfo(0) + "::OnSetRecast";
end;
-OnAttack:
- callsub S_CheckWand;
- if(@WandAttack != 1) goto L_Failed;
- if(target(BL_ID, @target_id, 22) != 22) goto L_Failed; // 0x02 | 0x04 | 0x10
- set Sp, (Sp - @WandCost);
- set @damage, (@Wand * (@spellpower / 3));
- void call("elt_damage", @damage,@damage,ELT_NEUTRAL,ELT_NEUTRAL,FX_MAGIC_RED);
+OnDischarge:
+ if (@wandspell[4] < 1) end;
+ set @wandspell[4], 0;
+ misceffect FX_FIRE_BURST, strcharinfo(0);
+ overrideattack;
end;
-S_CheckWand:
- set @Wand, 0;
- set @wand_loop, 0;
- goto S_Loop;
+OnSetRecast:
+ overrideattack @wandspell[3], 3, ATTACK_ICON_GENERIC, @wandspell[0], strnpcinfo(0)+"::OnAttack";
+ end;
+
+OnAttack:
+ if(target(BL_ID, @target_id, 22) != 22) goto L_FreeRecast; // 0x02 | 0x04 | 0x10
+ if (Sp < @wandspell[1]) goto L_LowSp;
+ set Sp, (Sp - @wandspell[1]);
+ void call("elt_damage", @wandspell[2],@wandspell[2],ELT_NEUTRAL,ELT_NEUTRAL,FX_MAGIC_RED);
+ set @wandspell[4], @wandspell[4] - 1;
+ goto L_FreeRecast;
S_Loop:
- if ((getequipid(equip_hand1) == .Wands[@wand_loop]) || (getequipid(equip_hand2) == .Wands[@wand_loop]))
+ if ((getequipid(equip_hand1) == .Wands[.@wand_loop]) || (getequipid(equip_hand2) == .Wands[.@wand_loop]))
goto S_SetWand;
- set @wand_loop, (@wand_loop + 1);
- if (@wand_loop >= getarraysize(.Wands))
+ set .@wand_loop, (.@wand_loop + 1);
+ if (.@wand_loop >= getarraysize(.Wands))
goto S_NoWand;
goto S_Loop;
S_SetWand:
- set @Wand, .WandsPwr[@wand_loop];
- set @WandID, .WandsAnim[@wand_loop];
+ set .@pwr, .WandsPwr[.@wand_loop];
if (QL_MORGAN == 2)
set QL_MORGAN, 3;
- set @WandCost, (@Wand * (BaseLevel / 15) + 2);
- set @WandAttack, 0;
- if (Sp < @WandCost)
- goto S_LowSp;
- set @WandAttack, 1; // everything is fine
+ setarray @wandspell[0],
+ .WandsAnim[.@wand_loop], // wand anim/id
+ (.@pwr * (BaseLevel / 15) + 2), // wand cost
+ (.@pwr * (@spellpower / 3)), // wand dmg
+ (((200 - Agi) * 1200) / 200), //delay
+ (.@pwr + (@spellpower / 10)); // charges
return;
S_NoWand:
message strcharinfo(0), "Wand : ##3##BYou need a wand Equipped!";
- set @WandAttack, 0;
return;
-S_LowSp:
+L_LowSp:
message strcharinfo(0), "Wand : ##3##BOut of Mana";
- set @WandAttack, 0;
- return;
+ end;
L_Failed:
//misceffect FX_ELECTRICITY_RED, strcharinfo(0); // XXX: do we show an effect on fail?
diff --git a/world/map/npc/magic/level1-aggravate.txt b/world/map/npc/magic/level1-aggravate.txt
index 05474a2a..bad64e02 100644
--- a/world/map/npc/magic/level1-aggravate.txt
+++ b/world/map/npc/magic/level1-aggravate.txt
@@ -10,7 +10,13 @@
set Sp, Sp - 3;
misceffect FX_MAGIC_GREEN, strcharinfo(0);
callfunc "magic_exp";
- aggravate getmap(), (POS_X - @distance), (POS_Y - @distance), (POS_X + @distance), (POS_Y + @distance), SFX_DEFAULT;
+ foreach 2, getmap(), (POS_X - @distance), (POS_Y - @distance), (POS_X + @distance), (POS_Y + @distance), strnpcinfo(0) + "::OnMob";
+ end;
+
+OnMob:
+ if (target(BL_ID, @target_id, 0x20) != 0x20) end; // line of sight
+ aggravate @target_id;
+ misceffect SFX_DEFAULT, @target_id;
end;
OnInit:
diff --git a/world/map/npc/magic/level1-flare-dart.txt b/world/map/npc/magic/level1-flare-dart.txt
index 6c0ef303..0f70637f 100644
--- a/world/map/npc/magic/level1-flare-dart.txt
+++ b/world/map/npc/magic/level1-flare-dart.txt
@@ -31,8 +31,15 @@ L_FreeRecast:
addtimer 0, strnpcinfo(0) + "::OnSetRecast";
end;
+OnDischarge:
+ if (@flarspell[2] < 1) end;
+ set @flarspell[2], 0;
+ misceffect FX_FIRE_BURST, strcharinfo(0);
+ overrideattack;
+ end;
+
OnSetRecast:
- overrideattack 1, @flarspell[3], 4, ATTACK_ICON_GENERIC, 34, strnpcinfo(0)+"::OnAttack";
+ overrideattack @flarspell[3], 4, ATTACK_ICON_GENERIC, 34, strnpcinfo(0)+"::OnAttack";
end;
OnInit:
diff --git a/world/map/npc/magic/level1-lesser-heal.txt b/world/map/npc/magic/level1-lesser-heal.txt
index d03031d6..d195956f 100644
--- a/world/map/npc/magic/level1-lesser-heal.txt
+++ b/world/map/npc/magic/level1-lesser-heal.txt
@@ -33,8 +33,12 @@ L_NotMe:
L_Continue:
if (getskilllv(SKILL_MAGIC_DARK) >= 1) sc_start SC_HALT_REGENERATE, 2000, 0;
- if (attachrid(@target_id) != 1) end; // XXX: to avoid the ugly attachrid method we would need some kind of `run_as` builtin
- if (!(isdead())) heal 200, 0, 1;
+ if (get(Hp, @target_id) < 1) end;
+ addtimer 0, strnpcinfo(0) + "::OnSlowHeal", @target_id;
+ end;
+
+OnSlowHeal:
+ heal 200, 0, 1;
end;
L_Mouboo:
diff --git a/world/map/npc/magic/level1-magic-blade.txt b/world/map/npc/magic/level1-magic-blade.txt
index ad39c244..851f8dea 100644
--- a/world/map/npc/magic/level1-magic-blade.txt
+++ b/world/map/npc/magic/level1-magic-blade.txt
@@ -23,6 +23,13 @@
callfunc "magic_exp";
goto L_FreeRecast;
+OnDischarge:
+ if (@chizaspell[2] < 1) end;
+ set @chizaspell[2], 0;
+ misceffect FX_FIRE_BURST, strcharinfo(0);
+ overrideattack;
+ end;
+
OnAttack:
if (target(BL_ID, @target_id, 22) != 22) goto L_FreeRecast; // 0x10 | 0x02 | 0x04
void call("melee_damage", @chizaspell[4], @target_id, (@chizaspell[0] + rand(@chizaspell[1] + 5)));
@@ -35,7 +42,7 @@ L_FreeRecast:
end;
OnSetRecast:
- overrideattack 1, @chizaspell[3], 1, ATTACK_ICON_GENERIC, 30, strnpcinfo(0)+"::OnAttack";
+ overrideattack @chizaspell[3], 1, ATTACK_ICON_GENERIC, 30, strnpcinfo(0)+"::OnAttack";
end;
OnInit:
diff --git a/world/map/npc/magic/level2-arrow-hail.txt b/world/map/npc/magic/level2-arrow-hail.txt
index 3be14f1a..c7deb852 100644
--- a/world/map/npc/magic/level2-arrow-hail.txt
+++ b/world/map/npc/magic/level2-arrow-hail.txt
@@ -4,7 +4,7 @@
end;
OnCast:
- if(call("magic_checks")) end;
+ if(call("magic_checks")) end;
if (getskilllv(.school) < .level) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
if (Sp < 25) end;
@@ -65,8 +65,8 @@ OnNearbyNpc:
end;
OnLaunch:
- if(attachrid(.caster) != 1) destroy; // destroy if caster is missing
- if(getmap() != strnpcinfo(3)) destroy; // destroy if caster left the map
+ if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(getmap(.caster) != strnpcinfo(3)) destroy; // destroy if caster left the map
set .hit, .hit + 1;
if(.hit > .max_hit) destroy;
set .launch, 0;
@@ -78,11 +78,11 @@ S_Launch:
npcareawarp .area_x - 6, .area_y - 6, .area_x + 6, .area_y + 6, 0, strnpcinfo(0);
misceffect FX_ARROW_HAIL;
set .done, 0;
- foreach 2, strnpcinfo(3), getnpcx(), getnpcy(), getnpcx(), getnpcy(), strnpcinfo(0) + "::OnHit";
- if (PVP_CHANNEL || getmapflag(getmap(), MF_PVP))
- foreach 0, strnpcinfo(3), getnpcx(), getnpcy(), getnpcx(), getnpcy(), strnpcinfo(0) + "::OnHit";
- if(!.done && getx() == getnpcx() && gety() == getnpcy())
- heal 0 - (.damage + rand(.damage_bonus) + rand(.damage_bonus)), 0; // injure caster
+ foreach 2, strnpcinfo(3), getnpcx(), getnpcy(), getnpcx(), getnpcy(), strnpcinfo(0) + "::OnHit", .caster;
+ if (get(PVP_CHANNEL, .caster) || getmapflag(getmap(.caster), MF_PVP))
+ foreach 0, strnpcinfo(3), getnpcx(), getnpcy(), getnpcx(), getnpcy(), strnpcinfo(0) + "::OnHit", .caster;
+ if(!.done && get(POS_X, .caster) == getnpcx() && get(POS_Y, .caster) == getnpcy())
+ set Hp, get(Hp, .caster) - (.damage + rand(.damage_bonus) + rand(.damage_bonus)), .caster; // injure caster
set .launch, .launch + 1;
if(.launch < 3) goto S_Launch;
return;
@@ -92,8 +92,8 @@ OnTimer30000:
destroy;
OnHit:
- if(attachrid(.caster) != 1) destroy; // destroy if caster is missing
- if(getmap() != strnpcinfo(3)) destroy; // destroy if caster left the map
+ if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(getmap(.caster) != strnpcinfo(3)) destroy; // destroy if caster left the map
if(target(.caster, @target_id, 16) != 16 && .caster != @target_id) end;
if((get(BL_TYPE, @target_id) & 1) == 0) end; // either mob or pc
diff --git a/world/map/npc/magic/level2-barrier.txt b/world/map/npc/magic/level2-barrier.txt
index 9afd4f38..9526ee5a 100644
--- a/world/map/npc/magic/level2-barrier.txt
+++ b/world/map/npc/magic/level2-barrier.txt
@@ -11,11 +11,7 @@
if (@target_id < 1 || !(isloggedin(@target_id)) || get(INVISIBLE, @target_id) == 1)
set @target_id, BL_ID; // fallback to self
- set @asorm_caster, BL_ID, @target_id;
- if (attachrid(@target_id) != 1) end;
- set @target_hat, getequipid(equip_head), @asorm_caster;
- if (attachrid(@asorm_caster) != 1) end;
- if (@target_hat == 888) end; // FIXME: this whole 5 line block could be done with only one line if we modify getequipid OR make equip_ into params
+ if (getequipid(equip_head, strcharinfo(0, @target_id)) == 888) end;
set @_M_BLOCK, 1; // block casting, until the timer clears it
addtimer 1000, "Magic Timer::OnClear"; // set the new debuff
@@ -31,8 +27,7 @@
set @asorm_time, .@time, @target_id;
sc_start SC_MBARRIER, .@time, max(30,(@spellpower/8))+20, @target_id;
message @args$, "Barrier : You are surrounded by a magical barrier.";
- if (attachrid(@target_id) != 1) end;
- addtimer @asorm_time, strnpcinfo(0)+"::OnEnd";
+ addtimer @asorm_time, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
diff --git a/world/map/npc/magic/level2-flying-backpack.txt b/world/map/npc/magic/level2-flying-backpack.txt
index 5e19468e..87c7d644 100644
--- a/world/map/npc/magic/level2-flying-backpack.txt
+++ b/world/map/npc/magic/level2-flying-backpack.txt
@@ -22,8 +22,7 @@
set @plugh_time, (@spellpower*500)+5000, @target_id;
sc_start SC_FLYING_BACKPACK, @plugh_time, 0, @target_id;
message @args$, "Backpack : Your backpack is lifted by a mystical force; you no longer feel it pressing on your back.";
- if (attachrid(@target_id) != 1) end;
- addtimer @plugh_time, strnpcinfo(0)+"::OnEnd";
+ addtimer @plugh_time, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
diff --git a/world/map/npc/magic/level2-happy-curse.txt b/world/map/npc/magic/level2-happy-curse.txt
index dbfea17a..a82dce21 100644
--- a/world/map/npc/magic/level2-happy-curse.txt
+++ b/world/map/npc/magic/level2-happy-curse.txt
@@ -23,9 +23,8 @@
set @joyplim_count, 1, @target_id;
set @joyplim_emote, if_then_else(getskilllv(SKILL_MAGIC_DARK) > 1, EMOTE_EVIL, EMOTE_HAPPY), @target_id;
set @joyplim_total, (@spellpower/10), @target_id;
- if (attachrid(@target_id) != 1) end;
- emotion @joyplim_emote, "self";
- addtimer 500, strnpcinfo(0)+"::OnEmote";
+ emotion @joyplim_emote, strcharinfo(0, @target_id);
+ addtimer 500, strnpcinfo(0)+"::OnEmote", @target_id;
end;
OnEmote:
diff --git a/world/map/npc/magic/level2-hide.txt b/world/map/npc/magic/level2-hide.txt
index ff67e6a5..6d9c125d 100644
--- a/world/map/npc/magic/level2-hide.txt
+++ b/world/map/npc/magic/level2-hide.txt
@@ -26,8 +26,7 @@
sc_start SC_HIDE, .@time, 0, @target_id;
message @args$, "Magic : You are hidden!";
if (BL_ID != @target_id) message strcharinfo(0), "Magic : You hid someone!";
- if (attachrid(@target_id) != 1) end;
- addtimer @anwiltyp_time, strnpcinfo(0)+"::OnEnd";
+ addtimer @anwiltyp_time, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
diff --git a/world/map/npc/magic/level2-lay-on-hands.txt b/world/map/npc/magic/level2-lay-on-hands.txt
index 22287497..0affb210 100644
--- a/world/map/npc/magic/level2-lay-on-hands.txt
+++ b/world/map/npc/magic/level2-lay-on-hands.txt
@@ -28,7 +28,6 @@ L_Pay:
set .@heal_value, if_then_else(.@payment < .@available, .@needed+1-1, (.@available * 200) / .@fraction); // FIXME / XXX why the f do I need to do +1-1 ?
if (.@payment > .@available) set .@payment, .@available;
- set @inma_power, .@heal_value, @target_id;
set @mexp, min(.exp_gain, .@payment/100);
callfunc "gain_heal_xp";
@@ -39,8 +38,9 @@ L_Pay:
if (.@dark) heal .@bad, 0;
sc_start SC_HALT_REGENERATE, if_then_else(.@dark, 5000, 10000), 0;
- if (attachrid(@target_id) != 1) end;
- if (!(isdead())) heal @inma_power, 0;
+ set .@thp, get(Hp, @target_id);
+ if (.@thp < 1) end;
+ set Hp, .@thp + .@heal_value, @target_id;
end;
L_Mouboo:
diff --git a/world/map/npc/magic/level2-lightning-strike.txt b/world/map/npc/magic/level2-lightning-strike.txt
index cf30a627..5cc6299b 100644
--- a/world/map/npc/magic/level2-lightning-strike.txt
+++ b/world/map/npc/magic/level2-lightning-strike.txt
@@ -24,7 +24,7 @@
goto L_FreeRecast;
OnAttack:
- if (target(BL_ID, @target_id, 22) != 22) goto L_FreeRecast; // 0x10 | 0x02 | 0x04
+ if (target(BL_ID, @target_id, 0x36) != 0x36) goto L_FreeRecast; // 0x10 | 0x02 | 0x04 | 0x20
set .@p, get(.max_radius, "rain") + 1;
set @ingravspell[5], @target_id; // store it because foreach overwrites it
@@ -41,8 +41,15 @@ L_FreeRecast:
addtimer 0, strnpcinfo(0) + "::OnSetRecast";
end;
+OnDischarge:
+ if (@ingravspell[2] < 1) end;
+ set @ingravspell[2], 0;
+ misceffect FX_FIRE_BURST, strcharinfo(0);
+ overrideattack;
+ end;
+
OnSetRecast:
- overrideattack 1, @ingravspell[3], 8, ATTACK_ICON_GENERIC, 31, strnpcinfo(0)+"::OnAttack";
+ overrideattack @ingravspell[3], 8, ATTACK_ICON_GENERIC, 31, strnpcinfo(0)+"::OnAttack";
end;
OnNpc:
diff --git a/world/map/npc/magic/level2-magic-knuckles.txt b/world/map/npc/magic/level2-magic-knuckles.txt
index 0984a7fd..d309804b 100644
--- a/world/map/npc/magic/level2-magic-knuckles.txt
+++ b/world/map/npc/magic/level2-magic-knuckles.txt
@@ -31,8 +31,15 @@ L_FreeRecast:
addtimer 0, strnpcinfo(0) + "::OnSetRecast";
end;
+OnDischarge:
+ if (@upmarmuspell[1] < 1) end;
+ set @upmarmuspell[1], 0;
+ misceffect FX_FIRE_BURST, strcharinfo(0);
+ overrideattack;
+ end;
+
OnSetRecast:
- overrideattack 1, @upmarmuspell[2], 1, ATTACK_ICON_GENERIC, 34, strnpcinfo(0)+"::OnAttack";
+ overrideattack @upmarmuspell[2], 1, ATTACK_ICON_GENERIC, 34, strnpcinfo(0)+"::OnAttack";
end;
OnInit:
diff --git a/world/map/npc/magic/level2-protect.txt b/world/map/npc/magic/level2-protect.txt
index a3096ad7..659efdc1 100644
--- a/world/map/npc/magic/level2-protect.txt
+++ b/world/map/npc/magic/level2-protect.txt
@@ -5,18 +5,17 @@
set .@level, getskilllv(.school);
if (.@level < .level) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
- if (.@level <= 3 && countitem("HardSpike") >= 1) delitem "HardSpike", 1;
+ if (.@level <= 3 && countitem("HardSpike") < 1) end;
elif (.@level <= 3) end;
set @target_id, getcharid(3, @args$);
if (@target_id < 1 || !(isloggedin(@target_id)) || get(INVISIBLE, @target_id))
set @target_id, BL_ID; // fallback to self
- set @betsanc_caster, BL_ID, @target_id;
- if (attachrid(@target_id) != 1) end;
- set @target_hat, getequipid(equip_head), @betsanc_caster;
- if (attachrid(@betsanc_caster) != 1) end;
- if (@target_hat == 888) end; // FIXME: this whole 5 line block could be done with only one line if we modify getequipid
+ if (getequipid(equip_head, strcharinfo(0, @target_id)) == 888) end;
+ if (distance(BL_ID, @target_id) >= (@spellpower/30)+2) set @target_id, BL_ID;
+ if (get(@antiprotect, @target_id) > 0) end;
+ delitem "HardSpike", 1;
set @_M_BLOCK, 1; // block casting, until the timer clears it
addtimer 1500, "Magic Timer::OnClear"; // set the new debuff
callfunc "adjust_spellpower";
@@ -24,15 +23,13 @@
misceffect FX_MAGIC_GREEN, strcharinfo(0);
callfunc "magic_exp";
- if (distance(BL_ID, @target_id) >= (@spellpower/30)+2) set @target_id, BL_ID;
if (BL_ID == @target_id) set @args$, strcharinfo(0);
misceffect FX_MAGIC_SHIELD, @args$;
set .@time, (@spellpower*1000)+5000;
set @betsanc_time, .@time, @target_id;
sc_start SC_PHYS_SHIELD, .@time, max(15,(@spellpower/20))+5, @target_id;
message @args$, "Shield : You feel more protected.";
- if (attachrid(@target_id) != 1) end;
- addtimer @betsanc_time, strnpcinfo(0)+"::OnEnd";
+ addtimer @betsanc_time, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
diff --git a/world/map/npc/magic/level2-rain.txt b/world/map/npc/magic/level2-rain.txt
index 53161b28..9a498c08 100644
--- a/world/map/npc/magic/level2-rain.txt
+++ b/world/map/npc/magic/level2-rain.txt
@@ -63,8 +63,8 @@ L_Tree:
close;
OnLaunch:
- if(attachrid(.caster) != 1) destroy; // destroy if caster is missing
- if(getmap() != strnpcinfo(3)) destroy; // destroy if caster left the map
+ if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(getmap(.caster) != strnpcinfo(3)) destroy; // destroy if caster left the map
set .count, .count + 1;
if(.count > .max) destroy;
set .launch, 0;
@@ -75,14 +75,14 @@ OnLaunch:
S_Launch:
npcareawarp .initial_x - .radius, .initial_y - .radius, .initial_x + .radius, .initial_y + .radius, 0, strnpcinfo(0);
misceffect FX_RAIN;
- foreach 2, strnpcinfo(3), getnpcx()-1, getnpcy()-1, getnpcx()+1, getnpcy()+1, strnpcinfo(0) + "::OnHit";
+ foreach 2, strnpcinfo(3), getnpcx()-1, getnpcy()-1, getnpcx()+1, getnpcy()+1, strnpcinfo(0) + "::OnHit", .caster;
set .launch, .launch + 1;
if(.launch < .max_launch) goto S_Launch;
return;
OnHit:
- if(attachrid(.caster) != 1) destroy; // destroy if caster is missing
- if(getmap() != strnpcinfo(3)) destroy; // destroy if caster left the map
+ if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(getmap(.caster) != strnpcinfo(3)) destroy; // destroy if caster left the map
if(target(.caster, @target_id, 16) != 16 && .caster != @target_id) end;
if((get(BL_TYPE, @target_id) & 1) == 0) end; // either mob or pc
if(get(ELTTYPE, @target_id) == ELT_FIRE)
@@ -90,7 +90,7 @@ OnHit:
end;
OnDestroy:
- debugmes "kaflosh timeout! [this shouldn't happen]";
+ debugmes "kaflosh timeout! [this shouldn't happen]"; // XXX: looks like this CAN happen with higher levels of magic, so we might want to cap max charges
destroy;
OnInit:
diff --git a/world/map/npc/magic/level2-shear.txt b/world/map/npc/magic/level2-shear.txt
index af825727..f65119c3 100644
--- a/world/map/npc/magic/level2-shear.txt
+++ b/world/map/npc/magic/level2-shear.txt
@@ -12,9 +12,8 @@
setarray @chipchipspell[0],
@spellpower,
(((200 - Agi) * 2000) / 200); //delay
- overrideattack 1, @chipchipspell[1], 1, ATTACK_ICON_SHEARING, 30, strnpcinfo(0)+"::OnAttack";
callfunc "magic_exp";
- end;
+ goto L_FreeRecast;
OnAttack:
if (isloggedin(@target_id)) goto L_FreeRecast; // can not shear a player
@@ -23,6 +22,7 @@ OnAttack:
sc_start SC_SHEARED, 600000, 0, @target_id;
set .@score, rand(1000 - rand(@chipchipspell[0]));
set .@id, get(Class, @target_id); // get the mob ID
+ set @chipchipspell[2], 0;
if (.@id == 1020 && .@score < 300) set .@item$, "WhiteFur"; // Fluffy
elif (.@id == 1027 && .@score < 300) set .@item$, "WhiteFur"; // EasterFluffy
@@ -43,11 +43,19 @@ OnAttack:
end;
L_FreeRecast:
+ set @chipchipspell[2], 1;
addtimer 0, strnpcinfo(0) + "::OnSetRecast"; // we can't do it while already overridden, until it reaches a script terminator
end;
+OnDischarge:
+ if (@chipchipspell[2] < 1) end;
+ set @chipchipspell[2], 0;
+ misceffect FX_FIRE_BURST, strcharinfo(0);
+ overrideattack;
+ end;
+
OnSetRecast:
- overrideattack 1, @chipchipspell[1], 1, ATTACK_ICON_SHEARING, 30, strnpcinfo(0)+"::OnAttack";
+ overrideattack @chipchipspell[1], 1, ATTACK_ICON_SHEARING, 30, strnpcinfo(0)+"::OnAttack";
end;
OnInit:
diff --git a/world/map/npc/magic/level2-toxic-dart.txt b/world/map/npc/magic/level2-toxic-dart.txt
index 357ae32b..c30eaa00 100644
--- a/world/map/npc/magic/level2-toxic-dart.txt
+++ b/world/map/npc/magic/level2-toxic-dart.txt
@@ -37,8 +37,15 @@ L_FreeRecast:
addtimer 0, strnpcinfo(0) + "::OnSetRecast";
end;
+OnDischarge:
+ if (@phlexspell[3] < 1) end;
+ set @phlexspell[3], 0;
+ misceffect FX_FIRE_BURST, strcharinfo(0);
+ overrideattack;
+ end;
+
OnSetRecast:
- overrideattack 1, @phlexspell[2], 4, ATTACK_ICON_GENERIC, 31, strnpcinfo(0)+"::OnAttack";
+ overrideattack @phlexspell[2], 4, ATTACK_ICON_GENERIC, 31, strnpcinfo(0)+"::OnAttack";
end;
OnInit:
diff --git a/world/map/npc/magic/level3-necromancy.txt b/world/map/npc/magic/level3-necromancy.txt
index 57f5a6cc..2cd6724d 100644
--- a/world/map/npc/magic/level3-necromancy.txt
+++ b/world/map/npc/magic/level3-necromancy.txt
@@ -24,8 +24,7 @@
set @necromancer, CHAR_ID, @target_id; // tell the target who is reviving them
- if (attachrid(@target_id) != 1) end;
- addtimer 6000, strnpcinfo(0)+"::OnRevive"; // TODO: make it take more or less time depending on the spell power
+ addtimer 6000, strnpcinfo(0)+"::OnRevive", @target_id; // TODO: make it take more or less time depending on the spell power
end;
OnRevive: