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/_procedures.txt39
-rw-r--r--world/map/npc/magic/level0-antiprotect.txt7
-rw-r--r--world/map/npc/magic/level1-summon-maggots.txt4
-rw-r--r--world/map/npc/magic/level2-arrow-hail.txt4
-rw-r--r--world/map/npc/magic/level2-barrier.txt4
-rw-r--r--world/map/npc/magic/level2-flying-backpack.txt4
-rw-r--r--world/map/npc/magic/level2-hide.txt2
-rw-r--r--world/map/npc/magic/level2-protect.txt7
-rw-r--r--world/map/npc/magic/level2-rain.txt4
-rw-r--r--world/map/npc/magic/level2-summon-fluffies.txt4
-rw-r--r--world/map/npc/magic/level2-summon-mouboo.txt4
-rw-r--r--world/map/npc/magic/level2-summon-pinkie.txt4
-rw-r--r--world/map/npc/magic/level2-summon-snakes.txt4
-rw-r--r--world/map/npc/magic/level2-summon-spiky-mushroom.txt4
-rw-r--r--world/map/npc/magic/level2-summon-wickedmushroom.txt4
15 files changed, 69 insertions, 30 deletions
diff --git a/world/map/npc/magic/_procedures.txt b/world/map/npc/magic/_procedures.txt
index bdeb6140..5d7e5c8a 100644
--- a/world/map/npc/magic/_procedures.txt
+++ b/world/map/npc/magic/_procedures.txt
@@ -14,7 +14,7 @@ function|script|magic_register
end;
OnLogin:
- set @_M_BLOCK, 1;
+ set @_M_BLOCK, 2;
addtimer 10000, "Magic Timer::OnClear";
end;
@@ -26,14 +26,35 @@ OnClear:
// this function is call()-only
function|script|magic_checks
{
- set .@r, 0;
- 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;
+ set .@flags, getarg(0);
+ set .@nonmagic, .@flags & (1<<0);
+
+ if(HIDDEN) goto L_Hidden; // can not cast with @hide
+ if(@_M_BLOCK == 2) goto L_Login; // login warmup
+ if(@_M_BLOCK) goto L_Blocked; // check if last debuff ended
+ if(Hp < 1) goto L_Dead; // can not cast when dead
+ if (MATK1 < 1 && .@nonmagic < 1) goto L_Greybar; // can not cast with a grey mana bar
+ return 0;
+
+L_Hidden:
+ smsg SMSG_FAILURE, "Magic: Impossible to cast while hidden!";
+ return 1;
+
+L_Blocked:
+ smsg SMSG_FAILURE, "Magic: Impossible to cast while a cooldown is in effect. Please wait.";
+ return 2;
+
+L_Dead:
+ smsg SMSG_FAILURE, "Magic: Impossible to cast while dead!";
+ return 3;
+
+L_Greybar:
+ smsg SMSG_FAILURE, "Magic: Impossible to cast with 0 m.atk. This might happen if your mana bar is grey. Some equipment can reduce your m.atk.";
+ return 4;
+
+L_Login:
+ smsg SMSG_FAILURE, "Magic: Impossible to cast for 10s after logging in.";
+ return 5;
}
function|script|elt_damage
diff --git a/world/map/npc/magic/level0-antiprotect.txt b/world/map/npc/magic/level0-antiprotect.txt
index 8e9b700c..129d3c62 100644
--- a/world/map/npc/magic/level0-antiprotect.txt
+++ b/world/map/npc/magic/level0-antiprotect.txt
@@ -1,6 +1,6 @@
-|script|antiprotect|32767
{
- if(call("magic_checks")) end;
+ if(call("magic_checks", 1)) end;
callfunc "magic_exp";
if (@antiprotect)
@@ -17,10 +17,7 @@ L_Disable:
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;
+ registercmd .invocation$, strnpcinfo(0);
end;
}
diff --git a/world/map/npc/magic/level1-summon-maggots.txt b/world/map/npc/magic/level1-summon-maggots.txt
index 49022635..28e99a87 100644
--- a/world/map/npc/magic/level1-summon-maggots.txt
+++ b/world/map/npc/magic/level1-summon-maggots.txt
@@ -27,6 +27,8 @@ OnCast:
end;
OnSummon:
+ if(get(Hp, .master) < 1) destroy; // destroy if master is missing
+ if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_PENTAGRAM_BURST;
set .@i, 0;
set .@x, getnpcx();
@@ -42,7 +44,7 @@ S_SummonAll:
summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, 1002, 2, .lifetime;
set .@i, .@i + 1;
if (.@i < .count) goto S_SummonAll;
- return;
+ destroy;
OnInit:
set .school, SKILL_MAGIC_ASTRAL;
diff --git a/world/map/npc/magic/level2-arrow-hail.txt b/world/map/npc/magic/level2-arrow-hail.txt
index 35cd584e..6e317232 100644
--- a/world/map/npc/magic/level2-arrow-hail.txt
+++ b/world/map/npc/magic/level2-arrow-hail.txt
@@ -66,7 +66,7 @@ OnNearbyNpc:
end;
OnLaunch:
- if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(get(Hp, .caster) < 1) 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;
@@ -93,7 +93,7 @@ OnTimer30000:
destroy;
OnHit:
- if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(get(Hp, .caster) < 1) 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;
diff --git a/world/map/npc/magic/level2-barrier.txt b/world/map/npc/magic/level2-barrier.txt
index 9526ee5a..3b7ffb77 100644
--- a/world/map/npc/magic/level2-barrier.txt
+++ b/world/map/npc/magic/level2-barrier.txt
@@ -27,10 +27,12 @@
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.";
- addtimer @asorm_time, strnpcinfo(0)+"::OnEnd", @target_id;
+ set @asorm_future, gettimetick(0) + @asorm_time - 100, @target_id;
+ addtimer @asorm_time - 100, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
+ if (gettimetick(0) - @asorm_future < 0) end;
if (sc_check(SC_MBARRIER) != 1) end;
message strcharinfo(0), "Barrier : Your magical barrier dissipates.";
misceffect FX_MAGIC_DEFAULT, strcharinfo(0);
diff --git a/world/map/npc/magic/level2-flying-backpack.txt b/world/map/npc/magic/level2-flying-backpack.txt
index 87c7d644..36e936fd 100644
--- a/world/map/npc/magic/level2-flying-backpack.txt
+++ b/world/map/npc/magic/level2-flying-backpack.txt
@@ -22,10 +22,12 @@
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.";
- addtimer @plugh_time, strnpcinfo(0)+"::OnEnd", @target_id;
+ set @plugh_future, gettimetick(0) + @plugh_time - 100, @target_id;
+ addtimer @plugh_time - 100, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
+ if (gettimetick(0) - @plugh_future < 0) end;
if (sc_check(SC_FLYING_BACKPACK) != 1) end;
message strcharinfo(0), "Backpack : Your backpack is no longer levitating.";
misceffect FX_MAGIC_GENERIC, strcharinfo(0);
diff --git a/world/map/npc/magic/level2-hide.txt b/world/map/npc/magic/level2-hide.txt
index 6d9c125d..f720dd43 100644
--- a/world/map/npc/magic/level2-hide.txt
+++ b/world/map/npc/magic/level2-hide.txt
@@ -26,10 +26,12 @@
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!";
+ set @anwiltyp_future, gettimetick(0) + @anwiltyp_time - 100, @target_id;
addtimer @anwiltyp_time, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
+ if (gettimetick(0) - @anwiltyp_future < 0) end;
if (sc_check(SC_HIDE) != 1) end;
message strcharinfo(0), "Magic : You are no longer hidden.";
misceffect FX_MAGIC_GENERIC, strcharinfo(0);
diff --git a/world/map/npc/magic/level2-protect.txt b/world/map/npc/magic/level2-protect.txt
index 659efdc1..38ea6a7d 100644
--- a/world/map/npc/magic/level2-protect.txt
+++ b/world/map/npc/magic/level2-protect.txt
@@ -6,7 +6,6 @@
if (.@level < .level) end;
if (getskilllv(SKILL_MAGIC) < .level) end;
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
@@ -15,7 +14,7 @@
if (distance(BL_ID, @target_id) >= (@spellpower/30)+2) set @target_id, BL_ID;
if (get(@antiprotect, @target_id) > 0) end;
- delitem "HardSpike", 1;
+ if (.@level <= 3) 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";
@@ -29,10 +28,12 @@
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.";
- addtimer @betsanc_time, strnpcinfo(0)+"::OnEnd", @target_id;
+ set @betsanc_future, gettimetick(0) + @betsanc_time - 100, @target_id;
+ addtimer @betsanc_time - 100, strnpcinfo(0)+"::OnEnd", @target_id;
end;
OnEnd:
+ if (gettimetick(0) - @betsanc_future < 0) end;
if (sc_check(SC_PHYS_SHIELD) != 1) end;
message strcharinfo(0), "Shield : You feel less protected.";
misceffect FX_MAGIC_SHIELD_ENDS, strcharinfo(0);
diff --git a/world/map/npc/magic/level2-rain.txt b/world/map/npc/magic/level2-rain.txt
index 9e62782d..c088acf4 100644
--- a/world/map/npc/magic/level2-rain.txt
+++ b/world/map/npc/magic/level2-rain.txt
@@ -64,7 +64,7 @@ L_Tree:
close;
OnLaunch:
- if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(get(Hp, .caster) < 1) 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;
@@ -82,7 +82,7 @@ S_Launch:
return;
OnHit:
- if(get(BL_ID, .caster) != .caster) destroy; // destroy if caster is missing
+ if(get(Hp, .caster) < 1) 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-summon-fluffies.txt b/world/map/npc/magic/level2-summon-fluffies.txt
index 2ca630ed..f4d60475 100644
--- a/world/map/npc/magic/level2-summon-fluffies.txt
+++ b/world/map/npc/magic/level2-summon-fluffies.txt
@@ -28,6 +28,8 @@ OnCast:
end;
OnSummon:
+ if(get(Hp, .master) < 1) destroy; // destroy if master is missing
+ if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_PENTAGRAM_BURST;
set .@i, 0;
set .@x, getnpcx();
@@ -43,7 +45,7 @@ S_SummonAll:
summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, 1020, 2, .lifetime;
set .@i, .@i + 1;
if (.@i < .count) goto S_SummonAll;
- return;
+ destroy;
OnInit:
set .school, SKILL_MAGIC_ASTRAL;
diff --git a/world/map/npc/magic/level2-summon-mouboo.txt b/world/map/npc/magic/level2-summon-mouboo.txt
index f6a68fcf..b098a3dd 100644
--- a/world/map/npc/magic/level2-summon-mouboo.txt
+++ b/world/map/npc/magic/level2-summon-mouboo.txt
@@ -28,6 +28,8 @@ OnCast:
end;
OnSummon:
+ if(get(Hp, .master) < 1) destroy; // destroy if master is missing
+ if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_PENTAGRAM_BURST;
set .@i, 0;
set .@x, getnpcx();
@@ -43,7 +45,7 @@ S_SummonAll:
summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, 1028, 2, .lifetime;
set .@i, .@i + 1;
if (.@i < .count) goto S_SummonAll;
- return;
+ destroy;
OnInit:
set .school, SKILL_MAGIC_ASTRAL;
diff --git a/world/map/npc/magic/level2-summon-pinkie.txt b/world/map/npc/magic/level2-summon-pinkie.txt
index 785c8364..059d16f6 100644
--- a/world/map/npc/magic/level2-summon-pinkie.txt
+++ b/world/map/npc/magic/level2-summon-pinkie.txt
@@ -28,6 +28,8 @@ OnCast:
end;
OnSummon:
+ if(get(Hp, .master) < 1) destroy; // destroy if master is missing
+ if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_PENTAGRAM_BURST;
set .@i, 0;
set .@x, getnpcx();
@@ -43,7 +45,7 @@ S_SummonAll:
summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, 1018, 2, .lifetime;
set .@i, .@i + 1;
if (.@i < .count) goto S_SummonAll;
- return;
+ destroy;
OnInit:
set .school, SKILL_MAGIC_ASTRAL;
diff --git a/world/map/npc/magic/level2-summon-snakes.txt b/world/map/npc/magic/level2-summon-snakes.txt
index 2c46f28b..a9d0dbfe 100644
--- a/world/map/npc/magic/level2-summon-snakes.txt
+++ b/world/map/npc/magic/level2-summon-snakes.txt
@@ -29,6 +29,8 @@ OnCast:
end;
OnSummon:
+ if(get(Hp, .master) < 1) destroy; // destroy if master is missing
+ if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_PENTAGRAM_BURST;
set .@i, 0;
set .@x, getnpcx();
@@ -44,7 +46,7 @@ S_SummonAll:
summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, 1010, 2, .lifetime;
set .@i, .@i + 1;
if (.@i < .count) goto S_SummonAll;
- return;
+ destroy;
OnInit:
set .school, SKILL_MAGIC_DARK;
diff --git a/world/map/npc/magic/level2-summon-spiky-mushroom.txt b/world/map/npc/magic/level2-summon-spiky-mushroom.txt
index 5659fc32..188e9b9f 100644
--- a/world/map/npc/magic/level2-summon-spiky-mushroom.txt
+++ b/world/map/npc/magic/level2-summon-spiky-mushroom.txt
@@ -28,6 +28,8 @@ OnCast:
end;
OnSummon:
+ if(get(Hp, .master) < 1) destroy; // destroy if master is missing
+ if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_PENTAGRAM_BURST;
set .@i, 0;
set .@x, getnpcx();
@@ -43,7 +45,7 @@ S_SummonAll:
summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, 1019, 2, .lifetime;
set .@i, .@i + 1;
if (.@i < .count) goto S_SummonAll;
- return;
+ destroy;
OnInit:
set .school, SKILL_MAGIC_ASTRAL;
diff --git a/world/map/npc/magic/level2-summon-wickedmushroom.txt b/world/map/npc/magic/level2-summon-wickedmushroom.txt
index 02442c6b..3b8b9cfc 100644
--- a/world/map/npc/magic/level2-summon-wickedmushroom.txt
+++ b/world/map/npc/magic/level2-summon-wickedmushroom.txt
@@ -29,6 +29,8 @@ OnCast:
end;
OnSummon:
+ if(get(Hp, .master) < 1) destroy; // destroy if master is missing
+ if(getmap(.master) != strnpcinfo(3)) destroy; // destroy if master left the map
specialeffect FX_PENTAGRAM_BURST;
set .@i, 0;
set .@x, getnpcx();
@@ -44,7 +46,7 @@ S_SummonAll:
summon .@map$, rand(.@x-2,.@x+2), rand(.@y-2,.@y+2), .master, 1106, 2, .lifetime;
set .@i, .@i + 1;
if (.@i < .count) goto S_SummonAll;
- return;
+ destroy;
OnInit:
set .school, SKILL_MAGIC_DARK;