Sepherose Posted May 24, 2016 Share Posted May 24, 2016 So after getting help from various people, a lot of google-fu, and just general frustration, I have this script attached to a quest that starts game enables, has one stage that can repeat, the quest is NOT marked to only run once, and I just can't get it to do it's thing, which is to set a soft HP cap and enforce it. Can anyone help me out? ScriptName SephSoftHPCapQuestScript Extends Quest ; ----------------------------------------------------------------------------- ; PROPERTIES ; ----------------------------------------------------------------------------- GlobalVariable Property SephLifeGiverRanks Auto Actor Property PlayerRef Auto ActorValue Property HealthAV Auto ActorValue Property EnduranceAV Auto Perk Property LifeGiver01 Auto Perk Property LifeGiver02 Auto Perk Property LifeGiver03 Auto Int Property BaseHealthCap Auto ; ----------------------------------------------------------------------------- ; EVENTS ; ----------------------------------------------------------------------------- Event OnMenuOpenCloseEvent(String asMenuName, Bool abClosing) If asMenuName == "LevelUpMenu" If abClosing Int iPlayerLevel = PlayerRef.GetLevel() If iPlayerLevel != 0 If PlayerRef.HasPerk(LifeGiver03) SephLifeGiverRanks.Value = 3 ElseIf PlayerRef.HasPerk(LifeGiver02) SephLifeGiverRanks.Value = 2 ElseIf PlayerRef.HasPerk(LifeGiver01) SephLifeGiverRanks.Value = 1 EndIf Float fEnduranceBonus = PlayerRef.GetValue(EnduranceAV) * 2.0 Float fLifeGiverBonus = SephLifeGiverRanks.Value * 10.0 Float fHealthBonus = (iPlayerLevel as Float) / 10.0 Float fCurrentPCHealth = PlayerRef.GetValue(HealthAV) Float fCurrentPCHealthCap = BaseHealthCap + fEnduranceBonus + fLifeGiverBonus + fHealthBonus If fCurrentPCHealth > fCurrentPCHealthCap PlayerRef.SetValue(HealthAV, fCurrentPCHealthCap) EndIf EndIf EndIf EndIf EndEvent Link to comment Share on other sites More sharing options...
Reneer Posted May 24, 2016 Share Posted May 24, 2016 (edited) Your only problem is that you need to use Self.RegisterForMenuOpenCloseEvent("LevelUpMenu") in a Event OnInit() block first before your quest will receive the OnMenuOpenCloseEvent.Your script should look something like this: ScriptName SephSoftHPCapQuestScript Extends Quest ; ----------------------------------------------------------------------------- ; PROPERTIES ; ----------------------------------------------------------------------------- GlobalVariable Property SephLifeGiverRanks Auto Actor Property PlayerRef Auto ActorValue Property HealthAV Auto ActorValue Property EnduranceAV Auto Perk Property LifeGiver01 Auto Perk Property LifeGiver02 Auto Perk Property LifeGiver03 Auto Int Property BaseHealthCap Auto ; ----------------------------------------------------------------------------- ; EVENTS ; ----------------------------------------------------------------------------- Event OnInit() Self.RegisterForMenuOpenCloseEvent("LevelUpMenu") endEvent Event OnMenuOpenCloseEvent(String asMenuName, Bool abClosing) If asMenuName == "LevelUpMenu" If abClosing Int iPlayerLevel = PlayerRef.GetLevel() If iPlayerLevel != 0 If PlayerRef.HasPerk(LifeGiver03) SephLifeGiverRanks.Value = 3 ElseIf PlayerRef.HasPerk(LifeGiver02) SephLifeGiverRanks.Value = 2 ElseIf PlayerRef.HasPerk(LifeGiver01) SephLifeGiverRanks.Value = 1 EndIf Float fEnduranceBonus = PlayerRef.GetValue(EnduranceAV) * 2.0 Float fLifeGiverBonus = SephLifeGiverRanks.Value * 10.0 Float fHealthBonus = (iPlayerLevel as Float) / 10.0 Float fCurrentPCHealth = PlayerRef.GetValue(HealthAV) Float fCurrentPCHealthCap = BaseHealthCap + fEnduranceBonus + fLifeGiverBonus + fHealthBonus If fCurrentPCHealth > fCurrentPCHealthCap PlayerRef.SetValue(HealthAV, fCurrentPCHealthCap) EndIf EndIf EndIf EndIf EndEvent Edited May 24, 2016 by Reneer Link to comment Share on other sites More sharing options...
Sepherose Posted May 25, 2016 Author Share Posted May 25, 2016 I was thinking about this earlier and wondering if I need an OnInit! Thank you! Link to comment Share on other sites More sharing options...
Reneer Posted May 25, 2016 Share Posted May 25, 2016 No problem, happy to help. Link to comment Share on other sites More sharing options...
Recommended Posts