Page 1 of 1

Scripting Friendly AI

Posted: Tue Mar 04, 2003 8:54 pm
by Gen Cobra
How do I script friendly ai?

Do I in the script

exec global/friendly.scr

Do I add ai actor and make it a captian or something?
Will he follow normal pathnodes?
Will he be a complete moron this way?
How can I make him follow me and help out?

I REALLY need some answers to these ones. Or a place to find answers.

Posted: Tue Mar 04, 2003 9:15 pm
by Gen Cobra
WOW :shock: I guess I should just shut my pie hole and read some scripts. I had no idea they had self explainations to them. Why didn't someone tell the idiot, me, that they existed? :cry:

Posted: Tue Mar 04, 2003 9:25 pm
by Butch
scripts exist on how to do that.

heeeheeeeeeheee

Posted: Wed Mar 05, 2003 7:04 am
by mohaa_rox
Read the SDK tuts.

Posted: Wed Mar 05, 2003 1:01 pm
by Gen Cobra
I just wanted a script line to make the ai follow me. I looked for an answer in the friendly scr but I don't see where to put the lines. I can activate them fine but I want them to follow like a Barney or lead like a Leader. Not stand there an wait to be shot. Can anyone tell me what the script line would be and where to place it in a script?
I have 6 allies all set with #fnum1-7. I have friendly pathnodes set up already with #set and #area. I want to just set them up as friendly type Barney. I set .avoidplayer 0. Is that wrong?
Thanks for responding ROX and Jv. I'll look through the SDK again for answers. :lol:
It's my birthday! :P

Posted: Wed Mar 05, 2003 2:02 pm
by Gen Cobra
What am I doing wrong, and don't be rude cause I'm justr learning how to do this type of scripting.

main:
level waittill prespawn
$player item weapons/silencedpistol.tik
$player item weapons/springfield.tik
$player item weapons/m1_garand.tik
$player item weapons/m2frag_grenade.tik
$player item weapons/thompsonsmg.tik
$player item items/binoculars.tik
$player ammo rifle 200
$player ammo grenades 3
$player ammo pistol 150
$player ammo smg 200
exec global/bomber.scr
exec global/weather.scr
exec global/exploder.scr
exec global/ambient.scr m5l1b
exec global/friendly.scr
fadein 2 0 0 0 1
wait 2
level.script = maps/test_IRON_TUSK.scr
thread objectives
end
objectives:
waitthread

global/objectives.scr::add_objectives 1 2 "Find and

kill Vlad, the WaffenSS officer." $obj1.origin
set_objective_pos $officer thread objective1
end
objective1:
waitthread global/objectives.scr::current_objectives

1
if (IsAlive $officer)
$officer waittill death
thread mission_complete
end
mission_complete:
waitthread global/objectives.scr::add_objectives 1 3

"Kill the Vlad the WaffenSS officer." $obj1.origin
waitthread global/objectives.scr::current_objectives

0 // clears objectives
iprintln_noloc "Vlad has been killed. Mission

complete!"
wait 1
exec global/missioncomplete.scr test_IRON_TUSK 1
end
//InitFriends:
level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3
level.friendly4.targetname = friend4
level.friendly5.targetname = friend5
level.friendly6.targetname = friend6
level.friendly7.targetname = friend7
end
$friend1.destination = $player
$friend2.destination = $player
$friend3.destination = $player
$friend5.destination = $player
$friend6.destination = $player
$friend7.destination = $player
$friend1.friendtype = 1
$friend2.friendtype = 1
$friend3.friendtype = 1
$friend4.friendtype = 1
$friend5.friendtype = 1
$friend6.friendtype = 1
$friend7.friendtype = 1
$friend1.distance = 175
$friend2.distance = 225
$friend3.distance = 250
$friend4.distance = 250
$friend5.distance = 200
$friend6.distance = 200
$friend7.distance = 250
$friend1 thread

global/friendly.scr::friendlythink
$friend2 thread

global/friendly.scr::friendlythink
$friend3 thread

global/friendly.scr::friendlythink
$friend4 thread

global/friendly.scr::friendlythink
$friend5 thread

global/friendly.scr::friendlythink
$friend6 thread

global/friendly.scr::friendlythink
$friend7 thread

global/friendly.scr::friendlythink
end
level waittill spawn
pain:
$hurtme volumedamage 25
end
level.flyplane=1
end

Posted: Wed Mar 05, 2003 3:21 pm
by jv_map
level.friendly1.targetname = friend1
level.friendly2.targetname = friend2
level.friendly3.targetname = friend3
level.friendly4.targetname = friend4
level.friendly5.targetname = friend5
level.friendly6.targetname = friend6
level.friendly7.targetname = friend7

Don't do this :shock:. They need the 'friendly' targetname.

end
level waittill spawn
pain:
$hurtme volumedamage 25
end
level.flyplane=1
end

Am I missing something? :?

You really need to get rid of all the random 'end's in your script.

Posted: Wed Mar 05, 2003 3:39 pm
by Gen Cobra
level waittill spawn
pain:
$hurtme volumedamage 25
end
level.flyplane=1
end

Do I not need the end at the end of these? The rest is just for the map like the planes and the fire.
So don't rename the targets and it should work. Is everything in the right place in the script?
I really don't care at this point if they follow me to their death I just want them to follow until I figure the rest out.

Posted: Wed Mar 05, 2003 3:43 pm
by jv_map
On a side note, all code below ' //InitFriends: ' is never called for some reason :?.

Posted: Wed Mar 05, 2003 3:57 pm
by Angex
Well, its needs the comment prefix removing, then put thread InitFriends in the main thread.

I don't think the levelwaittillspawn bits will work as they're not inside the main tread (I always though that was a requirment). Also level.flyplane=1 doesn't appear to be in any thread whats so ever.

Posted: Wed Mar 05, 2003 4:01 pm
by jv_map
Well the waittill spawn can be in any thread but I don't think it's doing any good where it is now.

Posted: Wed Mar 05, 2003 4:01 pm
by Gen Cobra
level.flyplane=1 was in nemesis' tutorial. I don't know if it has anything to do with the animations for the planes or not. I don't know. I'm gonna do my best to get this done. This map is VERY fun with the enemies in it. I didn't realize how well planned out the routes were. It really forces you in directions like across the bridge or through the alleys full of enemies oil barrels and gas barrels.. The nodes for the ai are targeted to each other too now so the ai seem very smart now. :wink: