Implement gold related functions
- GetGold - GiveGoldToCreature - TakeGoldFromCreature
This commit is contained in:
parent
9cacd1ddd0
commit
59a990b5e2
4 changed files with 60 additions and 3 deletions
|
@ -656,6 +656,14 @@ void Creature::onEventSignalled(const string &name) {
|
|||
}
|
||||
}
|
||||
|
||||
void Creature::giveGold(int amount) {
|
||||
_gold += amount;
|
||||
}
|
||||
|
||||
void Creature::takeGold(int amount) {
|
||||
_gold -= amount;
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
||||
|
|
|
@ -207,6 +207,15 @@ public:
|
|||
|
||||
// END Physics
|
||||
|
||||
// Gold
|
||||
|
||||
void giveGold(int amount);
|
||||
void takeGold(int amount);
|
||||
|
||||
int gold() const { return _gold; }
|
||||
|
||||
// END Gold
|
||||
|
||||
// Scripts
|
||||
|
||||
void runSpawnScript();
|
||||
|
@ -263,6 +272,7 @@ private:
|
|||
bool _disarmable { false };
|
||||
uint32_t _footstepType { 0 };
|
||||
int _walkmeshMaterial { -1 };
|
||||
int _gold { 0 }; /**< aka credits */
|
||||
|
||||
// Animation
|
||||
|
||||
|
|
|
@ -565,6 +565,48 @@ Variable Routines::objectToString(const VariablesList &args, ExecutionContext &c
|
|||
return Variable::ofString(move(result));
|
||||
}
|
||||
|
||||
Variable Routines::getGold(const VariablesList &args, ExecutionContext &ctx) {
|
||||
int result = 0;
|
||||
auto target = getCreatureOrCaller(args, 0, ctx);
|
||||
if (target) {
|
||||
result = target->gold();
|
||||
} else {
|
||||
debug("Script: getGold: target is invalid", 1, DebugChannels::script);
|
||||
}
|
||||
return Variable::ofInt(result);
|
||||
}
|
||||
|
||||
Variable Routines::giveGoldToCreature(const VariablesList &args, ExecutionContext &ctx) {
|
||||
auto creature = getCreature(args, 0, ctx);
|
||||
auto gp = getInt(args, 1);
|
||||
if (creature) {
|
||||
creature->giveGold(gp);
|
||||
} else {
|
||||
debug("Script: giveGoldToCreature: creature is invalid", 1, DebugChannels::script);
|
||||
}
|
||||
return Variable();
|
||||
}
|
||||
|
||||
Variable Routines::takeGoldFromCreature(const VariablesList &args, ExecutionContext &ctx) {
|
||||
auto amount = getInt(args, 0);
|
||||
auto creatureToTakeFrom = getCreature(args, 1, ctx);
|
||||
auto destroy = getBool(args, 2);
|
||||
if (creatureToTakeFrom) {
|
||||
creatureToTakeFrom->takeGold(amount);
|
||||
} else {
|
||||
debug("Script: takeGoldFromCreature: creatureToTakeFrom is invalid", 1, DebugChannels::script);
|
||||
}
|
||||
if (!destroy) {
|
||||
auto caller = getCallerAsCreature(ctx);
|
||||
if (caller) {
|
||||
caller->giveGold(amount);
|
||||
} else {
|
||||
debug("Script: takeGoldFromCreature: caller is invalid", 1, DebugChannels::script);
|
||||
}
|
||||
}
|
||||
return Variable();
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
||||
|
|
|
@ -152,7 +152,6 @@ Variable Routines::getFortitudeSavingThrow(const VariablesList &args, ExecutionC
|
|||
Variable Routines::getFoundEnemyCreature(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getGameDifficulty(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getGoingToBeAttackedBy(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getGold(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getGoldPieceValue(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getGoodEvilValue(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getHasFeatEffect(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
|
@ -293,7 +292,6 @@ Variable Routines::getTypeFromTalent(const VariablesList &args, ExecutionContext
|
|||
Variable Routines::getWasForcePowerSuccessful(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getWeaponRanged(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::getWillSavingThrow(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::giveGoldToCreature(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::giveItem(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::givePlotXP(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::grantFeat(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
|
@ -434,7 +432,6 @@ Variable Routines::surrenderByFaction(const VariablesList &args, ExecutionContex
|
|||
Variable Routines::surrenderRetainBuffs(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::surrenderToEnemies(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::switchPlayerCharacter(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::takeGoldFromCreature(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::talentFeat(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::talentSkill(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
Variable Routines::talentSpell(const VariablesList &args, ExecutionContext &ctx) { return Variable::notImplemented(); }
|
||||
|
|
Loading…
Reference in a new issue