feat: Implement GetModule and GetTag script functions

This commit is contained in:
Vsevolod Kremianskii 2020-11-16 00:39:49 +07:00
parent 339cf04703
commit f2f9ed06ae
4 changed files with 18 additions and 4 deletions

View file

@ -117,7 +117,9 @@ private:
script::Variable getIsObjectValid(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);
script::Variable getItemInSlot(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);
script::Variable getLocked(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);
script::Variable getModule(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);
script::Variable getObjectByTag(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);
script::Variable getTag(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);
script::Variable getWaypointByTag(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);
script::Variable setLocked(const std::vector<script::Variable> &args, script::ExecutionContext &ctx);

View file

@ -207,7 +207,7 @@ void Routines::addKotorRoutines() {
add("EffectMovementSpeedIncrease", Effect, { Int });
add("GetHitDice", Int, { Object }, bind(&Routines::getHitDice, this, _1, _2));
add("ActionForceFollowObject", Void, { Object, Float });
add("GetTag", String, { Object });
add("GetTag", String, { Object }, bind(&Routines::getTag, this, _1, _2));
add("ResistForce", Int, { Object, Object });
add("GetEffectType", Int, { Effect });
add("EffectAreaOfEffect", Effect, { Int, String, String, String });
@ -281,7 +281,7 @@ void Routines::addKotorRoutines() {
add("GetStringByStrRef", String, { Int });
add("ActionSpeakStringByStrRef", Void, { Int, Int });
add("DestroyObject", Void, { Object, Float, Int, Float }, bind(&Routines::destroyObject, this, _1, _2));
add("GetModule", Object, { });
add("GetModule", Object, { }, bind(&Routines::getModule, this, _1, _2));
add("CreateObject", Object, { Int, String, Location, Int });
add("EventSpellCastAt", Event, { Object, Int, Int });
add("GetLastSpellCaster", Object, { });

View file

@ -167,6 +167,18 @@ Variable Routines::createItemOnObject(const vector<Variable> &args, ExecutionCon
return move(result);
}
Variable Routines::getModule(const vector<Variable> &args, ExecutionContext &ctx) {
Variable result(VariableType::Object);
result.objectId = _game->module()->id();
return move(result);
}
Variable Routines::getTag(const vector<Variable> &args, ExecutionContext &ctx) {
int objectId = args[0].objectId;
shared_ptr<Object> object(getObjectById(objectId, ctx));
return object ? object->tag() : "";
}
} // namespace game
} // namespace reone

View file

@ -207,7 +207,7 @@ void Routines::addTslRoutines() {
add("EffectMovementSpeedIncrease", Effect, { Int });
add("GetHitDice", Int, { Object }, bind(&Routines::getHitDice, this, _1, _2));
add("ActionForceFollowObject", Void, { Object, Float });
add("GetTag", String, { Object });
add("GetTag", String, { Object }, bind(&Routines::getTag, this, _1, _2));
add("ResistForce", Int, { Object, Object });
add("GetEffectType", Int, { Effect });
add("EffectAreaOfEffect", Effect, { Int, String, String, String });
@ -281,7 +281,7 @@ void Routines::addTslRoutines() {
add("GetStringByStrRef", String, { Int });
add("ActionSpeakStringByStrRef", Void, { Int, Int });
add("DestroyObject", Void, { Object, Float, Int, Float, Int }, bind(&Routines::destroyObject, this, _1, _2));
add("GetModule", Object, { });
add("GetModule", Object, { }, bind(&Routines::getModule, this, _1, _2));
add("CreateObject", Object, { Int, String, Location, Int });
add("EventSpellCastAt", Event, { Object, Int, Int });
add("GetLastSpellCaster", Object, { });