HaZardModding/hzm-mohaa-coop-mod

e1l2 - Allied soldiers not moving

Closed this issue · 4 comments

Our rangers not moving and just staying!
Image

Think this is due to friendly rewrite. level.coop_player seems to be NULL so it's forever waiting in friendly.scr.

I think this needs to be for Chrissstrahl to sort. It's because friendtype = 1 is assumed to be only for players, but this doesn't seem to be true. In e1l2 the $infantry that are meant to follow the jeep in the intro are given a destination of an entity that isn't a player. Thus, level.coop_player is NULL and gets stuck. The best solution would be to implement some way of knowing whether the designer originally intended them to follow a player or some other entity, if it doesn't already exist, so we can then check for valid players every time or not.

Where it gets stuck is:
while(!level.coop_player || !($player)){ wait 2 }

My intuition is telling me that we just check for $player existing and after that do:

if (!self.destination || !isAlive self.destination || (self.destination.classname == "Player" && !waitthread game.main::isPlayerActive self.destination)) { self waitthread coop_mod/main.scr::destination self.originaldestination = self.destination }

There is something similar further up but that is only if friendly_auto_arrange is set to 1, which isn't always true for AA maps (e.g. M3L3, as the friendlygen thread is called directly rather than main.

I wonder if this would cause issues if the originally targeted player dies or leaves on M3L3. Do allies then stop following altogether on that map?

Also, if level.coop_player is NULL during this check, is it populated outside of this thread somewhere? If not, it seems it will stay here until another friendlythink call is made in the level. Is this true? Doesn't feel right to me.

More info on example:

This is taken from e1l2/Intro.scr:

	$infantry[local.i].distance = local.distance
	$infantry[local.i].destination		= $mrinvisible2
	$infantry[local.i].friendtype		= 1
	$infantry[local.i].waittime			= 3
	//$infantry[local.i].walkto         = 1
	// stagger how far away they keep from their destinations
	//$infantry[local.i].distance		= 90
	// setup the friendlies to follow the player...
	$infantry[local.i] thread global/friendly.scr::friendlythink

Note destination is $mrinvisible2 and friendtype is 1

This will need testing on as many friendly AI missions as possible, but initial testing passed.

Tested, fix is working.