summaryrefslogblamecommitdiff
path: root/npc/items/inc_sc_bonus.txt
blob: ac1dd8d9bc3760bc005761e3c35ed6f5b89b7aec (plain) (tree)
1
2
3
4
5
6
7
8
9




                                                   



                                                                     











                                    



                                 

                                           

                            

                                                      

                     
        
              

                                                            

                                                      
        
                    

                                           





                                                                          


                        
                               



          
// TMW-2 Script.
// Author:
//    Jesusalva
// Description:
//    Applies effects for INC_* (STR doesn't exist)
//    Valid values: INCAGI INCVIT INCINT INCDEX INCLUK INCHIT INCFLEE
//    Doesn't works: SC_STRUP
//    Works if @min == @max: INCMHP INCMHPRATE INCMSP INCMSPRATE
///   Untested Values: WALKSPEED (reverse logic) INVINCIBLE (broken)
//
// Variables:
//    @delay    Second of buffing
//    @min      Min amount of type
//    @max      Max amount of type
//    @type     SC_*

-	script	inc_sc_bonus	-1,{
OnUse:
    if (@delay <= 0) close;

    // Get the bonus value
    if (@min != @max)
        .@bonus=rand(@min, @max);
    else
        .@bonus=any(@min, @max);

    // Remaining time and effect conversion
    .@v=getstatus(@type, 1);
    .@t=getstatus(@type, 5);

    // Convert remaining time to seconds, rounded down
    if (.@t > 1000)
        .@t=.@t/1000;
    else
        .@t=0;

    // If there was effect previously, get ponderate average
    if (.@v > 0)
        .@v=((.@bonus*@delay)+(.@v*.@t))/(.@t+@delay);
    else
        .@v=.@bonus;

    // Update time value to ms and to stack
    .@t+=@delay;
    .@t*=1000;

    // Debug print if needed
    if (debug || $@GM_OVERRIDE)
        debugmes "Effect %d (+%d percent) for %d ms", @type, .@bonus, .@t;

    // Restart the bonus
    sc_end @type;
	sc_start @type,.@t,.@v;

    close;
}