1
0

current power and hp cannot be set negative via lua

This commit is contained in:
Emagi 2024-11-22 07:34:53 -05:00
parent 45da917e8a
commit 1f9010dc62

View File

@ -1413,6 +1413,9 @@ void Spawn::SetZone(ZoneServer* in_zone, int32 version){
/*** HIT POINT ***/ /*** HIT POINT ***/
void Spawn::SetHP(sint32 new_val, bool setUpdateFlags){ void Spawn::SetHP(sint32 new_val, bool setUpdateFlags){
if(new_val < 0)
new_val = 0;
if(new_val == 0){ if(new_val == 0){
ClearRunningLocations(); ClearRunningLocations();
CalculateRunningLocation(true); CalculateRunningLocation(true);
@ -1518,6 +1521,9 @@ sint32 Spawn::GetTotalPowerBaseInstance()
/*** POWER ***/ /*** POWER ***/
void Spawn::SetPower(sint32 power, bool setUpdateFlags){ void Spawn::SetPower(sint32 power, bool setUpdateFlags){
if(power < 0)
power = 0;
if(power > basic_info.max_power) if(power > basic_info.max_power)
SetInfo(&basic_info.max_power, power, setUpdateFlags); SetInfo(&basic_info.max_power, power, setUpdateFlags);
SetInfo(&basic_info.cur_power, power, setUpdateFlags); SetInfo(&basic_info.cur_power, power, setUpdateFlags);