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