View Full Version : migrating ai
Greenglow2004
December 7th, 2009, 12:37 AM
hello,
i am working on a single player mod, and ive got my ai spawning from triggers, and even randomly exploreing,
however i cant seem to understand how to get ai to migrate to one location,
for example i want my grunts that are spawnd around the corner to walk around the corner to attack the player,
currently they just walk randomly along there fireing positions,
i assume i would use the (Ai_migrate ) command, i cant figure out how it works i have experimented a little, can anyone give me a little more insight?
i dont have a problem with my script i just dont understand the usage of that command, how do i specify a location for the ai to move to?
(ai_migrate "squad_name" "location"? )
thanks in advance!
bobsam
December 8th, 2009, 07:49 AM
Maybe (ai_sleep ) command I don't even have experience with that stuff but it is a guess.
Rob Oplawar
December 8th, 2009, 11:28 AM
You need multiple squads in an encounter. Iirc the way the migrate command works is it takes two squads, and migrates the first squad to the second squad. I think that means the the ai in the first squad just have all their firing positions and move positions and all that updated to those of the second squad.
I do it in Bridge CE, let me take a look at the scripts...
fake edit:
yeah, here's one of the lines I have in BCE:
(ai_migrate_and_speak b2_rooftop_room/g1_g b2_rooftop_room/g1_e "advance")
;(ai_migrate_and_speak [squad] [squad] [advance|retreat])
But I still haven't got my AI working exactly right, and it's possible that this is one of the things I hadn't got working yet. Let me know how this turns out for you.
Greenglow2004
December 8th, 2009, 08:56 PM
firstly, thanks for the replys,
ive tryed to do what Rob has suggested in the previous post. however i guess im setting it up wrong? help Rob?
ive had some progress from experimenting.
by createing a encounter and 2 squads , squad a and and squad b, then having squad A have fireing positions A and squad b have fireing positions B , first squad has starting locations aswell to spwan marines.
then i use a script that migrates the marines when i enter a trigger volume. from squad a to squad b,this works correctly ! hooray ! however i must have done somthing wrong because i cant not get them to move to a squad C !!?!?
so firstly they migrate , but when u enter the second trigger volume they dont migrate again to squad C , having confused my self i even started afresh twice,and got the same results, i dont understand what im doing wrong at all. i use the same method to move the squad to squad c and nothing happens, ive made sure everything is the same,
here is the script i use. though i dont think there are any mistakes.
(script dormant mission_migrate
(Ai_migrate test1/squad1 test1/squad2)
(cinematic_show_letterbox true )
(sleep_until (volume_test_objects trig2 (players)) 15)
(Ai_migrate test1/squad1 test1/squad3)
)
(script startup mission_test_level
(ai_allegiance player human )
(sleep_until (volume_test_objects trig1 (players)) 15)
(wake mission_migrate )
)
also i have had troubles getting my ai to follow the player,
ive followed this tutorial here... http://www.modacity.net/forums/showthread.php?t=11492
but my marines just move to there first fireing points then guard them. and do not follow me at all,
has anyone got this to work from following that tutorial ? because its a bit vauge in places.
however some good news, i have managed to get grunts to walk round a corner kind of, using command_lists.
when i enter a trigger volume it spawns 4 grunts and they follow there command lists which is basicaly walk to point a b c d. this looks good for cutscenes but not for regular gameplay as it seems the grunts cannot be interupted untill they reach there final destination.
walking into them or shooting them doesnt stop them from trying to get to there goal and they wont shoot back either.
i really hope i can figure out all of my problems, some one must have a better idea of how to get ai to move correctly, and ill definatly be writeing a tutorial once i figure it out, as i could not find one anywhere and i know it would be usefull for beginers making single player maps.
long post i know, and its really late here now so i might have rambled slightly, hopefully someone can help me out:iamafag:
Rob Oplawar
December 8th, 2009, 10:55 PM
I see your problem right away with the migrate command:
(Ai_migrate test1/squad1 test1/squad2)
(cinematic_show_letterbox true )
(sleep_until (volume_test_objects trig2 (players)) 15)
(Ai_migrate test1/squad1 test1/squad3)
When you migrate them, they are no longer in squad1, they're in squad2. The second ai_migrate should be:
(Ai_migrate test1/squad2 test1/squad3)
As for the AI following the player, that tut does cover everything that you need to make it work, although it's sort of run-on.
For future reference, here it is in bullet step-by-step form:
Create encounter
Place a group of 'A' firing positions where you want the actors to start.
Place groups of 'B', 'C', 'D', etc firing positions around where you want the ai to be able to follow the player. e.g:
http://spacebrick.net/pictures/gallery/firing_positions.jpg
There is no need for the groups to be sequential (group A need not be next to group B, etc). Whichever firing position group the player is closest to is the one the AI will choose.
Create one squad for every firing position group you use. It's easiest to name them 'squad a', 'squad b', etc, because:
set the firing position group for all the attack/defend states to the corresponding letter for each squad, and nothing else.
Set the "initial state" and "return state" to "guarding at guard position" for all squads
Make sure the automatic migration box is checked for all squads
Set the maneuver to squad to squad a for all squads, including squad a
Set up the AI in squad a the way you normally would, setting initial positions and counts and all that
Now you're done in Sapien; in your scripts after placing the encounter issue the following command:
(ai_follow_target_players [encounter name])
e: The command list thing is fuzzier. I haven't used them for anything but cinematics so far, but iirc there's a flag somewhere that tells the AI executing the command list that it is interruptible. The flag is in Sapien somewhere; you set it when setting up the command list. I think it may actually be a command, come to think of it; something like "set interruptible true". In any case, look around Sapien and you should be able to find what you're looking for.
Greenglow2004
December 14th, 2009, 04:11 PM
sorry i have been away for a few days, thanks for the excellent reply, makes alot of sense to me, ill give it a try and see if i can get things working correctly now,
thanks
Dwood
December 14th, 2009, 06:48 PM
I wrote an intense script today while procrastinating studying for my finals.
Forgot to add that has_been_a# is 1-4.
(script continuous area_One_test
(if (and
(volume_test_objects area_1 (players)) (= has_been_a1 0)
)
)
(begin
(if (= has_been_a2 1)
(begin
(set has_been_a2 0)
(ai_migrate Alliez/Allies_2 Alliez/Alliez_3)
)
(begin );;else
)
(set has_been_a2 1) ;;then
(ai_command_list Alliez Ai_go_1)
)() ;;else
)
)
(script continuous area_Two_test
(if (and
(and (volume_test_objects area_2 (players)) (= has_been_a2 0)
(or(= has_been_a1 1) (= has_been_a3 1))
)
)
(begin
(if (= has_been_a3 1)
(begin
(set has_been_a3 0)
(ai_migrate Alliez/Allies_3 Alliez/Alliez_2)
)
(begin
(set has_been_a1 0)
(ai_migrate Alliez/Allies_1 Alliez/Alliez_2)
);;else
)
(set has_been_a2 1) ;;then
(ai_command_list Alliez Ai_go_2)
) () ;;else
)
)
(script continuous area_Three_test
(if (and
(and (volume_test_objects area_3 (players)) (= has_been_a3 0)
(or(= has_been_a2 1) (= has_been_a4 1))
)
)
(begin
(if (= has_been_a4 1)
(begin
(set has_been_a4 0)
;;(ai_migrate Alliez/Allies_4 Alliez/Alliez_3)
)
(begin
(set has_been_a2 0)
(ai_migrate Alliez/Allies_2 Alliez/Alliez_3)
);;else
)
(set has_been_a3 1) ;;then
(ai_command_list Alliez Ai_go_3)
) () ;;else
)
)
Try that if what Rob suggested doesn't work, even though we're using the same concept.
Dwood
December 14th, 2009, 07:44 PM
Doublepost: Nvm do not use that script, it gives Halo seizure. I'll edit with better script tomorrow perhaps.
Rob Oplawar
December 15th, 2009, 12:37 PM
(script continuous area_One_test
(if
(and
(volume_test_objects area_1 (players))
(= has_been_a1 0)
)
)
(begin
(if
(= has_been_a2 1)
(begin
(set has_been_a2 0)
(ai_migrate Alliez/Allies_2 Alliez/Alliez_3)
)
(begin );;else
)
(set has_been_a2 1);;then
(ai_command_list Alliez Ai_go_1)
)
();;else
)
)
(script continuous area_Two_test
(if
(and
(and
(volume_test_objects area_2 (players))
(= has_been_a2 0)
(or (= has_been_a1 1) (= has_been_a3 1))
)
)
(begin
(if (= has_been_a3 1)
(begin
(set has_been_a3 0)
(ai_migrate Alliez/Allies_3 Alliez/Alliez_2)
)
(begin
(set has_been_a1 0)
(ai_migrate Alliez/Allies_1 Alliez/Alliez_2)
);;else
)
(set has_been_a2 1);;then
(ai_command_list Alliez Ai_go_2)
)
();;else
)
)
(script continuous area_Three_test
(if
(and
(and
(volume_test_objects area_3 (players))
(= has_been_a3 0)
(or(= has_been_a2 1) (= has_been_a4 1))
)
)
(begin
(if (= has_been_a4 1)
(begin
(set has_been_a4 0)
;;(ai_migrate Alliez/Allies_4 Alliez/Alliez_3)
)
(begin
(set has_been_a2 0)
(ai_migrate Alliez/Allies_2 Alliez/Alliez_3)
);;else
)
(set has_been_a3 1);;then
(ai_command_list Alliez Ai_go_3)
)
();;else
)
)
FTFY. Seriously, indentation really helps you to understand the structure of the code you are writing. You have a couple of syntax/argument errors in there (highlighted in red); indenting it helps you put things in the right place.
Dwood
December 15th, 2009, 02:43 PM
I fixed that last night before I went to bed lol. The problem now is that the ai aren't moving to the command list points. :(
E: Nvm it seems that apparently I didn't have my command lists set up lol
Ex2 Nope it still won't work.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.