102 lines
2.9 KiB
Plaintext
102 lines
2.9 KiB
Plaintext
// Area decaying system - keep items cleaned up
|
|
int fnIsManaObject(object oItem)
|
|
{ // return true if mana crystal
|
|
int nRet=FALSE;
|
|
string sRes=GetResRef(oItem);
|
|
if (sRes=="mana_crystal_5"||sRes=="mana_crystal_2"||sRes=="mana_crystal_1") nRet=TRUE;
|
|
return nRet;
|
|
} // fnIsManaObject()
|
|
|
|
int fnIsSoulObject(object oItem)
|
|
{ // return true if is soul token
|
|
int nRet=FALSE;
|
|
string sRes=GetResRef(oItem);
|
|
if (sRes=="soultoken") nRet=TRUE;
|
|
return nRet;
|
|
} // fnIsSoulObject()
|
|
|
|
int fnFilterMineable(object oItem)
|
|
{ // return true if is a mineable resource
|
|
int nRet=FALSE;
|
|
string sTag=GetTag(oItem);
|
|
if (sTag=="x2_it_cmat_adam"||sTag=="x2_it_cmat_iron"||sTag=="x2_it_cmat_mith"||sTag=="NW_IT_GOLD001") nRet=TRUE;
|
|
return nRet;
|
|
} // fnFilterMineable()
|
|
|
|
void fnDestroyContainer(object oContainer)
|
|
{ // empty items
|
|
object oItem=GetFirstItemInInventory(oContainer);
|
|
while(oItem!=OBJECT_INVALID)
|
|
{
|
|
DelayCommand(0.2,DestroyObject(oItem));
|
|
oItem=GetNextItemInInventory(oContainer);
|
|
}
|
|
DelayCommand(0.3,DestroyObject(oContainer));
|
|
} // fnDestroyContainer()
|
|
|
|
void fnDecayContainers()
|
|
{
|
|
object oMe=OBJECT_SELF;
|
|
object oCenter=GetFirstObjectInArea(oMe);
|
|
object oItem;
|
|
int nC=1;
|
|
object oBody;
|
|
string sTag;
|
|
if (GetObjectType(oCenter)!=OBJECT_TYPE_WAYPOINT) oCenter=GetNearestObject(OBJECT_TYPE_WAYPOINT,oCenter,1);
|
|
oBody=GetNearestObject(OBJECT_TYPE_PLACEABLE,oCenter,nC);
|
|
while(oBody!=OBJECT_INVALID)
|
|
{ //!OI
|
|
sTag=GetTag(oBody);
|
|
if(GetHasInventory(oBody)==TRUE&&sTag!="pileogold"&&sTag!="vamp_coffin"&&GetStringLeft(sTag,4)!="rts_")
|
|
{ // destroy
|
|
if (GetLocalInt(oBody,"nDecay")==1)
|
|
fnDestroyContainer(oBody);
|
|
else { SetLocalInt(oBody,"nDecay",1); }
|
|
} // destroy
|
|
nC++;
|
|
oBody=GetNearestObject(OBJECT_TYPE_PLACEABLE,oCenter,nC);
|
|
} //!OI
|
|
}
|
|
|
|
void fnDecay()
|
|
{
|
|
object oMe=OBJECT_SELF;
|
|
object oCenter=GetFirstObjectInArea(oMe);
|
|
object oItem;
|
|
int nC=1;
|
|
if (GetObjectType(oCenter)!=OBJECT_TYPE_WAYPOINT) oCenter=GetNearestObject(OBJECT_TYPE_WAYPOINT,oCenter,1);
|
|
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oCenter,nC);
|
|
while(oItem!=OBJECT_INVALID)
|
|
{ // decay items
|
|
if(GetPlotFlag(oItem)==FALSE&&fnIsSoulObject(oItem)==FALSE&&fnIsManaObject(oItem)==FALSE&&fnFilterMineable(oItem)==FALSE)
|
|
{
|
|
if (GetLocalInt(oItem,"nDecay")==1)
|
|
DestroyObject(oItem);
|
|
else { SetLocalInt(oItem,"nDecay",1); }
|
|
}
|
|
nC++;
|
|
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oCenter,nC);
|
|
} // decay items
|
|
DelayCommand(5.0,fnDecayContainers());
|
|
}
|
|
|
|
void main()
|
|
{
|
|
object oMe=OBJECT_SELF;
|
|
int nCC=GetLocalInt(oMe,"nCC");
|
|
float fF=HoursToSeconds(6);
|
|
int nH=FloatToInt(fF);
|
|
object oMod=GetModule();
|
|
if (GetLocalInt(oMod,"nAISetting")==1)
|
|
{ // only active with challenging AI setting
|
|
nH=nH/6;
|
|
nCC++;
|
|
if (nCC>=nH)
|
|
{
|
|
nCC=0;
|
|
DelayCommand(1.0,fnDecay());
|
|
}
|
|
SetLocalInt(oMe,"nCC",nCC);
|
|
} // only active with challenging AI setting
|
|
}
|