Skip to content

Enemy Converting to Friendly Upon Defeat

nreyana edited this page Sep 11, 2024 · 10 revisions

Overview

Upon the defeat of an enemy NPC, the entity is transformed into a "friendly" version of itself. This new friendly NPC can then participate in combat alongside the player, providing support and assistance. The conversion process involves altering the entity’s AI, behaviour, animations, and attributes to reflect its new role as an ally. This not only changes the entity's interaction with the player but also adjusts its behaviour towards other enemies, making it a valuable asset in the player's team.

Methods Called

On the game win screen, convertToFriendly(enemy, plater, enemies) is called. This method systematically converts the enemy into a friendly NPC by removing components specific to its hostile nature, such as attack capabilities and enemy AI behaviours. It then replaces these with a friendly AI controller that enables cooperative behaviours like wandering near the player, avoiding other enemies, and pausing to interact with the player or other friendly NPCs.

Steps in the Conversion Process:

  • Remove Enemy Components: Enemy-specific components such as TouchAttackComponent and CombatStatsComponent are removed to disable hostile behaviours.

  • Update AI Behaviour: The enemy's aggressive AI is replaced with a friendly AI that includes tasks like wandering around, pausing to interact, and avoiding other enemies, making the NPC act more like an ally.

  • Adjust Animations: The entity's animations are updated to reflect its new friendly status, using configurations that are specific to friendly NPCs, such as idle or float animations.

  • Enhance Interaction: Event triggers are added to facilitate interactions with the player.

Event Triggers

Triggered upon game win in combat.

  • Dialogue Initiation: Upon conversion, the NPC can trigger dialogues or sound effects that provide hints or encouragement, using the initiateDialogue method from NPCFactory.

  • Behavioural Adjustments: Specific events like PauseStart and PauseEnd are used to manage how and when the NPC interacts with the player.

Testing Plan

EntityConverter Test Plan

Clone this wiki locally