Hello, I am in a bit of a pickle, as I am currently struggling to set a custom health slider via options to a certain monster, but I have no idea of how to put it in it's ZScript.
Is there any way to do it ?
Thank you for the help !
Moderator: GZDoom Developers
mymonster_health
, then you could adjust the health in the BeginPlay
override of your monster class:class MyMonster : Actor
{
...
override void BeginPlay()
{
Super.BeginPlay();
Health = StartHealth = Max(1, mymonster_health);
}
}
Health
and StartHealth
since the latter is required to make sure the monster's health is correctly reset upon resurrection. The latter is also necessary to correctly calculate the level of health when the "extreme" (i.e. gibbing) death animation is played.Max(...)
call is there to prevent setting non-positive health values (generally a bad idea for monsters: try it out and see what I mean). If you also want to take into account the health factor for the current skill, multiply the value by G_SkillPropertyFloat(SKILLP_HealthFactor)
(cast result to int
to avoid float truncation warning):class MyMonster : Actor
{
...
override void BeginPlay()
{
Super.BeginPlay();
Health = StartHealth = int(Max(1, mymonster_health * G_SkillPropertyFloat(SKILLP_HealthFactor)));
}
}
Player701 wrote:CVARs can be referenced directly from ZScript code
CVar.GetCVar(mymonster_health,Player).GetInt(); //Player specific CVar
CVar.FindCVar(mymonster_health).GetInt(); //Global or server CVar
22alpha22 wrote:I know this isn't my thread but the way you are showing the op to use CVars in ZScript is confusing to me.Player701 wrote:CVARs can be referenced directly from ZScript code
I thought you had to use either GetCVar for a CVar attached to a player or FindCVar for a global or server CVar.
- Code: Select all • Expand view
CVar.GetCVar(mymonster_health,Player).GetInt(); //Player specific CVar
CVar.FindCVar(mymonster_health).GetInt(); //Global or server CVar
Has something changed, is the above no longer the correct way to use CVars in ZScript?
CVar.FindCVar(...).GetXXX()
depending on its type. Both ways are correct.Users browsing this forum: No registered users and 1 guest