ok here's the edit:
haven't tested it yet because i'm at school right meow
;Artificial Intelligence Script
desc = Friendly AI
; *** contents ***
; state 0 = before ally has been recruited by player
; state 1 = while recruited and following player
; state 2 = while holding position
; state 3 & 4 = while in combat
; state 21 - 25 = random animations
; *** idle but notice player if close ***
:state=0,plrdistwithin=200:state=1,rotatetoplr,animate=1
:state=0:state=3
; *** follow player if player leaves ***
:state=1,plrdistfurther=200:animate=5,followplr
; *** stop if close to player ***
:state=1,plrdistwithin=100:freeze,state=0
; *** stay when G is pressed ***
:state=1,scancodekeypressed=34:state=2,animate=1
; *** hold position ***
:state=2:animate=81,state=3
; *** engage enemy ***
:state=1:state=3
:state=3:settargetname=enemy,rotatetotarget
:state=3,ifweapon=1:useweapon,rundecal=6
:state=3,ifweapon=0:state=4,setframe=6
; *** reload if empty ***
:state=4:animate=81
:state=4:incframe=6
:state=4,frameatend=6:reloadweapon,sound=audiobank/guns/reload.wav
;End of script
not quite sure if ":state=1:state=3" will allow the ally to engage the enemy while following the player, but we'll see
perhaps the desired behavior should be that the ally stops following the player to engage the enemy, then resumes his puppy-dog behavior when the enemy entity is dead
are there conditions to test for line of sight between entities (such as that between an ally and an ememy)?
and is there a condition to test whether the entity is dead or not?
also for holding position, how can i first stop the ally from moving, then have him crouch by default, then stand/move to engage the enemy?
i think i tried "freeze,animate=81,state=3" but someone told me that i cannot freeze and animate at the same time
makes sense
but that still doesn't solve the problem
if all else fails, i'll put a "crouched" state, with a timer, so when i press G, he crouches for a set amount of time, then changes to the "attack" state
this is becoming more of a task than i had anticipated
"There's more to life than being really, really, ridiculously good looking." - Derek Zoolander