OK so at this point in time, I’m sure we’re going in loops. Anyway, here’s the problem:
My AggroGroup straight up isn’t working. In other words, I can attack my Dialogue Guard and activate my aggroGroup as expected, but for god knows what reason, the other guards involved in the group don’t seem to be bothered by the fact that one of their team members is under my attack. I did check their ‘nonAggro’ and ‘aggrevateOthers’ (I set this one to true for my Dialogue Guard, but not the others) setting, and they didn’t work as expected (even though I didn’t change anything about the settings since they were last working, just the game environment in my project had a complete makeover). How do we fix this?
If it helps in anyway, here is my DialogueAggro.cs script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RPG.Combat;
namespace RPG.Respawnables
{
//This class will only go on the character PREFAB that has a dialogue.
public class DialogueAggro : MonoBehaviour
{
//As this is going to be on a prefab, you cannot serialize a scene reference in a prefab...
//[SerializeField] AggroGroup aggroGroup;
AggroGroup aggroGroup;
//This is the method that your DialogueTrigger will call to Aggrevate.
public void CallAggroGroup()
{
if (aggroGroup != null) aggroGroup.Activate(true);
}
//Sets the aggrogroup, called by RespawnManager so that when the trigger fires, this
//class has a link to the AggroGroup.
public void SetAggroGroup(AggroGroup aggroGroup2)
{
aggroGroup = aggroGroup2;
}
}
}
And my AggroGroup.cs script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using RPG.Respawnables;
using RPG.Attributes;
namespace RPG.Combat {
public class AggroGroup : MonoBehaviour
{
[SerializeField] List<Fighter> fighters = new List<Fighter>(); // fighters to aggregate when our player takes a wrong dialogue turn (and pisses everyone off)
[SerializeField] bool activateOnStart = false;
private bool isActivated;
private void Start() {
// Ensures guards are not active to fight you, if you didn't trigger them:
Activate(activateOnStart);
}
/* private void Awake() {
Health playerHealth = GameObject.FindWithTag("Player").GetComponent<Health>();
if (playerHealth) playerHealth.onDie.AddListener(() => Activate(activateOnStart));
} */
/* public void Activate(bool shouldActivate) {
isActivated = shouldActivate;
foreach (Fighter fighter in fighters) {
CombatTarget target = fighter.GetComponent<CombatTarget>();
if (target != null) {
target.enabled = shouldActivate;
}
fighter.enabled = shouldActivate;
}
} */
public void Activate(bool shouldActivate) {
isActivated = shouldActivate;
foreach (Fighter fighter in fighters) {
if (!fighter) continue;
fighter.enabled = shouldActivate;
if (fighter.TryGetComponent(out CombatTarget target)) {
target.enabled = shouldActivate;
}
}
}
/* public void AddFighterToGroup(Fighter fighter) {
if (fighters.Contains(fighter)) return;
fighters.Add(fighter);
if (fighter.TryGetComponent(out CombatTarget target)) {
target.enabled = isActivated; // synchronizing fighters with the remainder of the AggroGroup
}
} */
public void AddFighterToGroup(Fighter fighter) {
if (fighters.Contains(fighter)) return;
fighters.Add(fighter);
fighter.enabled = isActivated;
if (fighter.TryGetComponent(out CombatTarget target)) target.enabled = isActivated;
}
public void RemoveFighterFromGroup(Fighter fighter) {
fighters.Remove(fighter);
}
}
}
P.S: (Last time when it used to work, it would work under the condition that I would get close to the group members BEFORE we aggrevate the entire group through dialogue (with the dialogue guard). If you get close to someone you can’t attack, but then aggrevate the group, and the other member you got close to is out of the aggrevated guy’s shout distance, he’d still hunt you down. Now it’s not calling any other member in the group at all, and I’m not sure why…)