summaryrefslogtreecommitdiff
path: root/npc/magic/level2-arrow-hail.txt
diff options
context:
space:
mode:
Diffstat (limited to 'npc/magic/level2-arrow-hail.txt')
-rwxr-xr-xnpc/magic/level2-arrow-hail.txt115
1 files changed, 115 insertions, 0 deletions
diff --git a/npc/magic/level2-arrow-hail.txt b/npc/magic/level2-arrow-hail.txt
new file mode 100755
index 00000000..3d7525b1
--- /dev/null
+++ b/npc/magic/level2-arrow-hail.txt
@@ -0,0 +1,115 @@
+- script arrow-hail NPC32767,{
+ // we can not start here because for the puppets this is OnClick
+ end;
+
+OnCast:
+ if(call("magic_checks")) end;
+ if (getskilllv(.school) < .level) end;
+ if (getskilllv(SKILL_MAGIC) < .level) end;
+ if (Sp < 25) end;
+ explode .@map_ext[0], getmapname(), "-";
+ if (.@map_ext[1] != 1) end; // XXX this is fugly, in the future let's use MF_OUTSIDE to detect if a map is "outside" or "inside"
+ if (getmapflag(getmapname(), MF_TOWN)) end;
+ if (countitem("Arrow") >= 20 && countitem("SulphurPowder") >= 1) delitem "Arrow", 20;
+ elif (countitem("IronArrow") >= 20 && countitem("SulphurPowder") >= 1) delitem "IronArrow", 20;
+ else end;
+ delitem "SulphurPowder", 1;
+ Sp = Sp - 25;
+ set @_M_BLOCK, 1; // block casting, until the timer clears it
+ addtimer 5000, "Magic Timer::OnClear"; // set the new debuff
+
+ setarray @away[0], POS_X, POS_Y, getdir(), (.range + 1), 0;
+ callsub S_AwayFrom;
+
+ @nearby = 0;
+ foreach 1, getmapname(), @away[0] - 14, @away[1] - 14, @away[0] + 14, @away[1] + 14,
+ strnpcinfo(0) + "::OnNearbyNpc";
+ if (@nearby) goto L_Absorb;
+
+ callfunc "adjust_spellpower";
+ set @new_npc_name$, "#" + strnpcinfo(0) + "#" + getcharid(3); // make a unique puppet name for every player
+ callfunc "magic_exp";
+ misceffect FX_MAGIC_BLACK, strcharinfo(0);
+ set @spell_npc, puppet(getmapname(), POS_X, POS_Y, @new_npc_name$, 127); // clone npc => get puppet id
+ if (@spell_npc < 1) end;
+ set .max_hit, (@spellpower / 8), @spell_npc; // set .max_hit in the puppet
+ set .caster, getcharid(3), @spell_npc; // tell the puppet who controls it
+ .damage = 125, @spell_npc;
+ .damage_bonus = (@spellpower / 5), @spell_npc;
+ set .area_x, @away[0], @spell_npc; set .area_y, @away[1], @spell_npc;
+ donpcevent @new_npc_name$+"::OnLaunch"; // start the puppet timer and strike
+ initnpctimer @new_npc_name$; // start the destroy timer
+ end;
+
+S_AwayFrom:
+ if(@away[2] == 6 && !(iscollision(getmapname(), (@away[0] + 1), @away[1]))) // right
+ @away[0] = @away[0] + 1;
+ if(@away[2] == 4 && !(iscollision(getmapname(), @away[0], (@away[1] - 1)))) // up
+ @away[1] = @away[1] - 1;
+ if(@away[2] == 2 && !(iscollision(getmapname(), (@away[0] - 1), @away[1]))) // left
+ @away[0] = @away[0] - 1;
+ if(@away[2] == 0 && !(iscollision(getmapname(), @away[0], (@away[1] + 1)))) // down
+ @away[1] = @away[1] + 1;
+ @away[4] = @away[4] + 1;
+ if(@away[4] < @away[3]) goto S_AwayFrom;
+ return;
+
+L_Absorb:
+ message strcharinfo(0), "##3Arrow Hail : ##BA nearby arrow hail absorbs your magic!";
+ end;
+
+OnNearbyNpc:
+ explode .@nearby$[0], strnpcinfo(0,@target_id), "#";
+ if(.@nearby$[0] == "arrow-hail" || .@nearby$[1] == "arrow-hail")
+ @nearby = @nearby + 1;
+ end;
+
+OnLaunch:
+ if(get(Hp, .caster) < 1) destroy; // destroy if caster is missing
+ if(getmap(.caster) != strnpcinfo(3)) destroy; // destroy if caster left the map
+ .hit = .hit + 1;
+ if(.hit > .max_hit) destroy;
+ .launch = 0;
+ callsub S_Launch;
+ addnpctimer 250 + rand(50) + rand(50), strnpcinfo(0)+"::OnLaunch"; // loop until max
+ end;
+
+S_Launch:
+ npcareawarp .area_x - 6, .area_y - 6, .area_x + 6, .area_y + 6, 0, strnpcinfo(0);
+ misceffect FX_ARROW_HAIL;
+ .done = 0;
+ 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
+ .launch = .launch + 1;
+ if(.launch < 3) goto S_Launch;
+ return;
+
+OnTimer30000:
+ debugmes "frillyar timeout! [this shouldn't happen]";
+ destroy;
+
+OnHit:
+ 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
+ .@damage = .damage + rand(.damage_bonus) + rand(.damage_bonus);
+ if(.caster != @target_id)
+ .@damage = (.@damage * (100 - get(MDEF1, @target_id))) / 100;
+ injure .caster, @target_id, .@damage;
+ .done = 1;
+ end;
+
+OnInit:
+ .school = SKILL_MAGIC_WAR;
+ .range = 7;
+ set .invocation$, chr(MAGIC_SYMBOL) + "frillyar"; // used in npcs that refer to this spell
+ void call("magic_register", "OnCast");
+ .level = 2;
+ .exp_gain = 2;
+ end;
+}