Skip to content

Commit 0ee0f1a

Browse files
committed
validity check for setHealth and setArmour
1 parent 3e101db commit 0ee0f1a

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Server/Components/NPCs/NPC/npc.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,14 @@ void NPC::setVelocity(Vector3 velocity, bool update)
254254

255255
void NPC::setHealth(float health)
256256
{
257-
footSync_.HealthArmour.x = health;
257+
if (health < 0.0f)
258+
{
259+
footSync_.HealthArmour.x = 0.0f;
260+
}
261+
else
262+
{
263+
footSync_.HealthArmour.x = health;
264+
}
258265
}
259266

260267
float NPC::getHealth() const
@@ -264,7 +271,14 @@ float NPC::getHealth() const
264271

265272
void NPC::setArmour(float armour)
266273
{
267-
footSync_.HealthArmour.y = armour;
274+
if (armour < 0.0f)
275+
{
276+
footSync_.HealthArmour.y = 0.0f;
277+
}
278+
else
279+
{
280+
footSync_.HealthArmour.y = armour;
281+
}
268282
}
269283

270284
float NPC::getArmour() const

0 commit comments

Comments
 (0)