summaryrefslogblamecommitdiff
path: root/npc/items/alcohol.txt
blob: 0305ad4c727fe84e99d2801519c234d61def5eb3 (plain) (tree)
1
2
3
4
5
6
7
8
9
10









                                                         
                                                                                                



                                                                           
                                          
                                                                                                                
                                    
                                                                                               
 





                                         
                                    
        

      

                                                                          

            


                      


                                                     
                               
                                             

                                                                                                                        

                                                                                                                  
                                              
                                             

         

                                                                                    





                                                                                                
 
                                           
                                                                       
                                                                
                                                            
                                

                                                                 
                                 
 
                                                                               
                                                                         
                                               
 
                                             
                            
                                         
                                     

                               
                           
 



                                                                              


          
// TMW-2 Script.
// Author:
//    Crush
//    Jesusalva
// Description:
//    Alcohol effects
//    TODO: Retroactive, weakens every hour...
//
// Variables:
//    @taste    Alcohol taste (0~100) - influences exp up
//    @Alcohol   Alcoholic rating (0~100) - influences Attack Speed Malus, Min. Vit and duration
//    ALC_DELAYTIME For how long you are drunk (the delay) - gettimetick(2)
//    ALC_THRESHOLD How drunk you are (the bonus)
//
//    When drunk, attack speed is lowered but exp gain is increased.
//    Actual penalty: SC_HALT_REGENERATION
//    Attack Speed Reductor: SC_ATTHASTE_INFINITY (reset upon death), SC_ATTHASTE_POTION2 (not reset upon death)
//    Max HP Reductor: SC_INCMHPRATE
//    EXP Increaser: SC_CASH_PLUSEXP (not reset upon death), SC_OVERLAPEXPUP (reset upon death)

function	script	ALCReset	{
    if (ALC_DELAYTIME < gettimetick(2))
        ALC_THRESHOLD=0;
    return;
}

-	script	alcohol_sc	-1,{
    end;

OnUse:
    if (@Alcohol <= 0 || @taste <= 0) {
        Exception("Invalid alcoholic item, deleting without any effect.");
        end;
    }
    // Just to be sure
    ALCReset();

    // Do you have enough vitality to hold your beer?
    // Skip this check on the first drink
    if (ALC_THRESHOLD) {
        .@vit=readparam2(bVit);
        if (@Alcohol+ALC_THRESHOLD > .@vit) {
            if (GSET_ALCOHOL_NOOVERDRINK) dispbottom l("You vomit, you are too drunk for this to have effect anymore.");
            else dispbottom l("You vomit, you are too drunk and drinking is harmful.");
            dispbottom l("Raise vitality to be able to drink even more.");
		    sc_start SC_CONFUSION, 5000, 0, 10000, SCFLAG_NOAVOID; // Warning, forces user to use @resync!
            if (GSET_ALCOHOL_NOOVERDRINK) end;
            percentheal -@Alcohol, -@Alcohol;
        }
    }
    .@weight=2*60; // How long (in secs) each Alcohol point works? (max. 100 points)
    .@delay = (@Alcohol*.@weight);
    // Default value is 2 minutes per alcohol point - you'll be somber after at most four hours.
    // Beer (7): 14 minutes
    // Wine (16): 32 minutes
    // Sake (25): 50 minutes
    // Rum (40) : 80 minutes (1h20)
    // Ale (70) : 140 minutes (2h20)

    // Taste is affected by users near you.
    // Each user raises exp bonus in 2.4%, capped to the beverage taste
    // If you are with many people, drink a better beverage! ;-)
    // (Rounded down : So there's a "bonus" every ~3 people)
    getmapxy(.@m$, .@x, .@y, 0);
    .@bonus=getareausers(.@m$, .@x-14, .@y-14, .@x+14, .@y+14)-1;
    .@bonus=.@bonus*24/10;
    @taste+=min(@taste, .@bonus);

    // Alcohol EXP Bonus is ponderate average, so having more VIT doesn't means
    // more experience - only more time (be careful when mixing alcohol!)
    SC_Bonus(.@delay, SC_OVERLAPEXPUP, @taste);

    // Recalculate Alcohol Threshold and time
    ALC_THRESHOLD+=@Alcohol;
    if (ALC_DELAYTIME < gettimetick(2)) {
        ALC_DELAYTIME=gettimetick(2);
        ALC_THRESHOLD=@Alcohol;
    }
    ALC_DELAYTIME+=.@delay;

    // For debuff I'll use inc_sc_bonus utilities
    // (Now that I switched from SC_ATTHASTE_INFINITY to SC_HALT_REGENERATION,
    //  the actual value is no longer relevant)
    SC_Bonus(.@delay, SC_HALT_REGENERATION, 1);
    close;
}