JustDerb / RoR2-ProtectTheVIP

Risk of Rain 2 Mod - If the VIP dies, you die.
0 stars 0 forks source link

AI Doesn't seem to follow you #3

Open Hanabanashii opened 3 years ago

Hanabanashii commented 3 years ago

From what i've snooped through in the code, it seems like it's supposed to try to follow you?

From what I've played so far, it doesn't seem to follow you or at least places it at a very low priority. If anything, maybe have it try to path to the Teleporter directly, turn it into an Escort mission. (The VIP also contributes to Teleporter charge rate, so if in Singleplayer and they're not in the range, it'll charge at half the rate)

JustDerb commented 3 years ago

The AI is pretty dumb right now as it's using the built-in AI framework they wrote. I'll be working on a more intelligent AI in the next coming releases.

JustDerb commented 3 years ago

The VIP also contributes to Teleporter charge rate

This shouldn't be the case as it's not counted as an active player.

Hanabanashii commented 3 years ago

The VIP also contributes to Teleporter charge rate

This shouldn't be the case as it's not counted as an active player.

It does for me, maybe it is conflicting with another mod but if it isn't in the zone it takes noticeably longer.

The AI is pretty dumb right now as it's using the built-in AI framework they wrote. I'll be working on a more intelligent AI in the next coming releases.

I've noticed, wonder if there's a priority system as vanilla minions tend to follow you over go after an enemy. If it could be made to follow you like that or just make its way toward the teleporter it would make it much more interesting.

JustDerb commented 3 years ago

The VIP also contributes to Teleporter charge rate

This shouldn't be the case as it's not counted as an active player.

It does for me, maybe it is conflicting with another mod but if it isn't in the zone it takes noticeably longer.

Might be another mod? The way the zone charge rate is calculated is a formula that is based on "living players":

HoldoutZoneController.cs

int num = HoldoutZoneController.CountLivingPlayers(this.chargingTeam);
int num2 = HoldoutZoneController.CountPlayersInRadius(base.transform.position, this.currentRadius * this.currentRadius, this.chargingTeam);
// ...snip...
float num5 = this.baseChargeDuration;
float num6 = ((num != 0) ? ((float)num2 / (float)num) : 0f) / num5;
HoldoutZoneController.CalcChargeRateDelegate calcChargeRateDelegate = this.calcChargeRate;
if (calcChargeRateDelegate != null)
{
    calcChargeRateDelegate(ref num6);
}
this.charge = Mathf.Clamp01(this.charge + num6 * Time.fixedDeltaTime);
private static int CountLivingPlayers(TeamIndex teamIndex)
{
    int num = 0;
    ReadOnlyCollection<TeamComponent> teamMembers = TeamComponent.GetTeamMembers(teamIndex);
    for (int i = 0; i < teamMembers.Count; i++)
    {
        if (teamMembers[i].body.isPlayerControlled)
        {
            num++;
        }
    }
    return num;
}

The ally isn't player controlled, so body.isPlayerControlled would evaluate to false here (as would drones and other "allies" built into the game). It only evaluates to true if the ally has a PlayerCharacterMasterController attached to it. Via numerous testing to see if that is attached, I've found that this isn't the case. I actually tried adding it one time and it very much messed up the game, as I needed to populate the object with a ton of Unity info that I could grab at the time.

The AI is pretty dumb right now as it's using the built-in AI framework they wrote. I'll be working on a more intelligent AI in the next coming releases.

I've noticed, wonder if there's a priority system as vanilla minions tend to follow you over go after an enemy. If it could be made to follow you like that or just make its way toward the teleporter it would make it much more interesting.

Hopefully I'll have this improved on the next release. That behavior is what I'm am trending towards (without me adding too much overhead to the built-in code base).

Hanabanashii commented 3 years ago

I think somewhere in making its nameplate forced you made it also considered player controlled... I could be wrong, I'm not big on C#

JustDerb commented 3 years ago

The nameplate doesn't add/remove anything on the ally, so that shouldn't effect it. If you can repro the behavior I can look into it.

Hanabanashii commented 3 years ago

if (body?.isPlayerControlled == false) { Debug.LogWarning($"Forcing ally {body.GetDisplayName()} to have player nameplate."); typeof(CharacterBody) .GetProperty("isPlayerControlled", BindingFlags.Instance | BindingFlags.Public) .SetValue(body, true); Maybe this block here? Looks like you set the value to be true if it is false.

JustDerb commented 3 years ago

Ah, good catch. I might need to look into making it so I don't need to set that to get the nameplate working.

JustDerb commented 3 years ago

I have a very rough change to the AI in the works. I should expect it to make it into the 1.0.3 release.