Tutorial Request

If you're looking for mapping help or you reckon you're a mapping guru, post your questions / solutions here

Moderator: Moderators

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

Tutorial Request

Post by Sputnik »

Hey everyone, I'm still having problems with friendly AI (getting medics and teammates to follow you, etc), so I would appreciate if someone would send me a tutorial or a demo map & script. Jv_map and mohaa_rox seem to have a good grasp on this, but I can't seem to get it. Thanks!
Image
UBER_SOLDAT
Warrant Officer
Posts: 127
Joined: Wed Aug 07, 2002 7:44 pm
Location: ENGLAND
Contact:

Post by UBER_SOLDAT »

ive got normal allies working, but the medics just stay in one place, crouching. i got this ages ago, i never wrote it but it might help:


AI Friendly target names set up as follows -

level.friendly1 -
KEY/VALUE
$targetname - friendly
#fnum - 1

level.friendly2 -
KEY/VALUE
$targetname - friendly
#fnum - 2

level.friendly3 -
KEY/VALUE
$targetname - friendly
#fnum - 3

level.friendly4 (level.medic) -
KEY/VALUE
$targetname - friendly
#fnum - 4


and heres the scrpt:


// AI FRIENDLY TEST 1 - BEHAVIOUR 1 + MEDIC
// by Mirek - also know as Chris Freeman
// A test of the cardgame included - global/cardgame.src - to be found in the house at the start of level.
// Mirek
// email - mirek@eventideimaging.com
// The website is comming soon... send an email if you wish to know when that happens.




main:
exec global/ai.scr
exec global/loadout.scr maps/test_F1.scr // I found u must have this otherwise u get no us granades
exec global/cardgame.scr // initialize the card game


// ----------------------------

level waittill prespawn

// ----------------------------

fadeout .1 0 0 0 1

// INITIALISE FRIENDLY SCRIPT
exec global/friendly.scr


//--- SET MUSIC FOR LEVEL

exec global/ambient.scr test_astbridge
// ear candy.

// --------------------------------



//--- SET FRIENDLY SCRIPT

thread global/friendly.scr::friendlygen

// I belive this part takes the 'Friendly ' 'Targetname' and 'Fn#' and turns it into level.friendly#


// -------------------------------


//-- SET FRIENDLY 10 TO BE KNOW AS LEVEL.MEDIC TO PLAY AROUND WITH LEVEL NAME ASSIGNMENT

level.medic = level.friendly4

// From now on ' level.friendly4 ' will be know throughout the script as ' level.medic '.
// From memory - I think all original game scripts give their level.friendly# a name to use in the script.
// I've only changed the level.friendly4 for this example
// This certainly makes sence especially for enteties used often thourghout the script
// as one can change the target name of an entety in the map and update the enitre script with a single line
// otherwise a scriptwise edit would be needed and on a large script.... oooyyyyyyy yo yo yoy


//--- SETUP THE FARPLANE - FOG/MIST

level.farplane = 6200
$world farplane 6200
$world farplane_color (.62 .62 .61)
// Eye candy


// ----------------------------
level waittill spawn
// ----------------------------


//-- PLAYER WEAPON SETUP - NO ROCKET OR SHOTGUN PLEASE :)

//give weapon
$player item weapons/colt45.tik
$player item weapons/thompsonsmg.tik
$player item weapons/m1_garand.tik

//give ammo
$player ammo smg 200
$player ammo agrenade 5 // American type granade
$player ammo pistol 200
$player ammo rifle 200

//Player starts with the following weapon in hand
$player useweaponclass smg

level.script = "maps/test_F1.scr"



thread fader
thread ai_setup


end

// --- FADE IN

fader:
wait 0.5
fadein 2.5 0 0 0 1

end

//--- SETUP AND RUN THE FRIENDLIES

ai_setup: // setup the AI friendly behviour - AI Friendly following the player



//discription of use -

// FRIENDTYPE
//sets friendly behaviour type --- In this case 1 to follow player
//usage - level.friendly#.type=# / set type to -1 to stop following player

// FRIENDLY THINK
// Activates the friendly AI behaviour and begins the process of tracking nodes for that purpose.
//usage - level.friendly# thread global/friendly.scr::friendlythink

// DESTINATION
// sets the AI's target - this is what the AI will follow
// In this case it's $player but can be set so an AI will follow another AI as prefrence or perhaps a vehicle but I have not tried that
// I belive this set to $player will make the target as a first prefrence and if it's taken attach itself to a friendly.
//
// usage - level.friendly#.destination = $player

// DISTANCE ??
// still working on on this one. Changing it doesn't seem to do much for me

// There are some other commands that I will include later such as avoidplayer


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

level.friendly2.friendtype = 1
level.friendly2 thread global/friendly.scr::friendlythink
level.friendly2.destination = $player
level.friendly2.distance = 175

level.friendly3.friendtype = 1
level.friendly3 thread global/friendly.scr::friendlythink
level.friendly3.destination = $player
level.friendly3.distance = 225



level.medic.friendtype = 5 // set medic behviour ---- 5 = medic
level.medic thread global/friendly.scr::friendlythink
level.medic.destination = $player
level.medic.distance = 250


// set threads to check for deaths

level.friendly1 thread friendly1_death
level.friendly2 thread friendly2_death
level.friendly3 thread friendly3_death
level.medic thread medic_death



// -------------- AI BEHAVIOUR - NORMAL - ( APPLYS TO ALL AI NOT JUST ALLIES)

// --- The following section is to play around with standard AI behviour and alter the initial MohRadiant settings.
// I haven't quiet finished this section yet
// more info on these can also be found in the DOCS/AI tips.doc file that come with MoHHA Tools

// A note about midist & maxdist usage :
// By the use of both of these settings together you can control how the ai will react to it's enemy.
// whether he runs away or towards it,
// In this example script I have set both MINDIST & MAXDIST lower - this forces the Ai to run close to it's attack target.

// MINDIST
// How close the enemy/target gets to the AI before he starts retreating.
// set this higher if you wish for the AI to always stay far away from the enemy it's targetting
// MAXDIST
// Once the AI's enemy/target is outside this distance he will move towards it.
// -------



level.friendly1.accuracy = 80
level.friendly1.mindist = 128
level.friendly1.maxdist = 512
level.friendly1.leash = 1200
level.friendly1 tether $player
level.friendly1.sight = 4000
level.friendly1.noticescale = 1
level.friendly1.waittime = 0.1
level.friendly1.distance = 256
level.friendly1.interval = 256

level.friendly2.accuracy = 80
level.friendly2.mindist = 128
level.friendly2.maxdist = 512
level.friendly2.leash = 1200
level.friendly2 tether $player
level.friendly2.sight = 4000
level.friendly2.noticescale = 1
level.friendly2.waittime = 0.1
level.friendly2.distance = 256
level.friendly2.interval = 256

level.friendly3.accuracy = 80
level.friendly3.mindist = 128
level.friendly3.maxdist = 512
level.friendly3.leash = 1200
level.friendly3 tether $player
level.friendly3.sight = 4000
level.friendly3.noticescale = 1
level.friendly3.waittime = 0.1
level.friendly3.distance = 256
level.friendly3.interval = 256


level.medic.mindist = 384
level.medic.maxdist = 640
level.medic.leash = 800
level.medic tether $player
level.medic.sight = 4000
level.medic.noticescale = 1
level.medic.waittime = 0.1
level.medic.distance = 256
level.medic.interval = 256





end



/// --- THREADS TO MONITOR FOR DEATH AND PRINT THE EVENT



//============================================================//

friendly1_death:

self waittill death // Waits until the thread target - in this case level.friendly1 - dies before moving on
iprintlnbold "Friendly1 has been killed in action."

end

//============================================================//

friendly2_death:

self waittill death
iprintlnbold " Friendly2 has been killed in action."

end

//============================================================//

friendly3_death:

self waittill death
iprintlnbold "Friendly3 has been killed in action."

end

//============================================================//

medic_death:

self waittill death
iprintlnbold "Medic has been killed in action."

end

//============================================================//
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Example

Post by jv_map »

Image
Guest

Post by Guest »

WOW 8) That is exactly what I needed, thank you!

Some questions:

- For the allied soldiers talking, can this be set off by a trigger? if so how?
- how do you know what spawnflags to assign to a pathnode (Duck, etc).
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

Pathnodes are basically what AI use to move around when threatened. Just check "duck" or other spawnflags.
Live to map, not map to live.
-mohaa_rox, .map
moderator
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

See the document in the 'docs' folder within the Radiant directory.

There's quite some explanation about pathnodes in 'AI tips.doc'.
Image
UBER_SOLDAT
Warrant Officer
Posts: 127
Joined: Wed Aug 07, 2002 7:44 pm
Location: ENGLAND
Contact:

Post by UBER_SOLDAT »

i made an SP map once where you found some airbornes, and then one turned to you and said 'your on point'. all i had was a trigger where i wanted to make the AI speak, then had setthread/friendly_talk.
then i put this in the script:

friendly_talk:

level.parker lookat $player
level.parker say dfr_follow_04j_21 //"You're on point."

waittill saydone //wait till he's stopped talking

level.parker lookat NULL

end

you can replace level.parker with level.friendly1 or whichever friendly AI you want to speak.
Sputnik
Colour Sergeant
Posts: 85
Joined: Thu Jul 04, 2002 12:36 am
Location: V.A.

Post by Sputnik »

Thanks, I'll try it!
Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post by Gen Cobra »

Amazing explanation. Great work Uber.
Image
BiG_HeaD
Brigadier General
Posts: 531
Joined: Thu Jul 03, 2003 7:28 pm

Post by BiG_HeaD »

Let me know if you release anything. BtW-HoW do medics work/What are they?
Ive played more than u.
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post by Gen Cobra »

Well I messed around with this a lot and never got it to work. None of my #fnum had "Barney" like behaviors i.e. followed me. I even tried to stop the player avoiding. The ai will back you up but they didnt follow nodes or followed you or anhything. I dunno.
Image
vonderbakluft
Corporal
Posts: 46
Joined: Fri Aug 01, 2003 11:15 am
Location: NL
Contact:

Post by vonderbakluft »

Medics are usual friendly with the $targetname/friendly and an #fnum.

For medic behaviour you need to set them as friendtype 5.

Exampl. If your friendly with fnum 2 needs to be a medic.
Give before

level.friendly2 exec global/friendly.scr::friendlythink

the line

level.friendly2.friendtype = 5

However medics set this way will heal the player (or other friendly ) limited amount of times.

Since you cannot control the moment the medic heals a player, i prefer to make custom heal scripts. Works better

Von
Real mappers map in wordpad ;-)
BiG_HeaD
Brigadier General
Posts: 531
Joined: Thu Jul 03, 2003 7:28 pm

Post by BiG_HeaD »

is there a beta to this?
Ive played more than u.
vonderbakluft
Corporal
Posts: 46
Joined: Fri Aug 01, 2003 11:15 am
Location: NL
Contact:

Post by vonderbakluft »

is there a beta to this?
ehh...what part are you referring to? How to setup friendly medic behaviour or how to setup custom ways of healing a player?

von
Real mappers map in wordpad ;-)
vonderbakluft
Corporal
Posts: 46
Joined: Fri Aug 01, 2003 11:15 am
Location: NL
Contact:

Post by vonderbakluft »

For Uber_soldat:

Here's an exemple of a functioning medic in the Alsace - Defeating Operation Nordwind campaign i'm currently scripting on.

First a prepare thread thats called inmediately after waittill spawn:
(Disables and hides the friendly, since they are needed later on in the level)

Code: Select all

//hide friendly

level.friendly1.friendtype = -1
level.friendly2.friendtype = -1
level.friendly3.friendtype = -1
level.friendly4.friendtype = -1

wait 1

/*
level.friendly1.gun = none
level.friendly2.gun = none
level.friendly3.gun = none
level.friendly4.gun = none
*/

level.friendly1 exec global/disable_ai.scr
level.friendly2 exec global/disable_ai.scr
level.friendly3 exec global/disable_ai.scr
level.friendly4 exec global/disable_ai.scr

level.friendly1 holster
level.friendly2 holster
level.friendly3 holster
level.friendly4 holster

level.friendly1 hide
level.friendly2 hide
level.friendly3 hide
level.friendly4 hide

level.friendly1 thread global/friendly.scr::friendlythink
level.friendly2 thread global/friendly.scr::friendlythink
level.friendly3 thread global/friendly.scr::friendlythink
level.friendly4 thread global/friendly.scr::friendlythink

Some commands seems to be rendundant later on. After some OBJs they are initialized this way



Code: Select all

friendlystart:
self nottriggerable
//Enables friendly
$jurgen show
$jurgen exec global/enable_ai.scr
//$jurgen attack level.friendly1
iprintlnbold "friendlystart"

level.friendly1 show
level.friendly2 show
level.friendly3 show
level.friendly4 show

level.friendly1.friendtype = 1
level.friendly2.friendtype = 1
level.friendly3.friendtype = 1
level.friendly4.friendtype = 5


level.friendly1.distance = 160
level.friendly2.distance = 256
level.friendly3.distance = 192
level.friendly4.distance = 224




wait 1


level.friendly4.lasthealed = level.time

level.friendly1 exec global/enable_ai.scr
level.friendly2 exec global/enable_ai.scr
level.friendly3 exec global/enable_ai.scr
level.friendly4 exec global/enable_ai.scr


level.friendly1 thread friendlydie1
level.friendly2 thread friendlydie2
level.friendly3 thread friendlydie3
level.friendly4 thread friendlydie4


end

This sequence worked. However it can be done more efficient - but i didnt had the time yet to do so :wink:

Von
Real mappers map in wordpad ;-)
Post Reply