72 lines
2.5 KiB
Plaintext
72 lines
2.5 KiB
Plaintext
void Suffocation(object oCreature, int nCon, int nConMod)
|
|
{
|
|
// Check nTimer int set in OnEnter and incremented in OnHeartbeat void main()
|
|
// When the PC runs out of air (after 2 rounds per point of Constitution) start drowning process
|
|
if(GetLocalInt(oCreature, "nTimer") > (nCon * 2))
|
|
{
|
|
// Get current local int values on the PC
|
|
int nDC = GetLocalInt(oCreature, "nDC");
|
|
int nFail = GetLocalInt(oCreature, "nFail");
|
|
int nDrowning = GetLocalInt(oCreature, "nDrowning");
|
|
|
|
int nd20 = d20(); // Roll a d20
|
|
|
|
// Feedback for the player, showing the roll, modifier, DC, and success or failure
|
|
string nFeedBackPass = "You attempt to hold your breath longer. " + IntToString(nd20) + " + " + IntToString(nConMod) + " = " + IntToString(nd20 + nConMod) + " (DC " + IntToString(nDC) + ") *Success*";
|
|
string nFeedBackFail = "You attempt to hold your breath longer. " + IntToString(nd20) + " + " + IntToString(nConMod) + " = " + IntToString(nd20 + nConMod) + " (DC " + IntToString(nDC) + ") *Failure*";
|
|
|
|
// If the Constitution check was successful, send the result and increase the DC to try again next round
|
|
if((nd20 + nConMod >= nDC) && nFail != 1)
|
|
{
|
|
SendMessageToPC(oCreature, nFeedBackPass);
|
|
SetLocalInt(oCreature, "nDC", nDC + 1);
|
|
}
|
|
|
|
// If the check fails, send the result and set the local int nFail to 1
|
|
if((nd20 + nConMod < nDC) && nFail != 1)
|
|
{
|
|
SendMessageToPC(oCreature, nFeedBackFail);
|
|
SetLocalInt(oCreature, "nFail", 1);
|
|
}
|
|
|
|
nFail = GetLocalInt(oCreature, "nFail"); // Update nFail
|
|
|
|
// Drowning after failing a Constitution check lasts for three rounds:
|
|
// Round 1 - PC has hitpoints set to 0, and has fallen unconscious
|
|
// Round 2 - PC is completely out of oxygen abd begins taking in water
|
|
// Round 3 - PC dies from suffocation
|
|
if(nFail == 1)
|
|
{
|
|
switch(nDrowning)
|
|
{
|
|
case 0:
|
|
SetLocalInt(oCreature, "nDrowning", 1);
|
|
while(GetCurrentHitPoints(oCreature) > 0)
|
|
{
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(GetCurrentHitPoints(oCreature)), oCreature);
|
|
}
|
|
SendMessageToPC(oCreature, "You have fallen unconscious due to lack of oxygen.");
|
|
break;
|
|
case 1:
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(1), oCreature);
|
|
SetLocalInt(oCreature, "nDrowning", 2);
|
|
SendMessageToPC(oCreature, "Your lungs begin to fill with water.");
|
|
break;
|
|
case 2:
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(20), oCreature);
|
|
SendMessageToPC(oCreature, "You have drowned.");
|
|
|
|
// Reset local ints on PC after death
|
|
SetLocalInt(oCreature, "nDC", 10);
|
|
SetLocalInt(oCreature, "nFail", 0);
|
|
SetLocalInt(oCreature, "nDrowning", 0);
|
|
SetLocalInt(oCreature, "nTimer", 0);
|
|
break;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
|
|
|