summaryrefslogblamecommitdiff
path: root/npc/magic/level0-wand.txt
blob: 5852ef0e6bda77cf3b7d5893f74f13a4c28eb14d (plain) (tree)


















































































                                                                                                             
-	script	spell-wand	NPC32767,{
    if(call("magic_checks")) goto L_Failed;
    set @wandspell[0], 0; // reset state
    callfunc "adjust_spellpower";
    callsub S_Loop; // set up wand
    if(@wandspell[0] < 1) goto L_Failed;

    // here we install
    set @_M_BLOCK, 1; // block casting, until the timer clears it
    addtimer 500, "Magic Timer::OnClear"; // set the new debuff
    misceffect FX_MAGIC_GENERIC, strcharinfo(0);

    callfunc "magic_exp";
    goto L_FreeRecast;

L_FreeRecast:
    if (@wandspell[4] > 0)
        addtimer 0, strnpcinfo(0) + "::OnSetRecast";
    end;

OnDischarge:
    if (@wandspell[4] < 1) end;
    @wandspell[4] = 0;
    misceffect FX_FIRE_BURST, strcharinfo(0);
    overrideattack;
    end;

OnSetRecast:
    overrideattack @wandspell[3], 3, ATTACK_ICON_GENERIC, @wandspell[0], strnpcinfo(0)+"::OnAttack";
    end;

OnAttack:
    if(target(BL_ID, @target_id, 22) != 22) goto L_FreeRecast; // 0x02 | 0x04 | 0x10
    if (Sp < @wandspell[1]) goto L_LowSp;
    Sp = (Sp - @wandspell[1]);
    void call("elt_damage", @wandspell[2],@wandspell[2],ELT_NEUTRAL,ELT_NEUTRAL,FX_MAGIC_RED);
    @wandspell[4] = @wandspell[4] - 1;
    goto L_FreeRecast;

S_Loop:
    if ((getequipid(equip_hand1) == .Wands[.@wand_loop]) || (getequipid(equip_hand2) == .Wands[.@wand_loop]))
        goto S_SetWand;
    .@wand_loop = (.@wand_loop + 1);
    if (.@wand_loop >= getarraysize(.Wands))
        goto S_NoWand;
    goto S_Loop;

S_SetWand:
    .@pwr = .WandsPwr[.@wand_loop];
    if (QL_MORGAN == 2)
        QL_MORGAN = 3;
    setarray @wandspell[0],
        .WandsAnim[.@wand_loop], // wand anim/id
        (.@pwr * (BaseLevel / 15) + 2), // wand cost
        (.@pwr * (@spellpower / 3)), // wand dmg
        (((200 - Agi) * 1200) / 200), //delay
        (.@pwr + (@spellpower / 10)); // charges
    return;

S_NoWand:
    message strcharinfo(0), "Wand : ##3##BYou need a wand Equipped!";
    return;

L_LowSp:
    message strcharinfo(0), "Wand : ##3##BOut of Mana";
    end;

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], 0, 758, 1171;
    setarray .WandsPwr[0], 0, 2, 1;
    setarray .WandsAnim[0], 0, 35, 33;
    .school = SKILL_MAGIC;
    set .invocation$, chr(MAGIC_SYMBOL) + "confringo"; // used in npcs that refer to this spell
    void call("magic_register");
    .level = 0;
    .exp_gain = 1;
    end;
}