Not sure where to ask this, and not even sure what a good title for this post should be, but here’s a problem I am experiencing.
I have some monsters and some chests that have nice items and/or high amounts of gold in them (say 35000 gold). I want these finds to be a one-time deal for the player.
So what I do is create the placeable, check the has inventory, usable and plot boxes, give it a unique tag, but put nothing in the inventory. I then put an onopen script in the onopen slot, and no other scripts.
How when a player opens the container, any special items and/or high amounts of gold are only there if they haven’t been looted already. This is achieved through a combination of the onopen script and a onacquire script.
Here’s the code I have that’s relevant. (I included some of the on_client_enter script in case the way we set up the database needs explaining):
In on_client_enter script:
object oPC = GetEnteringObject(); string sPlayerName = GetPCPlayerName(oPC); string sPublicKey = GetPCPublicCDKey(oPC, TRUE); string sCName = GetStringLowerCase(GetName(oPC)); string sCharacterName; int iSpace = FindSubString(sCName, " "); if (iSpace > -1) { sCharacterName = GetStringLeft(sCName, iSpace); } else { sCharacterName = sCName; } string sThornsLoot = "FSDB_NTLOOT_"+sPlayerName+"_"+sPublicKey+"_"+sCharacterName; SetLocalString(oPC, "thorns_loot", sThornsLoot);
In on_acquire script:
object oItem = GetModuleItemAcquired();
object oPC = GetModuleItemAcquiredBy();
object oSource = GetModuleItemAcquiredFrom();
string sItem = GetTag(oItem);
string sSource = GetTag(oSource);
int nBaseItemType = GetBaseItemType(oItem);string FSDB_LOOT_THORNS = GetLocalString(oPC, “thorns_loot”);
// Heavy Duffel Bag in Abandoned Cottage - Surkarian Glade if (sSource == "suk_lrgduffel") { if (sItem == "lylshield_tmmls1") { SetCampaignInt(FSDB_LOOT_THORNS, "FSV_C005_IT1", 1); SetCampaignString(FSDB_LOOT_THORNS, "FSV_C005_IT1Name", GetName(oItem)); } if (sItem == "fs_sword_tahimai") { SetCampaignInt(FSDB_LOOT_THORNS, "FSV_C005_IT2", 1); SetCampaignString(FSDB_LOOT_THORNS, "FSV_C005_IT2Name", GetName(oItem)); } if (sItem == "lyspear_tahim002") { SetCampaignInt(FSDB_LOOT_THORNS, "FSV_C005_IT3", 1); SetCampaignString(FSDB_LOOT_THORNS, "FSV_C005_IT3Name", GetName(oItem)); } if (sItem == "nw_it_gold001") { SetCampaignInt(FSDB_LOOT_THORNS, "FSV_C005_IT4", 1); SetCampaignString(FSDB_LOOT_THORNS, "FSV_C005_IT4Name", GetName(oItem)); } return; }
In container on_open script:
object oPC = GetLastOpenedBy();
object oSource = OBJECT_SELF;
string sSource = GetTag(oSource);
object oItem;
object oArea = GetArea(oSource);
string sArea = GetTag(oArea);string FSDB_LOOT_THORNS = GetLocalString(oPC, “thorns_loot”);
// Heavy Duffel Bag in Abandoned Cottage - Surkarian Glade
if (sSource == “suk_lrgduffel”)
{
if (GetCampaignInt(FSDB_LOOT_THORNS, “FSV_C005_IT1”) != 1)
{
CreateItemOnObject(“lylshield_tmmls1”, oSource);
}
if (GetCampaignInt(FSDB_LOOT_THORNS, “FSV_C005_IT2”) != 1)
{
CreateItemOnObject(“fs_sword_tahimai”, oSource);
}
if (GetCampaignInt(FSDB_LOOT_THORNS, “FSV_C005_IT3”) != 1)
{
CreateItemOnObject(“lyspear_tahim002”, oSource);
}
if (GetCampaignInt(FSDB_LOOT_THORNS, “FSV_C005_IT4”) != 1)
{
CreateItemOnObject(“nw_it_gold001”, oSource, 9700);
}
return;
}
So this works great for any item on our item palette, except for nw_it_gold001. The scripts do not recognize that the player has looted any gold.
Any ideas why this happens?