Jump to content

[LE] Using Global Variables as conditions


Recommended Posts

I have a script attached to a magic effect that should update a gobal variable, but in practice it does not:

 

The script:

Scriptname TBPUnderwaterCheck extends activemagiceffect  Conditional
import PO3_SKSEFunctions
GlobalVariable property TBPUnderwaterCheckGlobal  auto 


Event OnEffectStart(Actor akTarget, Actor akCaster)
if IsActorUnderwater(akCaster) == 1
if TBPUnderwaterCheckGlobal.getValue() == 0 as Float
TBPUnderwaterCheckGlobal.setvalue(1 as float)
else
TBPUnderwaterCheckGlobal.setvalue(0 as float)
;Add 16 times the detail
endif
endif
EndEvent

The magic effect is a script with a constant effect and a self delivery.

 

The idea behind this is that it updates my global variable to 1 when the player is underwater, allowing me to use that as a condition in spell conditions.

Link to comment
Share on other sites

Slight tweak, see if it works:

Scriptname TBPUnderwaterCheck extends activemagiceffect  Conditional
import PO3_SKSEFunctions
GlobalVariable property TBPUnderwaterCheckGlobal  auto 

Event OnEffectStart(Actor akTarget, Actor akCaster)
  if IsActorUnderwater(akCaster)
    TBPUnderwaterCheckGlobal.setvalue(1.0)
  else
    TBPUnderwaterCheckGlobal.setvalue(0.0)
    ;Add 16 times the detail
  endif
EndEvent

I don't think it will though as it is a constant effect which means that the effect starts only once and thus the OnEffectStart event only runs once. You may need to check every so often with a re-registrating single update.

Link to comment
Share on other sites

I tried your version and edited to script to your suggestion but still nothing happens

the script right now:

Scriptname TBPUnderwaterCheck extends activemagiceffect
import PO3_SKSEFunctions
GlobalVariable property TBPUnderwaterCheckGlobal  auto 


Function OnEffectStart(Actor akTarget, Actor akCaster)
RegisterForUpdate(5.0) 
EndFunction


Event OnUpdate() 
Actor Player = Game.GetPlayer()
  if IsActorUnderwater(Player)
    TBPUnderwaterCheckGlobal.setvalue(1.0)  
Debug.Trace("Underwater")
 else
    TBPUnderwaterCheckGlobal.setvalue(0.0)
Debug.Trace("Not underwater")
    ;Add 16 times the detail
EndIf
EndEvent

It's as if the script itself just does not fire

Link to comment
Share on other sites

  On 6/10/2021 at 4:02 PM, maxarturo said:

 

Sorry IsharaMeradin for stepping in, but although that i haven't used this plugin function shouldn't this be something like:
If ( Self.IsActorUnderwater() == True )

 

That doesn't compile, I've tried switching it out with IsSwimming and no results with that either

Link to comment
Share on other sites

Did you actually manually create the global in the Creation Kit 1st? ... Is the global set to an INT then being called as a float?
If you're looking for a 1 or 0 set the global to an INT.


exp:
GlobalVariable Property v1 Auto <- set to my premade INT global made in the CK.
If(v1.GetValueInt()==(1))
v1.SetValueInt(0)
EndIf

There is also a problem with calling a global over and over. They don't always update as fast as you would wish.
For some odd reason this works better. Especially if you have a lot of globals.

Int v0 = 0
GlobalVariable Property v1 Auto

v0=(v1.GetValueInt())

If(v0==(1))
v1.SetValueInt(0)
EndIf

Also ...
if IsActorUnderwater(akCaster) == 1 ... False = 0, True = -1
I may be wrong here but normally true = -1

If ( Self.IsActorUnderwater() == True ) and extends activemagiceffect ... looks like you're asking if the effect is underwater.
Idk ... maybe change the reference to who it is vs self.
Edited by NexusComa2
Link to comment
Share on other sites

1) approach with cloak Spell and effect script like this:

TBPUnderwaterCheck

  Reveal hidden contents

 

 

2) approach with new created quest and player filled alias, which should use next script.

TBPUnderwaterCheckPlayerAliasScript

  Reveal hidden contents

 

Edited by ReDragon2013
Link to comment
Share on other sites

It works, thank you very much, this was a major roadblock in the development of what I am working on at the moment. You went above and beyond and included checks and features I did not think of. Kudos well earned.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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