TakeGoldFromCreature(int, object, int)
Takes a specified amount of gold away from a creature.
void TakeGoldFromCreature( int nAmount, object oCreatureToTakeFrom, int bDestroy = FALSE );
Contents |
[edit] 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)
[edit] Description
Take nAmount of gold from oCreatureToTakeFrom.
The taker needs to be a non-area and non-module object for it to work correctly. It can be the creature passed into oCreatureToTakeFrom, of course.
[edit] 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 it defaults bDestroy to TRUE (and subsequently calls this function).
If the function caller (OBJECT_SELF) is the module or an area, this function will fail. If you want to use this function in an area or module event (like an area's OnEnter), you can use AssignCommand() or ExecuteScript() to assign the function to another object. Alternatively, since it works on triggers, you can just paint a trigger around the arrival area to get the same effect.
[edit] Version
1.61
[edit] 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 nHD = GetHitDice(oDead); int nPenalty = 50 * nHD; // * 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)); }
[edit] See Also
functions: | TakeNumItems |
author: Tom Cassiotis, editor: Jasperre