Ok here is V1 of the Squad Control System we are working on to allow you to control up to four members of your 'Squad' and allow each of the four members to attack up to 9 different targets individually, specified by you, on command.
Using just the stock engine and the commands listed we have been able to engineer a set of scripts below, which when set as the AIMAIN of 4 characters will give you control over them in battle as a squad
Simply attack each fpi to a character (i name them according to the letter as its the letters which select each individual member)
The targeting works on entity names so you need to rename your entities to target1, target2, target3 etc etc and is controlled via the number keys on the right hand pad (not the numbers listed above the letters anf below the f keys)
start your test game after setting it up as shown and you can then alternate between squad members by pressing z,x,c or v to select between them accordingly
when selected the entity goes into 'Order mode' where it will wait to be given an order, but at this stage it doesnt have a target so hitting 'N' will enter 'target accqusition mode' allowing you to select the target this entity will focus on for the time being, once a target is selected it will then default to order mode to allow you to give it a command as follows
T-approach and attack current target once
Y-retreat some distance from current target and evade
U-take cover in present location and wait for orders
I-move around randomly while attacking selected target
o-follow player until otherwise ordered
p-suicide bomb selected target (dont forget to set explodable to yes in the entities properties and change destroy.fpi accordingly as it basically runs the destroy fpi after a predetermied amount of time)
N- target accquisition mode
group commands
M- recall all squad regardless of current activity back to player
B- instructs all squad members to perform retreat action
H- instructs all squad members to perform attack once action
any actions that require the entity to wait for another action before stopping what they are doing will continue to to it when you switch members, if you want it to stop simply selectit again defaulting it to 'order mode' however this timee it will retain its current target (hence the inclusion of 'N' to return to target accquisition mode)
The scripts are available in the zip attached along with a readme (squad command breakdown.fpi) which is also available to view here
A breakdown of the script (from suqad member c.fpi)
set up your characters (i find naming them helps so we will refer to them bny the lettters used to activate them z x c and v)
you will need:
-4squad members
-up to 9 individual targets (more if you edit the fpis)
give each squad member a squad script (eg give 'x' squadx.fpi, 'z' gets squad member z.fpi etc)
you should have 4 entities named z,x,c,v (or at least have the corresponding fpi's attached to each
now you need to name your entities, target1,target2,target3 etc all the way up to target 9
start the test level
now press z to activate squad member z, x to activate squad member x etc
when you have selected a squad member it goes to its internal order 'states' waiting for an order issued via t,y,u,i,o,p and with N selecting target accquisition mode
Before anything you need to give it a target, so press 'N' once and a ping will signify your in target accquisition mode, then using the number pad to the right on your keyboard hit 1-9 to select the relevant target.
Your selected squad member will then rotate to its target and a ping will once again confirm the target has been accquired
you can then give orders using the t,y,u,i,o,p as follows
t- attack once
y-retreat
u-takecover (select squad member again to cancel)
i-attack currently selected target until ordered otherwise (select squad member again to cancel)
o-follow player till ordered (select squad member again to cancel)
p-suicide bomb the currently selected target
n-return to target accqusition mode
group commands
M- recall all squad regardless of current activity back to player
B- instructs all squad members to perform retreat action
H- instructs all squad members to perform attack once action
you can switch between squad members at any time, when you switch between characters the one you switch from will continue performing whichever action you requested them perform (follow player and attack until commanded actions) so if you wish them to remain inactive you must give them an order to do so
The intelligence could be made a lot better if i knew how to make the entity 'see' if theres anything in front of it, which i think can be achieved using the 'raycast' command but im unsure of the syntax for it so if anyone wants to offer me any help with the actions that the entities are performing following the commands issued i would appreciate it, thats why i split it up into the modules outline below when coding, i know it doubles the code and a lot of it is uneccesary in theory, it helps to let me visualise the different components and make them interchangeable without affecting the rest of the code
;artificial intelligence script
desc = squad command script explanation
;triggers
this is where the entity takes its activation cue, sets it up waiting for a target and order
:scancodekeypressed=46:state=4,sound=audiobankmiscping.wav
while inactive it will crouch when player at distance, raising to a ready stance when closer
:state=0,plrdistfurther=200:animate=31
:state=0,plrdistwithin=200:animate=1
this is what enables you to select a target, relevant key press selecting targets
:state=1:animate=51
:state=1,scancodekeypressed=79:state=10,sound=audiobankmiscping.wav '1'
:state=1,scancodekeypressed=80:state=11,sound=audiobankmiscping.wav '2'
:state=1,scancodekeypressed=81:state=12,sound=audiobankmiscping.wav '3'
:state=1,scancodekeypressed=75:state=13,sound=audiobankmiscping.wav '4'
:state=1,scancodekeypressed=76:state=14,sound=audiobankmiscping.wav '5'
:state=1,scancodekeypressed=77:state=15,sound=audiobankmiscping.wav '6'
:state=1,scancodekeypressed=71:state=16,sound=audiobankmiscping.wav '7'
:state=1,scancodekeypressed=72:state=17,sound=audiobankmiscping.wav '8'
:state=1,scancodekeypressed=73:state=18,sound=audiobankmiscping.wav '9'
:state=1,scancodekeypressed=24:state=24
:state=1,scancodekeypressed=22:state=22
This is what gives the orders, the relevant key giving it the relevant order
:state=4:animate=51
:state=4,scancodekeypressed=20:state=20 't' attack in random pattern once
:state=4,scancodekeypressed=21:state=21 'y' retreat in random patter
:state=4,scancodekeypressed=22:state=22 'u' crouch till given further orders
:state=4,scancodekeypressed=23:state=23 'i' attack in random pattern till given other orders
:state=4,scancodekeypressed=24:state=24 'o' follow player till given other orders
:state=4,scancodekeypressed=25:state=25 'p' charge enemy and destroy self
:state=4,scancodekeypressed=49:state=1 'n' return to target accquisition mode
part 2 of the target selection process, these are the states that the relevant keypress put the entity into, it then sets the internal target accordingly and returns to waiting for an order (now with a target for the target specific order)
:state=10:settargetname=target1,rotatetotarget,state=4
:state=11:settargetname=target2,rotatetotarget,state=4
:state=12:settargetname=target3,rotatetotarget,state=4
:state=13:settargetname=target4,rotatetotarget,state=4
:state=14:settargetname=target5,rotatetotarget,state=4
:state=15:settargetname=target6,rotatetotarget,state=4
:state=16:settargetname=target7,rotatetotarget,state=4
:state=17:settargetname=target8,rotatetotarget,state=4
:state=18:settargetname=target9,rotatetotarget,state=4
Below are the individual code groups to actually perform the selected orders
order 1 -attack order -
This orders the enemey to get into position for firing (moves randomly around, in relation to the current target) and then approaches a little and fires
:state=20:timerstart,state=30
:STATE=30,TIMERGREATER=500,RANDOM=2:ROTATEY=-90,STATE=31
:state=30,timergreater=500,random=2:rotatey=90,state=31
:state=31,timergreater=1500:animate=55,movefore=30,state=32
:state=32,timergreater=2000,random=2:rotatey=-90,state=33
:state=32,timergreater=2000,random=2:rotatey=90,state=33
:state=33,timergreater=2500:animate=55,movefore=30,state=34
:state=34,timergreater=3500:rotatetotarget,movefore=50,state=35
:state=35,timergreater=4500:rotatetotarget,reloadweapon,useweapon,timerstart,state=4
order 2 - retreat order
This orders the entity to look at the target, rotate 180 degrees and move away from the target, before turning randomly left and right and moving forth again, before focusing on the target once mopre, this time hopefully from a safer position
:state=21:timerstart,state=40
:state=40:rotatetotarget,state=41
:state=41,timergreater=500:rotatey=180,state=42
:state=42,timergreater=1500:movefore=90,animate=55,state=43
:state=43,timergreater=2500:pivotrandom=90,state=44
:state=44,timergreater=3000:movefore=90,animate=55,state=45
:state=45,timergreater=4000:rotatetotarget,state=4
order 3 - crouch order
Very simple crouch animation, press the entity select button for this entity (z,x,c,v) to reactivate and call to attention
:state=22:animate=31
order 4 - attack enemy until otherwise instructed, will randomly move around the take taking shots at the target after pretermined amounts of time, tried to make it look like its trying to evade fire, again select this entity once more with (z,x,c,v) to return to attention waiting for orders
:state=23:timerstart,state=50
:state=50,timergreater=500:rotatetotarget,state=51
:state=51,timergreater=1000,random=2:rotatey=90,state=52
:state=51,timergreater=1000,random=2:rotatey=-90,state=52
:state=52,timergreater=1500:movefore=60,state=53
:state=53,timergreater=2000:rotatetotarget,state=54
:state=54,timergreater=2500:reloadweapon,useweapon,state=55
:state=55,timergreater=3000,random=2:rotatey=90,state=56
:state=55,timergreater=3000,random=2:rotatey=-90,state=56
:state=56,timergreater=3500:movefore=60,state=57
:state=57,timergreater=4500:pivotrandom=90,state=58
:state=58,timergreater=5000:movefore=60,state=23
order 5 - follow player
very simple follow player command
:state=24,plrdistfurther=40:rotatetoplr,movefore=10
order 6 - suicide bomb command
:state=25:rotatetotarget,timerstart,state=60
:state=60:movefore=1000
:STATE=60,TIMERGREATER=3000:RUNFPIDEFAULT=2
;end of script
It aims to detail how this was achieved and elaborate on the set up instructions outlined above
As you can see the actions are very basic at the moment but they are modulised to the specific states relating to the keys pressed to initiate them, this allows to entirely recode the modules at will to give you different actions but retain the command structure so hopefully someone better than me at actually animating the entities and controlling them intelligently can help me out with that.
Likewise the coders amongst you can re edit them to please without affecting the overall running of the script, pretty neat huh?]
Known issues:
right so the main issues identified through testing are as follows:
-anim wont play
-ai isnt the smartest
but as i said above im nogood at coding the actions for the entities (getting the animations to play, making them appear intelligent) so very basic actions in this version just to get it out and get a taster for public opinion, at the moment the entities rotate and move at random, or at random angles to their targets) what i want to achieve is to somehow how givem the the appearance of intelligence (stop them walking into walls and just trying to keep on going etc)
(if enough people want us to continue to work on this, remember the AI at the moment is very basic, its the command structure we want to demonstrate, if enough people can see a use for it we will pursue it , altho with these files you could as easily edit the intelligence yourselves! so think of it more of an intelligence development kit lol)
I used stock media all the way through design to completion so i know it works, any problems please let me know but no complaints about the AI!!! unless your offering to help me out cos im useless there!
UPDATED DOWNLOAD ATTACHED
Additional command instructions didnt appear on the post update they have been amanded above and are included here as follows
M- recall all squad regardless of current activity back to player
B- instructs all squad members to perform retreat action
H- instructs all squad members to perform attack once action
Additionally units will fall back to your position providing covering fire if damage to them is taken, next rewrite will include covering fire if the player takes damage as well, and further down the line the inclusion of a medic member to provide health to the player (but will still take orders as any other member with regards to attack and defense
- Why is everyone on here so rude? -