antstubell Posted November 12, 2019 Share Posted November 12, 2019 Have a nice light beam (spell) firing across a room from Xmarker to Xmarker. Using this script.. Actor Property PlayerRef AutoObjectReference Property beamSource AutoObjectReference Property beamTarget AutoSpell Property beamSpell AutoEvent OnActivate(ObjectReference akActionRef)if akActionRef == PlayerRefbeamSpell.cast(beamSource, beamTarget);Debug.Notification ("Beam Fired")EndifEndevent Now I want it to stop when player gets to a certain area, so tried this script... Actor Property PlayerRef AutoSpell Property beamSpell Autoauto state waitingEVENT onTriggerEnter(ObjectReference akActionRef)if akActionRef == PlayerRefbeamSpell.InterruptCast()GoToState("Done")else; Do nothingendifENDEVENTENDSTATEEVENT onTriggerLeave(ObjectReference akActionRef)if akActionRef == PlayerRef; Do nothingendifENDEVENT Got this error...11,10): InterruptCast is not a function or does not existI'm thinking that the script should be run not on the player but kind of confused how to go about this. Help please. Link to comment Share on other sites More sharing options...
maxarturo Posted November 12, 2019 Share Posted November 12, 2019 (edited) ThebeamSpell.InterruptCast()Must be called by the same Script/Activator that called it. In order to make this work you need to do something like this : YOUR FIRST SCRIPT Actor Property PlayerRef Auto ObjectReference Property beamSource Auto ObjectReference Property beamTarget Auto Spell Property beamSpell Auto bool Property isTriggered = false auto hidden Auto State Waiting Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerRef If ( !isTriggered ) isTriggered = True beamSpell.cast(beamSource, beamTarget) ;Debug.Notification ("Beam Fired") GoToState("Firing") EndIf Endif Endevent EndState State Firing Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerRef If ( isTriggered ) isTriggered = False beamSource.InterruptCast() GoToState("AllDone") EndIf EndIf EndEvent EndState ; Insert this state if you don't want this activator to FIRE AGAIN State AllDone Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState .............................................................................................. YOUR SECOND SCRIPT ObjectReference PROPERTY ObjectToActivate auto Actor Property PlayerRef Auto auto state waiting EVENT onTriggerEnter(ObjectReference akActionRef) if akActionRef == PlayerRef ObjectToActivate.Activate(Self) ; Link REF to the ACTIVATOR ABOVE Utility.Wait(0.5) GoToState("Done") else ; Do nothing endif ENDEVENT ENDSTATE State Done Event OnCellDetach() Self.Disable() self.Delete() EndEvent EndState Or without STATES YOUR FIRST SCRIPT Actor Property PlayerRef Auto ObjectReference Property beamSource Auto ObjectReference Property beamTarget Auto Spell Property beamSpell Auto bool Property isTriggered = false auto hidden Auto State Waiting Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerRef If ( !isTriggered ) isTriggered = True beamSpell.cast(beamSource, beamTarget) ;Debug.Notification ("Beam Fired") ElseIf ( isTriggered ) isTriggered = False beamSource.InterruptCast() GoToState("AllDone") EndIf EndIf EndEvent EndState ; Insert this state if you don't want this activator to FIRE AGAIN State AllDone Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState Edited November 13, 2019 by maxarturo Link to comment Share on other sites More sharing options...
antstubell Posted November 12, 2019 Author Share Posted November 12, 2019 The first script gave me the error-(18,0): mismatched input 'State' expecting ENDSTATE So I added the state - Actor Property PlayerRef AutoObjectReference Property beamSource AutoObjectReference Property beamTarget AutoSpell Property beamSpell AutoAuto State WaitingEvent OnActivate(ObjectReference akActionRef)if akActionRef == PlayerRefbeamSpell.cast(beamSource, beamTarget);Debug.Notification ("Beam Fired")GoToState("Firing")EndifEndeventEndStateState FiringEvent OnActivate(ObjectReference akActionRef)beamSpell.InterruptCast()EndEventEndState And tried again. Got this age old error-(22,22): InterruptCast is not a function or does not exist Link to comment Share on other sites More sharing options...
maxarturo Posted November 12, 2019 Share Posted November 12, 2019 Sorry about that.. i'm a little sick and not thinking clearly... It's been rectify. Also added the "GoToState("Done")". Link to comment Share on other sites More sharing options...
antstubell Posted November 12, 2019 Author Share Posted November 12, 2019 The OnTriggerEnter event isn't stopping the cast.I'm in no rush and if you're under the weather then leave it for now. Link to comment Share on other sites More sharing options...
maxarturo Posted November 12, 2019 Share Posted November 12, 2019 Sorry again... Try it now. Link to comment Share on other sites More sharing options...
antstubell Posted November 13, 2019 Author Share Posted November 13, 2019 Nope. Beam still doesn't stop its cast. I don't know if these screenshots will help.Damn it can't upload anything. Posting them here...https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2151482&parId=B60C11D037429D8E%21191&o=OneUphttps://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2151483&parId=B60C11D037429D8E%21191&o=OneUp Maybe the video will help. The OntriggerEnter event should happen when player walks into the newly revealed area.https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2151481&parId=B60C11D037429D8E%21191&o=OneUp Link to comment Share on other sites More sharing options...
maxarturo Posted November 13, 2019 Share Posted November 13, 2019 (edited) I don't see any problem with the scripts. The problem lies in the "Pull Chain", the way the game engine handles its assets, activation > double script insertion > activation with animation > the way that default scripts operates > .... etc. I've discovered that double - triple - ... scripts insertion will cause the secondary - third - .... script to malfunction (in a an unacceptable way or time or frequency), the primary is the one that has been inserted by "Edit Base". Try this : - Place the "Casting Beam" script in an "xMarker Activator", insert the simple one, the second. - "Activate Parent" the xMarker Activator to the Pull Chain. - Link the "Trigger Box" activate(self) property to the "xMarker Activator". * This way you will detach completely the possible "Failure" cause by the Pull Chain's default SCRIPTS. EDIT : I forgot to add that both Scripts had a mistake that i corrected them around 06:41 AM, right after the pills started doing their jobs, sorry but yesterday i had fever. Edited November 13, 2019 by maxarturo Link to comment Share on other sites More sharing options...
maxarturo Posted November 13, 2019 Share Posted November 13, 2019 (edited) Stupid... STUPID mistake on my part on your first script.It's waiting to get activated by the Player while is being activated by the Trigger box.* Although the above post it's valid.01 Script : YOUR FIRST SCRIPT ObjectReference Property beamSource Auto ObjectReference Property beamTarget Auto Spell Property beamSpell Auto bool Property isTriggered = false auto hidden Auto State Waiting Event OnActivate(ObjectReference akActionRef) If ( !isTriggered ) isTriggered = True beamSpell.cast(beamSource, beamTarget) ;Debug.Notification ("Beam Fired") ElseIf ( isTriggered ) isTriggered = False beamSource.InterruptCast() GoToState("AllDone") EndIf EndEvent EndState ; Insert this state if you don't want this activator to FIRE AGAIN State AllDone Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState If you don't want another npc (like a follower) to be able to activate the function (your script) in the "PullChain" the you need "States", so that only the Player can run it, and the second activation (turning OFF the beam) will be trigger by the trigger box.02 Script : YOUR FIRST SCRIPT Actor Property PlayerRef Auto ObjectReference Property beamSource Auto ObjectReference Property beamTarget Auto Spell Property beamSpell Auto bool Property isTriggered = false auto hidden Auto State Waiting Event OnActivate(ObjectReference akActionRef) if akActionRef == PlayerRef If ( !isTriggered ) isTriggered = True beamSpell.cast(beamSource, beamTarget) ;Debug.Notification ("Beam Fired") GoToState("Firing") EndIf Endif Endevent EndState State Firing Event OnActivate(ObjectReference akActionRef) If ( isTriggered ) isTriggered = False beamSource.InterruptCast() GoToState("AllDone") EndIf EndEvent EndState ; Insert this state if you don't want this activator to FIRE AGAIN State AllDone Event OnActivate(ObjectReference akActionRef) ; EndEvent EndState If you will add it to an "xMarker Activator" then you will need to place the "01 Script". Edited November 14, 2019 by maxarturo Link to comment Share on other sites More sharing options...
antstubell Posted November 14, 2019 Author Share Posted November 14, 2019 Excellent. You cracked it. Link to comment Share on other sites More sharing options...
Recommended Posts