TakeGoldFromCreature(int, object, int)
Takes a specified amount of gold away from a creature.
void TakeGoldFromCreature( int nAmount, object oCreatureToTakeFrom, int bDestroy = FALSE );
Parameters
nAmount
The amount in gold pieces to take a way
oCreatureToTakeFrom
If this is not a valid creature, nothing will happen.
bDestroy
If this is TRUE, the caller will not get the gold. Instead, the gold will be destroyed and will vanish from the game. (Default: FALSE)
Description
Take nAmount of gold from oCreatureToTakeFrom.
The taker needs to be a non-area and non-module for it to work correctly. It can be the creature passed into oCreatureToTakeFrom, of course.
Remarks
Although the default value for bDestroy is FALSE the most common usage is TRUE. In fact, Bioware has created a function TakeGold (in NW_I0_TOOL) that takes the same parameters except defaults bDestroy to TRUE (and subsequently calls this function).
This function will fail if called from an area or module event (like an area's OnEnter). However, it works on triggers, so you can just paint a trigger around the arrival area to get the same effect.
Version
1.61
Example
// This is taken from Bioware's Respawning code // * Applies an XP and GP penalty to the player respawning void ApplyPenalty(object oDead) { int nXP = GetXP(oDead); int nPenalty = 50 * GetHitDice(oDead); int nHD = GetHitDice(oDead); // * You can not lose a level with this respawning int nMin = ((nHD * (nHD - 1)) / 2) * 1000; int nNewXP = nXP - nPenalty; if (nNewXP < nMin) nNewXP = nMin; SetXP(oDead, nNewXP); int nGoldToTake = FloatToInt(0.10 * GetGold(oDead)); // * a cap of 10 000gp taken from you if (nGoldToTake > 10000) { nGoldToTake = 10000; } AssignCommand(oDead, TakeGoldFromCreature(nGoldToTake, oDead, TRUE)); DelayCommand(4.0, FloatingTextStrRefOnCreature(58299, oDead, FALSE)); DelayCommand(4.8, FloatingTextStrRefOnCreature(58300, oDead, FALSE)); }
See Also
functions: | GiveGoldToCreature | TakeGold | TakeNumItems |
categories: | Money Functions |
author: Tom Cassiotis, editor: Jasperre