diff --git a/SDK b/SDK index 308487558..2ab854da8 160000 --- a/SDK +++ b/SDK @@ -1 +1 @@ -Subproject commit 3084875585c3724b35bdcf99b6f41c6690e42215 +Subproject commit 2ab854da82117ddae5c24089440699cae9e61f6b diff --git a/Server/Components/NPCs/NPC/npc.cpp b/Server/Components/NPCs/NPC/npc.cpp index 169bdc22a..e6c526bb5 100644 --- a/Server/Components/NPCs/NPC/npc.cpp +++ b/Server/Components/NPCs/NPC/npc.cpp @@ -252,6 +252,26 @@ void NPC::setVelocity(Vector3 velocity, bool update) needsVelocityUpdate_ = update; } +void NPC::setHealth(float health) +{ + footSync_.HealthArmour.x = health; +} + +float NPC::getHealth() const +{ + return footSync_.HealthArmour.x; +} + +void NPC::setArmour(float armour) +{ + footSync_.HealthArmour.y = armour; +} + +float NPC::getArmour() const +{ + return footSync_.HealthArmour.y; +} + void NPC::sendFootSync() { // Only send foot sync if player is spawned diff --git a/Server/Components/NPCs/NPC/npc.hpp b/Server/Components/NPCs/NPC/npc.hpp index bda6af35a..2afc7c656 100644 --- a/Server/Components/NPCs/NPC/npc.hpp +++ b/Server/Components/NPCs/NPC/npc.hpp @@ -51,6 +51,14 @@ class NPC : public INPC, public PoolIDProvider, public NoCopy void setVelocity(Vector3 position, bool update = false) override; + void setHealth(float health) override; + + float getHealth() const override; + + void setArmour(float armour) override; + + float getArmour() const override; + void sendFootSync(); void tick(Microseconds elapsed, TimePoint now); diff --git a/Server/Components/Pawn/Scripting/NPC/Natives.cpp b/Server/Components/Pawn/Scripting/NPC/Natives.cpp index 0a83985f3..91ca746a8 100644 --- a/Server/Components/Pawn/Scripting/NPC/Natives.cpp +++ b/Server/Components/Pawn/Scripting/NPC/Natives.cpp @@ -157,3 +157,32 @@ SCRIPT_API(NPC_GetInterior, int(INPC& npc)) { return npc.getInterior(); } + +SCRIPT_API(NPC_SetHealth, bool(INPC& npc, float health)) +{ + npc.setHealth(health); + return true; +} + +SCRIPT_API(NPC_GetHealth, float(INPC& npc)) +{ + return npc.getHealth(); +} + +SCRIPT_API(NPC_SetArmour, bool(INPC& npc, float armour)) +{ + npc.setArmour(armour); + return true; +} + +SCRIPT_API(NPC_GetArmour, float(INPC& npc)) +{ + return npc.getArmour(); +} + +SCRIPT_API(NPC_ApplyAnimation, bool(INPC& npc, const std::string& animlib, const std::string& animname, float delta, bool loop, bool lockX, bool lockY, bool freeze, uint32_t time, int sync)) +{ + const AnimationData animationData(delta, loop, lockX, lockY, freeze, time, animlib, animname); + npc.getPlayer()->applyAnimation(animationData, PlayerAnimationSyncType_SyncOthers); + return true; +}