Jump to content

Stopping an object from casting


antstubell

Recommended Posts

Have a nice light beam (spell) firing across a room from Xmarker to Xmarker. Using this script..

 

Actor Property PlayerRef Auto
ObjectReference Property beamSource Auto
ObjectReference Property beamTarget Auto
Spell Property beamSpell Auto

Event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerRef
beamSpell.cast(beamSource, beamTarget)
;Debug.Notification ("Beam Fired")

Endif
Endevent

 

Now I want it to stop when player gets to a certain area, so tried this script...

 

Actor Property PlayerRef Auto
Spell Property beamSpell Auto

auto state waiting

EVENT onTriggerEnter(ObjectReference akActionRef)
if akActionRef == PlayerRef

beamSpell.InterruptCast()

GoToState("Done")
else
; Do nothing

endif
ENDEVENT
ENDSTATE
EVENT onTriggerLeave(ObjectReference akActionRef)
if akActionRef == PlayerRef
; Do nothing
endif
ENDEVENT

 

Got this error...

11,10): InterruptCast is not a function or does not exist

I'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

The
beamSpell.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 by maxarturo
Link to comment
Share on other sites

The first script gave me the error-

(18,0): mismatched input 'State' expecting ENDSTATE

So I added the state -

 

Actor Property PlayerRef Auto
ObjectReference Property beamSource Auto
ObjectReference Property beamTarget Auto
Spell Property beamSpell Auto

Auto State Waiting
Event OnActivate(ObjectReference akActionRef)
if akActionRef == PlayerRef
beamSpell.cast(beamSource, beamTarget)
;Debug.Notification ("Beam Fired")
GoToState("Firing")
Endif
Endevent
EndState


State Firing
Event OnActivate(ObjectReference akActionRef)

beamSpell.InterruptCast()

EndEvent
EndState

 

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

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=OneUp

https://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

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 by maxarturo
Link to comment
Share on other sites

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 by maxarturo
Link to comment
Share on other sites

  • Recently Browsing   0 members

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