85 lines
2.9 KiB
Plaintext
85 lines
2.9 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
// rts_powerart - Power Reservoir Artifact
|
|
// By Deva Bryson Winblood.
|
|
// #1 - check for Power Reservoir placeable
|
|
// #2 - Check for PC carrying
|
|
// #3 - if does not exist create it
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
void fnMessage(string sMsg)
|
|
{
|
|
object oPC=GetFirstPC();
|
|
float fDelay=0.1;
|
|
while(oPC!=OBJECT_INVALID)
|
|
{
|
|
DelayCommand(fDelay,SendMessageToPC(oPC,sMsg));
|
|
fDelay=fDelay+0.5;
|
|
oPC=GetNextPC();
|
|
}
|
|
} // fnMessage()
|
|
|
|
|
|
void main()
|
|
{
|
|
string sPLCRes = "plc_phylact001";
|
|
string sPLCTag = "RTS_POWER_RES";
|
|
string sItemTag = "rts_powerres";
|
|
object oOb;
|
|
object oItem;
|
|
int nR;
|
|
object oMod=GetModule();
|
|
int nDWF=GetLocalInt(oMod,"nDWFPower");
|
|
int nSPID=GetLocalInt(oMod,"nSPIDPower");
|
|
int nUND=GetLocalInt(oMod,"nUNDPower");
|
|
int nUNC=GetLocalInt(oMod,"nUNCPower");
|
|
int bFound=FALSE;
|
|
PrintString("rts_poweract called.");
|
|
if (GetIsObjectValid(GetObjectByTag(sPLCTag))==TRUE)
|
|
{
|
|
bFound=TRUE;
|
|
oItem=GetObjectByTag(sItemTag);
|
|
if (GetIsObjectValid(oItem)) DestroyObject(oItem);
|
|
}
|
|
if (!bFound&&GetIsObjectValid(GetObjectByTag(sItemTag)))
|
|
{ // object
|
|
oItem=GetObjectByTag(sItemTag);
|
|
oOb=GetItemPossessor(oItem);
|
|
if (GetIsObjectValid(oOb))
|
|
{
|
|
if (GetIsPC(oOb)==TRUE) bFound=TRUE;
|
|
else { DestroyObject(oItem); }
|
|
}
|
|
else { DestroyObject(oItem); }
|
|
} // object
|
|
if (bFound==TRUE)
|
|
{ // power reservoir is in play
|
|
oOb=GetObjectByTag(sPLCTag);
|
|
if (GetIsObjectValid(oOb))
|
|
{ // placeable
|
|
oItem=GetNearestObjectByTag("LAIR",oOb);
|
|
if (oItem!=OBJECT_INVALID) fnMessage("The Power Reservoir is in "+GetName(GetArea(oOb))+".");
|
|
else { fnMessage("The Power Reservoir is not in a lair."); }
|
|
fnMessage("Power Points DWARVES:"+IntToString(nDWF)+" SPIDERS:"+IntToString(nSPID)+" UNCLEAN:"+IntToString(nUNC)+" UNDEAD:"+IntToString(nUND));
|
|
} // placeable
|
|
else
|
|
{ // item
|
|
oItem=GetObjectByTag(sItemTag);
|
|
oOb=GetItemPossessor(oItem);
|
|
if (oOb!=OBJECT_INVALID) fnMessage("The Power Reservoir is being carried by "+GetName(oOb)+".");
|
|
fnMessage("Power Points DWARVES:"+IntToString(nDWF)+" SPIDERS:"+IntToString(nSPID)+" UNCLEAN:"+IntToString(nUNC)+" UNDEAD:"+IntToString(nUND));
|
|
} // item
|
|
} // power reservoir is in play
|
|
else
|
|
{ // place
|
|
nR=Random(11)+1;
|
|
oOb=GetWaypointByTag("POWERRES_SPAWN"+IntToString(nR));
|
|
if (oOb!=OBJECT_INVALID)
|
|
{ // place
|
|
oItem=CreateObject(OBJECT_TYPE_PLACEABLE,sPLCRes,GetLocation(oOb));
|
|
fnMessage("The Power Reservoir has been placed.");
|
|
} // place
|
|
fnMessage("Power Points DWARVES:"+IntToString(nDWF)+" SPIDERS:"+IntToString(nSPID)+" UNCLEAN:"+IntToString(nUNC)+" UNDEAD:"+IntToString(nUND));
|
|
} // place
|
|
PrintString("rts_poweract completed.");
|
|
}
|