76 lines
2.5 KiB
Plaintext
76 lines
2.5 KiB
Plaintext
// oe_watertrap
|
|
|
|
void fnWaterTrap()
|
|
{ // PURPOSE: Handle the water trap conditions for this PC or NPC
|
|
object oCreature=OBJECT_SELF;
|
|
object oMod=GetModule();
|
|
int nWaterLevel=GetLocalInt(oMod,"nTempleWaterLevel");
|
|
int nDmg;
|
|
int nDrownCount=GetLocalInt(oCreature,"nDrownCount");
|
|
int bEntered=GetLocalInt(oCreature,"bWaterTrapEntered");
|
|
int bWaterBreathing=GetLocalInt(oCreature,"bWaterBreathing");
|
|
effect eDmg;
|
|
if (bEntered)
|
|
{ // still inside trap
|
|
if (nWaterLevel>0)
|
|
{ // still water
|
|
if (nWaterLevel<3) DeleteLocalInt(oCreature,"nDrownCount");
|
|
if (nWaterLevel==1) nDmg=d4();
|
|
else if (nWaterLevel==2) nDmg=d4(2);
|
|
else if (nWaterLevel==3) nDmg=d4(3);
|
|
eDmg=EffectDamage(nDmg,DAMAGE_TYPE_ACID);
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDmg,oCreature,1.0);
|
|
if (!bWaterBreathing&&nWaterLevel>2)
|
|
{ // drowning
|
|
nDrownCount++;
|
|
SetLocalInt(oCreature,"nDrownCount",nDrownCount);
|
|
nDrownCount=nDrownCount-1;
|
|
if (nDrownCount==10)
|
|
{ // you have drowned
|
|
eDmg=EffectDeath();
|
|
if (GetIsPC(oCreature)) SendMessageToPC(oCreature,"You have drowned!!!");
|
|
else if (GetIsPC(GetMaster(oCreature)))
|
|
{
|
|
SendMessageToPC(GetMaster(oCreature),GetName(oCreature)+" has drowned!!");
|
|
}
|
|
ApplyEffectToObject(DURATION_TYPE_INSTANT,eDmg,oCreature);
|
|
} // you have drowned
|
|
else
|
|
{ // drowning message
|
|
nDrownCount=10-nDrownCount;
|
|
nDrownCount=nDrownCount*6;
|
|
if (GetIsPC(oCreature)) SendMessageToPC(oCreature,"You will drown in "+IntToString(nDrownCount)+" seconds.");
|
|
} // drowning message
|
|
} // drowning
|
|
else
|
|
{ // not drowning
|
|
DeleteLocalInt(oCreature,"nDrownCount");
|
|
} // not drowning
|
|
DelayCommand(6.0,fnWaterTrap());
|
|
} // still water
|
|
} // still inside trap
|
|
else
|
|
{ // exited
|
|
DeleteLocalInt(oCreature,"nDrownCount");
|
|
} // exited
|
|
} // fnWaterTrap()
|
|
|
|
|
|
|
|
void main()
|
|
{
|
|
object oPC=GetEnteringObject();
|
|
object oMod=GetModule();
|
|
int nLevel=GetLocalInt(oMod,"nTempleWaterLevel");
|
|
if (nLevel>0&&GetIsPC(oPC))
|
|
{ // send message
|
|
SendMessageToPC(oPC,"*** W A R N I N G ***:You have entered an area filled with acidic water!");
|
|
if (nLevel==3) SendMessageToPC(oPC," It is deep enough for you to drown in!!");
|
|
} // send message
|
|
if (GetResRef(oPC)!="watermother")
|
|
{ // not the water mother
|
|
SetLocalInt(oPC,"bWaterTrapEntered",TRUE);
|
|
AssignCommand(oPC,fnWaterTrap());
|
|
} // not the water mother
|
|
}
|