tunaisafish Posted March 31, 2012 Share Posted March 31, 2012 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 More sharing options...
TheMrDomino Posted March 31, 2012 Author Share Posted March 31, 2012 (edited) 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 March 31, 2012 by TheMrDomino Link to comment Share on other sites More sharing options...
tunaisafish Posted March 31, 2012 Share Posted March 31, 2012 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 More sharing options...
TheMrDomino Posted March 31, 2012 Author Share Posted March 31, 2012 Ah, thank you! That is exactly what I need to do. Link to comment Share on other sites More sharing options...
Montiness Posted December 21, 2013 Share Posted December 21, 2013 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 More sharing options...
meh321 Posted December 21, 2013 Share Posted December 21, 2013 http://www.creationkit.com/OnHit_-_ObjectReference talks about both this reference being and actor and not an actor, also a good indication is that the event is on an object reference and not actor script. That suggests that the event would fire on any object that is an object reference like a barrel. Link to comment Share on other sites More sharing options...
Recommended Posts