diff options
author | mekolat <mekolat@users.noreply.github.com> | 2015-06-11 11:13:11 -0400 |
---|---|---|
committer | mekolat <mekolat@users.noreply.github.com> | 2016-03-30 11:22:47 -0400 |
commit | bc4deaf81d9701261baac6a10d762b0f40e7f65f (patch) | |
tree | e539e3a49756626e27d4491fccb7a6862b12a120 /world/map/npc/magic | |
parent | 9e7f46ac732851c1359a15837c82ebf67ea2be39 (diff) | |
download | serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.tar.gz serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.tar.bz2 serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.tar.xz serverdata-bc4deaf81d9701261baac6a10d762b0f40e7f65f.zip |
initial commit for magic v3
Fix Druid Tree and add hug to TMW
Diffstat (limited to 'world/map/npc/magic')
40 files changed, 1939 insertions, 0 deletions
diff --git a/world/map/npc/magic/README.md b/world/map/npc/magic/README.md new file mode 100644 index 00000000..a9dedb6e --- /dev/null +++ b/world/map/npc/magic/README.md @@ -0,0 +1,63 @@ +# To-do +- [ ] finish the missing spells and push them so they can be tested + +--- +--- +to see other things that needs to be done do a grep for `TODO`, `FIXME` in this folder. +To see a list of things that needs further thoughts do a grep for `XXX`. + +--- +--- + +- [ ] check the new builtins and make sure they work as intended + - [ ] `puppet` + - [ ] check what happens when making a puppet whose name already exist (maybe it replaces?) + - [ ] `destroy` + - [ ] `registercmd` + - [ ] check what happens when registering a command that was already registered + - [ ] `target` + - [ ] `get` + - [ ] the new `set` + - [ ] `min` + - [ ] `max` + - [ ] `pow` + - [ ] `sqrt` + - [ ] `cbrt` + - [ ] `elttype` + - [ ] `eltlvl` + - [ ] `injure` + - [ ] `elif` + - [ ] `else` + - [ ] `getnpcid` + - [ ] `overrideattack` + - [ ] `summon` + - [ ] `addnpctimer` + - [ ] `explode` + - [ ] `foreach` + - [ ] modified `areatimer` + - [ ] `aggravate` + - [ ] `getdir` + - [ ] `distance` + - [ ] `if_then_else` + +--- +- [ ] test the spells + - [ ] test with no target + - [ ] test with a npc target + - [ ] random npc not part of any quest + - [ ] injured mouboo + - [ ] also test on a **player** with the name `Mouboo` or `mouboo` + - [ ] druid tree + - [ ] test with a mob target + - [ ] mob with clear path (walkable) + - [ ] mob with no clear path (unwalkable, blocked by collision) + - [ ] mob out of attack range + - [ ] test with a player target + - [ ] both the caster and the target have pvp disabled + - [ ] both the caster and the target have pvp enabled + - [ ] the caster has pvp enabled and the target has pvp disabled + - [ ] the caster has pvp disabled and the target has pvp enabled + - [ ] test with the spouse as target + +--- +- [ ] Once everything is done, remove this file diff --git a/world/map/npc/magic/_import.txt b/world/map/npc/magic/_import.txt new file mode 100644 index 00000000..4118170e --- /dev/null +++ b/world/map/npc/magic/_import.txt @@ -0,0 +1,38 @@ +npc: npc/magic/_procedures.txt +npc: npc/magic/level0-wand.txt +npc: npc/magic/level1-aggravate.txt +npc: npc/magic/level1-experience.txt +npc: npc/magic/level1-lesser-heal.txt +npc: npc/magic/level1-transmute-wood.txt +npc: npc/magic/level1-make-sulphur.txt +npc: npc/magic/level1-flare-dart.txt +npc: npc/magic/level1-magic-blade.txt +npc: npc/magic/level1-grow-mauve.txt +npc: npc/magic/level1-grow-alizarin.txt +npc: npc/magic/level1-grow-gamboge.txt +npc: npc/magic/level1-grow-cobalt.txt +npc: npc/magic/level1-summon-maggots.txt +npc: npc/magic/level1-detect-magic.txt +npc: npc/magic/level2-arrow-hail.txt +npc: npc/magic/level2-make-arrows.txt +npc: npc/magic/level2-make-iron-powder.txt +npc: npc/magic/level2-magic-knuckles.txt +npc: npc/magic/level2-summon-snakes.txt +npc: npc/magic/level2-summon-wickedmushroom.txt +npc: npc/magic/level2-summon-spiky-mushroom.txt +npc: npc/magic/level2-summon-fluffies.txt +npc: npc/magic/level2-summon-mouboo.txt +npc: npc/magic/level2-summon-pinkie.txt +npc: npc/magic/level2-toxic-dart.txt +npc: npc/magic/level2-enchant-lifestone.txt +npc: npc/magic/level2-flying-backpack.txt +npc: npc/magic/level2-protect.txt +npc: npc/magic/level2-barrier.txt +npc: npc/magic/level2-hide.txt +npc: npc/magic/level2-happy-curse.txt +npc: npc/magic/level2-detect-players.txt +npc: npc/magic/level2-shear.txt +npc: npc/magic/level2-lightning-strike.txt +npc: npc/magic/level2-rain.txt +npc: npc/magic/level2-lay-on-hands.txt +npc: npc/magic/level3-necromancy.txt diff --git a/world/map/npc/magic/_procedures.txt b/world/map/npc/magic/_procedures.txt new file mode 100644 index 00000000..71d12605 --- /dev/null +++ b/world/map/npc/magic/_procedures.txt @@ -0,0 +1,135 @@ +function|script|magic_register +{ + debugmes ">> Register " + .invocation$ + " @ " + strnpcinfo(0); + registercmd .invocation$, strnpcinfo(0); // register the spell + set .index, $@magic_index; + set $@magic_index, $@magic_index + 1; + return; +} + +function|script|magic_register2 +{ + debugmes ">> Register " + .invocation$ + " @ " + strnpcinfo(0); + registercmd .invocation$, strnpcinfo(0) + "::OnCast"; // register the spell <= this spell has a puppet + set .index, $@magic_index; + set $@magic_index, $@magic_index + 1; + return; +} + +function|script|magic_checks +{ + set @failed, 0; + if(getpvpflag(1)) set @failed, 1; // can not cast with @hide enabled + if((gettimetick(2) - MAGIC_CAST_TICK) < 0) set @failed, 1; // check if last debuff ended + if(isdead()) set @failed, 1; // can not cast when dead + return; +} + +function|script|elt_damage +{ + // @edmg is damage, dmgplus(mutation), bonus_elt, malus_elt, effect + set @edmg[5], @edmg[0] + rand(@edmg[1]); + if(elttype(@target_id) == @edmg[3]) // malus + set @edmg[5], @edmg[5] / 3; + if(elttype(@target_id) == @edmg[2]) // bonus + set @edmg[5], ((eltlvl(@target_id) + 4) * @edmg[5]) / 4; + set .@source, .caster; + if (!.@source) set .@source, getcharid(3); + + injure .@source, @target_id, @edmg[5]; + misceffect @edmg[4], @target_id; + cleararray @edmg, 0, getarraysize(@edmg); + return; +} + +function|script|melee_damage +{ + if ((@spellpower - rand(100)) < (get(BaseLevel, @target_id) + get(MDEF1, @target_id))) + injure BL_ID, @target_id, 0; + else injure BL_ID, @target_id, @melee_dmg[0] + rand(@melee_dmg[1]); + return; +} + +function|script|magic_create_item +{ + set .@exp, (MAGIC_EXPERIENCE & (BYTE_0_MASK | BYTE_1_MASK)) >> BYTE_0_SHIFT; + set .@score, (.@exp + rand(min(@spellpower, ((.@exp / 3) + 1)))); + set @create_params[2], 1; // success flag + if (.@score >= @create_params[1]) goto L_Perfect; + set @create_params[2], 0; // success flag + set .@score, .@score + rand(Luk) + rand(Luk); + if (.@score < (@create_params[1] / 3)) goto L_Backfire; + if (.@score < ((@create_params[1] * 2) / 3)) goto L_Iten; + message strcharinfo(0), "Magic : ##3##BYour spell takes on a mind of its own!"; + if (rand(3) == 1) getitem @create_items$[1], 1; // bad item + return; + +L_Iten: + if (rand(5) != 2) goto L_Escape; + message strcharinfo(0), "Magic : ##3##BYour spell solidifies into the shape of a mysterious object!"; + getitem "Iten", 1; + return; + +L_Escape: + message strcharinfo(0), "Magic : ##3##BYour spell escapes!"; + return; + +L_Backfire: + message strcharinfo(0), "Magic : ##3##BYour spell backfires!"; + if (rand(110) < Luk) heal 0 - ((BaseLevel+1)*(BaseLevel+2)*(rand(28)+3)), 0; + else heal 0 - (BaseLevel + 1), 0; + return; + +L_Perfect: + getitem @create_items$[0], @create_params[0]; // good item + return; +} + +function|script|magic_exp +{ + set @last_index, (MAGIC_EXPERIENCE & BYTE_2_MASK) >> BYTE_2_SHIFT; + set @last_exp, (MAGIC_EXPERIENCE & (BYTE_0_MASK | BYTE_1_MASK)) >> BYTE_0_SHIFT; + + debugmes "old spell index: " + @last_index; + debugmes "new spell index: " + .index; + + if(getskilllv(SKILL_MAGIC) < (.level + 3) && .index != @last_index) + goto L_Gain; + debugmes "same as last spell => don't proceed"; + goto L_Return; + +L_Gain: + if(.exp_gain < 1) goto L_Return; // only the spells that have exp register here. If you + // remove this line then players can cast a spell with + // no cost, then a spell with a reagents, then another + // spell with no costs and still get the exp + set @new_exp, @last_exp + .exp_gain; + if(@new_exp > (BYTE_0_MASK | BYTE_1_MASK)) set @new_exp, (BYTE_0_MASK | BYTE_1_MASK); + debugmes "old magic exp: "+ @last_exp; + debugmes "new magic exp: "+ @new_exp; + set MAGIC_EXPERIENCE, (MAGIC_EXPERIENCE &~ (BYTE_0_MASK | BYTE_1_MASK)) | (@new_exp << BYTE_0_SHIFT); + set MAGIC_EXPERIENCE, (MAGIC_EXPERIENCE &~ BYTE_2_MASK) | (.index << BYTE_2_SHIFT); + goto L_Return; + +L_Return: + return; +} + +function|script|adjust_spellpower +{ + set @spellpower, MATK1 + getskilllv(SKILL_MAGIC) + getskilllv(.school) + 10; + if((.school != SKILL_MAGIC_NATURE) && (.school != SKILL_MAGIC_LIFE)) goto L_Return; + if(@args$ == "" || !@args$ || getpartnerid2() == 0) goto L_Return; + if(getcharid(3, @args$) < 1 || getpartnerid2() != getcharid(3, @args$) || !(isloggedin(getcharid(3, @args$)))) + goto L_Return; + debugmes "You targeted your spouse!"; + // XXX: I need a builtin to check if the target is in range of the caster + // XXX: the spell power increases when the target is the spouse so one could + // just do #modrilax (spouse) right? + // + // ... let's just forget about spouse for now + goto L_Return; + +L_Return: + return; +} diff --git a/world/map/npc/magic/level0-wand.txt b/world/map/npc/magic/level0-wand.txt new file mode 100644 index 00000000..e38a26c7 --- /dev/null +++ b/world/map/npc/magic/level0-wand.txt @@ -0,0 +1,74 @@ +-|script|spell-wand|32767 +{ + callfunc "magic_checks"; if(@failed) goto L_Failed; // << I wish we had functions that could return >> + callsub S_CheckWand; + if(@WandAttack != 1) goto L_Failed; + + // here we install + set MAGIC_CAST_TICK, gettimetick(2) + 5; // set the new debuff + callfunc "adjust_spellpower"; + misceffect FX_MAGIC_GENERIC, strcharinfo(0); + overrideattack (@Wand + (@spellpower / 10)), 1200, 3, ATTACK_ICON_GENERIC, @WandID, strnpcinfo(0)+"::OnAttack"; + callfunc "magic_exp"; + 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)); + setarray @edmg,@damage,@damage,ELT_NEUTRAL,ELT_NEUTRAL,FX_MAGIC_RED; callfunc "elt_damage"; + end; + +S_CheckWand: + set @Wand, 0; + set @wand_loop, 0; + goto S_Loop; + +S_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)) + goto S_NoWand; + goto S_Loop; + +S_SetWand: + set @Wand, .WandsPwr[@wand_loop]; + set @WandID, .WandsAnim[@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 + return; + +S_NoWand: + message strcharinfo(0), "Wand : ##3##BYou need a wand Equipped!"; + set @WandAttack, 0; + return; + +S_LowSp: + message strcharinfo(0), "Wand : ##3##BOut of Mana"; + set @WandAttack, 0; + return; + +L_Failed: + //misceffect FX_ELECTRICITY_RED, strcharinfo(0); // XXX: do we show an effect on fail? + debugmes "cast or attack failed"; + end; + +OnInit: + setarray .Wands[0], 758, 1171; + setarray .WandsPwr[0], 2, 1; + setarray .WandsAnim[0], 35, 33; + set .school, SKILL_MAGIC; + set .invocation$, chr(MAGIC_SYMBOL) + "confringo"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 0; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-aggravate.txt b/world/map/npc/magic/level1-aggravate.txt new file mode 100644 index 00000000..74316b89 --- /dev/null +++ b/world/map/npc/magic/level1-aggravate.txt @@ -0,0 +1,22 @@ +-|script|spell-aggravate|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 3) end; + if (getskilllv(.school) < .level) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + set @args$, ""; callfunc "adjust_spellpower"; // we reset @args$ because this spell should not have a target + set @distance, (2 + (@spellpower / 50)); + 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; + end; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "itenplz"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 0; + end; +} diff --git a/world/map/npc/magic/level1-detect-magic.txt b/world/map/npc/magic/level1-detect-magic.txt new file mode 100644 index 00000000..c5dff558 --- /dev/null +++ b/world/map/npc/magic/level1-detect-magic.txt @@ -0,0 +1,29 @@ +-|script|detect-magic|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 3) end; + if (getskilllv(.school) < .level) end; + set MAGIC_CAST_TICK, gettimetick(2) + 6; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 3; + misceffect FX_MAGIC_GENERIC, strcharinfo(0); + set .@range, (@spellpower/50)+1; + foreach 1, getmap(), POS_X - .@range, POS_Y - .@range, POS_X + .@range, POS_Y + .@range, + strnpcinfo(0) + "::OnNearbyNpc"; + callfunc "magic_exp"; + end; + +OnNearbyNpc: + set .@e$, strnpcinfo(2,@target_id); + if(.@e$ == "#_M" || .@e$ == "#MAGIC") + misceffect FX_MAGIC_DEFAULT, @target_id; + end; + +OnInit: + set .school, SKILL_MAGIC; + set .invocation$, chr(MAGIC_SYMBOL) + "miteyo"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 0; + end; +} diff --git a/world/map/npc/magic/level1-experience.txt b/world/map/npc/magic/level1-experience.txt new file mode 100644 index 00000000..9492b6f2 --- /dev/null +++ b/world/map/npc/magic/level1-experience.txt @@ -0,0 +1,41 @@ +-|script|spell-experience|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 1) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + set @level, getskilllv(.school); + if (@level < .level) end; + callfunc "adjust_spellpower"; + set Sp, Sp - 1; + misceffect FX_MAGIC_GENERIC, strcharinfo(0); + callfunc "magic_exp"; // no exp for this spell + set @ratio, ((@last_exp*10) - rand(.MAX_MAGIC_EXP[@level]/30))/.MAX_MAGIC_EXP[@level]; + + set @mes$, "You feel completely overwhelmed by your magic."; + if(@ratio == 1) set @mes$, "You feel quite overwhelmed by your magic, but are beginning to see patterns."; + if(@ratio == 2) set @mes$, "You feel that you have only the bare minimum of control over your magic."; + if(@ratio == 3) set @mes$, "Trying to control your magic is still rather troublesome."; + if(@ratio == 4) set @mes$, "You feel you still have a few difficulties in controlling your magic."; + if(@ratio == 5) set @mes$, "You feel somewhat in control of your magic."; + if(@ratio == 6) set @mes$, "You feel mostly in control of your magic."; + if(@ratio == 7) set @mes$, "You feel quite in control of your magic."; + if(@ratio == 8) set @mes$, "You feel that you have very good control of your magic."; + if(@ratio == 9) set @mes$, "You feel in almost perfect control of your magic."; + if(@ratio >= 10) set @mes$, "You feel in perfect control of your magic" + if_then_else(@level >= MAX_MAGIC_LEVEL, ".", ", and seem on the verge of something more... perhaps you should see the Mana Seed to ask for more magic?"); + if(@ratio >= 20) set @mes$, "You have perfect control of what you understand now, but there is now a distinct sensation of something more, something indescribable. If only the Mana Seed would give more magic to you..."; + if(@ratio >= 45) set @mes$, "Magic flows naturally from you, readily and with ease. Your understanding of what you can currently control at present is flawless, far beyond your requirements to cast magic at this level."; + if(@ratio >= 45 && @level < MAX_MAGIC_LEVEL) set @mes$, @mes$ + " Surely the Mana Seed will more than readily offer more magic for such a proficient user."; + if(@level >= 5) set @mes$, "You are as proficient at magic as you can possibly be."; // this is the maximum magic level + message strcharinfo(0), "Magic : ##3##B"+@mes$; + // TODO put magic_exp somewhere + end; + +OnInit: + set .school, SKILL_MAGIC; + set .invocation$, chr(MAGIC_SYMBOL) + "abizit"; // used in npcs that refer to this spell + set .level, 1; + set .exp_gain, 0; + callfunc "magic_register"; + setarray .MAX_MAGIC_EXP[0], 0, 100, 1200, 8000, 40000, 65535; + end; +} diff --git a/world/map/npc/magic/level1-flare-dart.txt b/world/map/npc/magic/level1-flare-dart.txt new file mode 100644 index 00000000..ee08e7f4 --- /dev/null +++ b/world/map/npc/magic/level1-flare-dart.txt @@ -0,0 +1,33 @@ +-|script|flare-dart|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 10) end; + set @level, getskilllv(.school); + if (@level < .level) end; + if (@level <= 2 && countitem("SulphurPowder") >= 1) delitem "SulphurPowder", 1; + elif (@level <= 2) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 10; + misceffect FX_MAGIC_BLACK, strcharinfo(0); + set @damage, sqrt(@spellpower) * 5; + set @dmg_bonus, (BaseLevel/3) + 5; + overrideattack (@spellpower/50)+3, 1200, 4, ATTACK_ICON_GENERIC, 34, strnpcinfo(0)+"::OnAttack"; + callfunc "magic_exp"; + end; + +OnAttack: + misceffect FX_MAGIC_BLACK, strcharinfo(0); + if (target(BL_ID, @target_id, 50) != 50) end; // 0x20 | 0x02 | 0x10 + setarray @edmg[0], @damage, @dmg_bonus, ELT_WATER, ELT_FIRE, FX_MAGIC_BLACK; + callfunc "elt_damage"; + end; + +OnInit: + set .school, SKILL_MAGIC_WAR; + set .invocation$, chr(MAGIC_SYMBOL) + "flar"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-grow-alizarin.txt b/world/map/npc/magic/level1-grow-alizarin.txt new file mode 100644 index 00000000..64593975 --- /dev/null +++ b/world/map/npc/magic/level1-grow-alizarin.txt @@ -0,0 +1,37 @@ +-|script|grow-alizarin|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 4) end; + if (getskilllv(.school) < .level) end; + if (countitem("AlizarinHerb") < 1 || countitem("Root") < 1) end; + delitem "AlizarinHerb", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 2; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 4; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + setarray @summon[0], 0, (getskilllv(.school)/2)+1; + callfunc "magic_exp"; + addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon"; + end; + +OnSummon: + misceffect FX_PENTAGRAM_BURST, strcharinfo(0); + callsub S_SummonAll; + end; + +S_SummonAll: + summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, 1032, 1, (@spellpower*50)+10000; + set @summon[0], @summon[0] + 1; + if (@summon[0] < @summon[1]) goto S_SummonAll; + return; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "modriphoo"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-grow-cobalt.txt b/world/map/npc/magic/level1-grow-cobalt.txt new file mode 100644 index 00000000..c094fe6f --- /dev/null +++ b/world/map/npc/magic/level1-grow-cobalt.txt @@ -0,0 +1,37 @@ +-|script|grow-cobalt|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 4) end; + if (getskilllv(.school) < .level) end; + if (countitem("CobaltHerb") < 1 || countitem("Root") < 1) end; + delitem "CobaltHerb", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 2; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 4; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + setarray @summon[0], 0, (getskilllv(.school)/2)+1; + callfunc "magic_exp"; + addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon"; + end; + +OnSummon: + misceffect FX_PENTAGRAM_BURST, strcharinfo(0); + callsub S_SummonAll; + end; + +S_SummonAll: + summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, 1030, 1, (@spellpower*50)+10000; + set @summon[0], @summon[0] + 1; + if (@summon[0] < @summon[1]) goto S_SummonAll; + return; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "modrisump"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-grow-gamboge.txt b/world/map/npc/magic/level1-grow-gamboge.txt new file mode 100644 index 00000000..15bb9906 --- /dev/null +++ b/world/map/npc/magic/level1-grow-gamboge.txt @@ -0,0 +1,37 @@ +-|script|grow-gamboge|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 4) end; + if (getskilllv(.school) < .level) end; + if (countitem("GambogeHerb") < 1 || countitem("Root") < 1) end; + delitem "GambogeHerb", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 2; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 4; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + setarray @summon[0], 0, (getskilllv(.school)/2)+1; + callfunc "magic_exp"; + addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon"; + end; + +OnSummon: + misceffect FX_PENTAGRAM_BURST, strcharinfo(0); + callsub S_SummonAll; + end; + +S_SummonAll: + summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, 1031, 1, (@spellpower*50)+10000; + set @summon[0], @summon[0] + 1; + if (@summon[0] < @summon[1]) goto S_SummonAll; + return; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "modriyikam"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-grow-mauve.txt b/world/map/npc/magic/level1-grow-mauve.txt new file mode 100644 index 00000000..6cc15955 --- /dev/null +++ b/world/map/npc/magic/level1-grow-mauve.txt @@ -0,0 +1,37 @@ +-|script|grow-mauve|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 4) end; + if (getskilllv(.school) < .level) end; + if (countitem("MauveHerb") < 1 || countitem("Root") < 1) end; + delitem "MauveHerb", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 2; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 4; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + setarray @summon[0], 0, (getskilllv(.school)/2)+1; + callfunc "magic_exp"; + addtimer 4000-(@spellpower-9), strnpcinfo(0)+"::OnSummon"; + end; + +OnSummon: + misceffect FX_PENTAGRAM_BURST, strcharinfo(0); + callsub S_SummonAll; + end; + +S_SummonAll: + summon getmap(), rand(POS_X-2,POS_X+2), rand(POS_Y-2,POS_Y+2), BL_ID, 1029, 1, (@spellpower*50)+10000; + set @summon[0], @summon[0] + 1; + if (@summon[0] < @summon[1]) goto S_SummonAll; + return; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "modrilax"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-lesser-heal.txt b/world/map/npc/magic/level1-lesser-heal.txt new file mode 100644 index 00000000..ef087525 --- /dev/null +++ b/world/map/npc/magic/level1-lesser-heal.txt @@ -0,0 +1,41 @@ +-|script|lesser-heal|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 6) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + if (getskilllv(.school) < .level) end; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@target_id))) set @target_id, BL_ID; // fallback to self + if (@args$ == "Mouboo" || @args$ == "mouboo") set @target_id, getnpcid("Mouboo"); + set .@range, (((MATK1 + getskilllv(SKILL_MAGIC) + getskilllv(.school) + 10) / 100) + 2); + if (distance(BL_ID, @target_id) >= .@range) end; + if (PVP_CHANNEL != get(PVP_CHANNEL, @target_id) && get(PVP_CHANNEL, @target_id) != 0) end; + if (countitem("Lifestone") < 1) end; + delitem "Lifestone", 1; + callfunc "adjust_spellpower"; + set Sp, Sp - 6; + misceffect FX_MAGIC_WHITE, strcharinfo(0); + if (@target_id != BL_ID) misceffect FX_MAGIC_WHITE, @target_id; + // TODO gain_heal_exp + // TODO magic_exp + if (@args$ == "Mouboo" || @args$ == "mouboo") goto L_Mouboo; + + if (getskilllv(SKILL_MAGIC_DARK) >= 1) sc_start SC_HALT_REGENERATE, 2000, 0; + + set @heal_amount, 200, @target_id; + 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 @heal_amount, 0, 1; + end; + +L_Mouboo: + mes "Mouboo : ##3##BYour spell seems to have no effect on the mouboo."; + close; + +OnInit: + set .school, SKILL_MAGIC_LIFE; + set .invocation$, chr(MAGIC_SYMBOL) + "lum"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-magic-blade.txt b/world/map/npc/magic/level1-magic-blade.txt new file mode 100644 index 00000000..7c286678 --- /dev/null +++ b/world/map/npc/magic/level1-magic-blade.txt @@ -0,0 +1,34 @@ +-|script|magic-blade|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 9) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + set @chiza_component$, ""; + if (.@level <= 2 && countitem("SharpKnife") >= 1) set @chiza_component$, "SharpKnife"; + elif (.@level <= 2 && countitem("Knife") >= 1) set @chiza_component$, "Knife"; + elif (.@level <= 2) end; + if (@chiza_component$ != "") delitem @chiza_component$, 1; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 9; + misceffect FX_MAGIC_BLACK, strcharinfo(0); + overrideattack (@spellpower/15)+10, 1200, 1, ATTACK_ICON_GENERIC, 30, strnpcinfo(0)+"::OnAttack"; + callfunc "magic_exp"; + set @chiza_str, Str; // do not allow to equip light armor, cast, and then switch to heavy armor to get bonus str + end; + +OnAttack: + if (target(BL_ID, @target_id, 22) != 22) end; // 0x10 | 0x02 | 0x04 + setarray @melee_dmg[0], if_then_else(@chiza_component$ == "Knife", 40, 60), (@chiza_str + 5); + callfunc "melee_damage"; + end; + +OnInit: + set .school, SKILL_MAGIC_WAR; + set .invocation$, chr(MAGIC_SYMBOL) + "chiza"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-make-sulphur.txt b/world/map/npc/magic/level1-make-sulphur.txt new file mode 100644 index 00000000..2d11e5f6 --- /dev/null +++ b/world/map/npc/magic/level1-make-sulphur.txt @@ -0,0 +1,24 @@ +-|script|make-sulphur|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 4) end; + if (getskilllv(.school) < .level) end; + if (countitem("PileOfAsh") >= 1) delitem "PileOfAsh", 1; else end; + set MAGIC_CAST_TICK, gettimetick(2) + 4; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 4; + misceffect FX_MAGIC_RED, strcharinfo(0); + setarray @create_params[0], (@spellpower/100)+1+(rand(max(1,(800-@spellpower)))/180), 50; + setarray @create_items$[0], "SulphurPowder", "PileOfAsh"; + callfunc "magic_create_item"; + callfunc "magic_exp"; + end; + +OnInit: + set .school, SKILL_MAGIC_TRANSMUTE; + set .invocation$, chr(MAGIC_SYMBOL) + "gole"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-summon-maggots.txt b/world/map/npc/magic/level1-summon-maggots.txt new file mode 100644 index 00000000..12d2465c --- /dev/null +++ b/world/map/npc/magic/level1-summon-maggots.txt @@ -0,0 +1,52 @@ +-|script|summon-maggots|32767 +{ + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 21) end; + if (getskilllv(.school) < .level) end; + if (countitem("MaggotSlime") < 1 || countitem("Root") < 1) end; + delitem "MaggotSlime", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 20; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 21; + misceffect FX_MAGIC_BLUE, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + callfunc "magic_exp"; + set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID; + set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127); + set .count, ((sqrt(@spellpower)+(@spellpower/15))/5)+1, .@puppet; + set .master, BL_ID, .@puppet; + set .lifetime, (@spellpower*50)+10000, .@puppet; + addnpctimer 5000-(@spellpower*5), .@puppet$+"::OnSummon"; + addnpctimer 6000, .@puppet$+"::OnDestroy"; + end; + +OnSummon: + specialeffect FX_PENTAGRAM_BURST; + set .@i, 0; + set .@x, getnpcx(); + set .@y, getnpcy(); + set .@map$, strnpcinfo(3); + callsub S_SummonAll; + end; + +OnDestroy: + destroy; + +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; + +OnInit: + set .school, SKILL_MAGIC_ASTRAL; + set .invocation$, chr(MAGIC_SYMBOL) + "kalmurk"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level1-transmute-wood.txt b/world/map/npc/magic/level1-transmute-wood.txt new file mode 100644 index 00000000..9984d2b0 --- /dev/null +++ b/world/map/npc/magic/level1-transmute-wood.txt @@ -0,0 +1,36 @@ +-|script|spell-transmute-wood|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 5) end; + if (getskilllv(.school) < .level) end; + if (countitem("RawLog") >= 1) delitem "RawLog", 1; else end; + set MAGIC_CAST_TICK, gettimetick(2) + 4; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 5; + misceffect FX_MAGIC_RED, strcharinfo(0); + if (@args$ == "boo") goto L_Mouboo; + elif (@args$ == "lurk") goto L_Skytlurk; + else message strcharinfo(0), "Magic : ##3##BYou do not know how to transmute wood into this kind of animal."; // FIXME: write a better sentence + end; + +L_Mouboo: + setarray @create_params[0], 1, 40; + setarray @create_items$[0], "MoubooFigurine", "WarpedLog"; + callfunc "magic_create_item"; + callfunc "magic_exp"; + end; + +L_Skytlurk: + if (rand(2) == 1) getitem "Iten", 1; + else getitem "WarpedLog", 1; + message strcharinfo(0), "Magic : ##3##BYou have no idea what a Skrytlurk looks like."; + end; + +OnInit: + set .school, SKILL_MAGIC_TRANSMUTE; + set .invocation$, chr(MAGIC_SYMBOL) + "parum"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 1; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-arrow-hail.txt b/world/map/npc/magic/level2-arrow-hail.txt new file mode 100644 index 00000000..ecd79317 --- /dev/null +++ b/world/map/npc/magic/level2-arrow-hail.txt @@ -0,0 +1,112 @@ +-|script|arrow-hail|32767 +{ + // we can not start here because for the puppets this is OnClick + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (getskilllv(.school) < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (Sp < 25) end; + explode .@map_ext[0], getmap(), "-"; + 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(getmap(), 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; + set Sp, Sp - 25; + set MAGIC_CAST_TICK, gettimetick(2) + 5; // set the new debuff + + setarray @away[0], POS_X, POS_Y, getdir(), (.range + 1), 0; + callsub S_AwayFrom; + + set @nearby, 0; + foreach 1, getmap(), @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(getmap(), POS_X, POS_Y, @new_npc_name$, 127); // clone npc => get puppet id + 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 + set .damage, 125, @spell_npc; + set .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(getmap(), (@away[0] + 1), @away[1]))) // right + set @away[0], @away[0] + 1; + if(@away[2] == 4 && !(iscollision(getmap(), @away[0], (@away[1] - 1)))) // up + set @away[1], @away[1] - 1; + if(@away[2] == 2 && !(iscollision(getmap(), (@away[0] - 1), @away[1]))) // left + set @away[0], @away[0] - 1; + if(@away[2] == 0 && !(iscollision(getmap(), @away[0], (@away[1] + 1)))) // down + set @away[1], @away[1] + 1; + set @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") + set @nearby, @nearby + 1; + end; + +OnLaunch: + if(attachrid(.caster) != 1) destroy; // destroy if caster is missing + if(getmap() != strnpcinfo(3)) destroy; // destroy if caster left the map + set .hit, .hit + 1; + if(.hit > .max_hit) destroy; + set .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; + set .done, 0; + foreach 3, 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 + set .launch, .launch + 1; + if(.launch < 3) goto S_Launch; + return; + +OnTimer30000: + debugmes "frillyar timeout! [this shouldn't happen]"; + destroy; + +OnHit: + if(attachrid(.caster) != 1) destroy; // destroy if caster is missing + if(getmap() != 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 + set .@damage, .damage + rand(.damage_bonus) + rand(.damage_bonus); + if(.caster != @target_id) + set .@damage, (.@damage * (100 - get(MDEF1, @target_id))) / 100; + injure .caster, @target_id, .@damage; + set .done, 1; + end; + +OnInit: + set .school, SKILL_MAGIC_WAR; + set .range, 7; + set .invocation$, chr(MAGIC_SYMBOL) + "frillyar"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 2; + end; +} diff --git a/world/map/npc/magic/level2-barrier.txt b/world/map/npc/magic/level2-barrier.txt new file mode 100644 index 00000000..89a50044 --- /dev/null +++ b/world/map/npc/magic/level2-barrier.txt @@ -0,0 +1,48 @@ +-|script|magic-barrier|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 15) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (.@level <= 3 && countitem("SmallMushroom") >= 1) delitem "SmallMushroom", 1; + elif (.@level <= 3) end; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@target_id))) 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 + + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 15; + misceffect FX_MAGIC_BLUE, 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); + if (BL_ID != @target_id) misceffect FX_MAGIC_DEFAULT, @args$; + set .@time, (@spellpower*200)+2000; + 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"; + end; + +OnEnd: + message strcharinfo(0), "Barrier : Your magical barrier dissipates."; + misceffect FX_MAGIC_DEFAULT, strcharinfo(0); + end; + +OnInit: + set .school, SKILL_MAGIC_ASTRAL; + set .invocation$, chr(MAGIC_SYMBOL) + "asorm"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 3; + end; +} diff --git a/world/map/npc/magic/level2-detect-players.txt b/world/map/npc/magic/level2-detect-players.txt new file mode 100644 index 00000000..3b024d38 --- /dev/null +++ b/world/map/npc/magic/level2-detect-players.txt @@ -0,0 +1,32 @@ +-|script|detect-players|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 7) end; + if (getskilllv(.school) < .level) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // XXX the casttime is 300 so should this be 0 ? + callfunc "adjust_spellpower"; + set Sp, Sp - 7; + misceffect FX_MAGIC_DARKRED, strcharinfo(0); + callfunc "magic_exp"; + set @inwilt$, ""; + set .@d, @spellpower/2; + foreach 0, getmap(), POS_X - .@d, POS_Y - .@d, POS_X + .@d, POS_Y + .@d, strnpcinfo(0)+"::OnPC"; + message strcharinfo(0), if_then_else(@inwilt$=="", "You sense no-one else nearby.", "You sense the following: "+@inwilt$); + end; + +OnPC: + if (@target_id == BL_ID) end; // do not count the caster + if (sc_check(SC_HIDE, @target_id)) end; // do not count players with anwiltyp + if (getpvpflag(1, @target_id)) end; // do not count invisible players + if (@inwilt$ != "") set @inwilt$, @inwilt$ + ", "; + set @inwilt$, @inwilt$ + strcharinfo(0, @target_id) + if_then_else(@spellpower > 99, "("+get(BaseLevel, @target_id)+")", ""); + end; + +OnInit: + set .school, SKILL_MAGIC; + set .invocation$, chr(MAGIC_SYMBOL) + "inwilt"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 0; + end; +} diff --git a/world/map/npc/magic/level2-enchant-lifestone.txt b/world/map/npc/magic/level2-enchant-lifestone.txt new file mode 100644 index 00000000..9d56f84a --- /dev/null +++ b/world/map/npc/magic/level2-enchant-lifestone.txt @@ -0,0 +1,35 @@ +-|script|enchant-lifestone|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 15) end; + if (getskilllv(.school) < .level) end; + if (countitem("BugLeg") >= 1) delitem "BugLeg", 1; + elif (countitem("MaggotSlime") >= 1) delitem "MaggotSlime", 1; + elif (countitem("MauveHerb") >= 1 && countitem("AlizarinHerb") >= 1 && countitem("CobaltHerb") >= 1 && countitem("GambogeHerb") >= 1) goto L_Herbs; + else end; + goto L_Proceed; + +L_Herbs: + delitem "MauveHerb", 1; + delitem "AlizarinHerb", 1; + delitem "CobaltHerb", 1; + delitem "GambogeHerb", 1; + goto L_Proceed; + +L_Proceed: + set MAGIC_CAST_TICK, gettimetick(2) + 4; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 15; + misceffect FX_MAGIC_GENERIC, strcharinfo(0); + getitem "Lifestone", 1; + callfunc "magic_exp"; + end; + +OnInit: + set .school, SKILL_MAGIC; + set .invocation$, chr(MAGIC_SYMBOL) + "manpahil"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-flying-backpack.txt b/world/map/npc/magic/level2-flying-backpack.txt new file mode 100644 index 00000000..f2ab0b07 --- /dev/null +++ b/world/map/npc/magic/level2-flying-backpack.txt @@ -0,0 +1,39 @@ +-|script|flying-backpack|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 12) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (.@level <= 3 && countitem("SilkCocoon") >= 1) delitem "SilkCocoon", 1; + elif (.@level <= 3) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 12; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + callfunc "magic_exp"; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@target_id))) set @target_id, BL_ID; // fallback to self + if (distance(BL_ID, @target_id) >= (@spellpower/30)+2) set @target_id, BL_ID; + if (BL_ID != @target_id) misceffect FX_MAGIC_GENERIC, @args$; + if (BL_ID == @target_id) set @args$, strcharinfo(0); + 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"; + end; + +OnEnd: + message strcharinfo(0), "Backpack : Your backpack is no longer levitating."; + misceffect FX_MAGIC_GENERIC, strcharinfo(0); + end; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "plugh"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-happy-curse.txt b/world/map/npc/magic/level2-happy-curse.txt new file mode 100644 index 00000000..0ad2d113 --- /dev/null +++ b/world/map/npc/magic/level2-happy-curse.txt @@ -0,0 +1,42 @@ +-|script|happy-curse|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 13) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (.@level <= 3 && countitem("GingerBreadMan") >= 1) delitem "GingerBreadMan", 1; + elif (.@level <= 3) end; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@target_id))) set @target_id, BL_ID; // fallback to self + + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 13; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + callfunc "magic_exp"; + + if (distance(BL_ID, @target_id) >= (@spellpower/100)+1) set @target_id, BL_ID; + if (BL_ID == @target_id) set @args$, strcharinfo(0); + 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"; + end; + +OnEmote: + emotion @joyplim_emote, "self"; + set @joyplim_count, @joyplim_count + 1; + if (@joyplim_count < @joyplim_total) addtimer 500, strnpcinfo(0)+"::OnEmote"; + end; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "joyplim"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-hide.txt b/world/map/npc/magic/level2-hide.txt new file mode 100644 index 00000000..42de7f6a --- /dev/null +++ b/world/map/npc/magic/level2-hide.txt @@ -0,0 +1,43 @@ +-|script|spell-hide|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 11) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (.@level <= 3 && countitem("CottonCloth") >= 1) delitem "CottonCloth", 1; + elif (.@level <= 3) end; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@target_id))) set @target_id, BL_ID; // fallback to self + + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 11; + misceffect FX_MAGIC_BLUE, 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); + if (BL_ID != @target_id) misceffect FX_MAGIC_DEFAULT, @args$; + set .@time, (@spellpower*2500)+5000; + set @anwiltyp_time, .@time, @target_id; + 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"; + end; + +OnEnd: + message strcharinfo(0), "Magic : You are no longer hidden."; + misceffect FX_MAGIC_GENERIC, strcharinfo(0); + end; + +OnInit: + set .school, SKILL_MAGIC_ASTRAL; + set .invocation$, chr(MAGIC_SYMBOL) + "anwiltyp"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 2; + end; +} diff --git a/world/map/npc/magic/level2-lay-on-hands.txt b/world/map/npc/magic/level2-lay-on-hands.txt new file mode 100644 index 00000000..d106ac54 --- /dev/null +++ b/world/map/npc/magic/level2-lay-on-hands.txt @@ -0,0 +1,57 @@ +-|script|lay-on-hands|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 10) end; + if (getskilllv(.school) < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (@args$ == "Mouboo" || @args$ == "mouboo") goto L_Mouboo; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@target_id))) end; + if (Hp <= get(MaxHp, @target_id) / 20) end; // hp needs to be > 1/20 * target hp + callfunc "adjust_spellpower"; + if (distance(BL_ID, @target_id) >= (((sqrt(@spellpower)*12)+@spellpower)/100)+2) end; + if (sc_check(SC_HALT_REGENERATE,@target_id)) end; + if (getequipid(equip_head, @args$) == 888) end; // magic gm top hat + set .@needed, get(MaxHp, @target_id) - get(Hp, @target_id); + goto L_Pay; + +L_Pay: + set MAGIC_CAST_TICK, gettimetick(2) + 1; // XXX should this be 0 ? + set Sp, Sp - 10; + misceffect FX_MAGIC_WHITE, strcharinfo(0); // on caster + misceffect FX_MAGIC_WHITE, @args$; // on target + + set .@fraction, max(80, 200 - (Vit + (@spellpower/10))); // pay at least 40% + set .@payment, (.@needed * .@fraction) / 200; + set .@available, Hp - (MaxHp / 20); + set .@power, 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, .@power, @target_id; + + set @mexp, min(.exp_gain, .@payment/100); // TODO pass this to gain_heal_exp so it can be passed to gain_exp + // TODO gain_heal_exp(.@power, 1, 1, 3) => gain_exp + + set .@dark, getskilllv(SKILL_MAGIC_DARK) >= 2; // true if dark magic user + set .@bad, (MaxHp/20)*(0-1); + 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; + end; + +L_Mouboo: + set @spell, 1; + callfunc "QuestMoubooHeal"; + set .@needed, 1000; + goto L_Pay; + +OnInit: + set .school, SKILL_MAGIC_LIFE; + set .invocation$, chr(MAGIC_SYMBOL) + "inma"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 4; // this is MAX possible exp + end; +} diff --git a/world/map/npc/magic/level2-lightning-strike.txt b/world/map/npc/magic/level2-lightning-strike.txt new file mode 100644 index 00000000..d27d88df --- /dev/null +++ b/world/map/npc/magic/level2-lightning-strike.txt @@ -0,0 +1,67 @@ +-|script|lightning-strike|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 20) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (.@level <= 3 && countitem("IronPowder") >= 1) delitem "IronPowder", 1; + elif (.@level <= 3) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 20; + misceffect FX_MAGIC_BLACK, strcharinfo(0); + set @ingrav_sp, @spellpower; + set @ingrav_luk, Luk; + overrideattack (@spellpower/90)+1, 3000, 8, ATTACK_ICON_GENERIC, 31, strnpcinfo(0)+"::OnAttack"; + callfunc "magic_exp"; + end; + +OnAttack: + if (target(BL_ID, @target_id, 22) != 22) end; // 0x10 | 0x02 | 0x04 + + set @ingrav_rain, 0; + set .@p, get(.max_radius, "rain") + 1; + set @ingrav_target, @target_id; // store it because foreach overwrites it + foreach 1, getmap(), POS_X-.@p, POS_Y-.@p, POS_X+.@p, POS_Y+.@p, strnpcinfo(0)+"::OnNpc"; + set @target_id, @ingrav_target; // now restore it + + if (@ingrav_rain & 1) goto L_InRain; + setarray @edmg[0], @ingrav_sp, (@ingrav_sp/2)+1, ELT_EARTH, ELT_WIND, FX_LIGHTNING1 + rand(3); + callfunc "elt_damage"; + end; + +OnNpc: + set .@name$, strnpcinfo(0,@target_id); + explode .@nearby$[0], .@name$, "#"; + if (.@nearby$[0] != "rain" && .@nearby$[1] != "rain") end; + setarray .@l[0], getnpcx(.@name$), getnpcy(.@name$), get(.radius, @target_id); // kaflosh x, y, radius + setarray @ar[0], .@l[0]-.@l[2], .@l[1]-.@l[2], .@l[0]+.@l[2], .@l[1]+.@l[2]; // kaflosh x1, y1, x2, y2 <= this is "area" + if (POS_X >= @ar[0] && POS_Y >= @ar[1] && POS_X <= @ar[2] && POS_Y <= @ar[3]) + set @ingrav_rain, @ingrav_rain | 1; + end; + +L_InRain: + set @used, 0; + foreach 3, getmap(), @ar[0], @ar[1], @ar[2], @ar[3], strnpcinfo(0)+"::OnEntityInRain"; + if (@used >= 1 && (@ingrav_luk + rand(200)) >= 150) end; + misceffect FX_LIGHTNING1 + rand(3), strcharinfo(0); + heal 0 - @ingrav_sp, 0; + end; + +OnEntityInRain: + if (target(BL_ID, @target_id, 16) != 16) end; // 0x10 + if (@ingrav_luk + rand(200) <= 175) end; + set @used, @used + 1; + setarray @edmg[0], @ingrav_sp/6, (((@ingrav_sp/2)+1)/3)+1, ELT_EARTH, ELT_WIND, FX_LIGHTNING1 + rand(3); + callfunc "elt_damage"; + end; + +OnInit: + set .school, SKILL_MAGIC_WAR; + set .invocation$, chr(MAGIC_SYMBOL) + "ingrav"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 2; + end; +} diff --git a/world/map/npc/magic/level2-magic-knuckles.txt b/world/map/npc/magic/level2-magic-knuckles.txt new file mode 100644 index 00000000..76ff3215 --- /dev/null +++ b/world/map/npc/magic/level2-magic-knuckles.txt @@ -0,0 +1,32 @@ +-|script|magic-knuckles|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 20) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (.@level <= 3 && countitem("Beer") >= 1) delitem "Beer", 1; + elif (.@level <= 3) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 20; + misceffect FX_MAGIC_BLACK, strcharinfo(0); + overrideattack (@spellpower/10)+10, 1300, 1, ATTACK_ICON_GENERIC, 34, strnpcinfo(0)+"::OnAttack"; + callfunc "magic_exp"; + set @upmaru_str, Str; // do not allow to equip light armor, cast, and then switch to heavy armor to get bonus str + end; + +OnAttack: + if (target(BL_ID, @target_id, 22) != 22) end; // 0x10 | 0x02 | 0x04 + setarray @melee_dmg[0], 30, ((@upmaru_str*2) + 5); + callfunc "melee_damage"; + end; + +OnInit: + set .school, SKILL_MAGIC_WAR; + set .invocation$, chr(MAGIC_SYMBOL) + "upmaru"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-make-arrows.txt b/world/map/npc/magic/level2-make-arrows.txt new file mode 100644 index 00000000..897598f9 --- /dev/null +++ b/world/map/npc/magic/level2-make-arrows.txt @@ -0,0 +1,26 @@ +-|script|make-arrows|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 8) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("RawLog") < 1) end; + delitem "RawLog", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 5; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 8; + misceffect FX_MAGIC_RED, strcharinfo(0); + setarray @create_params[0], (@spellpower/40)+1+(rand(max(1,(800-@spellpower)))/80), 500; + setarray @create_items$[0], "Arrow", "WarpedLog"; + callfunc "magic_create_item"; + callfunc "magic_exp"; + end; + +OnInit: + set .school, SKILL_MAGIC_TRANSMUTE; + set .invocation$, chr(MAGIC_SYMBOL) + "kularzufrill"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-make-iron-powder.txt b/world/map/npc/magic/level2-make-iron-powder.txt new file mode 100644 index 00000000..089150ac --- /dev/null +++ b/world/map/npc/magic/level2-make-iron-powder.txt @@ -0,0 +1,26 @@ +-|script|make-iron-powder|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 8) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("IronOre") < 1) end; + delitem "IronOre", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 5; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 8; + misceffect FX_MAGIC_RED, strcharinfo(0); + setarray @create_params[0], (@spellpower/140)+1+(rand(max(1,(900-@spellpower)))/220), 700; + setarray @create_items$[0], "IronPowder", "IronOre"; + callfunc "magic_create_item"; + callfunc "magic_exp"; + end; + +OnInit: + set .school, SKILL_MAGIC_TRANSMUTE; + set .invocation$, chr(MAGIC_SYMBOL) + "zukminbirf"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 3; + end; +} diff --git a/world/map/npc/magic/level2-protect.txt b/world/map/npc/magic/level2-protect.txt new file mode 100644 index 00000000..e4ca8d76 --- /dev/null +++ b/world/map/npc/magic/level2-protect.txt @@ -0,0 +1,48 @@ +-|script|protect|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 14) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (.@level <= 3 && countitem("HardSpike") >= 1) delitem "HardSpike", 1; + elif (.@level <= 3) end; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@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 + + set MAGIC_CAST_TICK, gettimetick(2) + 2; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 14; + 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"; + end; + +OnEnd: + message strcharinfo(0), "Shield : You feel less protected."; + misceffect FX_MAGIC_SHIELD_ENDS, strcharinfo(0); + end; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "betsanc"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 2; + end; +} diff --git a/world/map/npc/magic/level2-rain.txt b/world/map/npc/magic/level2-rain.txt new file mode 100644 index 00000000..f12c9072 --- /dev/null +++ b/world/map/npc/magic/level2-rain.txt @@ -0,0 +1,103 @@ +-|script|rain|32767 +{ + // we can not start here because for the puppets this is OnClick + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (getskilllv(.school) < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (Sp < 17) end; + explode .@map_ext[0], getmap(), "-"; + 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(getmap(), MF_TOWN)) end; + if (getskilllv(.school) < 4 && countitem("BottleOfWater") >= 1) delitem "BottleOfWater", 1; + elif (getskilllv(.school) < 4) end; + set Sp, Sp - 17; + set MAGIC_CAST_TICK, gettimetick(2) + 3; // set the new debuff + + callfunc "adjust_spellpower"; + set @krad, min(.max_radius,(min(@spellpower,200)/30)+3); // kaflosh radius + + set @nearby, 0; + foreach 1, getmap(), POS_X - .max_radius, POS_Y - .max_radius, POS_X + .max_radius, POS_Y + .max_radius, + strnpcinfo(0) + "::OnNearbyNpc"; + if (@nearby) goto L_Absorb; + + set @new_npc_name$, "#" + strnpcinfo(0) + "#" + getcharid(3); // make a unique puppet name for every player + callfunc "magic_exp"; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + set @spell_npc, puppet(getmap(), POS_X, POS_Y, @new_npc_name$, 127); // clone npc => get puppet id + set .caster, getcharid(3), @spell_npc; // tell the puppet who controls it + set .radius, @krad, @spell_npc; // this is also used by ingrav, don't rename + set .initial_x, POS_X, @spell_npc; + set .initial_y, POS_Y, @spell_npc; + set .max, @spellpower/3, @spell_npc; + set .max_launch, min(200,@spellpower/2)/100, @spell_npc; + donpcevent @new_npc_name$+"::OnLaunch"; // start + addnpctimer 30000, @new_npc_name$+"::OnDestroy"; // this is just a failsafe in case the npc is not properly destroyed + if(isin("011-1", 85, 31, 103, 45)) goto L_Pumpkins; + end; + +L_Absorb: + message strcharinfo(0), "##3Rain : ##BA nearby raincloud absorbs your magic."; + end; + +OnNearbyNpc: + explode .@nearby$[0], strnpcinfo(0,@target_id), "#"; + if(.@nearby$[1] == "DruidTree0" || .@nearby$[1] == "DruidTree0") goto L_Tree; + if(.@nearby$[0] == "rain" || .@nearby$[1] == "rain") + set @nearby, @nearby + 1; + end; + +L_Pumpkins: + callfunc "HalloweenQuestWaterPumpkins"; + end; + +L_Tree: + set .@x, get(POS_X, @target_id); set .@y, get(POS_Y, @target_id); + if (.@x < POS_X-@krad || .@y < POS_Y-@krad || .@x > POS_X+@krad || .@y > POS_Y+@krad) end; // in max radius but not in puppet area + set @flag, 1; + callfunc "QuestTreeTrigger"; + close; + +OnLaunch: + if(attachrid(.caster) != 1) destroy; // destroy if caster is missing + if(getmap() != strnpcinfo(3)) destroy; // destroy if caster left the map + set .count, .count + 1; + if(.count > .max) destroy; + set .launch, 0; + callsub S_Launch; + addnpctimer 400 + rand(100), strnpcinfo(0)+"::OnLaunch"; // loop until max + end; + +S_Launch: + npcareawarp .initial_x - .radius, .initial_y - .radius, .initial_x + .radius, .initial_y + .radius, 0, strnpcinfo(0); + misceffect FX_RAIN; + foreach 3, strnpcinfo(3), getnpcx()-1, getnpcy()-1, getnpcx()+1, getnpcy()+1, strnpcinfo(0) + "::OnHit"; + 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(target(.caster, @target_id, 16) != 16 && .caster != @target_id) end; + if((get(BL_TYPE, @target_id) & 1) == 0) end; // either mob or pc + if(elttype(@target_id) == ELT_FIRE) + injure .caster, @target_id, rand((@spellpower/15)+5)+2; + end; + +OnDestroy: + debugmes "kaflosh timeout! [this shouldn't happen]"; + destroy; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "kaflosh"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 1; + set .max_radius, 15; + end; +} diff --git a/world/map/npc/magic/level2-shear.txt b/world/map/npc/magic/level2-shear.txt new file mode 100644 index 00000000..5af782e1 --- /dev/null +++ b/world/map/npc/magic/level2-shear.txt @@ -0,0 +1,49 @@ +-|script|shear|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 23) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 23; + misceffect FX_MAGIC_GREEN, strcharinfo(0); + overrideattack 1, 2000, 1, ATTACK_ICON_SHEARING, 30, strnpcinfo(0)+"::OnAttack"; + callfunc "magic_exp"; + set @chipchip_sp, @spellpower; + end; + +OnAttack: + if (isloggedin(@target_id)) end; // can not shear a player + if (sc_check(SC_SHEARED, @target_id)) end; // mob already sheared + if (target(BL_ID, @target_id, 22) != 22) end; // 0x10 | 0x02 | 0x04 + sc_start SC_SHEARED, 600000, 0, @target_id; + set .@score, rand(1000 - rand(@chipchip_sp)); + set .@id, get(Class, @target_id); // get the mob ID + + if (.@id == 1020 && .@score < 300) set .@item$, "WhiteFur"; // Fluffy + elif (.@id == 1027 && .@score < 300) set .@item$, "WhiteFur"; // EasterFluffy + elif (.@id == 1019 && .@score < 250) set .@item$, "HardSpike"; // SpikyMushroom + elif (.@id == 1028 && .@score < 175) set .@item$, "CottonCloth"; // Mouboo + elif (.@id == 1029 && .@score < 700) set .@item$, "MauveHerb"; // MauvePlant + elif (.@id == 1030 && .@score < 700) set .@item$, "CobaltHerb"; // CobaltPlant + elif (.@id == 1031 && .@score < 700) set .@item$, "GambogeHerb"; // GambogePlant + elif (.@id == 1032 && .@score < 700) set .@item$, "AlizarinHerb"; // AlizarinPlant + elif (.@id == 1035 && .@score < 300) set .@item$, "SilkCocoon"; // SilkWorm + elif (.@id == 1018 && .@score < 180) set .@item$, "PinkAntenna"; // Pinkie + else end; + makeitem .@item$, 1, getmap(), rand(POS_X - 1, POS_X + 1), rand(POS_Y - 1, POS_Y + 1); + + if (.@id != 1020 && .@id != 1028 && .@id != 1018 && rand(2) != 1) end; + set @value, 1; + callfunc "QuestSagathaHappy"; + end; + +OnInit: + set .school, SKILL_MAGIC_NATURE; + set .invocation$, chr(MAGIC_SYMBOL) + "chipchip"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 0; + end; +} diff --git a/world/map/npc/magic/level2-summon-fluffies.txt b/world/map/npc/magic/level2-summon-fluffies.txt new file mode 100644 index 00000000..9590b468 --- /dev/null +++ b/world/map/npc/magic/level2-summon-fluffies.txt @@ -0,0 +1,53 @@ +-|script|fluffies|32767 +{ + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 39) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("WhiteFur") < 1 || countitem("Root") < 1) end; + delitem "WhiteFur", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 20; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 39; + misceffect FX_MAGIC_BLUE, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + callfunc "magic_exp"; + set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID; + set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127); + set .count, (@spellpower/170)+1+(@spellpower/430), .@puppet; + set .master, BL_ID, .@puppet; + set .lifetime, @spellpower*350, .@puppet; + addnpctimer 5000-(@spellpower*8), .@puppet$+"::OnSummon"; + addnpctimer 6000, .@puppet$+"::OnDestroy"; + end; + +OnSummon: + specialeffect FX_PENTAGRAM_BURST; + set .@i, 0; + set .@x, getnpcx(); + set .@y, getnpcy(); + set .@map$, strnpcinfo(3); + callsub S_SummonAll; + end; + +OnDestroy: + destroy; + +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; + +OnInit: + set .school, SKILL_MAGIC_ASTRAL; + set .invocation$, chr(MAGIC_SYMBOL) + "kalakarenk"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-summon-mouboo.txt b/world/map/npc/magic/level2-summon-mouboo.txt new file mode 100644 index 00000000..6b82b8c9 --- /dev/null +++ b/world/map/npc/magic/level2-summon-mouboo.txt @@ -0,0 +1,53 @@ +-|script|mouboos|32767 +{ + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 35) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("MoubooFigurine") < 1 || countitem("Root") < 1) end; + delitem "MoubooFigurine", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 20; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 35; + misceffect FX_MAGIC_BLUE, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + callfunc "magic_exp"; + set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID; + set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127); + set .count, (@spellpower/270)+1, .@puppet; + set .master, BL_ID, .@puppet; + set .lifetime, @spellpower*100, .@puppet; + addnpctimer 4000-(@spellpower*9), .@puppet$+"::OnSummon"; + addnpctimer 6000, .@puppet$+"::OnDestroy"; + end; + +OnSummon: + specialeffect FX_PENTAGRAM_BURST; + set .@i, 0; + set .@x, getnpcx(); + set .@y, getnpcy(); + set .@map$, strnpcinfo(3); + callsub S_SummonAll; + end; + +OnDestroy: + destroy; + +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; + +OnInit: + set .school, SKILL_MAGIC_ASTRAL; + set .invocation$, chr(MAGIC_SYMBOL) + "kalboo"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 2; + end; +} diff --git a/world/map/npc/magic/level2-summon-pinkie.txt b/world/map/npc/magic/level2-summon-pinkie.txt new file mode 100644 index 00000000..2c8d235e --- /dev/null +++ b/world/map/npc/magic/level2-summon-pinkie.txt @@ -0,0 +1,53 @@ +-|script|pinkies|32767 +{ + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 35) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("PinkAntenna") < 1 || countitem("Root") < 1) end; + delitem "PinkAntenna", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 20; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 35; + misceffect FX_MAGIC_BLUE, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + callfunc "magic_exp"; + set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID; + set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127); + set .count, (@spellpower/120)+1, .@puppet; + set .master, BL_ID, .@puppet; + set .lifetime, @spellpower*150, .@puppet; + addnpctimer 5000-(@spellpower*9), .@puppet$+"::OnSummon"; + addnpctimer 6000, .@puppet$+"::OnDestroy"; + end; + +OnSummon: + specialeffect FX_PENTAGRAM_BURST; + set .@i, 0; + set .@x, getnpcx(); + set .@y, getnpcy(); + set .@map$, strnpcinfo(3); + callsub S_SummonAll; + end; + +OnDestroy: + destroy; + +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; + +OnInit: + set .school, SKILL_MAGIC_ASTRAL; + set .invocation$, chr(MAGIC_SYMBOL) + "kalgina"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 2; + end; +} diff --git a/world/map/npc/magic/level2-summon-snakes.txt b/world/map/npc/magic/level2-summon-snakes.txt new file mode 100644 index 00000000..2bce0f96 --- /dev/null +++ b/world/map/npc/magic/level2-summon-snakes.txt @@ -0,0 +1,54 @@ +-|script|summon-snakes|32767 +{ + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 40) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("DarkCrystal") < 1 || countitem("SnakeEgg") < 1) end; + if (OrumQuest <= 40) end; + delitem "DarkCrystal", 1; + delitem "SnakeEgg", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 15; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 40; + misceffect FX_MAGIC_DARKRED, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + callfunc "magic_exp"; + set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID; + set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127); + set .count, (@spellpower/300)+1, .@puppet; + set .master, BL_ID, .@puppet; + set .lifetime, @spellpower*80, .@puppet; + addnpctimer 4000-(@spellpower*9), .@puppet$+"::OnSummon"; + addnpctimer 6000, .@puppet$+"::OnDestroy"; + end; + +OnSummon: + specialeffect FX_PENTAGRAM_BURST; + set .@i, 0; + set .@x, getnpcx(); + set .@y, getnpcy(); + set .@map$, strnpcinfo(3); + callsub S_SummonAll; + end; + +OnDestroy: + destroy; + +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; + +OnInit: + set .school, SKILL_MAGIC_DARK; + set .invocation$, chr(MAGIC_SYMBOL) + "halhiss"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 3; + end; +} diff --git a/world/map/npc/magic/level2-summon-spiky-mushroom.txt b/world/map/npc/magic/level2-summon-spiky-mushroom.txt new file mode 100644 index 00000000..182bbda5 --- /dev/null +++ b/world/map/npc/magic/level2-summon-spiky-mushroom.txt @@ -0,0 +1,53 @@ +-|script|spikymushroom|32767 +{ + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 33) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("HardSpike") < 1 || countitem("Root") < 1) end; + delitem "HardSpike", 1; + delitem "Root", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 20; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 33; + misceffect FX_MAGIC_BLUE, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + callfunc "magic_exp"; + set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID; + set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127); + set .count, (@spellpower/120)+1, .@puppet; + set .master, BL_ID, .@puppet; + set .lifetime, @spellpower*400, .@puppet; + addnpctimer 5000-(@spellpower*9), .@puppet$+"::OnSummon"; + addnpctimer 6000, .@puppet$+"::OnDestroy"; + end; + +OnSummon: + specialeffect FX_PENTAGRAM_BURST; + set .@i, 0; + set .@x, getnpcx(); + set .@y, getnpcy(); + set .@map$, strnpcinfo(3); + callsub S_SummonAll; + end; + +OnDestroy: + destroy; + +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; + +OnInit: + set .school, SKILL_MAGIC_ASTRAL; + set .invocation$, chr(MAGIC_SYMBOL) + "kalrenk"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 1; + end; +} diff --git a/world/map/npc/magic/level2-summon-wickedmushroom.txt b/world/map/npc/magic/level2-summon-wickedmushroom.txt new file mode 100644 index 00000000..bceef8b6 --- /dev/null +++ b/world/map/npc/magic/level2-summon-wickedmushroom.txt @@ -0,0 +1,54 @@ +-|script|wickedmushroom|32767 +{ + end; + +OnCast: + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 35) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + if (getskilllv(.school) < .level) end; + if (countitem("DarkCrystal") < 1 || countitem("SmallMushroom") < 1) end; + if (OrumQuest <= 36) end; + delitem "DarkCrystal", 1; + delitem "SmallMushroom", 1; + set MAGIC_CAST_TICK, gettimetick(2) + 15; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 35; + misceffect FX_MAGIC_DARKRED, strcharinfo(0); + misceffect FX_PENTAGRAM_BUILDUP, strcharinfo(0); + callfunc "magic_exp"; + set .@puppet$, "#"+strnpcinfo(0)+"#"+BL_ID; + set .@puppet, puppet(getmap(), POS_X, POS_Y, .@puppet$, 127); + set .count, (@spellpower/250)+1, .@puppet; + set .master, BL_ID, .@puppet; + set .lifetime, @spellpower*80, .@puppet; + addnpctimer 4000-(@spellpower*9), .@puppet$+"::OnSummon"; + addnpctimer 6000, .@puppet$+"::OnDestroy"; + end; + +OnSummon: + specialeffect FX_PENTAGRAM_BURST; + set .@i, 0; + set .@x, getnpcx(); + set .@y, getnpcy(); + set .@map$, strnpcinfo(3); + callsub S_SummonAll; + end; + +OnDestroy: + destroy; + +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; + +OnInit: + set .school, SKILL_MAGIC_DARK; + set .invocation$, chr(MAGIC_SYMBOL) + "helorp"; // used in npcs that refer to this spell + callfunc "magic_register2"; + set .level, 2; + set .exp_gain, 3; + end; +} diff --git a/world/map/npc/magic/level2-toxic-dart.txt b/world/map/npc/magic/level2-toxic-dart.txt new file mode 100644 index 00000000..91522a58 --- /dev/null +++ b/world/map/npc/magic/level2-toxic-dart.txt @@ -0,0 +1,36 @@ +-|script|toxic-dart|32767 +{ + callfunc "magic_checks"; if(@failed) end; // << I wish we had functions that could return >> + if (Sp < 15) end; + set .@level, getskilllv(.school); + if (.@level < .level) end; + if (OrumQuest <= 37) end; + if (.@level <= 2 && countitem("Root") >= 2) delitem "Root", 2; + elif (.@level <= 2) end; + set MAGIC_CAST_TICK, gettimetick(2) + 1; // set the new debuff + callfunc "adjust_spellpower"; + set Sp, Sp - 15; + misceffect FX_MAGIC_DARKRED, strcharinfo(0); + set @damage, sqrt(@spellpower) * 5; + set @dmg_bonus, (BaseLevel/3) + 5; + overrideattack (@spellpower/75)+3, 1200, 4, ATTACK_ICON_GENERIC, 31, strnpcinfo(0)+"::OnAttack"; + callfunc "magic_exp"; + end; + +OnAttack: + misceffect FX_MAGIC_DARKRED, strcharinfo(0); + if (target(BL_ID, @target_id, 50) != 50) end; // 0x20 | 0x02 | 0x10 + setarray @edmg[0], @damage, @dmg_bonus, ELT_NEUTRAL, ELT_POISON, FX_FIRE_BURST; + callfunc "elt_damage"; + if(@target_id != BL_ID && isloggedin(@target_id)) // this is a dirty trick to check if the target is a player + sc_start sc_poison, 5000+(@spellpower*1200), max(15,@spellpower/15)+5, @target_id; + end; + +OnInit: + set .school, SKILL_MAGIC_DARK; + set .invocation$, chr(MAGIC_SYMBOL) + "phlex"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 2; + set .exp_gain, 3; + end; +} diff --git a/world/map/npc/magic/level3-necromancy.txt b/world/map/npc/magic/level3-necromancy.txt new file mode 100644 index 00000000..bd1f611c --- /dev/null +++ b/world/map/npc/magic/level3-necromancy.txt @@ -0,0 +1,54 @@ +// see https://tmworld.uservoice.com/forums/255809-general/suggestions/6051818-sacrifice +// author: gumi +-|script|necromancy|32767 +{ + callfunc "magic_checks"; if(@failed) end; + if (Sp < 50) end; + if (getskilllv(.school) < .level) end; + if (getskilllv(SKILL_MAGIC) < .level) end; + set @target_id, getcharid(3, @args$); + if (@target_id < 1 || !(isloggedin(@target_id))) end; + if (get(Hp, @target_id) > 0) end; + if (Hp < (get(MaxHp, @target_id) / 3)) end; // hp must be at least a third of the max hp of the target + callfunc "adjust_spellpower"; + if (distance(BL_ID, @target_id) >= (((sqrt(@spellpower)*12)+@spellpower)/100)+2) end; + if (get(@necromancer, @target_id) > 0) end; // someone else is already trying to resurrect this player + if (getmapflag(getmap(), MF_NOSAVE)) end; // do not allow for maps like illia or candor + if (countitem("Soul") >= 1) delitem "Soul", 1; else end; + + set MAGIC_CAST_TICK, gettimetick(2) + 20; + set Sp, Sp - 50; + misceffect FX_MAGIC_DARKRED, strcharinfo(0); // on caster + misceffect FX_PENTAGRAM_BUILDUP, @args$; // on target + + 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 + end; + +OnRevive: + set .@necro, get(BL_ID, @necromancer); + if (.@necro < 1) goto L_Clean; + if (get(Hp, .@necro) < 1) end; + misceffect FX_PENTAGRAM_BURST, strcharinfo(0); + misceffect FX_CRITICAL, strcharinfo(0, .@necro); + heal 1, 0; // revive + set Hp, 1; + set Sp, 0; + set Hp, 1, .@necro; + set Sp, 0, .@necro; + goto L_Clean; + +L_Clean: + set @necromancer, 0; + end; + +OnInit: + set .school, SKILL_MAGIC_DARK; + set .invocation$, chr(MAGIC_SYMBOL) + "nevela"; // used in npcs that refer to this spell + callfunc "magic_register"; + set .level, 3; + set .exp_gain, 1; + end; +} |