UW2_PRC8/_module/nss/respawn20.nss
Jaysyn904 5197ad9a4d Initial upload
Initial upload
2023-09-25 20:24:01 -04:00

38 lines
1.3 KiB
Plaintext

void main()
{
// Replenish chect only once every 20 seconds
// Check if we already have enough gold (will be FALSE the first time through)
int bAlreadyHaveGold = GetLocalInt (OBJECT_SELF, "ALREADY_HAVE_GOLD");
if (!bAlreadyHaveGold)
{
// Can replenish, so do it now
// If there is any gold there already, don't create any more
object oItem = GetFirstItemInInventory (OBJECT_SELF);
int bFoundGold = FALSE;
while (GetIsObjectValid (oItem))
{
if (GetBaseItemType (oItem) == BASE_ITEM_GOLD)
{
// Found some gold in the chest !!
bFoundGold = TRUE;
break;
}
oItem = GetNextItemInInventory (OBJECT_SELF);
}
// Check if no gold found
if (!bFoundGold)
{
// Put 20 gp into the chest's inventory
object oItem = CreateItemOnObject ("nw_it_gold001", OBJECT_SELF, 20);
// We have created the gold, so say we have enough
SetLocalInt (OBJECT_SELF, "ALREADY_HAVE_GOLD", TRUE);
// Only allow more gold in 20 secs
float fSecsToDelay = 20.0;
DelayCommand (fSecsToDelay, SetLocalInt (OBJECT_SELF, "ALREADY_HAVE_GOLD", FALSE));
}
}
}