Jump to content

Scripting: several questions for a constant-running script


TheMrDomino

Recommended Posts

The error is because of the 'int initialValue' declaration. You can't use functions to set the value. literal values are fine though (as you found out).

 

If the bug you talk about is because you end up with too many OnHit's running, then there's a far more efficient way to ensure only one runs at a time if you use states. Using a globalVariable is unneeded.

 

Scriptname myscript extends ObjectReference

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
       GotoState("busy")
       Debug.Notification("Onhit has triggered")
       ; more stuff here
       GotoState("")
EndEvent

State busy
Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)
       ; ignore OnHit's while still processing
EndEvent
EndState

Link to comment
Share on other sites

Well, the entire point of the script is to change that particular global, as it's what I have set up to control whether kill moves are enabled or not.

 

As for initializing with GetValue(), I thought I had, but I was mistaken. I had actually taken the index value from a message box.

 

That being said, is it possible to store a global value with GetValue() in a local variable? I need to hold its initial value in order to restore it at the end of the script.

 

edit: also, thanks for the code snippet. States look like they could be immensely helpful.

Edited by TheMrDomino
Link to comment
Share on other sites

Ah, okay gotcha :)

 

In the last script you posted just move the line...

 

int initialValue = killmoveEnabled.GetValue()

 

to the first line of the OnHit Event.

 

That will compile ok then, as you can use calculated assignments in variable declarations within functions and Events (just not at the script level as you'd tried).

It will also read the value at the start of each OnHit, which I think you are wanting to do anyway.

Link to comment
Share on other sites

  • 1 year later...

I know this is a very long time after this was initially posted and probably stupid, but I have a question for you about that script. Does that last script you posted trigger whenever you hit any target, ie a barrel, or another actor hits you or only when you hit another actor? From what I've read of the onHit event, what I took from what I read using it globally would trigger at times other than when the player hits another actor. I'm trying to get a better understanding for something I'd like to delve into myself.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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