An item with the tag GP_MED_10GP can be placed into a container to make a donation. If the donation equals a specific amount, the player receives a spell cast upon them. Only the special tagged item will result in this, but there are more than one a player can find.
In testing with only one special item, it's creating gold on the container as if there is more than one special item placed into the container.
With the script posted below, and my testing, it creates 30gp on the container, rather than 10gp as I am expecting.
void main()
{
object oPC = GetFirstPC();
object oContainer = OBJECT_SELF;
// ITEM WORTH 10GP
string nGPM1 = "GP_MED_10GP"; // TAG OF SPECIAL ITEM
object oItems = GetFirstItemInInventory(oContainer);
int nNumberM1 = 0; // STACK count
while(GetIsObjectValid(oItems))
{
if(GetTag(oItems) == nGPM1)
{
SetPlotFlag(oItems,FALSE);
nNumberM1 += GetNumStackedItems(oItems);
string sString = IntToString(nNumberM1);
DestroyObject(oItems);
SendMessageToPC(GetFirstPC(), "DEBUG: Fired 10*nNumberM1.");
SendMessageToPC(GetFirstPC(), "This container found this many stacked items: " +sString);
//GiveGoldToCreature(oContainer,10*nNumberM1); // PLACEABLE CONTAINER, SO THIS DOES NOT WORK
CreateItemOnObject("NW_IT_GOLD001", oContainer, 10*nNumberM1);
// VALUE OF SPECIAL ITEMS IS 10GP, SO CREATE GOLD AMOUNT BASED ON STACK SIZE
// 1 = 10gp
// 2 = 20gp
}
oItems=GetNextItemInInventory(oContainer);
} // While loop
if ( (GetGold(oContainer) >=1) && (GetGold(oContainer) <=8) )
{
AssignCommand(OBJECT_SELF, SpeakString("You make a small donation."));
DestroyObject(oItems);
return;
}
if ( (GetGold(oContainer) >=9) && (GetGold(oContainer) <=19) )
{
AssignCommand(OBJECT_SELF, ActionCastSpellAtObject(SPELL_DIVINE_FAVOR, oPC, METAMAGIC_ANY, TRUE, 2, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
AssignCommand(OBJECT_SELF, SpeakString("You make a small donation (>=9 && <=19)."));
return;
}
if ( (GetGold(oContainer) >=20) && (GetGold(oContainer) <=29) )
{
AssignCommand(OBJECT_SELF, ActionCastSpellAtObject(SPELL_BULLS_STRENGTH, oPC, METAMAGIC_ANY, TRUE, 2, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
AssignCommand(OBJECT_SELF, SpeakString("You make a small donation."));
return;
}
if (GetGold(oContainer) >=30)
{
AssignCommand(OBJECT_SELF, ActionCastSpellAtObject(SPELL_DIVINE_POWER, oPC, METAMAGIC_ANY, TRUE, 2, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
AssignCommand(OBJECT_SELF, SpeakString("You make a small donation."));
return;
}
}
Could someone point out what crazy mistake I've made? The debug notes I put in says it finds 2 stacked items, even though there is only one item placed into the container.
Thanks,
FP!
Modifié par Fester Pot, 16 juillet 2013 - 07:37 .





Retour en haut







