Friendly AI

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Sputnik
Colour Sergeant
Posts: 85
Joined: Thu Jul 04, 2002 12:36 am
Location: V.A.

Friendly AI

Post by Sputnik »

Hey, you probably haven't heard from me for a while, but I've got more questions for you guys about friendly AI.

I understand the concept of the type of friendly AI (0 = lead/follow, 1 = lead, 5 = medic, etc) but I can't seem to get a medic or even a simple allied soldier to follow me around in a singleplayer level.

I have the following typed into the entity of my AI allied ranger:

$targetname friendly
#fnum 1

and in the script I have:

level.friendly1 thread global/friendly.scr::friendlythink
level.friendly1.friendtype = 0
level.friendly1.distance = 128
level.friendly1.destination = $player

I don't want to worry about the medic until I can properly use this kind of AI. Thanks guys, I'm sure its something simple I'm missing.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

Pathnodes

Post by tltrude »

The friendly guys won't follow you unless they have a place to stop near you. So you need to add a bunch of friendly pathnodes to your map.

Map m4L0 in the docs folder has friendies, so you might wana look that over and copy the nodes (gold ones I think). And, the nodes have properties that you can set to make the friendies do things or follow a path by targeting another node.

Enemy guys need nodes too (pink ones).
Last edited by tltrude on Tue Dec 17, 2002 1:25 am, edited 3 times in total.
Tom Trude,

Image
Guest

Post by Guest »

hmm... Ok, I'll try some stuff out, and tell you what works.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Friendly AI and German AI use the same path nodes. Their default color is pink, but it will switch to green when the node has a targetname. Also, you may define a custom color by using the '_color' key.

I think the reason why your friendlies don't work is because you don't seem to have the 'exec global/friendly.scr' in your script file. Put that line between level waittill prespawn and level waittill spawn.
Image
Guest

Post by Guest »

exec global/ai.scr
exec global/friendly.scr
exec global/loadout.scr maps/test_basestorm.scr

thread global/friendly.scr::friendlygen

main:

level waittill prespawn

// Initialization of spawning triggers (Enemies)

thread global/ai.scr::spawngroup #1

level.medic = level.friendly2


level waittill spawn

$player item weapons/colt45.tik
$player item weapons/thompsonsmg.tik
$player item weapons/springfield.tik

$player ammo smg 1000
$player ammo pistol 1000
$player ammo rifle 1000


// thread objectivesetup
thread friendly_setup

end

Thats my script, I have friendly.scr in it, and i know it should work, because enemy AI works, and its in the same spot..
Sputnik
Colour Sergeant
Posts: 85
Joined: Thu Jul 04, 2002 12:36 am
Location: V.A.

Post by Sputnik »

The above was mine.. I forgot to log in

the script above doesnt include this:

//---------------------------------------
// Friendly AI (Medic, Lieutenant) setup:
//---------------------------------------

friendly_setup:

level.friendly1 thread global/friendly.scr::friendlythink
level.friendly1.friendtype = 0
level.friendly1.distance = 128
level.friendly1.destination = $player

level.medic.friendtype = 5
level.medic thread global/friendly.scr::friendlythink
level.medic.distance = 200
level.medic.destination = $player

level.medic.mindist = 10
level.medic.maxdist = 30
level.medic.leash = 300
level.medic.sight = 2500
level.medic.waittime = 0.1
level.medic.distance = 20
level.medic.interval = 250
level.medic.noticescale = 1
level.medic tether $player

// -Checking threads:

level.friendly1 thread friendly1_death
level.medic thread medic_death


Also: Do my pathnodes have to have a certain targetname or anything, or can they just be there?
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

In the above script, remove

Code: Select all

exec global/loadout.scr maps/test_basestorm.scr

thread global/friendly.scr::friendlygen 
and place the 'exec global/friendly.scr' below 'level waittill prespawn'.

Also don't have code above the main thread.

info_pathnodes don't need no targetname.
Image
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

Then how do you get someone to lead the way, use pathnodes?
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Yeah, see the description in friendly.scr. However, it's way more complicated than have an AI follow you and I honestly don't know if it works very well on a map that's a bit more complicated than the first mission.
Image
Sputnik
Colour Sergeant
Posts: 85
Joined: Thu Jul 04, 2002 12:36 am
Location: V.A.

Post by Sputnik »

Thanks...
Image
Post Reply