Big Saw Fish (Enemy NPC) - UQcsse3200/2024-studio-2 GitHub Wiki

Overview

The Big Sawfish NPC is a formidable enemy residing in the Water Kingdom. This massive aquatic creature is known for its powerful and aggressive nature, making it a significant challenge for players. It's a big, tanky creature adept at navigating underwater environments, using its strength and defences to overwhelm those who target it.

bigsawfish

Enemy Stats

The Big Saw Fish NPC's stats are defined in an NPC.json file, which is loaded into the game using the FileLoader class.

  • Health: 10
  • Base Attack: 10
  • Base Defense: 15
  • Speed: 75
  • Experience: 100

Big Saw Fish NPC Implementation

The Big Saw Fish NPC is generated through the EnemyFactory class, which is responsible for creating non-playable character (NPC) entities.

This includes the creation of the Big Saw Fish NPC, complete with texture and animation, utilizing the following stats:

public static Entity createBigsawfishCombatEnemy() {
        BaseEnemyEntityConfig config = configs.bigsawfish;
        Entity bigsawfishEnemy = createCombatNPC(config);
        bigsawfishEnemy.setEnemyType(Entity.EnemyType.BIGSAWFISH);
        
        bigsawfishEnemy
                .addComponent(new TextureRenderComponent("images/bigsawfish_idle.png"));
        bigsawfishEnemy.scaleHeight(90.0f);
        
        return bigsawfishEnemy;
    }

Enemy big saw fish NPCs are spawned in ForestGameTerrain class through randomisation based on the player's position:

 private void spawnRandomEnemy(Supplier<Entity> creator, int numItems, double proximityRange) {
    GridPoint2 minPos = new GridPoint2(PLAYER_SPAWN.x - 20, PLAYER_SPAWN.y - 20);
    GridPoint2 maxPos = new GridPoint2(PLAYER_SPAWN.x + 20, PLAYER_SPAWN.y + 20);

    for (int i = 0; i < numItems; i++) {
      GridPoint2 randomPos = RandomUtils.random(minPos, maxPos);
      Entity enemy = creator.get();
      spawnEntityAt(enemy, randomPos, true, false);
      enemies.add(enemy);
      enemy.addComponent(new ProximityComponent(player, proximityRange)); // Add ProximityComponent
    }
  }

Sequence Diagram

sequenceDiagram
Player        -> EnemyFactory            : Player within proximity
EnemyFactory  -> BigSawfish Entity       : createBigSawfish(target)
BigSawfish    -> AnimationRenderComponent: Add sawfish animations (IDLE, SWIM)
BigSawfish    -> AI Task Component       : Add chase and attack tasks (ChaseTask, AttackTask)
Player        -> BigSawfish Entity       : Within attack range
BigSawfish    -> AnimationRenderComponent: Start SWIM or attack animation
BigSawfish    -> Player                  : Attack player
BigSawfish    -> ItemDropSystem          : Drop item on defeat
Loading
⚠️ **GitHub.com Fallback** ⚠️