From af5a62138afffdad43f507bf6c09aaa0a501ada0 Mon Sep 17 00:00:00 2001 From: iAmir Date: Sun, 20 Oct 2024 08:05:48 +0330 Subject: [PATCH] validity check for setHealth and setArmour --- Server/Components/NPCs/NPC/npc.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Server/Components/NPCs/NPC/npc.cpp b/Server/Components/NPCs/NPC/npc.cpp index e6c526bb5..08eb5fef5 100644 --- a/Server/Components/NPCs/NPC/npc.cpp +++ b/Server/Components/NPCs/NPC/npc.cpp @@ -254,7 +254,14 @@ void NPC::setVelocity(Vector3 velocity, bool update) void NPC::setHealth(float health) { - footSync_.HealthArmour.x = health; + if (health < 0.0f) + { + footSync_.HealthArmour.x = 0.0f; + } + else + { + footSync_.HealthArmour.x = health; + } } float NPC::getHealth() const @@ -264,7 +271,14 @@ float NPC::getHealth() const void NPC::setArmour(float armour) { - footSync_.HealthArmour.y = armour; + if (armour < 0.0f) + { + footSync_.HealthArmour.y = 0.0f; + } + else + { + footSync_.HealthArmour.y = armour; + } } float NPC::getArmour() const