Skip to content

Enemy NPC's

LJ edited this page Sep 12, 2024 · 67 revisions

Overview

The enemy NPC feature will introduce dynamic and challenging opponents and diverse animal types that increase in stat difficulty as the player progresses through levels. Enemies will spawn and then initiate battles when within a certain radius, and each animal type will have unique abilities and potentially super effective moves. Defeated enemies will drop items, and players will face a new set of enemies in each elemental kingdom, ensuring a fresh and exciting experience.

Enemy NPC Documentation

A list of enemy NPCs implemented in the game, as well as their respective stats, specific implementations and other details can be found below.

Enemies are spawned by the Map Team, who are responsible for generating and placing enemy entities within the game world, specifically in the ForestGameArea. It uses a supplier to generate entities of the selected enemy type and spawns them randomly within the specified proximity range. The number of enemies spawned is determined in the configuration settings. This method of generation ensures that enemies are spawned in a way that is challenging for the player while keeping the game novel. The amount of enemies are determined by the spawn configurations:

    public int NUM_FROGS;
    public int NUM_MONKEYS;
    public int NUM_BEARS;

The numbers for each enemy type are defined in the entitySpawn json file:

  "NUM_FROGS" : 4,
  "NUM_MONKEYS" : 5,
  "NUM_BEARS" : 4, ... 

Feature Components

NPC Design

The NPC enemy design will be consistent using pixel art for enemies which aligning with the game's aesthetic and style guidelines. Unique and recognisable enemy character sprites will be used, collaborating with the design committee and studio to ensure consistency with the game's vision.

Player Interaction

Enemy NPCs remain invisible and dormant until the player enters a designated proximity radius, at which point they spawn and give chase. Upon reaching a specific distance from the player, they engage the player in battle (developed in conjunction with the combat feature team). An enemy cut screen displaying the enemy's stats - attack and health, is displayed before combat is engaged.

Details about each sub-feature functionality can be found below:

Statistics

As mentioned earlier, each enemy has slightly different statistics, and as the game progresses, the general strength of enemies will increase. Enemies have four base statistics:

  • Health: an enemy endures more hits.
  • baseAttack: an enemy deals more damage with each attack.
  • baseDefense: an enemy has a higher success rate when blocking an attack.
  • Speed: an enemy attacks faster and is more likely to parry attacks.

On each enemy spawn, these statistics (except for speed) will be altered by around 10%. So for example, if an enemies baseAttack is 50 then the actual in game value will be between 45 and 55. Note that these values will always be a round integer.

Generally, these statistics will be reflected in the type of enemy animal. For example, a chicken has low health, attack and defense but is moderately fast. Whereas a bear has high health and attack, moderate defense and fairly low speed.

As mentioned earlier the general strength of enemies is increased as the game progresses, but within each kingdom (forest, aquatic and aerial) there is also a gradient in animal strength. There will be 4-5 enemy types in each kingdom and there will be varying overall strength between them. In the forest, for example, the chicken is the weakest overall animal, then the monkey, frog and the bear is the strongest. Note that 'strength' here is defined as the sum of all the enemy base stats.

To see how these statistics will function in battle, refer to the Combat Wiki.
To see the specific statistic for each enemy NPC, refer to the Enemy NPC Statistics Wiki

Effort Values (EVs) Not Implemented Yet

Similar to Pokemon, the user player can train their statistics by defeating enemies of a certain type. Each enemy has an associated statistic, that when defeated, has a chance to increment the user's equivalent statistic.

For example, if a chicken's associated EV statistic is speed, and an EV increment is triggered, the user's speed will be incremented (likely by just 1). An enemy's associated EV statistic will likely reflect what they are disproportionately good at, so a chicken would be speed because it has a high speed relative to its total base stats. Within each location, there will be five different enemies to accommodate for the 5 different stats that can be boosted via EVs.

Enemy NPC Implementation

Types of enemies:

private enum EnemyType {
    FROG,
    CHICKEN,
    MONKEY,
    BEAR;
  }

Example implementation of Base Enemy to create a new enemy NPC of Monkey type:

Entity monkey = createBaseEnemy(playerEntity, EnemyType.MONKEY);

Create Base Enemy Function:

private static Entity createBaseEnemy(Entity target, EnemyType type) {
    AITaskComponent aiComponent = new AITaskComponent();

    if (type == EnemyType.MONKEY) {
      aiComponent.addTask(new SpecialWanderTask(new Vector2(2f, 2f), 2f));
      aiComponent.addTask(new RunTask(target, 10, 3f));
    } else {
      aiComponent.addTask(new WanderTask(new Vector2(2f, 2f), 2f));
      aiComponent.addTask(new ChaseTask(target, 10, 3f, 4f));
    }

    Entity npc =
        new Entity()
            .addComponent(new PhysicsComponent())
            .addComponent(new PhysicsMovementComponent())
            .addComponent(new ColliderComponent())
            .addComponent(new HitboxComponent().setLayer(PhysicsLayer.NPC))
            .addComponent(new TouchAttackComponent(PhysicsLayer.PLAYER))
            .addComponent(aiComponent);

    PhysicsUtils.setScaledCollider(npc, 0.9f, 0.4f);
    return npc;
  }

Testing Plan

Sprint 1

Sub-Feature Functionalities to be Tested & Validated

  • Enemy creation
  • Enemies show up in the game
  • Animations are loaded correctly
  • Enemies spawn correctly
  • Enemy NPCs rise from the ground based on player vicinity
  • Player Detection
  • Enemy NPCs correctly detect and react to the player
  • Combat Initiation
  • Enemy NPCs initiate combat depending on player vicinity.

Testing Methods

  • Visual Testing through running the game to ensure that:

    • Enemy NPCs have spawned in the correct locations.
    • Animations and textures have loaded for the monkey, chicken and frog.
    • Combat is initiated when a player collides with an enemy.
    • Run task makes the owner (monkey) run from player.
  • JUnit Tests to cover entity behaviour and event triggers (see Enemy NPC Test Cases)

The test plan for Sprint 2 outlines the approach and scope for testing the latest iteration of the Enemy NPCs and functionalities and features implemented. The plan focuses on ensuring that the new features and functionality implemented during this sprint meet the required quality and functionality standards. By identifying key test areas, outlining the testing approach, and estimating resource requirements, this plan documents the testing done on these functionalities to ensure that all important aspects of this feature are thoroughly validated.

UML Diagram

image
Clone this wiki locally