441 lines
14 KiB
Plaintext
441 lines
14 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////////
|
|
// RTS - Harvest Of Souls
|
|
// rts_pcdrop - drop stuff on Pkill rules
|
|
// By Deva Bryson Winblood
|
|
//------------------------------------------------------------------------------
|
|
// nRTSDeathMeth
|
|
// 0 = default, 1 = drop 50% gold, 2 = 50% drop artifact, 3 = both 1 and 2
|
|
// 4 = drop all non artifacts, 50% gold, each artifact has % chance to drop
|
|
// 5 = drop everything but, only 50% of gold
|
|
// nRTSDeathMethWho
|
|
// 0 = only when PC kills PC, 1 = when PC is within 30 meters and enemy,
|
|
// 2 = anytime a PC dies
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//////////////////////////////////////////////////
|
|
// PROTOTYPES
|
|
//////////////////////////////////////////////////
|
|
int fnIsArtifact(object oItem);
|
|
int fnIsStartingAdvantage(object oItem);
|
|
void fnDropIt(object oItem,location lLoc);
|
|
void fnDropArtifact(object oPC,location lLoc,int nAC);
|
|
void fnCheckDrop(object oItem,location lLoc,int nEquipped);
|
|
|
|
///////////////////////////////////////////////////////////////// MAIN
|
|
void main()
|
|
{
|
|
object oPC=OBJECT_SELF;
|
|
object oKiller=GetLastHostileActor();
|
|
object oMod=GetModule();
|
|
int nDM=GetLocalInt(oMod,"nRTSDeathMeth"); // method
|
|
int nDMW=GetLocalInt(oMod,"nRTSDeathMethWho"); // who
|
|
int nL;
|
|
object oItem;
|
|
object oNew;
|
|
string sS;
|
|
int nW;
|
|
int nAC; // artifact count
|
|
float fDist;
|
|
object oOb;
|
|
object oBag;
|
|
int nGold=GetGold(oPC);
|
|
int bDropOkay=FALSE;
|
|
location lLoc=GetLocation(oPC);
|
|
string sBagRef="pileogold";
|
|
PrintString("rts_pcdrop was called for "+GetName(oPC)+".");
|
|
if (nDMW==2) bDropOkay=TRUE;
|
|
else if (GetIsPC(oKiller)==TRUE||GetIsPC(GetMaster(oKiller))==TRUE) bDropOkay=TRUE;
|
|
else if (nDMW==1)
|
|
{ // test for nearby hostile PC
|
|
oOb=GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR,PLAYER_CHAR_IS_PC,oPC,1,CREATURE_TYPE_REPUTATION,REPUTATION_TYPE_ENEMY,CREATURE_TYPE_IS_ALIVE,TRUE);
|
|
if (GetIsObjectValid(oOb)&&GetDistanceBetween(oOb,oPC)<=30.0) bDropOkay=TRUE;
|
|
} // test for nearby hostile PC
|
|
if (bDropOkay)
|
|
{ // DROP ITEMS
|
|
// Drop gold first - it is always dropped
|
|
if (nGold>0)
|
|
{
|
|
// create new type of bag to hold gold
|
|
oBag=CreateObject(OBJECT_TYPE_PLACEABLE,sBagRef,lLoc,FALSE);
|
|
nW=nGold/2;
|
|
if (GetLocalInt(oMod,"nRTSGoldDrop")==100) nW=nGold;
|
|
else if (GetLocalInt(oMod,"nRTSGoldDrop")==25) nW=nGold/4;
|
|
if (nW<1) nW=1;
|
|
TakeGoldFromCreature(nW,oPC,TRUE);
|
|
oNew=CreateItemOnObject("nw_it_gold001",oBag,nW);
|
|
}
|
|
if (nDM>1)
|
|
{ // other stuff dropped-------------------------------------------------
|
|
oItem=GetFirstItemInInventory(oPC);
|
|
while(GetIsObjectValid(oItem))
|
|
{ // traverse inventory
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop everything
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop everything
|
|
oItem=GetNextItemInInventory(oPC);
|
|
} // traverse inventory
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_ARROWS,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_BELT,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_BOLTS,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_BOOTS,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_BULLETS,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_CLOAK,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_NECK,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
oItem=GetItemInSlot(INVENTORY_SLOT_ARMS,oPC);
|
|
if (fnIsArtifact(oItem)&&fnIsStartingAdvantage(oItem)==FALSE&&nDM<5)
|
|
{
|
|
if(nDM<4) nAC++;
|
|
else fnCheckDrop(oItem,lLoc,FALSE);
|
|
}
|
|
else if (fnIsStartingAdvantage(oItem)==FALSE&&nDM==5)
|
|
{ // drop it
|
|
fnDropIt(oItem,lLoc);
|
|
} // drop it
|
|
if (nAC>0&&(nDM==2||nDM==3))
|
|
{ // drop artifact
|
|
if(d100()<51) DelayCommand(3.0,fnDropArtifact(oPC,lLoc,nAC));
|
|
} // drop artifact
|
|
} // other stuff dropped-------------------------------------------------
|
|
} // DROP ITEMS
|
|
}
|
|
////////////////////////////////////////////////////////////////////// MAIN
|
|
|
|
////////////////////////////////
|
|
// FUNCTIONS
|
|
////////////////////////////////
|
|
void fnDropIt(object oItem,location lLoc)
|
|
{ // DROP the item
|
|
object oNew=CopyObject(oItem,lLoc);
|
|
DelayCommand(2.0,DestroyObject(oItem));
|
|
} // fnDropIt()
|
|
|
|
int fnIsArtifact(object oItem)
|
|
{ // artifact item
|
|
int bRet=FALSE;
|
|
string sTag=GetTag(oItem);
|
|
string sL4=GetStringLeft(sTag,4);
|
|
if (sL4=="RTS_"||sL4=="rts_") return TRUE;
|
|
return bRet;
|
|
} // fnIsArtifact()
|
|
|
|
|
|
int fnIsStartingAdvantage(object oItem)
|
|
{ // Starting advantage item -- this stuff is NEVER dropped
|
|
int bRet=FALSE;
|
|
string sTag=GetTag(oItem);
|
|
string sL7=GetStringLeft(sTag,7);
|
|
if (sL7=="rts_mw_"||sL7=="RTS_MW_") return TRUE;
|
|
else if (sTag=="rts_it_vote"||sTag=="rts_it_manual") return TRUE;
|
|
else if (sTag=="rts_it_teamwand"||sTag=="RTSUnit_Creation") return TRUE;
|
|
else if (sTag=="rtstool_rebirth"||sTag=="RTSStatus_Tool") return TRUE;
|
|
else if (sTag=="rts_vampire"||sTag=="rts_lycanthropy") return TRUE;
|
|
else if (sTag=="SoulToken"||sTag=="RTSCreation_Tool") return TRUE;
|
|
else if (sTag=="rts_it_squadbadge") return TRUE;
|
|
else if (sTag=="NODROP") return TRUE;
|
|
return bRet;
|
|
} // fnIsStartingAdvantage()
|
|
|
|
void fnDropArtifact(object oPC,location lLoc,int nAC)
|
|
{ // Drop a random artifact from 1 to nAC
|
|
int nR=Random(nAC)+1;
|
|
object oInv;
|
|
int bDone=FALSE;
|
|
int nC=0;
|
|
oInv=GetFirstItemInInventory(oPC);
|
|
while(GetIsObjectValid(oInv)&&!bDone)
|
|
{ // traverse inventory
|
|
if(fnIsArtifact(oInv)&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetNextItemInInventory(oPC);
|
|
} // traverse inventory
|
|
if (!bDone)
|
|
{ // drop an equipped artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_ARMS,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_ARROWS,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_BELT,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_BOLTS,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_BOOTS,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_BULLETS,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_CHEST,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_CLOAK,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_HEAD,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_LEFTHAND,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_LEFTRING,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_NECK,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_RIGHTHAND,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
oInv=GetItemInSlot(INVENTORY_SLOT_RIGHTRING,oPC);
|
|
if (fnIsArtifact(oInv)&&!bDone&&fnIsStartingAdvantage(oInv)==FALSE)
|
|
{ // is an artifact
|
|
nC++;
|
|
if (nC==nR)
|
|
{ // drop it
|
|
fnDropIt(oInv,lLoc);
|
|
bDone=TRUE;
|
|
} // drop it
|
|
} // is an artifact
|
|
} // drop an equipped artifact
|
|
} // fnDropArtifact()
|
|
|
|
void fnCheckDrop(object oItem,location lLoc,int nEquipped)
|
|
{
|
|
if(GetItemHasItemProperty(oItem,ITEM_PROPERTY_USE_LIMITATION_CLASS))
|
|
{
|
|
if(nEquipped==TRUE&&d10()<2) fnDropIt(oItem,lLoc);
|
|
else if(d10()<10) fnDropIt(oItem,lLoc);
|
|
}
|
|
else if(d10()<6) fnDropIt(oItem,lLoc);
|
|
}
|