summaryrefslogblamecommitdiff
path: root/npc/magic/mpregen.txt
blob: dc8ad2bd30e684677f4faac8674d6e76796de7ee (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12
13












                                                                        

                                  
                                  
                             

                                                        


           
















                                         

















                                                                
// TMW2 script
// Author: Jesusalva <jesusalva@tmw2.org>
//
// Magic Script: -
//
// mpgen to make mana from HP

function	script	SK_mpregen	{
    // Convert HP to mana (20% HP - 1) (To prevent 5 casts from killing)
    .@basehp=(MaxHp/5)-1;
    // How much MP is that worth?
    // Well, 400HP:120MP so base formula is 4:1
    // Let's have a 50% penalty, so, 6:1
    .@lv=getskilllv(TMW2_MPREGEN);
    .@ratio=max(40, 60-.@lv);
    .@mpheal=.@basehp*.@ratio/100;
    heal -.@basehp, .@mpheal;
    // Temporarily block healing and regeneration skills
    SC_Bonus(1+.@lv, SC_HALT_REGENERATION, 1);
    return;
}

function	script	SK_transfermp	{
    .@mp = Sp;
    .@me = getcharid(3);
    .@tg = getarg(0, @skillTarget);
    detachrid();
    attachrid(.@tg);
    .@mo = MaxSp - Sp;
    // Heal will be the smallest from:
    // Current MP or Missing Mp
    .@vl = min(.@mo, .@mp);
    Sp += .@vl;
    detachrid();
    attachrid(.@me);
    Sp -= .@vl;
    return;
}

/*
-	script	sk#mpgen	32767,{
    end;

OnCall:
    // Must have magic
    if (!MAGIC_LVL)
        end;

    unitskilluseid(getcharid(3), TMW2_MPREGEN, 1, getcharid(3));
    end;

OnInit:
    bindatcmd "sk-mpgen", "sk#mpgen::OnCall", 0, 100, 0;
    end;
}
*/