void AIFollow(GEntity target) { GTeam team = m_entity.m_controller.GetTeam(m_entity.m_team_id); if (team == null || team.GetLeader() == null || team.m_waypoint_set == false) { return; } Vector3 waypoint = team.GetLeader().transform.position + team.GetOrbitPosition(m_entity.m_team_member_id); float waypoint_distance = Vector3.Distance(transform.position, waypoint); float target_distance = Vector3.Distance(transform.position, team.GetLeader().transform.position); if (!m_entity.m_combatant.IsUsingActionThatBlocksMovement() && (target_distance > m_combat_range.max * 2 && waypoint_distance > .8f) && !m_at_ideal_range) { Vector3 dir = waypoint - transform.position; Vector2 target_direction = new Vector2(dir.x, dir.z); m_entity.m_mobile.Move(m_entity.m_move_speed * 2, target_direction); } else if (!m_entity.m_combatant.IsUsingActionThatBlocksMovement() && (target_distance > m_combat_range.min || waypoint_distance > .8f) && !m_at_ideal_range) { Vector3 dir = waypoint - transform.position; Vector2 target_direction = new Vector2(dir.x, dir.z); m_entity.m_mobile.Move(m_entity.m_move_speed, target_direction); } m_follow_point_reached = waypoint_distance <= .8f; }
void AIStateFlee() { GTeam team = m_entity.m_controller.GetTeam(m_entity.m_team_id); if (team != null && team.GetLeader() != null) { AIFollow(team.GetLeader()); } }
void AIStateFight() { GEntity nearby_enemy = GetClosestEnemyInSight(); if (nearby_enemy != null) { AIPursue(nearby_enemy); } else { GTeam team = m_entity.m_controller.GetTeam(m_entity.m_team_id); if (team != null && team.GetLeader() != null) { AIFollow(team.GetLeader()); } } AIUseActions(); }