Hi, im new to the forum. I am attempting to write a script for an enemy to run over to a switch and activate it. I am able to activate the switch( with a change to the switches script, testing if its activated and setting ifused if it is)
I can also run toward the switch, however i cannot test for when the entity reaches the switch. I also would like the entity to activate the switch after they reach it.
Heres the code:
;Artificial Intelligence Script
;Header
desc = face forward
;Triggers
:waypointstate=0:animate=2,waypointstart
:waypointstate=3:animate=2,waypointnext
:waypointstate=4:animate=2,waypointrandom
:waypointstate=5:animate=2,waypointreverse
:nearactivatable=0:settarget,activatetarget=2,animate=1,state=0
:state=0:state=1
:state=1,plrcannotbeseen,shotdamage=5:setframe=14,state=5
:state=1,plrcanbeseen:state=6
:state=1,noiseheard=5:rotateheadrandom=85
:state=2:waypointstop,rotatetoplr,state=3,shootplr
:state=3:animate=1,waypointstart,state=0
:state=4,plrcanbeseen=46:settarget,state=2
:state=4,random=20:animate=2,waypointstart,state=1
:state=5:incframe=14
:state=5,frameatend=14:runfpi=destroy/leavecorpse.fpi
:state=6:settargetname=switch_guardRunTo,rotatetotarget,state=8
:state=8:state=9,movetotarget
:state=9,reachtarget:activatetarget=1
;End of Script
some things to note, i think reachtarget may not work here as i would wish, as i have the switch on a wall so the entity never really reaches the switch.
I have also tried this with raycast=20 50 instead of reachtarget and it still does not work.
I have tried movefore instead of movetotarget and try a raycast everytime before movefore again but doesn't work.
Also i realise that the script cannot access states 2,3 and 4, im just trying to get the switch part to work.
any help would be greatly appreciated.