Jump to content

Need to make this script monitor the player via quest, help?


Recommended Posts

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

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 by Reneer
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...