From aa34129e2fd21a39f1113ba30bac8ccce9c01327 Mon Sep 17 00:00:00 2001 From: MiniSoda17 Date: Tue, 17 Oct 2023 09:57:34 +1000 Subject: [PATCH 1/7] Fixing code smell in wizard animation controller --- .../csse3200/game/components/npc/WizardAnimationController.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java b/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java index 80623d6d..9b4660af 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java +++ b/source/core/src/main/com/csse3200/game/components/npc/WizardAnimationController.java @@ -25,8 +25,6 @@ public void create() { entity.getEvents().addListener("mob_walk", this::animateWalk); entity.getEvents().addListener("mob_attack", this::animateAttack); entity.getEvents().addListener("mob_death", this::animateDeath); - - } void animateWalk() { From 5c86d9b97e39260575edf9cf5946088556b890f1 Mon Sep 17 00:00:00 2001 From: gregchan550 <86044792+gregchan550@users.noreply.github.com> Date: Tue, 17 Oct 2023 10:39:22 +1000 Subject: [PATCH 2/7] set normal speed for bosses and general mobs so slow and stun works properly --- .../com/csse3200/game/components/tasks/MobTask/MobTask.java | 3 ++- .../csse3200/game/components/tasks/bosstask/IceBabyTask.java | 1 + .../csse3200/game/components/tasks/bosstask/PatrickTask.java | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java index 2cc103bd..9eebbf1d 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java @@ -89,7 +89,6 @@ public void start() { super.start(); mob = owner.getEntity(); animation = mob.getComponent(AnimationRenderComponent.class); - mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED); melee = mobType.isMelee(); movementTask = new MovementTask(new Vector2(0f, mob.getPosition().y)); @@ -102,8 +101,10 @@ public void start() { if (melee) { mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_MOB_SPEED); + mob.getComponent(PhysicsMovementComponent.class).setNormalSpeed(MELEE_MOB_SPEED); } else { mob.getComponent(PhysicsMovementComponent.class).setSpeed(MELEE_RANGE_SPEED); + mob.getComponent(PhysicsMovementComponent.class).setNormalSpeed(MELEE_RANGE_SPEED); } } diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java index 4b298c05..7cfea58d 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/IceBabyTask.java @@ -71,6 +71,7 @@ public void start() { animation = iceBaby.getComponent(AnimationRenderComponent.class); currentPos = iceBaby.getPosition(); iceBaby.getComponent(PhysicsMovementComponent.class).setSpeed(ICEBABY_SPEED); + iceBaby.getComponent(PhysicsMovementComponent.class).setNormalSpeed(ICEBABY_SPEED); Timer.schedule(new Timer.Task() { @Override public void run() { diff --git a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java index bf5e6c30..cb3f27b8 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/bosstask/PatrickTask.java @@ -64,6 +64,7 @@ public void start() { patrick = owner.getEntity(); animation = owner.getEntity().getComponent(AnimationRenderComponent.class); // get animation patrick.getComponent(PhysicsMovementComponent.class).setSpeed(PATRICK_SPEED); // set speed + patrick.getComponent(PhysicsMovementComponent.class).setNormalSpeed(PATRICK_SPEED); // give game time to load Timer.schedule(new Timer.Task() { From 3775af502798cf1e9a81afa26c7d3dbadb468ae8 Mon Sep 17 00:00:00 2001 From: freshc0w <121275444+freshc0w@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:13:04 +1000 Subject: [PATCH 3/7] Fix unkilable deflect wizard bug --- .../com/csse3200/game/components/npc/DeflectingComponent.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/npc/DeflectingComponent.java b/source/core/src/main/com/csse3200/game/components/npc/DeflectingComponent.java index ab5aa645..15fe60fc 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/DeflectingComponent.java +++ b/source/core/src/main/com/csse3200/game/components/npc/DeflectingComponent.java @@ -60,7 +60,7 @@ public void create() { @Override public void update() { - resetHealth(); + super.update(); } /** @@ -77,8 +77,6 @@ private void deflectProj(Fixture me, Fixture other) { if (deflectLimitAmount-- <= 0) { // Reached deflect limit amt, return. entity.getComponent(this.getClass()).setEnabled(false); - // reset health - resetHealth(); return; } From 4c4cc85a78668da89a71777909d6cc0840cd166e Mon Sep 17 00:00:00 2001 From: freshc0w <121275444+freshc0w@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:47:42 +1000 Subject: [PATCH 4/7] Fix dodging dragonknight stuck sometimes --- .../com/csse3200/game/components/npc/DodgingComponent.java | 5 +++-- .../com/csse3200/game/entities/factories/NPCFactory.java | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/npc/DodgingComponent.java b/source/core/src/main/com/csse3200/game/components/npc/DodgingComponent.java index 96cefd60..f0702887 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/DodgingComponent.java +++ b/source/core/src/main/com/csse3200/game/components/npc/DodgingComponent.java @@ -29,7 +29,7 @@ public class DodgingComponent extends Component { private final RaycastHit hit = new RaycastHit(); private short targetLayer; private float rangeDetection; - private float dodgeSpeed = 1.75f; + private float dodgeSpeed = 1.75f; private float originalSpeed; // Original entity vertical speed private PhysicsEngine physics; private Random random = new Random(); @@ -96,13 +96,14 @@ public void create() { */ public void changeTraverseDirection(Vector2 mobPos) { int randDirection = random.nextInt(2) == 1 ? -1 : 1; + if (isTargetVisible(mobPos)) { // If mob is in the top half quadrant of the map grid, make the entity dodge // downwards. // setVerticalAngleDirection(mobPos.y > 3.5 ? mobPos.y - 15 : mobPos.y + 15); // Random direction setVerticalAngleDirection(mobPos.y + (15 * randDirection)); - setVerticalSpeed(dodgeSpeed); + setVerticalSpeed(dodgeSpeed); } else { setVerticalAngleDirection(mobPos.y); setVerticalSpeed(originalSpeed); diff --git a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java index cecd77e9..f4dab8d2 100644 --- a/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java +++ b/source/core/src/main/com/csse3200/game/entities/factories/NPCFactory.java @@ -624,8 +624,8 @@ public static Entity createDodgingDragonKnight(int health) { dodgeKnight.addComponent(new DodgingComponent(PhysicsLayer.PROJECTILE, 0.25f, 5f)); dodgeKnight.getComponent(AITaskComponent.class).getTask(MobTask.class).setDodge(true); - PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 1f); - dodgeKnight.setScale(0.3f, 1f); + // PhysicsUtils.setScaledCollider(dodgeKnight, 0.3f, 1f); + dodgeKnight.setScale(0.5f, 1.2f); return dodgeKnight; } From 3330c638ae9a5c985f88834c502e1fe1904affe5 Mon Sep 17 00:00:00 2001 From: gregchan550 <86044792+gregchan550@users.noreply.github.com> Date: Tue, 17 Oct 2023 11:49:43 +1000 Subject: [PATCH 5/7] changed melee attack range to 0 --- .../com/csse3200/game/components/tasks/MobTask/MobTask.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java index 9eebbf1d..38a73799 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java @@ -32,7 +32,7 @@ public class MobTask extends DefaultTask implements PriorityTask { private static final int MELEE_DAMAGE = 10; private static final long MELEE_ATTACK_SPEED = 2000; private static final long RANGE_ATTACK_SPEED = 5000; - private static final float MELEE_ATTACK_RANGE = 0.2f; + private static final float MELEE_ATTACK_RANGE = 0f; // Private variables private final MobType mobType; From 6a870fd184c30b315528345bdc8e78bbe4872a9a Mon Sep 17 00:00:00 2001 From: gregchan550 <86044792+gregchan550@users.noreply.github.com> Date: Tue, 17 Oct 2023 12:06:42 +1000 Subject: [PATCH 6/7] fixed bug where melee mob was moving in between attacks so itd get too close and not attack anymore --- .../csse3200/game/components/tasks/MobTask/MobTask.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java index 38a73799..d3b2b978 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobTask/MobTask.java @@ -155,6 +155,9 @@ public void update() { animate(); runFlag = false; } + if (!enemyDetected() && melee) { + runFlag = true; + } if (melee && enemyDetected() && gameTime.getTime() - lastTimeAttacked >= MELEE_ATTACK_SPEED) { changeState(State.ATTACK); meleeAttackFlag = true; @@ -178,7 +181,9 @@ public void update() { if (animation.isFinished()) { movementTask.start(); changeState(State.RUN); - runFlag = true; + if (!melee) { + runFlag = true; + } } } case DODGE -> { From 2146f7517af3133104ec509bc28f72018893cdaf Mon Sep 17 00:00:00 2001 From: freshc0w <121275444+freshc0w@users.noreply.github.com> Date: Tue, 17 Oct 2023 13:11:39 +1000 Subject: [PATCH 7/7] Remove code smells in SplitMoblings --- .../game/components/npc/SplitMoblings.java | 33 +++++++------------ 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java index 3fd20bb9..6b92dd1c 100644 --- a/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java +++ b/source/core/src/main/com/csse3200/game/components/npc/SplitMoblings.java @@ -97,7 +97,7 @@ private void onDeath() { // left. if (amount == 1) { float newXPosition = (float) (entity.getPosition().x - OFFSET_DISTANCE); - float newYPosition = (float) (entity.getPosition().y); + float newYPosition = (entity.getPosition().y); if (withinBounds(newXPosition, newYPosition)) { spawnAdditionalMob(newXPosition, newYPosition, initialScaleX, initialScaleY); @@ -133,37 +133,31 @@ private void onDeath() { */ public void spawnAdditionalMob(float positionX, float positionY, float initialScaleX, float initialScaleY) { - // Entity waterSlime = NPCFactory.createBaseWaterSlime(60); Entity entityType; switch (mobType) { - case WATER_SLIME -> { + case WATER_SLIME -> entityType = NPCFactory.createBaseWaterSlime(baseMoblingHealth); - } - case NIGHT_BORNE -> { + case NIGHT_BORNE -> entityType = NPCFactory.createNightBorne(baseMoblingHealth); - } - case ROCKY -> { + case ROCKY -> entityType = NPCFactory.createRocky(baseMoblingHealth); - } - default -> { + default -> entityType = NPCFactory.createBaseWaterSlime(baseMoblingHealth); - } } - + entityType.setPosition(positionX, positionY); switch (mobType) { - case NIGHT_BORNE -> { + case NIGHT_BORNE -> entityType.setScale(initialScaleX, initialScaleY); - } - default -> { + + default -> entityType.setScale(initialScaleX * scaleX, initialScaleY * scaleY); - } - } + } ServiceLocator.getEntityService().register(entityType); @@ -180,12 +174,9 @@ public void spawnAdditionalMob(float positionX, float positionY, * False otherwise. */ private boolean withinBounds(float currX, float currY) { - if (currX >= MIN_X_BOUNDS + return currX >= MIN_X_BOUNDS && currX <= MAX_X_BOUNDS && currY >= MIN_Y_BOUNDS - && currY <= MAX_Y_BOUNDS) { - return true; - } - return false; + && currY <= MAX_Y_BOUNDS; } }