Posted: 14th Mar 2008 06:20
Edited at: 14th Mar 2008 06:24
For testing I used the thug with pistol. Since he had "chase" in the shoot parameter, I used that. I copied the "chase" fpi and put it in a blank script document and added the lines that are in bold.
============================
;Artificial Intelligence Script
;Header
desc = Look and Shoot Far From Player (SHOOTCLOSE replaces CHASE until DarkAI added)
;Triggers
:state=0,plrcanbeseen:state=1,settarget
:state=0:runfpidefault=1
:state=1,scancodekeypressed=37:state=20
:state=1:rotatetoplr
:state=1,plrcanbeseen:settarget
:state=1,ifweapon=1,plrdistfurther=100,plrelevwithin=10:movetotarget=1,animate=5
:state=1,plrdistwithin=101:rotatetoplr
:state=1,ifweapon=1,plrdistwithin=400,plrcanbeseen=46,rateoffire:animate=1,rotatetoplr,freeze,useweapon,rundecal=6
:state=1,ifweapon=0:animate=1,freeze,state=2,setframe=6
:state=1,plrdistwithin=200,random=20:state=5
:state=1,plrdistwithin=50:state=10
:state=1,losetarget=100:state=5
:state=2,scancodekeypressed=37:state=20
:state=2:incframe=6
:state=2,frameatend=6:state=1,reloadweapon,sound=audiobankgunsreload.wav
:state=5,scancodekeypressed=37:state=20
:state=5,random=1:state=6,setframe=4
:state=5:state=7,setframe=3
:state=6,scancodekeypressed=37:state=20
:state=6:incframe=4,strafe=90,rotatetoplr
:state=6,frameatend=4:state=1,animate=1
:state=7,scancodekeypressed=37:state=20
:state=7:incframe=3,strafe=-90,rotatetoplr
:state=7,frameatend=3:state=1,animate=1
:state=10,scancodekeypressed=37:state=20
:state=10:state=11,setframe=5
:state=11,scancodekeypressed=37:state=20
:state=11:incframe=5,strafe=180,rotatetoplr
:state=11,frameatend=5:state=1,animate=1
:state=20,plrdistfurther=90:state=1
:state=20,plrdistwithin=90:setframe=11,state=30
:state=30:incframe=11
:state=30,frameatend=11:state=40
:state=40:destroy
;End of Script
====================================
Since we don't know exactly where the script is going to be at any given moment I thought it would be best to place the key press code at the beginning of each new state.
Since the player can press the "k" key anytime he wants we need to be sure that the character resumes the chase script. I used 90 units as the distance. Further from this, he will continue shooting. Within this distance he will die.
This is just a quick look and test haven't tried other situations as yet. However, maybe this is enough to get others started who are interested. If I finish with a full blown workable script other than this one will let you know.
BTW, if there is script in the shoot parameter you need to put the additional code in that script rather than the main script. Also, for some reason rundefaultfpi doesn't seem to work using this code although it did in the simple test. That's why I used destroy. Maybe it is because it is being run from the "shoot" script rather than the main. If you want the character to fade then you probably just need to add the script for that.