From 64fcf5b69cd1930e0d67446a9f62c2f5c48c2bbc Mon Sep 17 00:00:00 2001 From: Dan R Date: Wed, 20 May 2020 18:34:05 +0200 Subject: [PATCH] Various fixes - Fixed *Make it possible to keep copter ears by holding the jump button while in mid-air, like in JJ2+* - Fixed *Player gets stuck between two horizontal springs* (in *Loose Screws* and probably some other places) - Fixed *SchwartzenGuard's walking animation plays too fast* - Fixed *Spamming the weapon change button sometimes gets the current weapon stuck for a few moments* - Fixed *While flying towards you, the bats don't look at you, making them fly backwards sometimes* - Fixed *When grabbing the full life restore carrot, Spaz says "Yummy!"* - Fixed *Player can buttstomp SchwartzenGuard's mace* - Fixed *Make the number keys able to change to their respective weapon* --- Content/Metadata/Boss/TurtleTough.res | 4 +-- Content/Metadata/Interactive/PlayerLori.res | 2 +- Content/Metadata/Interactive/PlayerSpaz.res | 2 +- Shared/Jazz2.Core.Server/Server/GameServer.cs | 2 +- Shared/Jazz2.Core/Actors/Enemies/Bat.cs | 4 +++ .../Actors/Enemies/Bosses/TurtleTough.cs | 1 + Shared/Jazz2.Core/Actors/Player.Weapons.cs | 18 +++++++++++ Shared/Jazz2.Core/Actors/Player.cs | 32 +++++++++++++------ 8 files changed, 50 insertions(+), 15 deletions(-) diff --git a/Content/Metadata/Boss/TurtleTough.res b/Content/Metadata/Boss/TurtleTough.res index 5ed8bad5..edfdeaa7 100644 --- a/Content/Metadata/Boss/TurtleTough.res +++ b/Content/Metadata/Boss/TurtleTough.res @@ -12,7 +12,7 @@ "Walk": { "Path": "TurtleToughBoss/walk.png", "States": [ 1 ], - "FrameRate": 8 + "FrameRate": 5 }, "AttackStart": { @@ -37,7 +37,7 @@ "Mace": { "Path": "TurtleToughBoss/mace.png", "States": [ 1073741827 ], - "FrameRate": 15 + "FrameRate": 12 } }, diff --git a/Content/Metadata/Interactive/PlayerLori.res b/Content/Metadata/Interactive/PlayerLori.res index 9506aa88..0ce07299 100644 --- a/Content/Metadata/Interactive/PlayerLori.res +++ b/Content/Metadata/Interactive/PlayerLori.res @@ -365,7 +365,7 @@ "Paths": [ "Pickup/food_edible_1.wav", "Pickup/food_edible_2.wav", "Pickup/food_edible_3.wav", "Pickup/food_edible_4.wav" ] }, "PickupMaxCarrot": { - + "Paths": [ "Pickup/food_edible_1.wav" ] }, "WeaponBlaster": { "__Paths": [ "Weapon/bullet_blaster_jazz_1.wav", "Weapon/bullet_blaster_jazz_2.wav", "Weapon/bullet_blaster_jazz_3.wav", "Weapon/bullet_blaster_jazz_4.wav" ], diff --git a/Content/Metadata/Interactive/PlayerSpaz.res b/Content/Metadata/Interactive/PlayerSpaz.res index 567b78b1..4066b6e5 100644 --- a/Content/Metadata/Interactive/PlayerSpaz.res +++ b/Content/Metadata/Interactive/PlayerSpaz.res @@ -371,7 +371,7 @@ "Paths": [ "Pickup/food_edible_1.wav", "Pickup/food_edible_2.wav", "Pickup/food_edible_3.wav", "Pickup/food_edible_4.wav" ] }, "PickupMaxCarrot": { - "Paths": [ "Jazz/carrot.wav" ] + "Paths": [ "Pickup/food_edible_1.wav" ] }, "WeaponBlaster": { "__Paths": [ "Weapon/bullet_blaster_spaz_1.wav", "Weapon/bullet_blaster_spaz_2.wav", "Weapon/bullet_blaster_spaz_3.wav" ], diff --git a/Shared/Jazz2.Core.Server/Server/GameServer.cs b/Shared/Jazz2.Core.Server/Server/GameServer.cs index e7531417..8cb1662e 100644 --- a/Shared/Jazz2.Core.Server/Server/GameServer.cs +++ b/Shared/Jazz2.Core.Server/Server/GameServer.cs @@ -315,7 +315,7 @@ private void OnPublishToServerList() } } - Thread.Sleep(300000); // 5 minutes + Thread.Sleep(600000); // 10 minutes } } diff --git a/Shared/Jazz2.Core/Actors/Enemies/Bat.cs b/Shared/Jazz2.Core/Actors/Enemies/Bat.cs index e3a61de9..00eeada7 100644 --- a/Shared/Jazz2.Core/Actors/Enemies/Bat.cs +++ b/Shared/Jazz2.Core/Actors/Enemies/Bat.cs @@ -49,6 +49,8 @@ public override void OnFixedUpdate(float timeMult) speedX = direction.X * DefaultSpeed; speedY = direction.Y * DefaultSpeed; + IsFacingLeft = (speedX < 0f); + if (noiseCooldown > 0f) { noiseCooldown -= timeMult; } else { @@ -86,6 +88,8 @@ public override void OnFixedUpdate(float timeMult) direction.Normalize(); speedX = direction.X * DefaultSpeed; speedY = direction.Y * DefaultSpeed; + + IsFacingLeft = (speedX < 0f); } } } diff --git a/Shared/Jazz2.Core/Actors/Enemies/Bosses/TurtleTough.cs b/Shared/Jazz2.Core/Actors/Enemies/Bosses/TurtleTough.cs index 402bf4eb..7a65d4cc 100644 --- a/Shared/Jazz2.Core/Actors/Enemies/Bosses/TurtleTough.cs +++ b/Shared/Jazz2.Core/Actors/Enemies/Bosses/TurtleTough.cs @@ -187,6 +187,7 @@ private class Mace : EnemyBase protected override async Task OnActivatedAsync(ActorActivationDetails details) { base.canBeFrozen = false; + base.isInvulnerable = true; base.canCollideWithAmmo = false; base.CollisionFlags = CollisionFlags.CollideWithOtherActors; diff --git a/Shared/Jazz2.Core/Actors/Player.Weapons.cs b/Shared/Jazz2.Core/Actors/Player.Weapons.cs index c5ca8b9b..6ba673c2 100644 --- a/Shared/Jazz2.Core/Actors/Player.Weapons.cs +++ b/Shared/Jazz2.Core/Actors/Player.Weapons.cs @@ -102,6 +102,24 @@ private void SwitchToNextWeapon() currentWeapon = (WeaponType)((int)(currentWeapon + 1) % (int)WeaponType.Count); } + weaponCooldown = 1f; + +#if MULTIPLAYER && SERVER + ((LevelHandler)levelHandler).OnPlayerRefreshAmmo(this, currentWeapon, weaponAmmo[(int)currentWeapon], true); +#endif + + PreloadMetadata("Weapon/" + currentWeapon); + } + + private void SwitchToWeaponByIndex(int weaponIndex) + { + if (weaponIndex >= weaponAmmo.Length || weaponAmmo[weaponIndex] == 0) { + return; + } + + currentWeapon = (WeaponType)weaponIndex; + weaponCooldown = 1f; + #if MULTIPLAYER && SERVER ((LevelHandler)levelHandler).OnPlayerRefreshAmmo(this, currentWeapon, weaponAmmo[(int)currentWeapon], true); #endif diff --git a/Shared/Jazz2.Core/Actors/Player.cs b/Shared/Jazz2.Core/Actors/Player.cs index c09a9930..f3477c2b 100644 --- a/Shared/Jazz2.Core/Actors/Player.cs +++ b/Shared/Jazz2.Core/Actors/Player.cs @@ -651,7 +651,6 @@ public override void OnFixedUpdate(float timeMult) else #endif { - speedX = MathF.Max((MathF.Abs(speedX) - Deceleration * timeMult), 0) * (speedX < 0 ? -1 : 1); isActivelyPushing = false; @@ -670,7 +669,7 @@ public override void OnFixedUpdate(float timeMult) float absSpeedX = MathF.Abs(speedX); if (absSpeedX > 1f) { IsFacingLeft = (speedX < 0f); - } else if (absSpeedX < 0.001f) { + } else if (absSpeedX < 1f) { keepRunningTime = 0f; } } @@ -821,7 +820,6 @@ public override void OnFixedUpdate(float timeMult) CollisionFlags |= CollisionFlags.CollideWithSolidObjects; }); } else { - switch (playerType) { case PlayerType.Jazz: { if ((currentAnimationState & AnimState.Crouch) != 0) { @@ -922,7 +920,11 @@ public override void OnFixedUpdate(float timeMult) } canJump = true; } - if (canJump && currentSpecialMove == SpecialMoveType.None && !ControlScheme.PlayerActionPressed(playerIndex, PlayerActions.Down)) { + if (!canJump) { + if (copterFramesLeft > 0f) { + copterFramesLeft = 70f; + } + } else if (currentSpecialMove == SpecialMoveType.None && !ControlScheme.PlayerActionPressed(playerIndex, PlayerActions.Down)) { canJump = false; isFreefall = false; SetAnimation(currentAnimationState & (~AnimState.Lookup & ~AnimState.Crouch)); @@ -995,8 +997,18 @@ public override void OnFixedUpdate(float timeMult) } } - if (playerType != PlayerType.Frog && ControlScheme.PlayerActionHit(playerIndex, PlayerActions.SwitchWeapon)) { - SwitchToNextWeapon(); + if (playerType != PlayerType.Frog) { + if (ControlScheme.PlayerActionHit(playerIndex, PlayerActions.SwitchWeapon)) { + SwitchToNextWeapon(); + } else if (playerIndex == 0) { + // Use numeric key to switch weapons for the first player + int maxWeaponCount = Math.Min(weaponAmmo.Length, 9); + for (int i = 0; i < maxWeaponCount; i++) { + if (weaponAmmo[i] != 0 && DualityApp.Keyboard.KeyHit(Duality.Input.Key.Number1 + i)) { + SwitchToWeaponByIndex(i); + } + } + } } #endif } @@ -1041,6 +1053,7 @@ protected override void OnHitWall() // Reset speed and show Push animation speedX = 0f; pushFramesLeft = 2f; + keepRunningTime = 0f; Vector3 pos = Transform.Pos; if (levelHandler.EventMap.IsHurting(pos.X + (speedX > 0f ? 1f : -1f) * 16f, pos.Y)) { @@ -1298,7 +1311,7 @@ private void UpdateAnimation(float timeMult) newState = AnimState.Swing; } else if (isLifting) { newState = AnimState.Lift; - } else if (canJump && isActivelyPushing && pushFramesLeft > 0f) { + } else if (canJump && isActivelyPushing && pushFramesLeft > 0f && keepRunningTime <= 0f) { newState = AnimState.Push; } else { // Only certain ones don't need to be preserved from earlier state, others should be set as expected @@ -2143,9 +2156,8 @@ public void OnSpringActivated(Vector2 force, bool keepSpeedX, bool keepSpeedY) externalForceY = 0f; } - SetPlayerTransition(AnimState.Dash | AnimState.Jump, true, true, SpecialMoveType.None); - // ToDo: ... - controllableTimeout = 20f; + SetPlayerTransition(AnimState.Dash | AnimState.Jump, true, false, SpecialMoveType.None); + controllableTimeout = 2f; } else if (MathF.Abs(force.Y) > 0f) { copterFramesLeft = 0f; speedY = (4 + MathF.Abs(force.Y)) * sign;