This is my first real attempt at writing a script. Any comments or critisism,(constructive only please),welcome. The enemy character walks forwards until it meets an obstacle at which point it will turn 90 degrees,(random left or right),and continue walking. It will keep doing this until,
1: It sees the player.
2: It is shot.
If it sees the player, or it is shot before it sees the player,it will close in and start shooting and also attempt to follow if the player runs away. If it's health falls to 30 or below it will beat a hasty retreat and will run away if the player gets too close but will fire a parting shot as it does so.
Like I said, this is my first attempt so be gentle with me
Darkfoil.
[;Artificial Intelligence Script
;Header
desc = Search area Shoot player if seen Return fire if shot Run away if too much damage taken
;Triggers
:state=0:state=1
:state=1,losetarget=5:state=10
:state=1,plrcanbeseen,plrdistwithin=400:state=20
:state=1,shotdamage=1:rotatetoplr,state=20
:state=1,random=20:rotateheadrandom=55
:state=1:animate=2,movefore=2.5
:state=10,random=1:state=11
:state=10:rotatey=90,animate=2,movefore=2.5,state=0
:state=11:rotatey=-90,animate=2,movefore=2.5,state=0
:state=20,plrcanbeseen:state=21
:state=21,plrcanbeseen:settarget
:state=21,plrcannotbeseen,losetarget=1:state=10
:state=21,healthless=31:state=40
:state=21,ifweapon=1,plrdistfurther=100:followplr=1,animate=5
:state=21,plrdistwithin=101:rotatetoplr
:state=21,ifweapon=1,plrdistwithin=301,plrcanbeseen=46:animate=1,rotatetoplr,freeze,useweapon,rundecal=6
:state=21,ifweapon=0:animate=1,freeze,state=22,setframe=6
:state=21,plrdistwithin=300,random=20:state=25
:state=21,plrdistwithin=100:state=30
:state=22:incframe=6
:state=22,frameatend=6:state=21,reloadweapon,sound=audiobank\guns\reload.wav
:state=25,random=1:state=26,setframe=4
:state=25:state=27,setframe=3
:state=26:incframe=4,strafe=90,rotatetoplr
:state=26,frameatend=4:state=21,animate=1
:state=27:incframe=3,strafe=-90,rotatetoplr
:state=27,frameatend=3:state=21,animate=1
:state=30:state=31,setframe=5
:state=31:incframe=5,strafe=180,rotatetoplr
:state=31,frameatend=5:state=21,animate=1
:state=40:state=42
:state=42,ifweapon=1,plrdistwithin=601,plrcanbeseen=46:animate=1,rotatetoplr,freeze,useweapon,rundecal=6
:state=42:rotatetotarget,rotatey=180,resethead,animate=5,state=43
:state=43:runfore=10
:state=43,random=5:rotateheadrandom=65
:state=43,losetarget=1:state=50
:state=43,plrcanbeseen:settarget,state=42
:state=50:timerstart,state=51,rotatey=180,animate=31
:state=51,timergreater=5000:state=10,animate=5
:state=51,random=5:rotateheadrandom=35
;End of Script]