Scripting Friendly AI

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Scripting Friendly AI

Post 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.
Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post 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:
Image
User avatar
Butch
Lieutenant Colonel
Posts: 398
Joined: Fri Jan 24, 2003 11:30 am

Post by Butch »

scripts exist on how to do that.

heeeheeeeeeheee
PFC.Butch
B Company, 2nd Ranger Battalion
US Army
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

Read the SDK tuts.
Live to map, not map to live.
-mohaa_rox, .map
moderator
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post 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
Last edited by Gen Cobra on Wed Mar 05, 2003 2:13 pm, edited 2 times in total.
Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post 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
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post 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.
Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

On a side note, all code below ' //InitFriends: ' is never called for some reason :?.
Image
Angex
Major
Posts: 293
Joined: Mon Dec 30, 2002 1:23 pm
Contact:

Post 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.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post 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.
Image
User avatar
Gen Cobra
Major General
Posts: 739
Joined: Tue Jan 28, 2003 4:26 pm

Post 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:
Image
Post Reply