// 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.
// Attack Speed Reductor: SC_ATTHASTE_INFINITY
// Max HP Reductor: SC_INCMHPRATE
// EXP Increaser: SC_CASH_PLUSEXP
- script alcohol_sc -1,{
// Stack remaning bonuses if the last one hasn't finished
// remaining_bonuses(sc, type)
// type 0: delay
// type 1: value
function remaining_bonus
{
if (getstatus(getarg(0)))
{
if (getarg(1))
return getstatus(getarg(0), 1);
else
return getstatus(getarg(0), 5); // Shouldn't it be 5?
}
return 0;
}
OnUse:
if (@Alcohol <= 0) close;
// Do you have enough vitality to hold your beer?
.@vit=readparam(bVit);
if (@Alcohol+ALC_THRESHOLD > .@vit) {
dispbottom l("You vomit, you are too drunk for this to have effect anymore.");
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!
end;
}
.@deltatime=60*1000; // How long (in ms) each Alcohol point works? (max. 100 points)
// Default value is 1 minute per alcohol point - you'll be somber after at most two hours.
// Taste is affected by users near you.
// Each user raises exp bonus in 1%, capped to twice the beverage taste
// If you are with many people, drink a better beverage! ;-)
getmapxy(.@m$, .@x, .@y, 0);
.@bonus=getareausers(.@m$, .@x-10, .@y-10, .@x+10, .@y+10)-1;
@taste+=min(@taste*2, .@bonus);
// Put the delay in ms. Each Alcohol point is 10 minutes.
.@delay = remaining_bonus(SC_CASH_PLUSEXP, false);
.@delay += @Alcohol*.@deltatime;
// Alcohol EXP Bonus sums to previous exp bonus
.@val1 = remaining_bonus(SC_CASH_PLUSEXP, true);
.@val1 += @taste;
// Reset EXP Bonus
sc_end SC_CASH_PLUSEXP;
sc_start SC_CASH_PLUSEXP, .@delay, .@val1;
// Same goes for attack speed debuff
// Except malus is recalculated
.@delay = remaining_bonus(SC_ATTHASTE_INFINITY, false)+@Alcohol*.@deltatime;
.@val1 = (ALC_THRESHOLD+@Alcohol)/2;
// Reset Attack Speed Debuff
sc_end SC_ATTHASTE_INFINITY;
sc_start SC_ATTHASTE_INFINITY, .@delay, -.@val1;
// Recalculate Alcohol Threshold and time
ALC_THRESHOLD+=@Alcohol;
if (ALC_DELAYTIME < gettimetick(2))
ALC_DELAYTIME=gettimetick(2);
ALC_DELAYTIME+=@Alcohol*.@deltatime;
// Debug comment if you need to check stuff
//debugmes "%d %d | %d %d | f t ", remaining_bonus(SC_CASH_PLUSEXP, false), remaining_bonus(SC_CASH_PLUSEXP, true), remaining_bonus(SC_ATTHASTE_INFINITY, false), remaining_bonus(SC_ATTHASTE_INFINITY, true);
close;
}