Page 1 of 2
Working Medic
Posted: Sat Apr 15, 2006 2:06 am
by Broadus
I'm trying to add a medic to a map using a .scr file. I can get normal allies (friendtype 1) to follow the player just fine, but the medic (friendtype 5) won't move anywhere. It will just stand and look around.
What do I need to put in the script (I know how to spawn it) so that the medic will follow the player (or any other specified target) and heal wounded friendlies and whatnot?
Posted: Sat Apr 15, 2006 8:41 am
by jv_map
Just making sure, is this for moh:aa and single player? Or are you trying to place a medic in a multiplayer map?
Posted: Sat Apr 15, 2006 6:39 pm
by Broadus
Oh, sorry. Forgot to mention that. It's just for Allied Assault single player.
Posted: Sun Apr 16, 2006 8:55 am
by jv_map
Ah ok

Could you post relevant bits of your script please? We might be able to spot an error somewhere.
Posted: Sun Apr 16, 2006 9:12 am
by lizardkid
it sounds like you may not have pathnoded your map correctly, make sure the medic is near pathnodes and you have AI enabled (it is by default)
Posted: Sun Apr 16, 2006 9:28 am
by Broadus
**INVALID, PLEASE READ NEXT POST**
Nevermind, guys! I actually just took the medic script from a fan map called The Trenches so now everything works fine. Thanks for offering the help.
I actually didn't put any pathnodes on the map. I'm (still) modifying the Allied Assault single player so it has lots of teammates, Arcade-type health for enemies (Privates have 300 health, while Officers have 900 health), and I've even added two "super enemies", a gasmask soldier and the "Frogman". I'm even going to add some bosses at the end of every mission, which will just be large versions of normal enemies with really high health (AKA a giant dog with 5000 health).
300 health might sound like a lot for the basic soldier, but when you have four guys and a medic backing you up, an enemy with 300 health doesn't last three seconds.
I've only finished the first two levels. So far so good, but I'm afraid that, like in my Breakthrough single player mod, I will constantly run into invisible brushes that stop AI from passing, thus ruining things like squads. I haven't, yet, but that's because the first two levels wouldn't work with invisible brushes like that.
**INVALID, PLEASE READ NEXT POST**
Posted: Sun Apr 16, 2006 10:33 am
by Broadus
No, wait. You guys were right. Do medics have to have pathnodes to be able to follow the player and his squad around? On the first level of Allied Assault's single player (I'm modifying the Allied Assault single player levels with scripts), the medic worked out just fine, following one of the player's allies as they moved up the pathnodes. He would stop following that one specific ally to heal any other wounded allies, so he's just great on level one.
On the second level, however, the medic takes it upon himself to run the entire route of Major Grillo without waiting for anyone.
He stands still in the beginning and doesn't follow anyone (he's spawned just on the other side of the gate in the beginning). I'm not sure if he moves to heal. I never had anyone injured enough to need healing at that point.
A little bit of adventuring and no medic following us later, Major Grillo will begin unlocking a gate and talking about his explosives and documents being confiscated. At the beginning of the unlocking, the medic will start to move down Major Grillo's pathnodes. He'll stop to heal anyone on the way, but then he'll just keep running off without everyone and gets himself killed. It's funny, but also terrible.
Is there a way to have a medic follow the player (or his allies) on any part of any level without the use of pathnodes, or are pathnodes always required? Many of the levels I want to put medics on wouldn't have pathnodes in straight lines like on level 1 and 2.
Here are the medic's specifications or whatever. Works fine on level one, but acts funky on level two.
local.person = spawn models/human/2nd-ranger_medic.tik "origin" "6386.08 -4293.94 21.92" "targetname" "FFally1"
$FFally1.friendtype = 5
$FFally1 thread global/friendly.scr::friendlythink
$FFally1.destination = $player
$FFally1.distance = 250
$FFally1.mindist = 384
$FFally1.maxdist = 640
$FFally1.leash = 800
$FFally1 tether $player
$FFally1.sight = 3000
$FFally1.noticescale = 1
$FFally1.waittime = 0.1
$FFally1.distance = 256
$FFally1.interval = 256
$FFally1 thread FFally1DEAD // So the player knows when his medic dies.
...
FFally1DEAD:
$FFally1 waittill death
iprintlnbold "Your medic has been killed in action."
end
Posted: Sun Apr 16, 2006 11:01 am
by jv_map
Pathnodes are required by all AI to follow anyone or moveto anywhere.
Posted: Sun Apr 16, 2006 11:05 am
by Broadus
The normal type 1 AI don't apparently need pathnodes at all. If they did, then they would have the same problem as the medic. That would also ruin my Breakthrough single player modification, which places allies that follow the player all over the place, irrelevant of any pathnodes.
The problems would have to be the way type 5 AI act. It says in the friendly.scr that the medic behavior is as follows:
"The AI follows the player and friendlies around like a Barney guy (with preference for friendlies over the player) and will heal them if they're wounded sufficiently. He'll also heal himself a few times (limited). Occurs in m5l1b and m4l0. You don't have to do anything special with medics, but its nice to make sure they have a medic model. You can set their .distance to control how close they follow."
The barney guys (type 1) are the ones that will follow the player without problems on any level. The friendly.scr says that type 0 and 4 AI are the kinds of AI that would need pathnodes to move around, type 4 being specifically for Major Grillo. I'm thinking maybe I should just move the medic to another place on the path, like at the beginning, in the prison cell with Major Grillo. I still wouldn't be able to place medics on levels without pathnodes, then.
Posted: Sun Apr 16, 2006 11:15 am
by jv_map
All single player maps have pathnodes. They are built into the map.
Posted: Sun Apr 16, 2006 8:47 pm
by Broadus
Then why won't the type 5 Medic follow the player like the type 1 Barneys will if there are already pathnodes, and the friendly.scr made by the Medal of Honor team says medics follow the player just like Barneys would? No matter where I put the Barneys, they'll follow the player. No matter where I put the medic, he won't follow the player. They all start in the same area and I've tried switching them around, but to no avail.
I'm not saying there aren't pathnodes. I'd just like some help with the medic.
Posted: Mon Apr 17, 2006 9:18 am
by jv_map
In that case, probably the friendly.scr doesn't do what it promises. Personally, I never use the scripts in the global folder because often they are poorly done and unreliable. Besides it's more fun to script the friendly / medic behaviour entirely yourself and you can adjust it to your specific map more easily.
$medic runto $player
Will make the medic follow the player (where 'medic' is the targetname of the medic), although he will quite literally run into you
Other neat commands:
$guy tether $player
Which will make the guy stick close to the player during firefights (basically, the AI is told only to take cover, crate or corner positions near the player). Tether will have no effect in 'peacetime' situations.
A simple follow loop, so that it won't bump into you:
Code: Select all
$guy movedonedist 200 // maybe tweak
while(isAlive $guy)
{
if(!$guy.enemy) // am not currently engaging someone
{
$guy runto $player // or walkto if he's really relaxed
$guy waittill movedone
}
wait 1.0 // wait a bit before following again.
}
Instead of checking for $guy.enemy you could also check for $guy.thinkstate, although I think it's not as convenient.
Great scripting tutorials and references can be found at our tutorials section and at Bjarne's site:
http://gronnevik.se/rjukan/
Posted: Mon Apr 17, 2006 12:00 pm
by Broadus
I already used those things in the Medic specs above, aside from the Following Loop. I tried ONLY using the specs from what you said and what that website with tutorials said, but that just broke the level's .scr file so nothing would happen.
http://rapidshare.de/files/18224187/ZZZ ... s.rar.html
There's what I've gotten so far. I'm still conflicting over how much accuracy/health I want to give allies, and if I'll just give them different accuracy/health each level or keep the same accuracy/health every level.
Just load up m1l2a and you'll see what I mean about the medic not doing anything.
Posted: Mon Apr 17, 2006 8:21 pm
by jv_map
I think this is the problem:
Code: Select all
if (isalive level.friendly2)
self.destination = level.friendly2
else
if (isalive level.friendly3)
self.destination = level.friendly3
else
self.destination = $player
(lines 980-986 in global/friendly.scr)
m1l2a contains level.friendly2 and level.friendly3: they are the friendlies held by the germans in the kind of secret room. The medic is trying to follow them rather than the player as long as they're alive. However from his starting point the medic can't reach friendly2 (or friendly3) and is therefore locked in place.
As I said, the global scripts are unreliable

. They're not truly global scripts but mostly bits of map specific scripts (not meant to be used for anything but that particular map) that for some reason were put in a global folder. The result is a complete mess (global/friendly.scr is utterly unreadable), limited functionality and weird bugs.
So if you want a medic that does what
you want, consider making one.. trust me it's fun

and surely we'll help you along the way.

Posted: Mon Apr 17, 2006 10:07 pm
by Broadus
WOW! That was it! I removed the lines about friendly2 and friendly3 from the friendly.scr and now the medic follows the player without problem. Thanks a lot, JV!
Since we're here, I am having even more problems.
The player's allies don't react to following him fast enough. They stand next to him close enough, and I have their waittime set to 0.1. However, they wait a bit before they decide to follow the player. The medic follows the player just fine, but the Barneys seem to have trouble.
Also, I looked at the medic tutorial on that one website you linked, but they don't say much about medics. How can I specifiy how often the medic heals others and himself? On the first level, he'll heal others all of the time, but on the second level, I've only gotten him to heal the player. I've had two wounded Barneys stumbling around with 100 health left (out of 750), and even the medic himself will be stumbling, but he won't lift a finger to heal anyone but the player.
Here are the specs for the medic (of level 2, where he follows the player fast enough but doesn't seem to heal anyone but the player) and the Barneys (where on level 2, they don't seem to follow the player fast enough).
local.person = spawn models/human/2nd-ranger_medic.tik "origin" "6386.08 -4293.94 21.92" "targetname" "FFally1"
$FFally1.friendtype = 5
$FFally1 thread global/friendly.scr::friendlythink
$FFally1.health = 750
$FFally1.destination = $player
$FFally1.distance = 192
$FFally1.leash = 640
$FFally1 tether $player
$FFally1.sight = 4000
$FFally1.noticescale = 1
$FFally1.waittime = 0.1
$FFally1.hearing = 1
$FFally1.fov = 360
$FFally1.movedoneradius = 50
$FFally1 thread FFally1DEAD
local.person = spawn models/human/2nd-ranger_private.tik "origin" "6484.95 -4319.90 6.23" "targetname" "FFally2" "gun" "m1 garand"
$FFally2.accuracy = 20
$FFally2.mindist = 192
$FFally2.maxdist = 192
$FFally2.health = 750
$FFally2.leash = 640
$FFally2 tether $player
$FFally2.sight = 4000
$FFally2.noticescale = 1
$FFally2.waittime = 0.1
$FFally2 thread global/friendly.scr::friendlythink
$FFally2.destination = $player
$FFally2.distance = 192
$FFally2.friendtype = 1
$FFally2.ammo_grenade = 99
$FFally2 type_attack "cover"
$FFally2.hearing = 1
$FFally2.fov = 360
$FFally2.movedoneradius = 50
$FFally2 thread FFally2DEAD
$FFally2 also applies to $FFally3 and $FFally4.
When I say the Barneys don't move fast enough, I don't mean their move speed is too slow. I mean it seems like the player has to move way too far before they decide to start following him. They also seem to "take turns" moving, as if they were following eachother instead of just following the player. However, they are all definitely following the player, because they'll group around him properly.