From 6bba3c8477f5c43cfe1d8edfa3fd0b698f5e0974 Mon Sep 17 00:00:00 2001 From: gentlespoon Date: Sat, 7 May 2022 00:37:27 -0700 Subject: [PATCH] Kamisato Ayaka and Mona talent moving costs stamina --- .../MovementManager/MovementManager.java | 38 ++++++++++++++++--- .../recv/HandlerEvtDoSkillSuccNotify.java | 6 +-- 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/managers/MovementManager/MovementManager.java b/src/main/java/emu/grasscutter/game/managers/MovementManager/MovementManager.java index 60de57055..23b45903a 100644 --- a/src/main/java/emu/grasscutter/game/managers/MovementManager/MovementManager.java +++ b/src/main/java/emu/grasscutter/game/managers/MovementManager/MovementManager.java @@ -37,6 +37,7 @@ public class MovementManager { SWIM_DASH_START(-200), SWIM_DASH(-200), SWIMMING(-80), + FIGHT(0), // restore STANDBY(500), @@ -75,8 +76,9 @@ public class MovementManager { private Timer movementManagerTickTimer; private GameSession cachedSession = null; private GameEntity cachedEntity = null; - private int staminaRecoverDelay = 0; + private int skillCaster = 0; + private int skillCasting = 0; public MovementManager(Player player) { previousCoordinates.add(new Position(0,0,0)); @@ -125,6 +127,12 @@ public class MovementManager { MotionState.MOTION_WALK, MotionState.MOTION_DANGER_WALK ))); + + MotionStatesCategorized.put("FIGHT", new HashSet<>(Arrays.asList( + MotionState.MOTION_FIGHT + ))); + + } public void handle(GameSession session, EntityMoveInfoOuterClass.EntityMoveInfo moveInfo, GameEntity entity) { @@ -145,7 +153,7 @@ public class MovementManager { currentCoordinates = newPos; } currentState = motionInfo.getState(); - Grasscutter.getLogger().debug("" + currentState); + Grasscutter.getLogger().debug("" + currentState + "\t" + (moveInfo.getIsReliable() ? "reliable" : "")); handleFallOnGround(motionInfo); } @@ -293,6 +301,8 @@ public class MovementManager { consumption = getFlyConsumption(); } else if (MotionStatesCategorized.get("STANDBY").contains(currentState)) { consumption = getStandConsumption(); + } else if (MotionStatesCategorized.get("FIGHT").contains(currentState)) { + consumption = getFightConsumption(); } // delay 2 seconds before start recovering - as official server does. @@ -306,7 +316,7 @@ public class MovementManager { consumption = new Consumption(ConsumptionType.None); } } - Grasscutter.getLogger().debug(getCurrentStamina() + "/" + getMaximumStamina() + "\t" + currentState + "\t" + "isMoving: " + isPlayerMoving() + "\t(" + consumption.consumptionType + "," + consumption.amount + ")"); + // Grasscutter.getLogger().debug(getCurrentStamina() + "/" + getMaximumStamina() + "\t" + currentState + "\t" + "isMoving: " + isPlayerMoving() + "\t(" + consumption.consumptionType + "," + consumption.amount + ")"); updateStamina(cachedSession, consumption.amount); } @@ -340,8 +350,6 @@ public class MovementManager { return consumption; } - // TODO: Kamisato Ayaka & Mona - private Consumption getSwimConsumptions() { Consumption consumption = new Consumption(ConsumptionType.None); if (currentState == MotionState.MOTION_SWIM_MOVE) { @@ -410,5 +418,25 @@ public class MovementManager { } return consumption; } + + private Consumption getFightConsumption() { + Consumption consumption = new Consumption(ConsumptionType.None); + HashMap fightingCost = new HashMap<>() {{ + put(10013, -1000); // Kamisato Ayaka + put(10413, -1000); // Mona + }}; + if (fightingCost.containsKey(skillCasting)) { + consumption = new Consumption(ConsumptionType.FIGHT, fightingCost.get(skillCasting)); + // only handle once, so reset. + skillCasting = 0; + skillCaster = 0; + } + return consumption; + } + + public void notifySkill(int caster, int skillId) { + skillCaster = caster; + skillCasting = skillId; + } } diff --git a/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java b/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java index d1db944d2..a57ae9665 100644 --- a/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java +++ b/src/main/java/emu/grasscutter/server/packet/recv/HandlerEvtDoSkillSuccNotify.java @@ -16,11 +16,9 @@ public class HandlerEvtDoSkillSuccNotify extends PacketHandler { // TODO: Will be used for deducting stamina for charged skills. int caster = notify.getCasterId(); - int skill = notify.getSkillId(); + int skillId = notify.getSkillId(); - // Grasscutter.getLogger().warn(caster + "\t" + skill); - -// session.getPlayer().getScene().broadcastPacket(new PacketEvtAvatarStandUpNotify(notify)); + session.getPlayer().getMovementManager().notifySkill(caster, skillId); } }