feat: Implement (get|set)Commandable
This commit is contained in:
parent
c3558f4437
commit
144e0ac3c5
6 changed files with 37 additions and 4 deletions
|
@ -48,6 +48,10 @@ bool Object::isDead() const {
|
|||
return _dead;
|
||||
}
|
||||
|
||||
bool Object::isCommandable() const {
|
||||
return _commandable;
|
||||
}
|
||||
|
||||
ObjectType Object::type() const {
|
||||
return _type;
|
||||
}
|
||||
|
@ -108,6 +112,10 @@ void Object::setPlotFlag(int flag) {
|
|||
_plotFlag = flag;
|
||||
}
|
||||
|
||||
void Object::setCommandable(bool value) {
|
||||
_commandable = value;
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
||||
|
|
|
@ -37,6 +37,7 @@ public:
|
|||
|
||||
bool isMinOneHP() const;
|
||||
bool isDead() const;
|
||||
bool isCommandable() const;
|
||||
|
||||
ObjectType type() const;
|
||||
const std::string &blueprintResRef() const;
|
||||
|
@ -48,6 +49,7 @@ public:
|
|||
|
||||
void setTag(const std::string &tag);
|
||||
void setPlotFlag(int flag);
|
||||
void setCommandable(bool value);
|
||||
|
||||
// Hit Points
|
||||
|
||||
|
@ -84,6 +86,7 @@ protected:
|
|||
int _currentHitPoints { 0 };
|
||||
bool _dead { false };
|
||||
int _plotFlag { 0 };
|
||||
bool _commandable { true };
|
||||
|
||||
// Scripts
|
||||
|
||||
|
|
|
@ -156,6 +156,7 @@ private:
|
|||
script::Variable destroyObject(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable faceObjectAwayFromObject(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getArea(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getCommandable(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getDistanceBetween(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getDistanceBetween2D(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
script::Variable getDistanceToObject(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
|
@ -181,6 +182,7 @@ 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 setCommandable(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 setIdentified(const VariablesList &args, script::ExecutionContext &ctx);
|
||||
|
|
|
@ -200,8 +200,8 @@ void Routines::addKotorRoutines() {
|
|||
add("EffectChoke", Effect, { }, &Routines::effectChoke);
|
||||
add("SetGlobalString", Void, { String, String }, &Routines::setGlobalString);
|
||||
add("EffectStunned", Effect, { }, &Routines::effectStunned);
|
||||
add("SetCommandable", Void, { Int, Object });
|
||||
add("GetCommandable", Int, { Object });
|
||||
add("SetCommandable", Void, { Int, Object }, &Routines::setCommandable);
|
||||
add("GetCommandable", Int, { Object }, &Routines::getCommandable);
|
||||
add("EffectRegenerate", Effect, { Int, Float }, &Routines::effectRegenerate);
|
||||
add("EffectMovementSpeedIncrease", Effect, { Int }, &Routines::effectMovementSpeedIncrease);
|
||||
add("GetHitDice", Int, { Object }, &Routines::getHitDice);
|
||||
|
|
|
@ -430,6 +430,26 @@ Variable Routines::setIdentified(const VariablesList &args, ExecutionContext &ct
|
|||
return Variable();
|
||||
}
|
||||
|
||||
Variable Routines::getCommandable(const VariablesList &args, ExecutionContext &ctx) {
|
||||
auto target = getObjectOrCaller(args, 0, ctx);
|
||||
if (!target) {
|
||||
warn("Routines: getCommandable: target is invalid");
|
||||
return 0;
|
||||
}
|
||||
return target->isCommandable() ? 1 : 0;
|
||||
}
|
||||
|
||||
Variable Routines::setCommandable(const VariablesList &args, ExecutionContext &ctx) {
|
||||
auto target = getObjectOrCaller(args, 1, ctx);
|
||||
if (target) {
|
||||
bool commandable = getBool(args, 0);
|
||||
target->setCommandable(commandable);
|
||||
} else {
|
||||
warn("Routines: setCommandable: target is invalid");
|
||||
}
|
||||
return Variable();
|
||||
}
|
||||
|
||||
} // namespace game
|
||||
|
||||
} // namespace reone
|
||||
|
|
|
@ -200,8 +200,8 @@ void Routines::addTslRoutines() {
|
|||
add("EffectChoke", Effect, { }, &Routines::effectChoke);
|
||||
add("SetGlobalString", Void, { String, String }, &Routines::setGlobalString);
|
||||
add("EffectStunned", Effect, { }, &Routines::effectStunned);
|
||||
add("SetCommandable", Void, { Int, Object });
|
||||
add("GetCommandable", Int, { Object });
|
||||
add("SetCommandable", Void, { Int, Object }, &Routines::setCommandable);
|
||||
add("GetCommandable", Int, { Object }, &Routines::getCommandable);
|
||||
add("EffectRegenerate", Effect, { Int, Float }, &Routines::effectRegenerate);
|
||||
add("EffectMovementSpeedIncrease", Effect, { Int }, &Routines::effectMovementSpeedIncrease);
|
||||
add("GetHitDice", Int, { Object }, &Routines::getHitDice);
|
||||
|
|
Loading…
Reference in a new issue