262 lines
9.2 KiB
Plaintext
262 lines
9.2 KiB
Plaintext
// lairclean - script for cleaning
|
|
/*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"||sRes=="rtsa_message") 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 fnGetValue(object oItem)
|
|
{
|
|
int nValue=0;
|
|
if (GetIdentified(oItem)==TRUE) return GetGoldPieceValue(oItem);
|
|
else
|
|
{
|
|
SetIdentified(oItem,TRUE);
|
|
nValue=GetGoldPieceValue(oItem);
|
|
SetIdentified(oItem,FALSE);
|
|
}
|
|
return nValue;
|
|
} // fnGetValue()
|
|
|
|
/*void fnDestroyContainer(object oContainer,object oStorage,object oTaxes,object oLead)
|
|
{ // empty items
|
|
object oItem=GetFirstItemInInventory(oContainer);
|
|
int nVal;
|
|
object oNew;
|
|
while(oItem!=OBJECT_INVALID)
|
|
{
|
|
DelayCommand(0.2,DestroyObject(oItem));
|
|
nVal=fnGetValue(oItem);
|
|
if (GetPlotFlag(oItem)==TRUE||nVal>99)
|
|
{ // place item in chest
|
|
oNew=CreateItemOnObject(GetResRef(oItem),oStorage,GetItemStackSize(oItem));
|
|
} // place item in chest
|
|
else
|
|
{ // convert to gold
|
|
nVal=nVal/5;
|
|
if (nVal<1) nVal=1;
|
|
oNew=CreateItemOnObject("nw_it_gold001",oTaxes,nVal);
|
|
SendMessageToPC(oLead,GetName(OBJECT_SELF)+" has placed "+IntToString(nVal)+" in your "+GetName(oTaxes)+".");
|
|
} // convert to gold
|
|
oItem=GetNextItemInInventory(oContainer);
|
|
}
|
|
DelayCommand(0.3,DestroyObject(oContainer));
|
|
} // fnDestroyContainer()*/
|
|
|
|
/*void main()
|
|
{
|
|
object oMe=OBJECT_SELF;
|
|
string sID=GetLocalString(oMe,"sTeamID");
|
|
object oStorage=GetObjectByTag(sID+"_STORAGE");
|
|
object oChest=GetObjectByTag(sID+"_CHEST");
|
|
float fDist;
|
|
object oItem;
|
|
object oContainer;
|
|
effect eBeam=EffectBeam(VFX_BEAM_SILENT_MIND,oMe,BODY_NODE_HAND);
|
|
int nC=1;
|
|
int nValue;
|
|
int nSoulIssue=TRUE;
|
|
int bOkayToCleanup=FALSE;
|
|
object oLeader=GetLocalObject(GetModule(),"oTeamLead"+sID);
|
|
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oMe,nC);
|
|
fDist=GetDistanceBetween(oMe,oItem);
|
|
if (GetIsPC(oLeader)==FALSE) nSoulIssue=FALSE;
|
|
SetLocalInt(oMe,"nGNBDisabled",TRUE);
|
|
while(oItem!=OBJECT_INVALID&&fDist<30.0)
|
|
{ // cleanup- items
|
|
bOkayToCleanup=FALSE;
|
|
if (nSoulIssue==TRUE&&fnIsManaObject(oItem)==FALSE&&fnIsSoulObject(oItem)==FALSE&&GetTag(oItem)!="rts_it_report") bOkayToCleanup=TRUE;
|
|
if (nSoulIssue==FALSE&&fnIsManaObject(oItem)==FALSE) bOkayToCleanup=TRUE;
|
|
if(bOkayToCleanup)
|
|
{ // valid objects
|
|
if (GetResRef(oItem)=="nw_it_gold001")
|
|
{ // gold
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam,oItem,2.0);
|
|
CreateItemOnObject(GetResRef(oItem),oChest,GetItemStackSize(oItem));
|
|
if (GetIsPC(oLeader)==TRUE) SendMessageToPC(oLeader,GetName(oMe)+" added "+IntToString(GetItemStackSize(oItem))+" to your chest.");
|
|
DelayCommand(1.0,DestroyObject(oItem));
|
|
} // gold
|
|
else if (GetPlotFlag(oItem)!=TRUE)
|
|
{ // not plot
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam,oItem,2.0);
|
|
nValue=fnGetValue(oItem);
|
|
if (nValue>99)
|
|
{ // move to storage
|
|
CreateItemOnObject(GetResRef(oItem),oStorage,GetItemStackSize(oItem));
|
|
DelayCommand(1.0,DestroyObject(oItem));
|
|
} // move to storage
|
|
else if (nValue>1)
|
|
{ // convert value
|
|
nValue=FloatToInt(IntToFloat(nValue)*0.2);
|
|
if (nValue<1) nValue=1;
|
|
} // convert value
|
|
if (nValue<100)
|
|
{ // gold
|
|
DelayCommand(1.0,DestroyObject(oItem));
|
|
CreateItemOnObject("nw_it_gold001",oChest,nValue);
|
|
if (GetIsPC(oLeader)==TRUE) SendMessageToPC(oLeader,GetName(oMe)+" added "+IntToString(nValue)+" to the chest.");
|
|
} // gold
|
|
} // not plot
|
|
else
|
|
{ // plot
|
|
CreateItemOnObject(GetResRef(oItem),oStorage,GetItemStackSize(oItem));
|
|
DelayCommand(1.0,DestroyObject(oItem));
|
|
} // plot
|
|
nC++;
|
|
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oMe,nC);
|
|
fDist=GetDistanceBetween(oMe,oItem);
|
|
} // cleanup - items
|
|
} // valid objects
|
|
nC=1;
|
|
oContainer=GetNearestObject(OBJECT_TYPE_PLACEABLE,oMe,nC);
|
|
fDist=GetDistanceBetween(oContainer,oMe);
|
|
while(oContainer!=OBJECT_INVALID&&fDist<30.0)
|
|
{ // !OI
|
|
if(GetHasInventory(oContainer)==TRUE&&oContainer!=oChest&&oContainer!=oStorage)
|
|
{ //
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam,oContainer,2.0);
|
|
fnDestroyContainer(oContainer,oStorage,oChest,oLeader);
|
|
} //
|
|
nC++;
|
|
oContainer=GetNearestObject(OBJECT_TYPE_PLACEABLE,oMe,nC);
|
|
fDist=GetDistanceBetween(oContainer,oMe);
|
|
} // !OI
|
|
SetLocalInt(oMe,"nGNBDisabled",FALSE);
|
|
} */
|
|
|
|
|
|
int fnInvalidItem(object oItem)
|
|
{ // PURPOSE: Return TRUE if the item is invalid
|
|
int bRet=FALSE;
|
|
string sTag=GetTag(oItem);
|
|
string sRes=GetResRef(oItem);
|
|
if (GetLocalInt(oItem,"bNoClean")) return TRUE;
|
|
if (sRes=="mana_crystal_5"||sRes=="mana_crystal_2"||sRes=="mana_crystal_1"||sRes=="rtsa_message") return TRUE;
|
|
return bRet;
|
|
} // fnInvalidItem()
|
|
|
|
|
|
void fnCreate(int nType,string sRes,location lLoc,string sTag)
|
|
{
|
|
CreateObject(nType,sRes,lLoc,FALSE,sTag);
|
|
} // fnCreate()
|
|
|
|
|
|
void fnProcessItem(object oItem,object oStorage,object oChest,object oLeader)
|
|
{ // PURPOSE: Deal with the item
|
|
int nSS;
|
|
if (GetPlotFlag(oItem))
|
|
{ // plot item - move to storage
|
|
nSS=GetItemStackSize(oItem);
|
|
CreateItemOnObject(GetResRef(oItem),oStorage,nSS);
|
|
DestroyObject(oItem);
|
|
} // plot item - move to storage
|
|
else
|
|
{ // not a plot item
|
|
nSS=GetItemStackSize(oItem);
|
|
if (GetResRef(oItem)=="soultoken"&&GetIsPC(oLeader))
|
|
{ // soul token must be preserved
|
|
CreateItemOnObject(GetResRef(oItem),oStorage,nSS);
|
|
DestroyObject(oItem);
|
|
} // soul token must be preserved
|
|
else if (GetTag(oItem)=="nw_it_gold001")
|
|
{ // gold
|
|
DestroyObject(oItem);
|
|
CreateItemOnObject("nw_it_gold001",oChest,nSS);
|
|
SendMessageToPC(oLeader,"Lair cleaner deposited "+IntToString(nSS)+" gold in the tax chest.");
|
|
} // gold
|
|
else if (fnGetValue(oItem)>199)
|
|
{ // item should not be destroyed
|
|
CreateItemOnObject(GetResRef(oItem),oStorage,nSS);
|
|
DestroyObject(oItem);
|
|
} // item should not be destroyed
|
|
else
|
|
{ // destroy
|
|
nSS=GetGoldPieceValue(oItem);
|
|
DestroyObject(oItem);
|
|
nSS=FloatToInt(IntToFloat(nSS)*0.2);
|
|
if (nSS>0)
|
|
{ // gold
|
|
CreateItemOnObject("nw_it_gold001",oChest,nSS);
|
|
SendMessageToPC(oLeader,"Lair cleaner deposited "+IntToString(nSS)+" gold in the tax chest.");
|
|
} // gold
|
|
} // destroy
|
|
} // not a plot item
|
|
} // fnProcessItem()
|
|
|
|
|
|
void fnDestroyContainer(object oContainer,object oStorage,object oChest,object oLeader)
|
|
{ // PURPOSE: Empty contents of container and get rid of it
|
|
location lLoc=GetLocation(oContainer);
|
|
object oItem=GetFirstItemInInventory(oContainer);
|
|
int nSS;
|
|
while(oItem!=OBJECT_INVALID)
|
|
{ // process contents
|
|
if (!fnInvalidItem(oItem))
|
|
{ // valid item
|
|
DelayCommand(0.5,fnProcessItem(oItem,oStorage,oChest,oLeader));
|
|
} // valid item
|
|
else
|
|
{ // copy at location
|
|
nSS=GetItemStackSize(oItem);
|
|
DelayCommand(1.0,fnCreate(OBJECT_TYPE_ITEM,GetResRef(oItem),lLoc,GetTag(oItem)));
|
|
DelayCommand(1.0,DestroyObject(oItem));
|
|
} // copy at location
|
|
oItem=GetNextItemInInventory(oContainer);
|
|
} // process contents
|
|
DelayCommand(4.0,DestroyObject(oContainer));
|
|
} // fnDestroyContainer()
|
|
|
|
|
|
void main()
|
|
{
|
|
object oMe=OBJECT_SELF;
|
|
string sID=GetLocalString(oMe,"sTeamID");
|
|
object oStorage=GetObjectByTag(sID+"_STORAGE");
|
|
object oChest=GetObjectByTag(sID+"_CHEST");
|
|
effect eBeam=EffectBeam(VFX_BEAM_SILENT_MIND,oMe,BODY_NODE_HAND);
|
|
object oItem;
|
|
float fRange=30.0;
|
|
int nN;
|
|
object oContainer;
|
|
object oLeader=GetLocalObject(GetModule(),"oTeamLead"+sID);
|
|
SetLocalInt(oMe,"bGNBDisabled",TRUE); // Disable NPC ACTIVITIES temporarily
|
|
SetLocalInt(oMe,"nGNBDisabled",TRUE);
|
|
nN=1;
|
|
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oMe,nN);
|
|
while(oItem!=OBJECT_INVALID&&GetDistanceBetween(oMe,oItem)<fRange)
|
|
{ // check items
|
|
if(!fnInvalidItem(oItem))
|
|
{ // item is not invalid for consideration
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam,oItem,3.0);
|
|
DelayCommand(1.0,fnProcessItem(oItem,oStorage,oChest,oLeader));
|
|
} // item is not invalid for consideration
|
|
nN++;
|
|
oItem=GetNearestObject(OBJECT_TYPE_ITEM,oMe,nN);
|
|
} // check items
|
|
nN=1;
|
|
oContainer=GetNearestObject(OBJECT_TYPE_PLACEABLE,oMe,nN);
|
|
while(oContainer!=OBJECT_INVALID&&GetDistanceBetween(oMe,oContainer)<fRange)
|
|
{ // check containers
|
|
if (GetLocalInt(oContainer,"bNoClean")!=TRUE&&oContainer!=oChest&&oContainer!=oStorage&&GetHasInventory(oContainer)&&GetTag(oContainer)!="wazoo_pl_chest"&&GetTag(oContainer)!="unit_inv")
|
|
{ // process
|
|
ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eBeam,oContainer,3.0);
|
|
DelayCommand(1.5,fnDestroyContainer(oContainer,oStorage,oChest,oLeader));
|
|
} // process
|
|
nN++;
|
|
oContainer=GetNearestObject(OBJECT_TYPE_PLACEABLE,oMe,nN);
|
|
} // check containers
|
|
DelayCommand(2.0,DeleteLocalInt(oMe,"bGNBDisabled"));
|
|
DelayCommand(2.0,DeleteLocalInt(oMe,"nGNBDisabled"));
|
|
}
|