diff --git a/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java b/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java index cdf8bacbe..6382d3ad3 100644 --- a/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java +++ b/source/core/src/main/com/csse3200/game/components/CombatStatsComponent.java @@ -40,7 +40,7 @@ public class CombatStatsComponent extends Component { private String state; private ArrayList drops; private ArrayList closeRangeAbilities; - private ArrayList longRangeAbilities; //TODO change String to Projectiles + private ArrayList longRangeAbilities; public CombatStatsComponent(int health, int baseAttack) { setHealth(health); diff --git a/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java b/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java index fa6e41433..6ec6e2b95 100644 --- a/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java +++ b/source/core/src/main/com/csse3200/game/components/tasks/MobAttackTask.java @@ -102,7 +102,7 @@ public void updateMobState() { case IDLE -> { if (isTargetVisible()) { // targets detected in idle mode - start deployment -// owner.getEntity().getEvents().trigger(DEPLOY); + owner.getEntity().getEvents().trigger(DEPLOY); mobState = STATE.DEPLOY; } } @@ -124,20 +124,20 @@ public void updateMobState() { if (!isTargetVisible() || this.meleeOrProjectile() == null) { this.owner.getEntity().getEvents().trigger(STOW); mobState = STATE.STOW; + } else { + // produce a projectile or melee attack based on chosen weapon if (this.meleeOrProjectile() instanceof Melee) { System.out.println("Melee attack"); TouchAttackComponent attackComp = owner.getEntity().getComponent(TouchAttackComponent.class); HitboxComponent hitboxComp = owner.getEntity().getComponent(HitboxComponent.class); attackComp.onCollisionStart(hitboxComp.getFixture(), target); this.owner.getEntity().getEvents().trigger("meleeStart"); + } else { Entity newProjectile = ProjectileFactory.createMobBall(PhysicsLayer.HUMANS, new Vector2(0, owner.getEntity().getPosition().y), new Vector2(2f,2f)); newProjectile.setPosition((float) (owner.getEntity().getPosition().x), (float) (owner.getEntity().getPosition().y)); -// newProjectile.setScale(-1f, 0.5f); ServiceLocator.getEntityService().register(newProjectile); - -// System.out.printf("ANIMATION: " + owner.getEntity().getComponent(AnimationRenderComponent.class).getCurrentAnimation() + "\n"); this.owner.getEntity().getEvents().trigger(FIRING); mobState = STATE.STOW; } @@ -149,7 +149,7 @@ public void updateMobState() { case STOW -> { // currently stowing if (isTargetVisible()) { -// owner.getEntity().getEvents().trigger(DEPLOY); + owner.getEntity().getEvents().trigger(DEPLOY); mobState = STATE.DEPLOY; } else { owner.getEntity().getEvents().trigger(IDLE); @@ -226,8 +226,6 @@ private boolean isTargetVisible() { * returns the Weapon (Melee or Projectile) the mob will use to attack the target. null if immune target or no target * */ private Weapon meleeOrProjectile() { -// Vector2 newVector = new Vector2(owner.getEntity().getPosition().x - 10f, owner.getEntity().getPosition().y - 2f); -// Fixture hitraycast = physics.raycastGetHit(owner.getEntity().getPosition(), newVector, TARGET); setTarget(); TouchAttackComponent comp = owner.getEntity().getComponent(TouchAttackComponent.class); Weapon chosenWeapon = null; @@ -238,6 +236,9 @@ private Weapon meleeOrProjectile() { return chosenWeapon; } + /** + * set the target of this attack taskto the closest HUMAN target to the mob + * */ private void setTarget() { Vector2 newVector = new Vector2(owner.getEntity().getPosition().x - 10f, owner.getEntity().getPosition().y - 2f); target = physics.raycastGetHit(owner.getEntity().getPosition(), newVector, TARGET); diff --git a/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java b/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java index 5955f34f6..8d2651bdf 100644 --- a/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java +++ b/source/core/src/main/com/csse3200/game/entities/PredefinedWeapons.java @@ -2,6 +2,7 @@ import com.csse3200.game.entities.configs.NPCConfigs; import com.csse3200.game.entities.configs.ProjectileConfig; +import com.csse3200.game.files.FileLoader; public class PredefinedWeapons { // Melee attacks @@ -10,11 +11,8 @@ public class PredefinedWeapons { public static Melee axe = new Melee(9, 3, "fire", 1, 1); public static Melee kick = new Melee(2, 1, "earth", 1, 1); + //TODO import defined projectiles for mobs public static ProjectileConfig fireBall = new ProjectileConfig(); public static ProjectileConfig frostBall = new ProjectileConfig(); - // Projectile attacks TODO: change Weapon and Melee to Projectile class -// public static Weapon fireBall = new Melee(9, 20, "fire", 1, 1); -// public static Weapon frostBall = new Melee(6, 20, "ice", 1, 1); -// public static Weapon hurricane = new Melee(7, 20, "air", 1, 1); }