feat: Implement XP script routines
This commit is contained in:
parent
dae935b81b
commit
20aa99f25d
6 changed files with 57 additions and 6 deletions
|
@ -408,6 +408,10 @@ Faction Creature::faction() const {
|
|||
return _faction;
|
||||
}
|
||||
|
||||
int Creature::xp() const {
|
||||
return _xp;
|
||||
}
|
||||
|
||||
float Creature::getAttackRange() const {
|
||||
float result = kDefaultAttackRange;
|
||||
|
||||
|
@ -443,6 +447,10 @@ void Creature::setImmortal(bool immortal) {
|
|||
_immortal = immortal;
|
||||
}
|
||||
|
||||
void Creature::setXP(int xp) {
|
||||
_xp = xp;
|
||||
}
|
||||
|
||||
void Creature::runSpawnScript() {
|
||||
if (!_onSpawn.empty()) {
|
||||
// TODO: enable when more routines are implemented
|
||||
|
@ -450,6 +458,10 @@ void Creature::runSpawnScript() {
|
|||
}
|
||||
}
|
||||
|
||||
void Creature::giveXP(int amount) {
|
||||
_xp += amount;
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
||||
|
|
|
@ -95,6 +95,8 @@ public:
|
|||
void playAnimation(Animation anim);
|
||||
void updateModelAnimation();
|
||||
|
||||
void giveXP(int amount);
|
||||
|
||||
bool isMovementRestricted() const;
|
||||
bool isInCombat() const;
|
||||
|
||||
|
@ -108,6 +110,7 @@ public:
|
|||
float runSpeed() const;
|
||||
CreatureAttributes &attributes();
|
||||
Faction faction() const;
|
||||
int xp() const;
|
||||
|
||||
void setMovementType(MovementType type);
|
||||
void setTalking(bool talking);
|
||||
|
@ -115,6 +118,7 @@ public:
|
|||
void setMovementRestricted(bool restricted);
|
||||
void setInCombat(bool inCombat);
|
||||
void setImmortal(bool immortal);
|
||||
void setXP(int xp);
|
||||
|
||||
// Equipment
|
||||
|
||||
|
@ -167,6 +171,7 @@ private:
|
|||
CreatureModelBuilder _modelBuilder;
|
||||
CreatureAnimationResolver _animResolver;
|
||||
bool _immortal { false };
|
||||
int _xp { 0 };
|
||||
|
||||
// Scripts
|
||||
|
||||
|
|
|
@ -178,11 +178,14 @@ private:
|
|||
script::Variable getPosition(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getTag(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getWaypointByTag(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getXP(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable giveXPToCreature(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable setFacing(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable setFacingPoint(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable setItemStackSize(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable setLocked(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable setPlotFlag(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable setXP(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable soundObjectPlay(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable soundObjectStop(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
|
||||
|
|
|
@ -431,9 +431,9 @@ void Routines::addKotorRoutines() {
|
|||
add("GetIsLinkImmune", Int, { Object, Effect });
|
||||
add("EffectDroidStun", Effect, { }, &Routines::effectDroidStun);
|
||||
add("EffectForcePushed", Effect, { }, &Routines::effectForcePushed);
|
||||
add("GiveXPToCreature", Void, { Object, Int });
|
||||
add("SetXP", Void, { Object, Int });
|
||||
add("GetXP", Int, { Object });
|
||||
add("GiveXPToCreature", Void, { Object, Int }, &Routines::giveXPToCreature);
|
||||
add("SetXP", Void, { Object, Int }, &Routines::setXP);
|
||||
add("GetXP", Int, { Object }, &Routines::getXP);
|
||||
add("IntToHexString", String, { Int }, &Routines::intToHexString);
|
||||
add("GetBaseItemType", Int, { Object });
|
||||
add("GetItemHasItemProperty", Int, { Object, Int });
|
||||
|
|
|
@ -394,6 +394,37 @@ Variable Routines::setPlotFlag(const VariablesList &args, ExecutionContext &ctx)
|
|||
return Variable();
|
||||
}
|
||||
|
||||
Variable Routines::getXP(const VariablesList &args, ExecutionContext &ctx) {
|
||||
auto creature = getCreature(args, 0);
|
||||
if (!creature) {
|
||||
warn("Routines: getXP: creature is invalid");
|
||||
return 0;
|
||||
}
|
||||
return creature->xp();
|
||||
}
|
||||
|
||||
Variable Routines::setXP(const VariablesList &args, ExecutionContext &ctx) {
|
||||
auto creature = getCreature(args, 0);
|
||||
if (creature) {
|
||||
int xpAmount = getInt(args, 1);
|
||||
creature->setXP(xpAmount);
|
||||
} else {
|
||||
warn("Routines: setXP: creature is invalid");
|
||||
}
|
||||
return Variable();
|
||||
}
|
||||
|
||||
Variable Routines::giveXPToCreature(const VariablesList &args, ExecutionContext &ctx) {
|
||||
auto creature = getCreature(args, 0);
|
||||
if (creature) {
|
||||
int xpAmount = getInt(args, 1);
|
||||
creature->giveXP(xpAmount);
|
||||
} else {
|
||||
warn("Routines: giveXPToCreature: creature is invalid");
|
||||
}
|
||||
return Variable();
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
||||
|
|
|
@ -431,9 +431,9 @@ void Routines::addTslRoutines() {
|
|||
add("GetIsLinkImmune", Int, { Object, Effect });
|
||||
add("EffectDroidStun", Effect, { }, &Routines::effectDroidStun);
|
||||
add("EffectForcePushed", Effect, { }, &Routines::effectForcePushed);
|
||||
add("GiveXPToCreature", Void, { Object, Int });
|
||||
add("SetXP", Void, { Object, Int });
|
||||
add("GetXP", Int, { Object });
|
||||
add("GiveXPToCreature", Void, { Object, Int }, &Routines::giveXPToCreature);
|
||||
add("SetXP", Void, { Object, Int }, &Routines::setXP);
|
||||
add("GetXP", Int, { Object }, &Routines::getXP);
|
||||
add("IntToHexString", String, { Int }, &Routines::intToHexString);
|
||||
add("GetBaseItemType", Int, { Object });
|
||||
add("GetItemHasItemProperty", Int, { Object, Int });
|
||||
|
|
Loading…
Reference in a new issue