summaryrefslogblamecommitdiff
path: root/world/map/npc/magic/level2-lightning-strike.txt
blob: bdd311a69d9748a419aa9abe56fd53b34fd3580e (plain) (tree)
1
2
3
4
5
6
7
8
9

                               
                                 





                                                                              

                                                                 
                                         

                                 

                                            
                                                  

                             
                   
                                        
                                                     

                             

                                                                           
 
                         
                      

         
                                                                                                
 
                                          
                                                                              
                                                                                             





                                                                                                                  
 




                                                    


                                 
                                                  


                   
            
                                                                                                            






                                                                                                          


                                                                                                                                     


         


                                                                                                                              
                                                       

                                


                                                         


                                                                                                                            




                                                                                            
                                



                     
-|script|lightning-strike|32767
{
    if(call("magic_checks")) end;
    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 @_M_BLOCK, 1; // block casting, until the timer clears it
    addtimer 1000, "Magic Timer::OnClear"; // set the new debuff
    sc_start SC_COOLDOWN, 1000, 0, BL_ID;
    callfunc "adjust_spellpower";
    set Sp, Sp - 20;
    set CASTS, CASTS + 1;
    if (CASTS < 0) set CASTS, 1; // overflow
    misceffect FX_MAGIC_BOLT_CAST, strcharinfo(0);
    setarray @ingravspell[0],
        @spellpower,
        (Luk+Luk2),
        ((@spellpower/90)+1), // charges
        (((200 - (Agi+Agi2)) * 3000) / 200), // delay
        0, // in_rain
        0; // target id (tmp)
    if (getequipid(equip_misc1) == 5253 || getequipid(equip_misc2) == 5253)
        set @ingravspell[3], @ingravspell[3]*8/10+1;

    callfunc "magic_exp";
    goto L_FreeRecast;

OnAttack:
    if (target(BL_ID, @target_id, 0x36) != 0x36) goto L_FreeRecast; // 0x10 | 0x02 | 0x04 | 0x20

    set .@p, get(.max_radius, "rain") + 1;
    set @ingravspell[5], @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, @ingravspell[5]; // now restore it

    set @ingravspell[2], @ingravspell[2] - 1;
    if (@ingravspell[4] & 1) goto L_InRain;
    void call("elt_damage", @ingravspell[0], (@ingravspell[0]/2)+1, ELT_EARTH, ELT_WIND, FX_LIGHTNING1 + rand(3));
    goto L_FreeRecast;

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

OnDischarge:
    if (@ingravspell[2] < 1) end;
    set @ingravspell[2], 0;
    misceffect FX_MAGIC_DISCHARGE, strcharinfo(0);
    overrideattack;
    end;

OnSetRecast:
    overrideattack @ingravspell[3], 8, ATTACK_ICON_GENERIC, 31, strnpcinfo(0)+"::OnAttack", @ingravspell[2];
    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 @ingravspell[6], .@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 >= @ingravspell[6] && POS_Y >= @ingravspell[7] && POS_X <= @ingravspell[8] && POS_Y <= @ingravspell[9])
        set @ingravspell[4], @ingravspell[4] | 1;
    end;

L_InRain:
    set @ingravspell[10], 0;
    foreach 0, getmap(), @ingravspell[6], @ingravspell[7], @ingravspell[8], @ingravspell[9], strnpcinfo(0)+"::OnEntityInRain";
    if (@ingravspell[10] >= 1 && (@ingravspell[1] + rand(200)) >= 150) goto L_FreeRecast;
    misceffect FX_LIGHTNING1 + rand(3), strcharinfo(0);
    heal 0 - @ingravspell[0], 0;
    goto L_FreeRecast;

OnEntityInRain:
    if (target(BL_ID, @target_id, 16) != 16) end; // 0x10
    if (@ingravspell[1] + rand(200) <= 175) end;
    set @ingravspell[10], @ingravspell[10] + 1;
    void call("elt_damage", @ingravspell[0]/6, (((@ingravspell[0]/2)+1)/3)+1, ELT_EARTH, ELT_WIND, FX_LIGHTNING1 + rand(3));
    end;

OnInit:
    set .school, SKILL_MAGIC_WAR;
    set .invocation$, chr(MAGIC_SYMBOL) + "ingrav"; // used in npcs that refer to this spell
    void call("magic_register");
    set .level, 2;
    set .exp_gain, 2;
    end;
}