126 lines
4.5 KiB
Plaintext
126 lines
4.5 KiB
Plaintext
//while wysiwyg's booze system is excellent, it is a bit more invasive than I liked
|
|
//this scipt is loosely inspired by that work - caesarbear
|
|
#include "x2_inc_switches"
|
|
#include "prc_inc_racial"
|
|
|
|
void main()
|
|
{
|
|
if (GetUserDefinedItemEventNumber() != X2_ITEM_EVENT_ACTIVATE)
|
|
{
|
|
return;
|
|
}
|
|
object oPC = GetItemActivator();
|
|
//
|
|
int iDrunkRisk = GetLocalInt(oPC, "DRUNKRISK");
|
|
|
|
int iDrinkTime = GetLocalInt(oPC, "DRINKHOUR");
|
|
int iCurrentHour = (GetCalendarDay()*24)+(GetCalendarMonth()*672)+(GetTimeHour()); //hour of the year
|
|
if (iCurrentHour > iDrinkTime)
|
|
{
|
|
iDrunkRisk = iDrunkRisk-((iCurrentHour-iDrinkTime)*(10+GetAbilityModifier(ABILITY_CONSTITUTION, oPC)));
|
|
if (iDrunkRisk < 0) iDrunkRisk = 0;
|
|
}
|
|
iDrinkTime = (GetCalendarDay()*24)+(GetCalendarMonth()*672)+(GetTimeHour());
|
|
SetLocalInt(oPC, "DRINKHOUR", iDrinkTime);
|
|
|
|
iDrunkRisk = iDrunkRisk+(d10()+6);
|
|
iDrunkRisk = iDrunkRisk-((GetCreatureSize(oPC)-3)*2);
|
|
if (GetPhenoType(oPC) == PHENOTYPE_BIG) iDrunkRisk=iDrunkRisk-2;
|
|
if (MyPRCGetRacialType(oPC) == RACIAL_TYPE_DWARF) iDrunkRisk=iDrunkRisk-2;
|
|
iDrunkRisk = iDrunkRisk-(GetAbilityModifier(ABILITY_CONSTITUTION, oPC));
|
|
iDrunkRisk = iDrunkRisk-(GetFortitudeSavingThrow(oPC)/10);
|
|
if (iDrunkRisk < 0) iDrunkRisk = 0;
|
|
|
|
int iSave = FortitudeSave(oPC, ((iDrunkRisk/2)+1), SAVING_THROW_TYPE_POISON);
|
|
switch (iSave)
|
|
{
|
|
case 0:
|
|
iDrunkRisk = iDrunkRisk+4;
|
|
break;
|
|
case 1:
|
|
iDrunkRisk = iDrunkRisk-2;
|
|
if (iDrunkRisk < 0) iDrunkRisk = 0;
|
|
break;
|
|
case 2:
|
|
iDrunkRisk = 0;
|
|
break;
|
|
}
|
|
|
|
effect eSkillDec = EffectSkillDecrease(SKILL_ALL_SKILLS, (iDrunkRisk/20));
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSkillDec, oPC, IntToFloat(iDrunkRisk)*3.0);
|
|
|
|
effect eAbilityDec;
|
|
if (FloatToInt(sqrt(IntToFloat(iDrunkRisk))) > d10(1)+3)
|
|
{
|
|
eAbilityDec = EffectAbilityDecrease(ABILITY_CHARISMA, 1);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAbilityDec, oPC, IntToFloat(iDrunkRisk)*2.0);
|
|
}
|
|
if (FloatToInt(sqrt(IntToFloat(iDrunkRisk))) > d6(3)+1)
|
|
{
|
|
eAbilityDec = EffectAbilityDecrease(ABILITY_CONSTITUTION, 1);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAbilityDec, oPC, IntToFloat(iDrunkRisk)*2.0);
|
|
}
|
|
if (FloatToInt(sqrt(IntToFloat(iDrunkRisk))) > d8(1)+2)
|
|
{
|
|
eAbilityDec = EffectAbilityDecrease(ABILITY_DEXTERITY, 1);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAbilityDec, oPC, IntToFloat(iDrunkRisk)*2.0);
|
|
}
|
|
if (FloatToInt(sqrt(IntToFloat(iDrunkRisk))) > d12(2)+3)
|
|
{
|
|
eAbilityDec = EffectAbilityDecrease(ABILITY_INTELLIGENCE, 1);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAbilityDec, oPC, IntToFloat(iDrunkRisk)*2.0);
|
|
}
|
|
if (FloatToInt(sqrt(IntToFloat(iDrunkRisk))) > d6(1)+2)
|
|
{
|
|
eAbilityDec = EffectAbilityDecrease(ABILITY_WISDOM, 1);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAbilityDec, oPC, IntToFloat(iDrunkRisk)*2.0);
|
|
}
|
|
if (FloatToInt(sqrt(IntToFloat(iDrunkRisk))) > d8(4)+3)
|
|
{
|
|
eAbilityDec = EffectAbilityDecrease(ABILITY_STRENGTH, 1);
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eAbilityDec, oPC, IntToFloat(iDrunkRisk)*2.0);
|
|
}
|
|
|
|
if (d10(1) > 7)
|
|
{
|
|
effect eSaveDec = EffectSavingThrowDecrease(SAVING_THROW_ALL, FloatToInt(sqrt(IntToFloat(iDrunkRisk))));
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSaveDec, oPC, IntToFloat(iDrunkRisk)*1.5);
|
|
}
|
|
|
|
effect eState;
|
|
float fDelay = 0.0;
|
|
float fStateDur = (IntToFloat(iDrunkRisk)/2);
|
|
if (FloatToInt(sqrt(IntToFloat(iDrunkRisk))) > d20(1))
|
|
{
|
|
if (iDrunkRisk < 60)
|
|
{
|
|
eState = EffectSlow();
|
|
}
|
|
else if (iDrunkRisk < 200)
|
|
{
|
|
eState = EffectDazed();
|
|
fStateDur = (IntToFloat(iDrunkRisk)*2);
|
|
}
|
|
else if (iDrunkRisk < 240)
|
|
{
|
|
eState = EffectKnockdown();
|
|
fStateDur = (IntToFloat(iDrunkRisk)/3);
|
|
fDelay = (IntToFloat(d100()))/16.7; //to prevent a tie in drinking games
|
|
}
|
|
else if (iDrunkRisk > 239)
|
|
{
|
|
eState = EffectSleep();
|
|
fStateDur = (IntToFloat(iDrunkRisk));
|
|
fDelay = (IntToFloat(d100()))/16.7;
|
|
}
|
|
DelayCommand(fDelay, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eState, oPC, fStateDur));
|
|
}
|
|
|
|
SetLocalInt(oPC, "DRUNKRISK", iDrunkRisk);
|
|
//
|
|
|
|
//object oItem = GetItemActivated();
|
|
//DestroyObject(oItem);
|
|
CreateItemOnObject("bastardalecup", oPC);
|
|
}
|