summaryrefslogblamecommitdiff
path: root/npc/config/magic.txt
blob: 85d3442bfc6d83fb286c9221bbb4cd216d1e309f (plain) (tree)
1
2
3
4
5
6
7






                                                                            








                                                          
 

                                         
                                               
                   
                   
                                                        



                                                  
                                                    
                           
            
                                                   
                    
                                     
                                                  

        
 

                                         
                    




                      

                             
                 







                                                                       

                 



                      


             
                                                         

                                         


                                    



                                                                                              


            
                   

                                                                                                

                                                              
                                           

 
// TMW2 script
// Author: Jesusalva <admin@tmw2.org>
//
// Magic Script Core Functions
// 
// Used for our pseudo-magic.
// These are only helpers, you can add more restrictions and effects freely.
// Important Variables: 
//  MAGIC_EXP
//      Current mana magic experience
//  LAST_SKILL
//      Last Mana Skill used
//  MAGIC_LVL
//      Maximum tier of usable magic, capped by Mana Stone
//  MAGIC_SUBCLASS
//      Bitmasked magic subclass.

// SkillID, EXP Points
function	script	GetManaExp	{
    debugmes "--- Magic Subsystem: GME called";
    .@sk=getarg(0);
    .@pt=getarg(1);
    debugmes "--- Magic Subsystem: GME: Arguments Read";
    if (getskilllv(TMW2_SAGE))
        .@bonus=rand(0,getskilllv(TMW2_SAGE)*3/2);
    else
        .@bonus=0;
    debugmes "--- Magic Subsystem: GME: Evaluating";
    if (LAST_SKILL == .@sk)
        end;
    debugmes "--- Magic Subsystem: GME: Recording";
    LAST_SKILL=.@sk;
    MAGIC_EXP=MAGIC_EXP+.@pt+.@bonus;
    debugmes "--- Magic Subsystem: GME: Complete";
    end;
}

// SkillID, Mana{, MP per level}
function	script	MagicCheck	{
    // PRE EXECUTION
    // Load Variables
    .@sk=getarg(0);
    .@mp=getarg(1);
    .@amp=getarg(2,0);

    // Check Skill
    if (getskilllv(.@sk) < 1)
        return 0;

    // Load mana cost
    .@amp=getarg(3,0);
    .@mp=.@mp+getskilllv(.@sk)*.@amp-.@amp;

    // Check mana
    if (readparam(Sp) < .@mp) {
        dispbottom l("Insufficient mana: @@/@@.", readparam(Sp), .@mp);
        return 0;
    }

    // Apply mana cost
    heal 0, 0-.@mp;

    return 1;
}

// SkillID, MobID{, SkillLevelPerMob=2{, Level Override}}
function	script	SummonMagic	{
    .@sk=getarg(0);
    .@id=getarg(1);
    .@adj=getarg(2,2);
    .@lv=getarg(3,getskilllv(.@sk));

    if (.@adj < 1) {
        debugmes "\033[31mInvalid MobPerSkillLevel for SummonMagic (.@adj): "+.@adj+"\033[0m";
        dispbottom l("Invalid parameter specified, blame saulc.");
        end;
    }

    // Cause effect
    // Summoned monsters live from 45 to 60 seconds, and each skill levels grants 10s extra life
    // The 35~50 is not a defect, remember skill starts at level 1...
    for (.@i = 0; .@i < (.@lv+(.@adj-1))/.@adj; .@i++)
    	summon("Summoned Monster", .@id, rand(35,50)+.@lv*10);
    dispbottom l("All monsters summoned!");

}