diff --git a/src/engine/game/d20/attributes.h b/src/engine/game/d20/attributes.h index 748c305e..8e132852 100644 --- a/src/engine/game/d20/attributes.h +++ b/src/engine/game/d20/attributes.h @@ -18,6 +18,7 @@ #pragma once #include +#include #include #include "../types.h" @@ -104,10 +105,20 @@ public: // END Skills + // Feats + + bool hasFeat(FeatType type) const { return _feats.count(type) > 0; } + + void addFeat(FeatType type) { _feats.insert(type); } + void removeFeat(FeatType type) { _feats.erase(type); } + + // END Feats + private: std::vector> _classLevels; std::map _abilityScores; std::map _skillRanks; + std::set _feats; }; } // namespace game diff --git a/src/engine/game/object/creature_blueprint.cpp b/src/engine/game/object/creature_blueprint.cpp index 2d2f4f9e..81c980e9 100644 --- a/src/engine/game/object/creature_blueprint.cpp +++ b/src/engine/game/object/creature_blueprint.cpp @@ -100,6 +100,10 @@ void Creature::loadUTC(const GffStruct &utc) { bool dropable = itemGffs->getBool("Dropable"); addItem(resRef, 1, dropable); } + for (auto &featGffs : utc.getList("FeatList")) { + auto feat = static_cast(featGffs->getUint("Feat")); + _attributes.addFeat(feat); + } // Unused fields: // diff --git a/src/engine/game/script/routines.h b/src/engine/game/script/routines.h index c7c7ceaf..3d6a4a82 100644 --- a/src/engine/game/script/routines.h +++ b/src/engine/game/script/routines.h @@ -328,6 +328,7 @@ private: REO_DECL_ROUTINE(getGlobalLocation) REO_DECL_ROUTINE(getGlobalNumber) REO_DECL_ROUTINE(getGlobalString) + REO_DECL_ROUTINE(getHasFeat) REO_DECL_ROUTINE(getHasSkill) REO_DECL_ROUTINE(getHasSpell) REO_DECL_ROUTINE(getHitDice) diff --git a/src/engine/game/script/routines_d20.cpp b/src/engine/game/script/routines_d20.cpp index 31edaf99..a9c98978 100644 --- a/src/engine/game/script/routines_d20.cpp +++ b/src/engine/game/script/routines_d20.cpp @@ -188,6 +188,20 @@ Variable Routines::getLevelByClass(const VariablesList &args, ExecutionContext & return Variable::ofInt(result); } +Variable Routines::getHasFeat(const VariablesList &args, ExecutionContext &ctx) { + bool result = false; + auto feat = getEnum(args, 0); + auto creature = getCreatureOrCaller(args, 1, ctx); + + if (creature) { + result = creature->attributes().hasFeat(feat); + } else { + debug("Script: getHasFeat: creature is invalid", 1, DebugChannels::script); + } + + return Variable::ofInt(static_cast(result)); +} + Variable Routines::getHasSkill(const VariablesList &args, ExecutionContext &ctx) { bool result = false; auto creature = getCreatureOrCaller(args, 1, ctx); diff --git a/src/engine/game/script/routines_kotor.cpp b/src/engine/game/script/routines_kotor.cpp index b1378333..c5a805bc 100644 --- a/src/engine/game/script/routines_kotor.cpp +++ b/src/engine/game/script/routines_kotor.cpp @@ -327,7 +327,7 @@ void Routines::addKotorRoutines() { add("GetModuleItemAcquired", Object, { }); add("GetModuleItemAcquiredFrom", Object, { }); add("SetCustomToken", Void, { Int, String }); - add("GetHasFeat", Int, { Int, Object }); + add("GetHasFeat", Int, { Int, Object }, &Routines::getHasFeat); add("GetHasSkill", Int, { Int, Object }, &Routines::getHasSkill); add("ActionUseFeat", Void, { Int, Object }, &Routines::actionUseFeat); add("ActionUseSkill", Void, { Int, Object, Int, Object }, &Routines::actionUseSkill); diff --git a/src/engine/game/script/routines_tsl.cpp b/src/engine/game/script/routines_tsl.cpp index f10f9cc9..9a8b58cc 100644 --- a/src/engine/game/script/routines_tsl.cpp +++ b/src/engine/game/script/routines_tsl.cpp @@ -328,7 +328,7 @@ void Routines::addTslRoutines() { add("GetModuleItemAcquired", Object, { }); add("GetModuleItemAcquiredFrom", Object, { }); add("SetCustomToken", Void, { Int, String }); - add("GetHasFeat", Int, { Int, Object }); + add("GetHasFeat", Int, { Int, Object }, &Routines::getHasFeat); add("GetHasSkill", Int, { Int, Object }, &Routines::getHasSkill); add("ActionUseFeat", Void, { Int, Object }, &Routines::actionUseFeat); add("ActionUseSkill", Void, { Int, Object, Int, Object }, &Routines::actionUseSkill); diff --git a/src/engine/graphics/model/modelnode.h b/src/engine/graphics/model/modelnode.h index 122f422e..2152b66a 100644 --- a/src/engine/graphics/model/modelnode.h +++ b/src/engine/graphics/model/modelnode.h @@ -33,7 +33,7 @@ namespace reone { namespace graphics { -#define DECL_ANIM_PROP(a, b, c) \ +#define REO_DECL_ANIMPROP(a, b, c) \ const AnimatedProperty &b() const { return c; }; \ AnimatedProperty &b() { return c; }; @@ -236,66 +236,66 @@ public: const AnimatedProperty &orientation() const { return _orientation; } AnimatedProperty &orientation() { return _orientation; } - DECL_ANIM_PROP(glm::vec3, position, _position) - DECL_ANIM_PROP(float, scale, _scale) + REO_DECL_ANIMPROP(glm::vec3, position, _position) + REO_DECL_ANIMPROP(float, scale, _scale) - DECL_ANIM_PROP(glm::vec3, selfIllumColor, _selfIllumColor) - DECL_ANIM_PROP(float, alpha, _alpha) + REO_DECL_ANIMPROP(glm::vec3, selfIllumColor, _selfIllumColor) + REO_DECL_ANIMPROP(float, alpha, _alpha) - DECL_ANIM_PROP(glm::vec3, color, _color) - DECL_ANIM_PROP(float, radius, _radius) - DECL_ANIM_PROP(float, shadowRadius, _shadowRadius) - DECL_ANIM_PROP(float, verticalDisplacement, _verticalDisplacement) - DECL_ANIM_PROP(float, multiplier, _multiplier) + REO_DECL_ANIMPROP(glm::vec3, color, _color) + REO_DECL_ANIMPROP(float, radius, _radius) + REO_DECL_ANIMPROP(float, shadowRadius, _shadowRadius) + REO_DECL_ANIMPROP(float, verticalDisplacement, _verticalDisplacement) + REO_DECL_ANIMPROP(float, multiplier, _multiplier) - DECL_ANIM_PROP(float, alphaEnd, _alphaEnd) - DECL_ANIM_PROP(float, alphaStart, _alphaStart) - DECL_ANIM_PROP(float, birthrate, _birthrate) - DECL_ANIM_PROP(float, bounceCo, _bounceCo) - DECL_ANIM_PROP(float, combineTime, _combineTime) - DECL_ANIM_PROP(float, drag, _drag) - DECL_ANIM_PROP(float, fps, _fps) - DECL_ANIM_PROP(float, frameEnd, _frameEnd) - DECL_ANIM_PROP(float, frameStart, _frameStart) - DECL_ANIM_PROP(float, grav, _grav) - DECL_ANIM_PROP(float, lifeExp, _lifeExp) - DECL_ANIM_PROP(float, mass, _mass) - DECL_ANIM_PROP(float, p2pBezier2, _p2pBezier2) - DECL_ANIM_PROP(float, p2pBezier3, _p2pBezier3) - DECL_ANIM_PROP(float, particleRot, _particleRot) - DECL_ANIM_PROP(float, randVel, _randVel) - DECL_ANIM_PROP(float, sizeStart, _sizeStart) - DECL_ANIM_PROP(float, sizeEnd, _sizeEnd) - DECL_ANIM_PROP(float, sizeStartY, _sizeStartY) - DECL_ANIM_PROP(float, sizeEndY, _sizeEndY) - DECL_ANIM_PROP(float, spread, _spread) - DECL_ANIM_PROP(float, threshold, _threshold) - DECL_ANIM_PROP(float, velocity, _velocity) - DECL_ANIM_PROP(float, xSize, _xSize) - DECL_ANIM_PROP(float, ySize, _ySize) - DECL_ANIM_PROP(float, blurLength, _blurLength) - DECL_ANIM_PROP(float, lightingDelay, _lightingDelay) - DECL_ANIM_PROP(float, lightingRadius, _lightingRadius) - DECL_ANIM_PROP(float, lightingScale, _lightingScale) - DECL_ANIM_PROP(float, lightingSubDiv, _lightingSubDiv) - DECL_ANIM_PROP(float, lightingZigZag, _lightingZigZag) - DECL_ANIM_PROP(float, alphaMid, _alphaMid) - DECL_ANIM_PROP(float, percentStart, _percentStart) - DECL_ANIM_PROP(float, percentMid, _percentMid) - DECL_ANIM_PROP(float, percentEnd, _percentEnd) - DECL_ANIM_PROP(float, sizeMid, _sizeMid) - DECL_ANIM_PROP(float, sizeMidY, _sizeMidY) - DECL_ANIM_PROP(float, randomBirthRate, _randomBirthRate) - DECL_ANIM_PROP(float, targetSize, _targetSize) - DECL_ANIM_PROP(float, numControlPts, _numControlPts) - DECL_ANIM_PROP(float, controlPtRadius, _controlPtRadius) - DECL_ANIM_PROP(float, controlPtDelay, _controlPtDelay) - DECL_ANIM_PROP(float, tangentSpread, _tangentSpread) - DECL_ANIM_PROP(float, tangentLength, _tangentLength) - DECL_ANIM_PROP(glm::vec3, colorMid, _colorMid) - DECL_ANIM_PROP(glm::vec3, colorEnd, _colorEnd) - DECL_ANIM_PROP(glm::vec3, colorStart, _colorStart) - DECL_ANIM_PROP(float, detonate, _detonate) + REO_DECL_ANIMPROP(float, alphaEnd, _alphaEnd) + REO_DECL_ANIMPROP(float, alphaStart, _alphaStart) + REO_DECL_ANIMPROP(float, birthrate, _birthrate) + REO_DECL_ANIMPROP(float, bounceCo, _bounceCo) + REO_DECL_ANIMPROP(float, combineTime, _combineTime) + REO_DECL_ANIMPROP(float, drag, _drag) + REO_DECL_ANIMPROP(float, fps, _fps) + REO_DECL_ANIMPROP(float, frameEnd, _frameEnd) + REO_DECL_ANIMPROP(float, frameStart, _frameStart) + REO_DECL_ANIMPROP(float, grav, _grav) + REO_DECL_ANIMPROP(float, lifeExp, _lifeExp) + REO_DECL_ANIMPROP(float, mass, _mass) + REO_DECL_ANIMPROP(float, p2pBezier2, _p2pBezier2) + REO_DECL_ANIMPROP(float, p2pBezier3, _p2pBezier3) + REO_DECL_ANIMPROP(float, particleRot, _particleRot) + REO_DECL_ANIMPROP(float, randVel, _randVel) + REO_DECL_ANIMPROP(float, sizeStart, _sizeStart) + REO_DECL_ANIMPROP(float, sizeEnd, _sizeEnd) + REO_DECL_ANIMPROP(float, sizeStartY, _sizeStartY) + REO_DECL_ANIMPROP(float, sizeEndY, _sizeEndY) + REO_DECL_ANIMPROP(float, spread, _spread) + REO_DECL_ANIMPROP(float, threshold, _threshold) + REO_DECL_ANIMPROP(float, velocity, _velocity) + REO_DECL_ANIMPROP(float, xSize, _xSize) + REO_DECL_ANIMPROP(float, ySize, _ySize) + REO_DECL_ANIMPROP(float, blurLength, _blurLength) + REO_DECL_ANIMPROP(float, lightingDelay, _lightingDelay) + REO_DECL_ANIMPROP(float, lightingRadius, _lightingRadius) + REO_DECL_ANIMPROP(float, lightingScale, _lightingScale) + REO_DECL_ANIMPROP(float, lightingSubDiv, _lightingSubDiv) + REO_DECL_ANIMPROP(float, lightingZigZag, _lightingZigZag) + REO_DECL_ANIMPROP(float, alphaMid, _alphaMid) + REO_DECL_ANIMPROP(float, percentStart, _percentStart) + REO_DECL_ANIMPROP(float, percentMid, _percentMid) + REO_DECL_ANIMPROP(float, percentEnd, _percentEnd) + REO_DECL_ANIMPROP(float, sizeMid, _sizeMid) + REO_DECL_ANIMPROP(float, sizeMidY, _sizeMidY) + REO_DECL_ANIMPROP(float, randomBirthRate, _randomBirthRate) + REO_DECL_ANIMPROP(float, targetSize, _targetSize) + REO_DECL_ANIMPROP(float, numControlPts, _numControlPts) + REO_DECL_ANIMPROP(float, controlPtRadius, _controlPtRadius) + REO_DECL_ANIMPROP(float, controlPtDelay, _controlPtDelay) + REO_DECL_ANIMPROP(float, tangentSpread, _tangentSpread) + REO_DECL_ANIMPROP(float, tangentLength, _tangentLength) + REO_DECL_ANIMPROP(glm::vec3, colorMid, _colorMid) + REO_DECL_ANIMPROP(glm::vec3, colorEnd, _colorEnd) + REO_DECL_ANIMPROP(glm::vec3, colorStart, _colorStart) + REO_DECL_ANIMPROP(float, detonate, _detonate) // END Keyframes