Jump to content


Photo

Local variables as markers


  • Please log in to reply
3 replies to this topic

#1 temnix

temnix
  • Member
  • 983 posts

Posted 13 April 2018 - 04:55 AM

Why not use local variables on creatures as markers instead of spell states? Except for the Apply Effects List opcode, which is the effects road of using a spell state as a marker, they are going to be used in script triggers, probably in some combination. But it's just as easy to write a local variable check:

 

IF

 

Detect([ANYONE])

TriggerOverride(LastSeenBy,Global("ANORAK","LOCALS",1))

 

THEN

 

RESPONSE #1

 

... (if you want to set the variable to 0, use ActionOverride in conclusion here, or if you want to avoid breaking the actions queue, e.g. in combat, ApplyRES a custom spell that nullifies the variable with opcode 309)

 

END

 

As for how to set the local variable in the first place, there is the same opcode 309, and here you can type any variable name without having to worry about unique combinations of states or states outside of the known range. Just make a custom spell. I tend to include a Delayed/Permanent reset of my locals, to keep them from accumulating. What time interval to write in before the variable goes back to 0 is a decision no different from deciding how long to give to the spell states. I also preface these effects with a clear-the-table reset to make sure the creature doesn't have any lingering locals from, say, its last life, when it died under a local before the delayed reset could take place:

 

309 -> Set to 0, Inst/Perm

309 -> Set to 1, Inst/Perm

309 -> Set to 0, Delayed/Perm

 

I think this method has all of the advantages of spell states and none of their drawbacks.



#2 -kjeron-

-kjeron-
  • Guest

Posted 13 April 2018 - 08:14 AM

Delayed effects are not reliable for "cleanup" of permanent effects, which variables always are.  They are removed by death, character export, and the Ctrl+R debug, as well as other ways not used in vanilla (opcode 17).  They are also not passed on to Images (Mislead/Project/Simulacrum), while variables are.

 

Variables can only be detected by scripts, but not by items, spells, or projectiles, that's a major drawback.



#3 temnix

temnix
  • Member
  • 983 posts

Posted 13 April 2018 - 10:30 AM

Variables can only be detected by scripts, but not by items, spells, or projectiles, that's a major drawback.

 

You are still talking about the same Apply Effects List, I think... :shifty:

 

Even with these limitations, for script purposes I found that a variable delayed to reset within a few seconds will almost always do the job. If it's something being put on an enemy, we don't have to worry about those locals not getting erased by death, and if it's being recorded on a character who then dies, the situation or script where that variable mattered will probably be over by the time the character is raised. The situation clears itself up, so to speak. It's not universal, but if you know what you're doing... And for the next use of this variable in that spell, ability or what have you, it will first be set to 0, as I described, in that trinity of effects.



#4 subtledoctor

subtledoctor
  • Modder
  • 656 posts

Posted 13 April 2018 - 02:34 PM

From my understanding, more or less the sole advantage of using spellstates or stats over local variables is that the former can be detected ny spell and item effects. (Man, an opcode to detect local variables is like my wet dream for modding these games. But alas, it's not to be.)

If I was doing something with scripts or dialogue, and not spell effects, I would (and do) 100% ignore spellstates and stats.