Skip to content

Eel (Enemy NPC)

Urawee Thani edited this page Oct 21, 2024 · 3 revisions

Overview

The Eel enemy is a force to be reckoned with in the ocean kingdom. Not because of its statistics, because it is kind of weak in that respect, but for its SPECIAL ABILITY, more on this later... The eel is unique in that it has animations to move in all 8 directions. Also, you might notice the electricity zapping around the eel, and sometimes it can't contain the insane voltage that it possesses.

Screenshot 2024-10-03 at 12 24 10 PM

Enemy Stats

  • Health: 5
  • baseAttack: 2
  • baseDefense: 1
  • speed: 2
  • experience: 10

Eel NPC Implementation

The eel enemy NPC is spawned through the EnemyFactory class, which is responsible for creating non-playable character (NPC) entities.

Create new pigeon enemy NPC:

Entity eel = createBaseEnemy(playerEntity, EnemyType.EEL);

Creation of pigeon enemy NPC, with all the relevant movement animations, as well as the textures:

    public static Entity createEel(Entity target) {
        BaseEnemyEntityConfig config = configs.eel;
        Entity eel = createBaseEnemy(target, EnemyType.EEL, config);
        eel.setEnemyType(Entity.EnemyType.EEL);

        AnimationRenderComponent animator =
                new AnimationRenderComponent(
                        ServiceLocator.getResourceService().getAsset(config.getSpritePath(), TextureAtlas.class));
        animator.addAnimation("swim_down", 0.25f, Animation.PlayMode.LOOP);
        animator.addAnimation("swim_down_right", 0.25f, Animation.PlayMode.LOOP);
        animator.addAnimation("swim_right", 0.25f, Animation.PlayMode.LOOP);
        animator.addAnimation("swim_up_right", 0.25f, Animation.PlayMode.LOOP);
        animator.addAnimation("swim_up", 0.25f, Animation.PlayMode.LOOP);

        eel
                .addComponent(animator)
                .addComponent(new EelAnimationController());

        eel.getComponent(AnimationRenderComponent.class).scaleEntity();

        return eel;
    }

Eel Special Ability

The eel is overflowing with electricity and sometimes gets angry at the player and lashes out! WHen this happens, the eel sends a ball of electric energy at the player, and if hit, the player with be paralysed momentarily:

case EnemyType.EEL -> {
    aiComponent.addTask(new SpecialWanderTask(new Vector2((float) configStats.getSpeed() / 100, (float) configStats.getSpeed() / 100), 2f));
    aiComponent.addTask(new ChaseTask(target, 4, 10f, 8f, new Vector2((float) configStats.getSpeed() / 100, (float) configStats.getSpeed() / 100), false));
    aiComponent.addTask(new ShootTask(5000, target, 10f));
}

Sequence Diagram

image image
Clone this wiki locally