Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions on enemy patrol despawn logic #933

Closed
GoldJohnKing opened this issue Aug 5, 2020 · 5 comments
Closed

Questions on enemy patrol despawn logic #933

GoldJohnKing opened this issue Aug 5, 2020 · 5 comments
Labels

Comments

@GoldJohnKing
Copy link

GoldJohnKing commented Aug 5, 2020

Greetings!

I've recently noticed on my server that there're many enemy patrol infantries far away from players. They continuously generate new waypoints in the same city after older ones are reached, and seems never despawned.

I've taken a close look into the code in btc_fnc_patrol_playersInAreaCityGroup, btc_fnc_patrol_WPCheck, btc_fnc_patrol_eh, and btc_fnc_patrol_disabled, but I still don't get a clear view on how patrols are despawned.

I've understood:

  1. How patrols and their waypoints are created.
  2. For patrol vehicles, they should despawn once they arrive at their final waypoint. I suppose patrol infantries should do the same, but they seems not, new waypoints are generated at destination city once they reached their former final waypoint.

But I still don't unsterand:

  1. How are patrol infantries despawned?
  2. What if patrol vehicle stuck and will never reach their waypoint? (You know vanilla AI drives like a nightmare...)
  3. Will the stuck patrol despawn if player are far away from them?
  4. I see there's a event handler for patrol being hit, what does it do actually?

If you have a way to better explain the patrol system, please enlighten me.

Thanks!

Another off topic question: I've noticed sometimes enemy groups will have a waypoint at [0, 0] coordinate but still have other normal waypoints near cities, I think it might related to the terrain I use, how could I check it?

@Vdauphin
Copy link
Owner

Vdauphin commented Aug 5, 2020

Hello,

For patrol vehicles, they should despawn once they arrive at their final waypoint. I suppose patrol infantries should do the same, but they seems not, new waypoints are generated at destination city once they reached their former final waypoint.

  1. How are patrol infantries despawned?

Vehicles and patrol infantries use exactly the same system. And use btc_fnc_patrol_playersInAreaCityGroup to check if player is around (btc_patrol_area = 2500) here.

  1. What if patrol vehicle stuck and will never reach their waypoint? (You know vanilla AI drives like a nightmare...)
  2. Will the stuck patrol despawn if player are far away from them?

Most of the time, if the vehicle/infantries doesn't reach the destination. The waypoint trigger the btc_fnc_patrol_WPCheck.
First it test if player is still around and then check if waypoint is completed but not too far. In this last case, the city which is not accessible is stored so next patrol will not use it and then the btc_fnc_patrol_init is called to find a new city to patrol.

  1. I see there's a event handler for patrol being hit, what does it do actually?

Remove drunk driver loosing wheel, breaking engine ... (https://github.com/Vdauphin/HeartsAndMinds/blob/master/%3DBTC%3Dco%4030_Hearts_and_Minds.Altis/core/fnc/patrol/disabled.sqf#L6)

Another off topic question: I've noticed sometimes enemy groups will have a waypoint at [0, 0] coordinate but still have other normal waypoints near cities,

Should not append in master. And since CBA 3.14 CBATeam/CBA_A3#1274 should not append in master_daily

I think it might related to the terrain I use,

I don't think

how could I check it?

H&M use CBA_fnc_addWaypoint or CBA_fnc_taskPatrol to add waypoint so basically every time the h&m call tehm, you should check if the [0, 0] position is passed.
I would first check if those enemy group are btc_fnc_patrol_init, btc_fnc_mil_send or btc_fnc_mil_create_group

@GoldJohnKing
Copy link
Author

Thanks to your explanation, I now better understand the patrol system.

Should not append in master. And since CBA 3.14 CBATeam/CBA_A3#1274 should not append in master_daily

I use a modified version of master_daily, and it seems the exact same problem as CBATeam/CBA_A3#1274.
I started noticing this issue since #922 was merged. I think those units are btc_fnc_mil_create_group and it seems happen on city reactivation, could it be related?

I would first check if those enemy group are btc_fnc_patrol_init, btc_fnc_mil_send or btc_fnc_mil_create_group

They are not empty groups, the [0,0] waypoints are assigned to groups contain units.

Anyway, I'll check that as you suggest.

@GoldJohnKing
Copy link
Author

GoldJohnKing commented Aug 6, 2020

Hi, I've looked into the waypoint [0,0,0] issue.

First, those groups with [0,0,0] waypoint are created by btc_fnc_mil_create_group btc_fnc_patrol_init.

When patrols are created, patrol units are spawn at a closest city to players' city, then generate waypoints at players' city, finally generate waypoint to another closest city.

[_group, _pos, -1, "MOVE", "UNCHANGED", "RED", "LIMITED", "STAG COLUMN", "", [0, 0, 0], 20] call CBA_fnc_addWaypoint;
for "_i" from 0 to (2 + (floor (random 3))) do {
private _newPos = [_pos, 150] call CBA_fnc_randPos;
[_group, _newPos, -1, "MOVE", "UNCHANGED", "RED", "UNCHANGED", "NO CHANGE", "", [0, 0, 0], 20] call CBA_fnc_addWaypoint;
};
private _waypoint_WPCheck = [_group, _pos, -1, "MOVE", "UNCHANGED", "NO CHANGE", "UNCHANGED", "NO CHANGE", _waypointStatements, [0, 0, 0], 20] call CBA_fnc_addWaypoint;

I found the waypoints that should be at players' city are actually at [0,0,0], that is to say, waypoints generated by:

for "_i" from 0 to (2 + (floor (random 3))) do {
private _newPos = [_pos, 150] call CBA_fnc_randPos;
[_group, _newPos, -1, "MOVE", "UNCHANGED", "RED", "UNCHANGED", "NO CHANGE", "", [0, 0, 0], 20] call CBA_fnc_addWaypoint;
};

are at position [0,0,0]. so I wonder if it's caused by CBA_fnc_randPos.

So what I said before:

it seems happen on city reactivation

could not be truth.

I'm still not sure if this always happens.

Just in case, I'm using Kujari as terrain.

@Vdauphin
Copy link
Owner

Vdauphin commented Aug 6, 2020

First, those groups with [0,0,0] waypoint are created by btc_fnc_mil_create_group.

Patrols system don't use btc_fnc_mil_create_group

then generate waypoints at players' city,

This is wrong, the patrol system find (https://github.com/Vdauphin/HeartsAndMinds/blob/master_daily/%3DBTC%3Dco%4030_Hearts_and_Minds.Altis/core/fnc/patrol/init.sqf#L49-L51):

  • a city around the activated city (_start_cityID) to spawn the patrol
  • _active_cityID nothing append to this city from the patrol system point of view
  • a another city around the activated city (_end_cityID ) where waypoint are created

I found the waypoints that should be at players' city are actually at [0,0,0], that is to say, waypoints generated by:

May be because _pos is nil

Just in case, I'm using Kujari as terrain.

Create an issue

@GoldJohnKing
Copy link
Author

An, my fault, I copied the wrong function name... I now edited my previous post.

Anyway, I'll create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants