Im not a genius when it comes to this scripting lark, im still finding mu feet and usually rush to get a new script out thinking ive hit upon a great idea only to find out theres a thread already about it so im looking before i leap this time.
now i understand there are a lot of 'ally' scripts out there for x9 but i was wondering if it might be possible to code in a sort of squad based behaviour, well maybe thats the wrong description, more sort of Ghost Recon order giving system, where with single keystrokes you could direct certain entities to perform pre programmed actions, see this i knocked up as an example
;artificial intelligence script
desc = battling starship script 3
;triggers
:state=0:settargetname=target1,state=2
:state=1,scancodekeypressed=21:state=21,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=22:state=22,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=23:state=23,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=24:state=24,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=25:state=25,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=37:state=37
:state=2,scancodekeypressed=20:sound=audiobankmiscping.wav,state=1
:state=21:rotatetotarget,timerstart,state=31
:state=31,timergreater=500:movefore=200,reloadweapon,useweapon,timerstart,state=1
:state=22:rotatetotarget,timerstart,state=32
:state=32,timergreater=500:rotatey=180,state=42
:state=42,timergreater=1000:movefore=300,state=52
:state=52,timergreater=5000:rotatetotarget,timerstart,state=1
:state=23:rotatetotarget,timerstart,state=33
:state=33,timergreater=500:rotatey=180,state=43
:state=43,timergreater=1000:movefore=300,state=53
:state=53,timergreater=4000:rotatetotarget,state=63
:state=63:reloadweapon,useweapon,timerstart,state=1
:state=24:rotatetotarget,timerstart,state=34
:state=24,scancodekeypressed=20:state=1
:state=34,timergreater=1000:reloadweapon,useweapon,state=44
:state=34,scancodekeypressed=20:state=1
:state=44,timergreater=2000:pivotrandom=90,state=54
:state=44,scancodekeypressed=20:state=1
:state=54,timergreater=3000:movefore=200,state=24
:state=54,scancodekeypressed=20:state=1
:state=25:rotatetotarget,timerstart,state=35
:state=25,scancodekeypressed=20:state=1
:state=35,timergreater=1000:pivotrandom=90,state=45
:state=35,scancodekeypressed=20:state=1
:state=45,timergreater=2000:movefore=300,state=55
:state=45,scancodekeypressed=20:state=1
:state=55,timergreater=7000:state=25
:state=37:destroy
;end script
It gives you command over an entity with a preprogrammed target (altho theoretically if my mathes serves correctly, and there is the possibility for an infinite number of states then you could simply have multiple set target commands and number your targets correspondingly and give the player key strokes to adjust the targets state value manually effectively giving them control of the entities targeting system?see this example
eg
:state=0,scancodekeypressed=1:state=1
:state=0,scancodekeypressed=2:state=2 etc etc
:state=1:settargetname=target1,state=3
:state=2:settargetname=target2,state=3
;state=3:rotatetotarget,useweapon
for a basic idea?
The actions the above mentioned perform are very basic i didnt take any time to animate or plan out the movements so will occasionally get stuck at the edges if less than 8x8 squares when performing the autonomous actions (manouvre randomly and fire, and the manouvre randomly till orderd otherwise)
The Commands are:
-T (activate/deactivate)
While active
-Y (attack and move foreward) performs one per keystroke
-U (retreat) performs one per keystroke
-I (retreat and then fire once from safe distance) performs one per keystroke
-O (manouvre randomly round the map taking the odd pot shot) until deactivated
-P (randomly manouvre round the map)until deactivated
-k (self destruct)
Then using the activate option i used to put the entity in and out of standby you could control multiple enemies, say numbering them on the number pad, selecting a different number giving you control over a different 'squad' member
eg squad of four controlled by number keys 1 to 4
when 1 is pressed entity 1 is active and the generic keys are used to give orders, pressing 2 registers in entity 1's script to put it into standby (where the other 3 are at this point) so it will ignore the order keystrokes til active again, while at the same time in entity 2's script this registers as its cue to become active and begin responding to the generic command key strokes, and so on and so forth for the remainder of your squad
The point of this is being able to assign different entities to perform different actions, giving the impression of a somewhat cohesive and controllable AI team.
Come on, let me have it
Theory no More!
its 3;30am but i was so intrigued by this concept i had to go ahead and use the above command script, tweak it just the way i said it should be tweaked and bam! it worked first time!
place 4 character entities assign each one these scripts in order (the characters are selected using z,x,c,v but u must go through in that order at the moment, whn u get to v back to z again) give each character the script with the corresponding letter, eg squadz.fpi for the entity controlled by z, squadx.fpi for the entity controlled by x and so on (yes i know c is crouch but im to tired to worry now!
) once ready, load up the level and select your characters (remember z>x>c>v back to z and on through is the order, later i will make it any order but for now, courage)
now as you go through each letter you can give corresponding orders to each entity
still a few glitches to be worked out but what d'ya think for a first draft?
Squadz.fpi
;artificial intelligence script
desc = battling starship script 3
;triggers
:state=0:settargetname=target1,state=2
:state=1,scancodekeypressed=21:state=21,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=22:state=22,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=23:state=23,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=24:state=24,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=25:state=25,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=45:state=0
:state=1,scancodekeypressed=37:state=37
:state=2,scancodekeypressed=44:sound=audiobankmiscping.wav,state=1
:state=21:rotatetotarget,timerstart,state=31
:state=31,timergreater=500:movefore=200,reloadweapon,useweapon,timerstart,state=1
:state=22:rotatetotarget,timerstart,state=32
:state=32,timergreater=500:rotatey=180,state=42
:state=42,timergreater=1000:movefore=300,state=52
:state=52,timergreater=5000:rotatetotarget,timerstart,state=1
:state=23:rotatetotarget,timerstart,state=33
:state=33,timergreater=500:rotatey=180,state=43
:state=43,timergreater=1000:movefore=300,state=53
:state=53,timergreater=4000:rotatetotarget,state=63
:state=63:reloadweapon,useweapon,timerstart,state=1
:state=24:rotatetotarget,timerstart,state=34
:state=24,scancodekeypressed=20:state=1
:state=34,timergreater=1000:reloadweapon,useweapon,state=44
:state=34,scancodekeypressed=20:state=1
:state=44,timergreater=2000:pivotrandom=90,state=54
:state=44,scancodekeypressed=20:state=1
:state=54,timergreater=3000:movefore=200,state=24
:state=54,scancodekeypressed=20:state=1
:state=25:rotatetotarget,timerstart,state=35
:state=25,scancodekeypressed=20:state=1
:state=35,timergreater=1000:pivotrandom=90,state=45
:state=35,scancodekeypressed=20:state=1
:state=45,timergreater=2000:movefore=300,state=55
:state=45,scancodekeypressed=20:state=1
:state=55,timergreater=7000:state=25
:state=37:destroy
;end script
Squadx.fpi
;artificial intelligence script
desc = battling starship script 3
;triggers
:state=0:settargetname=target1,state=2
:state=1,scancodekeypressed=21:state=21,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=22:state=22,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=23:state=23,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=24:state=24,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=25:state=25,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=46:state=0
:state=1,scancodekeypressed=37:state=37
:state=2,scancodekeypressed=45:sound=audiobankmiscping.wav,state=1
:state=21:rotatetotarget,timerstart,state=31
:state=31,timergreater=500:movefore=200,reloadweapon,useweapon,timerstart,state=1
:state=22:rotatetotarget,timerstart,state=32
:state=32,timergreater=500:rotatey=180,state=42
:state=42,timergreater=1000:movefore=300,state=52
:state=52,timergreater=5000:rotatetotarget,timerstart,state=1
:state=23:rotatetotarget,timerstart,state=33
:state=33,timergreater=500:rotatey=180,state=43
:state=43,timergreater=1000:movefore=300,state=53
:state=53,timergreater=4000:rotatetotarget,state=63
:state=63:reloadweapon,useweapon,timerstart,state=1
:state=24:rotatetotarget,timerstart,state=34
:state=24,scancodekeypressed=20:state=1
:state=34,timergreater=1000:reloadweapon,useweapon,state=44
:state=34,scancodekeypressed=20:state=1
:state=44,timergreater=2000:pivotrandom=90,state=54
:state=44,scancodekeypressed=20:state=1
:state=54,timergreater=3000:movefore=200,state=24
:state=54,scancodekeypressed=20:state=1
:state=25:rotatetotarget,timerstart,state=35
:state=25,scancodekeypressed=20:state=1
:state=35,timergreater=1000:pivotrandom=90,state=45
:state=35,scancodekeypressed=20:state=1
:state=45,timergreater=2000:movefore=300,state=55
:state=45,scancodekeypressed=20:state=1
:state=55,timergreater=7000:state=25
:state=37:destroy
;end script
Squadc.fpi
;artificial intelligence script
desc = battling starship script 3
;triggers
:state=0:settargetname=target1,state=2
:state=1,scancodekeypressed=21:state=21,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=22:state=22,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=23:state=23,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=24:state=24,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=25:state=25,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=47:state=0
:state=1,scancodekeypressed=37:state=37
:state=2,scancodekeypressed=46:sound=audiobankmiscping.wav,state=1
:state=21:rotatetotarget,timerstart,state=31
:state=31,timergreater=500:movefore=200,reloadweapon,useweapon,timerstart,state=1
:state=22:rotatetotarget,timerstart,state=32
:state=32,timergreater=500:rotatey=180,state=42
:state=42,timergreater=1000:movefore=300,state=52
:state=52,timergreater=5000:rotatetotarget,timerstart,state=1
:state=23:rotatetotarget,timerstart,state=33
:state=33,timergreater=500:rotatey=180,state=43
:state=43,timergreater=1000:movefore=300,state=53
:state=53,timergreater=4000:rotatetotarget,state=63
:state=63:reloadweapon,useweapon,timerstart,state=1
:state=24:rotatetotarget,timerstart,state=34
:state=24,scancodekeypressed=20:state=1
:state=34,timergreater=1000:reloadweapon,useweapon,state=44
:state=34,scancodekeypressed=20:state=1
:state=44,timergreater=2000:pivotrandom=90,state=54
:state=44,scancodekeypressed=20:state=1
:state=54,timergreater=3000:movefore=200,state=24
:state=54,scancodekeypressed=20:state=1
:state=25:rotatetotarget,timerstart,state=35
:state=25,scancodekeypressed=20:state=1
:state=35,timergreater=1000:pivotrandom=90,state=45
:state=35,scancodekeypressed=20:state=1
:state=45,timergreater=2000:movefore=300,state=55
:state=45,scancodekeypressed=20:state=1
:state=55,timergreater=7000:state=25
:state=37:destroy
;end script
Squadv.fpi
;artificial intelligence script
desc = battling starship script 3
;triggers
:state=0:settargetname=target1,state=2
:state=1,scancodekeypressed=21:state=21,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=22:state=22,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=23:state=23,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=24:state=24,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=25:state=25,sound=audiobankmiscping.wav
:state=1,scancodekeypressed=44:state=0
:state=1,scancodekeypressed=37:state=37
:state=2,scancodekeypressed=47:sound=audiobankmiscping.wav,state=1
:state=21:rotatetotarget,timerstart,state=31
:state=31,timergreater=500:movefore=200,reloadweapon,useweapon,timerstart,state=1
:state=22:rotatetotarget,timerstart,state=32
:state=32,timergreater=500:rotatey=180,state=42
:state=42,timergreater=1000:movefore=300,state=52
:state=52,timergreater=5000:rotatetotarget,timerstart,state=1
:state=23:rotatetotarget,timerstart,state=33
:state=33,timergreater=500:rotatey=180,state=43
:state=43,timergreater=1000:movefore=300,state=53
:state=53,timergreater=4000:rotatetotarget,state=63
:state=63:reloadweapon,useweapon,timerstart,state=1
:state=24:rotatetotarget,timerstart,state=34
:state=24,scancodekeypressed=20:state=1
:state=34,timergreater=1000:reloadweapon,useweapon,state=44
:state=34,scancodekeypressed=20:state=1
:state=44,timergreater=2000:pivotrandom=90,state=54
:state=44,scancodekeypressed=20:state=1
:state=54,timergreater=3000:movefore=200,state=24
:state=54,scancodekeypressed=20:state=1
:state=25:rotatetotarget,timerstart,state=35
:state=25,scancodekeypressed=20:state=1
:state=35,timergreater=1000:pivotrandom=90,state=45
:state=35,scancodekeypressed=20:state=1
:state=45,timergreater=2000:movefore=300,state=55
:state=45,scancodekeypressed=20:state=1
:state=55,timergreater=7000:state=25
:state=37:destroy
;end script
once you have selecterd your unit, give it a command as described above and off you go, next unit give command, i only tested it with the forward backward commands as the script stil expects a target variable and altho that one should be easy enough to be able to let the player cycle through, i just am too tired to code
be gentle with it! its fragile lol, still working on the kinks, like you seem to need to wait for it to finish one command before moving to another command or unit
but go through it methodically and you should be surprised, i was! i cant believe it just worked first time lol, well all i did was change the scancodekey conditions to alternating letters instead of the same allowing different entities to use the same keystroke commands at different times, you could also play around for teams of two teams of two where in each pair follow the same keystrokes at the same time but randomise the action they take within the pairings?
on a side musing, i wonder if it would be possible using this command system to rip out chunks from the better ai scripts, ie strage, shoot close, pace etc, re number the states, edit in the scancode state selection eg order it to pace a waypoint, then manually order it over to attack, then send it a command to strafe, then when your finished order it back to waypoints etc?
GOD Im gonna have so many ideas now >.<
- Why is everyone on here so rude? -