I've written a small script that I've attached to a copy of the Bear Trap activator that I want to make disappear when activated in specific state and add a miscellaneous object to the player's inventory.
The script extends to the default "TrapBear" script and I want it to intercept the "OnActivate" function only when the parent script is in a specific state. However, I have been unable to find any information on whether child scripts can access the states of their parents, and I'm having problems getting it to recognize functions and variables that I know to be heritable.
The relevant parts of the TrapBear Script read...
scriptName TrapBear extends objectReference
...
state Open
Event OnBeginState()
...debug message
EndEvent
Event OnActivate(objectReference TriggerRef)
GoToState("Busy")
hitBase.goToState("CannotHit")
playAnimationAndWait("Trigger01", "Trans01")
goToState("Closed")
endEvent
endState
and the script I'm trying to extend to it reads...
scriptName aaaTrapBear extends TrapBear
miscObject Property aaaTrapBearMisc Auto; OBJECT I'M TRYING TO ADD ON ACTIVATION
Event OnActivate(objectReference TriggerRef)
Debug.Notification("Script Intercepted Activation"); THIS NEVER FIRES
endEvent
State Open
Event OnBeginState()
Debug.Notification("Inherited Open State");THIS FIRES WHEN OBJECT LOADS
endEvent
Event OnActivate(objectReference TriggerRef)
Debug.Notification("Intercepted Activation In Open State");THIS FIRES, BUT IN EVERY STATE
endEvent
endState
...but it experiences problems as outlined in the debug notifications, notably the child script seems to ignore functions outside the parent script's state, but doesn't actually respond to the state that is active at any given time.
I feel like I'm probably missing something, either how to declare states or functions or some call like "getParentScript()" that would be used to refer to the parent script. I've found online tutorials that deal with inheriting variables and global functions, but never specific functions or states like this. Does anyone have experience here? Thanks