I like to use the fewest amount of scripts possible. So another option would be to not give any of your placeables an inventory and just create the objects and do it all from one script in all your placeables OnDeath events. Something kinda like so for example:
//Placeable resources OnDeath script.
void main()
{
string sTag = GetTag(OBJECT_SELF);
location lLoc = GetLocation(OBJECT_SELF);
int iObjectType;
int iX;
int iN;
//You could also just add the X and N values as integer variables directly
//to the placeable objects, then get rid of the iX and iN in each "if" below:
//int iX = GetLocalInt(OBJECT_SELF, "MY_X_VALUE");
//int iN = GetLocalInt(OBJECT_SELF, "MY_N_VALUE");
string sResRef;
if (sTag == "BIG_TREE")
{
iX = 4;
iN = 2;
iObjectType = OBJECT_TYPE_PLACEABLE;
sResRef = "plc_woodpile";
}
if (sTag == "SMALL_TREE")
{
iX = 1;
iN = 1;
iObjectType = OBJECT_TYPE_ITEM;
sResRef = "x2_it_cmat_elmw";
}
if (sTag == "IRON_ORE")
{
iX = 1;
iN = 2;
iObjectType = OBJECT_TYPE_ITEM;
sResRef = "iron_ore";
}
//if (sTag == etc.....
int iAmount = iX + d6(iN);
//For items to appear on the ground at the location of the destroyed
//placeable use this:
int Y;
for (Y = 0; Y <= iAmount; Y++)
{
CreateObject(iObjectType, sResRef, lLoc);
}
//For stack items to appear in the inventory of the destroyer use this:
/*
object oKiller = GetLastDamager(OBJECT_SELF);
if (GetIsObjectValid(GetMaster(oKiller)))
oKiller = GetMaster(oKiller);
CreateItemOnObject(sResRef, oKiller, iAmount);
*/
}
Hope it helps.
P.S. I used the Aurora toolset to whip this up. Hopefully functions used are the same.
Modifié par GhostOfGod, 18 juin 2012 - 04:02 .