From ed596e4524b6d939bc9a2d00bf9da03eba28c4d5 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Wed, 24 Mar 2021 22:20:31 -0400 Subject: [PATCH 01/10] [GOMPS-330] Pillars do not stun the boss - IDamageable now has a "flags" field, and a flag for "stuns the boss". - BreakablePillar now has the flag indicating that it stuns the boss. Also gave the pillar prefab a (nonmoving) rigidbody so that the boss can collide with it - refactored TrampleAction to remove repetitive code. (The flow between functions is still kinda choppy, but I don't see an easy fix there.) - added the Stunned action to the GameDataSource again. (Who keeps removing it?!) --- .../Prefabs/Game/BreakablePillar.prefab | 22 +++++++- Assets/BossRoom/Prefabs/GameDataSource.prefab | 1 + .../Server/Game/Action/TrampleAction.cs | 52 ++++++++++++++----- .../Server/Game/Character/ServerCharacter.cs | 5 ++ .../Scripts/Server/Game/Entity/IDamageable.cs | 9 ++++ .../Game/Entity/ServerBreakableLogic.cs | 8 +++ 6 files changed, 81 insertions(+), 16 deletions(-) diff --git a/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab b/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab index 262b9101e..ef75a3c67 100644 --- a/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab +++ b/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab @@ -13,6 +13,7 @@ GameObject: - component: {fileID: 7561466626167410996} - component: {fileID: -8903857516321632127} - component: {fileID: 1460791283510277443} + - component: {fileID: -8878007979862267063} m_Layer: 6 m_Name: BreakablePillar m_TagString: Untagged @@ -47,7 +48,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: d5a57f767e5e46a458fc5d3c628d0cbb, type: 3} m_Name: m_EditorClassIdentifier: - NetworkedInstanceId: 0 + NetworkInstanceId: 0 PrefabHash: 2392659144527479458 PrefabHashGenerator: BreakablePillar AlwaysReplicateAsRoot: 0 @@ -65,7 +66,7 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: IsBroken: - InternalValue: 0 + m_InternalValue: 0 --- !u!114 &-8903857516321632127 MonoBehaviour: m_ObjectHideFlags: 0 @@ -78,6 +79,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: eb44a31731a459546bdf01f1af48173c, type: 3} m_Name: m_EditorClassIdentifier: + m_SpecialDamageFlags: -1 --- !u!65 &1460791283510277443 BoxCollider: m_ObjectHideFlags: 0 @@ -91,6 +93,22 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 3.54, y: 8.287147, z: 3.8} m_Center: {x: 1.18, y: 4.1465364, z: 2} +--- !u!54 &-8878007979862267063 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 884761565141663561} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 126 + m_CollisionDetection: 0 --- !u!1001 &2926384259182416435 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/BossRoom/Prefabs/GameDataSource.prefab b/Assets/BossRoom/Prefabs/GameDataSource.prefab index 7099e31de..a60c09c40 100644 --- a/Assets/BossRoom/Prefabs/GameDataSource.prefab +++ b/Assets/BossRoom/Prefabs/GameDataSource.prefab @@ -72,3 +72,4 @@ MonoBehaviour: - {fileID: 11400000, guid: 90a7c42b138147742a5ef0e724143a74, type: 2} - {fileID: 11400000, guid: c8770f39d4807a842bea85cfb3b8a649, type: 2} - {fileID: 11400000, guid: 0626aa2c2ce0d3a4ab4cad814432c2e5, type: 2} + - {fileID: 11400000, guid: 08dc234d2353e0f489e45a0a4a09bf60, type: 2} diff --git a/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs b/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs index fedd5f28d..a3494b6f2 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs @@ -132,9 +132,7 @@ private void CollideWithVictim(ServerCharacter victim) if (chanceToStun > 0 && Random.Range(0,1) < chanceToStun) { // we're stunned! No collision behavior for the victim. Stun ourselves and abort. - m_WasStunned = true; - m_Movement.CancelMove(); - m_Parent.NetState.RecvCancelAllActionsClientRpc(); + StunSelf(); return; } @@ -156,23 +154,44 @@ private void CollideWithVictim(ServerCharacter victim) victimMovement.StartKnockback(m_Parent.transform.position, Description.KnockbackSpeed, Description.KnockbackDuration); } + // called by owning class when parent's Collider collides with stuff public override void OnCollisionEnter(Collision collision) { - var actionStage = GetCurrentStage(); // we only detect other possible victims when we start charging - if (actionStage != ActionStage.Charging) + if (GetCurrentStage() != ActionStage.Charging) return; - if (m_CollidedAlready.Contains(collision.collider)) + Collide(collision.collider); + } + + // here we handle colliding with anything (whether a victim or not) + private void Collide(Collider collider) + { + if (m_CollidedAlready.Contains(collider)) return; // already hit them! - m_CollidedAlready.Add(collision.collider); + m_CollidedAlready.Add(collider); - var victim = collision.collider.gameObject.GetComponent(); + var victim = collider.gameObject.GetComponent(); if (victim) { CollideWithVictim(victim); } + else if (!m_WasStunned) + { + // they aren't a living, breathing victim, but they might still be destructible... + var damageable = collider.gameObject.GetComponent(); + if (damageable != null) + { + damageable.ReceiveHP(this.m_Parent, -Description.SplashDamage); + + // lastly, a special case: if the boss runs into certain breakables, he is stunned! + if ((damageable.GetSpecialDamageFlags() & IDamageable.SpecialDamageFlags.StunBossOnImpact) == IDamageable.SpecialDamageFlags.StunBossOnImpact) + { + StunSelf(); + } + } + } } private void SimulateCollisionWithNearbyFoes() @@ -184,13 +203,18 @@ private void SimulateCollisionWithNearbyFoes() int numResults = ActionUtils.DetectNearbyEntities(true, true, m_Parent.GetComponent(), k_PhysicalTouchDistance, out results); for (int i = 0; i < numResults; i++) { - m_CollidedAlready.Add(results[i].collider); - var serverChar = results[i].collider.GetComponent(); - if (serverChar) - { - CollideWithVictim(serverChar); - } + Collide(results[i].collider); + } + } + + private void StunSelf() + { + if (!m_WasStunned) + { + m_Movement.CancelMove(); + m_Parent.NetState.RecvCancelAllActionsClientRpc(); } + m_WasStunned = true; } public override bool ChainIntoNewAction(ref ActionRequestData newAction) diff --git a/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs b/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs index a139caf77..187255e92 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Character/ServerCharacter.cs @@ -269,5 +269,10 @@ private void OnStoppedChargingUp() { m_ActionPlayer.OnGameplayActivity(Action.GameplayActivity.StoppedChargingUp); } + + public IDamageable.SpecialDamageFlags GetSpecialDamageFlags() + { + return IDamageable.SpecialDamageFlags.None; + } } } diff --git a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs index a2e72446e..dce63252a 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs @@ -1,3 +1,4 @@ +using System; using UnityEngine; namespace BossRoom.Server @@ -24,6 +25,14 @@ public interface IDamageable /// The transform of this object. /// Transform transform { get; } + + [Flags] + public enum SpecialDamageFlags + { + None = 0, + StunBossOnImpact = 1 << 0, + } + SpecialDamageFlags GetSpecialDamageFlags(); } } diff --git a/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs b/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs index 5a80389cc..68453ebbe 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs @@ -11,6 +11,10 @@ namespace BossRoom.Server [RequireComponent(typeof(NetworkBreakableState))] public class ServerBreakableLogic : NetworkBehaviour, IDamageable { + [SerializeField] + [Tooltip("Indicate which special interaction behaviors are needed for this breakable")] + IDamageable.SpecialDamageFlags m_SpecialDamageFlags; + public override void NetworkStart() { if (!IsServer) @@ -31,6 +35,10 @@ public void ReceiveHP(ServerCharacter inflicter, int HP) } } + public IDamageable.SpecialDamageFlags GetSpecialDamageFlags() + { + return m_SpecialDamageFlags; + } } From 193dba87382860e37942df5b4fbf9c76ff521c27 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Sat, 27 Mar 2021 18:47:41 -0400 Subject: [PATCH 02/10] Trying to revert these weird changes... testing one ability first --- .../BossRoom/GameData/Action/Archer/ArcherChargedShot.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/BossRoom/GameData/Action/Archer/ArcherChargedShot.asset b/Assets/BossRoom/GameData/Action/Archer/ArcherChargedShot.asset index ecfc537bc..c015af111 100644 --- a/Assets/BossRoom/GameData/Action/Archer/ArcherChargedShot.asset +++ b/Assets/BossRoom/GameData/Action/Archer/ArcherChargedShot.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:0d6fa246f654972e29337a14892aeff0135208af558f53bd1f8d2dd7730e307a -size 1694 +oid sha256:cc2a1897d7481e9175e942ff9fddc495d84b0daace2ab96f21cfbad2a6d7dfa3 +size 1693 From 252bcd0d105a3b0ec7d62788fb2fa70a74c451c3 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Sat, 27 Mar 2021 18:49:44 -0400 Subject: [PATCH 03/10] Reverting more changes that shouldnt be in this PR --- Assets/BossRoom/GameData/Action/Archer/ArcherVolley.asset | 4 ++-- Assets/BossRoom/GameData/Action/Mage/MageBaseAttack.asset | 4 ++-- Assets/BossRoom/GameData/Action/Mage/MageHeal.asset | 4 ++-- Assets/BossRoom/GameData/Action/Rogue/RogueBaseAttack.asset | 4 ++-- Assets/BossRoom/GameData/Action/Rogue/RogueStealthMode.asset | 4 ++-- Assets/BossRoom/GameData/Action/Tank/TankBaseAttack.asset | 4 ++-- Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Assets/BossRoom/GameData/Action/Archer/ArcherVolley.asset b/Assets/BossRoom/GameData/Action/Archer/ArcherVolley.asset index 6c720fd11..922c92fd1 100644 --- a/Assets/BossRoom/GameData/Action/Archer/ArcherVolley.asset +++ b/Assets/BossRoom/GameData/Action/Archer/ArcherVolley.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:e4cbc024a9f4fb05a661e57b37b40d8cb539be8d77adc940ccba5d40bdc574e1 -size 1641 +oid sha256:998273feff4776bba54d84096227d3b8f6e8e638889863dd1640de95677fff16 +size 1615 diff --git a/Assets/BossRoom/GameData/Action/Mage/MageBaseAttack.asset b/Assets/BossRoom/GameData/Action/Mage/MageBaseAttack.asset index e33c21bd6..524eb44e4 100644 --- a/Assets/BossRoom/GameData/Action/Mage/MageBaseAttack.asset +++ b/Assets/BossRoom/GameData/Action/Mage/MageBaseAttack.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:16f1e4e87c336d6fafb006cd362b670b2cd39e8b5175b8c7508caa42776c8c62 -size 1189 +oid sha256:8edafce485a5b0b0dc6e9dea20045a22adc3b0cb653df8dfe6ba2d59cd7eceee +size 1094 diff --git a/Assets/BossRoom/GameData/Action/Mage/MageHeal.asset b/Assets/BossRoom/GameData/Action/Mage/MageHeal.asset index f27e29065..bbf0791c0 100644 --- a/Assets/BossRoom/GameData/Action/Mage/MageHeal.asset +++ b/Assets/BossRoom/GameData/Action/Mage/MageHeal.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d023bc5396323d41d1f0565403f54bbbf0fddb4deaa795c2c4ed78968cf05bc2 -size 981 +oid sha256:c62a8dd9dc1a73578ff2d58615130439e545dc1e923ff657bb1af5d25a1b3a46 +size 912 diff --git a/Assets/BossRoom/GameData/Action/Rogue/RogueBaseAttack.asset b/Assets/BossRoom/GameData/Action/Rogue/RogueBaseAttack.asset index a1afcd884..41c175924 100644 --- a/Assets/BossRoom/GameData/Action/Rogue/RogueBaseAttack.asset +++ b/Assets/BossRoom/GameData/Action/Rogue/RogueBaseAttack.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:13b63c0d8bad9f642d070acaefee8350f00b36e2f28212d319d68a20a8d1530b -size 965 +oid sha256:4dfade7efdf20465d6bd15ffb592308f38b955bd088a765cb623a80f6555d042 +size 909 diff --git a/Assets/BossRoom/GameData/Action/Rogue/RogueStealthMode.asset b/Assets/BossRoom/GameData/Action/Rogue/RogueStealthMode.asset index 1d74cda3a..b33019a34 100644 --- a/Assets/BossRoom/GameData/Action/Rogue/RogueStealthMode.asset +++ b/Assets/BossRoom/GameData/Action/Rogue/RogueStealthMode.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:58755676a15bbc6388f93733586af2e48ffd45dd65e9c2f06db1a8fae5e59316 -size 1099 +oid sha256:cfbc9679d36eaa6faafb7eeb1ddee2261f56a33090ce9bec7d0579ab8e3ef989 +size 1139 diff --git a/Assets/BossRoom/GameData/Action/Tank/TankBaseAttack.asset b/Assets/BossRoom/GameData/Action/Tank/TankBaseAttack.asset index 890dc4782..2b7ed86d1 100644 --- a/Assets/BossRoom/GameData/Action/Tank/TankBaseAttack.asset +++ b/Assets/BossRoom/GameData/Action/Tank/TankBaseAttack.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:211bd02ddeab899dddc763cadc09e6ee40d1bee6367a460663c9c112587f4b8b -size 982 +oid sha256:88a968516e55f334b9e9376978b8866a11953fb5cc86bd296ef40cd2e95d8771 +size 956 diff --git a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset index 0b01f2ee1..2597d7fa6 100644 --- a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset +++ b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6390057410bb0b9bb89869e58c9e2515ecf57fff3e1ffd77ba4784b3ea6c7552 -size 1192 +oid sha256:44384e99d22a7b9824ba6e6e0298669e3b45897928a0573f3ce5ddd3dbd387e3 +size 1175 From 64199b53d3d21a1d5e38b1a4f1e36532ace5b603 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Sat, 27 Mar 2021 18:50:56 -0400 Subject: [PATCH 04/10] get this TankShieldBuff out of here --- Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset index 2597d7fa6..0b01f2ee1 100644 --- a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset +++ b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:44384e99d22a7b9824ba6e6e0298669e3b45897928a0573f3ce5ddd3dbd387e3 -size 1175 +oid sha256:6390057410bb0b9bb89869e58c9e2515ecf57fff3e1ffd77ba4784b3ea6c7552 +size 1192 From f7c3a8b616f3d542d319e267f906e92605625c91 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Sat, 27 Mar 2021 18:52:06 -0400 Subject: [PATCH 05/10] Trying again to get an LFS file out of my PR I can't see the diffs so I can't tell what's going to work --- Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset index 0b01f2ee1..2597d7fa6 100644 --- a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset +++ b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6390057410bb0b9bb89869e58c9e2515ecf57fff3e1ffd77ba4784b3ea6c7552 -size 1192 +oid sha256:44384e99d22a7b9824ba6e6e0298669e3b45897928a0573f3ce5ddd3dbd387e3 +size 1175 From 073f3edb83560bdc9cab01ce829f9757c2619934 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Sat, 27 Mar 2021 19:01:24 -0400 Subject: [PATCH 06/10] Manually copied the version from Develop into this PR These LFS files are not easy to work with --- Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset index 2597d7fa6..d11c5fa60 100644 --- a/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset +++ b/Assets/BossRoom/GameData/Action/Tank/TankShieldBuff.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:44384e99d22a7b9824ba6e6e0298669e3b45897928a0573f3ce5ddd3dbd387e3 -size 1175 +oid sha256:e3dcba9e8f40b82312b33a93364957e5dd6d1a5afb8f011ed50205bf82649882 +size 1200 From 6ad00b66d10d64abc59159e6862f368bcc07bf64 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Sat, 27 Mar 2021 19:14:56 -0400 Subject: [PATCH 07/10] Remove [Flags] from enum with one value to work around Unity bug --- Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab | 2 +- Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab b/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab index ef75a3c67..2aa7fdc87 100644 --- a/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab +++ b/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab @@ -79,7 +79,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: eb44a31731a459546bdf01f1af48173c, type: 3} m_Name: m_EditorClassIdentifier: - m_SpecialDamageFlags: -1 + m_SpecialDamageFlags: 1 --- !u!65 &1460791283510277443 BoxCollider: m_ObjectHideFlags: 0 diff --git a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs index dce63252a..3cbc177cc 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs @@ -26,11 +26,16 @@ public interface IDamageable /// Transform transform { get; } - [Flags] + //[Flags] public enum SpecialDamageFlags { None = 0, StunBossOnImpact = 1 << 0, + // Adding another flag? Uncomment the [Flags] field! (It's commented out because + // the Unity editor doesn't behave well when a [Flags] enum has only one flag: it + // assumes that if you turn the flag on, you want ALL flags on, and stores the + // enum as -1. This means your prefabs would magically have any NEW flags you + // added later.) } SpecialDamageFlags GetSpecialDamageFlags(); } From 8c1b575aa80508aa8f755084983e4863dd288ed5 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Sat, 27 Mar 2021 19:22:13 -0400 Subject: [PATCH 08/10] typo --- Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs index 3cbc177cc..74be3b09e 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs @@ -31,7 +31,7 @@ public enum SpecialDamageFlags { None = 0, StunBossOnImpact = 1 << 0, - // Adding another flag? Uncomment the [Flags] field! (It's commented out because + // Adding another flag? Uncomment the [Flags] attribute! (It's commented out because // the Unity editor doesn't behave well when a [Flags] enum has only one flag: it // assumes that if you turn the flag on, you want ALL flags on, and stores the // enum as -1. This means your prefabs would magically have any NEW flags you From a86b904731bb9221bfe52f711c029f0f9699453d Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Thu, 8 Apr 2021 03:01:02 -0400 Subject: [PATCH 09/10] More boss-stun refinements --- .../Action/Boss/BossImpTrampleAttack.asset | 4 +-- .../CharacterSetController.controller | 30 +++++++++++++++++-- .../Prefabs/Game/BreakablePillar.prefab | 22 +++++++++++++- .../Server/Game/Action/TrampleAction.cs | 4 +-- .../Scripts/Server/Game/Entity/IDamageable.cs | 18 ++++++----- .../Game/Entity/ServerBreakableLogic.cs | 11 +++++++ 6 files changed, 75 insertions(+), 14 deletions(-) diff --git a/Assets/BossRoom/GameData/Action/Boss/BossImpTrampleAttack.asset b/Assets/BossRoom/GameData/Action/Boss/BossImpTrampleAttack.asset index 22e378459..3cfd05360 100644 --- a/Assets/BossRoom/GameData/Action/Boss/BossImpTrampleAttack.asset +++ b/Assets/BossRoom/GameData/Action/Boss/BossImpTrampleAttack.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:042274c3870033c4f5bf81bb62fed2740a97a9541df03ab5cc7a885000dc9bcc -size 935 +oid sha256:818857ebae4fad947db07995cf25acf9838d60e6c8c60ec16c9238c1b16546b3 +size 955 diff --git a/Assets/BossRoom/Models/Animation Controllers/CharacterSetController.controller b/Assets/BossRoom/Models/Animation Controllers/CharacterSetController.controller index 0ad2e669c..a0057dbea 100644 --- a/Assets/BossRoom/Models/Animation Controllers/CharacterSetController.controller +++ b/Assets/BossRoom/Models/Animation Controllers/CharacterSetController.controller @@ -273,7 +273,7 @@ AnimatorStateTransition: m_TransitionDuration: 0.12049153 m_TransitionOffset: 0 m_ExitTime: 0.1350613 - m_HasExitTime: 1 + m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 @@ -1851,6 +1851,7 @@ AnimatorState: m_CycleOffset: 0 m_Transitions: - {fileID: -5472320550880040946} + - {fileID: 8725031495282662693} m_StateMachineBehaviours: [] m_Position: {x: 50, y: 50, z: 0} m_IKOnFeet: 0 @@ -2477,7 +2478,7 @@ AnimatorStateTransition: m_TransitionDuration: 0.07605173 m_TransitionOffset: 0 m_ExitTime: 0.042834345 - m_HasExitTime: 1 + m_HasExitTime: 0 m_HasFixedDuration: 1 m_InterruptionSource: 0 m_OrderedInterruption: 1 @@ -3054,6 +3055,31 @@ AnimatorStateTransition: m_InterruptionSource: 0 m_OrderedInterruption: 1 m_CanTransitionToSelf: 1 +--- !u!1101 &8725031495282662693 +AnimatorStateTransition: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: + m_Conditions: + - m_ConditionMode: 1 + m_ConditionEvent: Stunned + m_EventTreshold: 0 + m_DstStateMachine: {fileID: 0} + m_DstState: {fileID: -1989540649778147493} + m_Solo: 0 + m_Mute: 0 + m_IsExit: 0 + serializedVersion: 3 + m_TransitionDuration: 0.25 + m_TransitionOffset: 0 + m_ExitTime: 0.8214297 + m_HasExitTime: 0 + m_HasFixedDuration: 1 + m_InterruptionSource: 0 + m_OrderedInterruption: 1 + m_CanTransitionToSelf: 1 --- !u!1101 &8727437690882463675 AnimatorStateTransition: m_ObjectHideFlags: 1 diff --git a/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab b/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab index 0f4682d6a..0d6a60b18 100644 --- a/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab +++ b/Assets/BossRoom/Prefabs/Game/BreakablePillar.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: -8903857516321632127} - component: {fileID: 1460791283510277443} - component: {fileID: 7670444733571025649} + - component: {fileID: 6825752226794478105} m_Layer: 6 m_Name: BreakablePillar m_TagString: Untagged @@ -79,7 +80,10 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: eb44a31731a459546bdf01f1af48173c, type: 3} m_Name: m_EditorClassIdentifier: - m_SpecialDamageFlags: 1 + m_MaxHealth: {fileID: 0} + m_NetworkHealthState: {fileID: 0} + m_Collider: {fileID: 1460791283510277443} + m_SpecialDamageFlags: 6 --- !u!65 &1460791283510277443 BoxCollider: m_ObjectHideFlags: 0 @@ -110,6 +114,22 @@ MonoBehaviour: m_UnbrokenGameObjects: - {fileID: 3658718798844854089} m_NetState: {fileID: 7561466626167410996} +--- !u!54 &6825752226794478105 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 884761565141663561} + serializedVersion: 2 + m_Mass: 1 + m_Drag: 0 + m_AngularDrag: 0.05 + m_UseGravity: 1 + m_IsKinematic: 0 + m_Interpolate: 0 + m_Constraints: 126 + m_CollisionDetection: 0 --- !u!1001 &2926384259182416435 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs b/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs index a3494b6f2..0e13040a6 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Action/TrampleAction.cs @@ -185,8 +185,8 @@ private void Collide(Collider collider) { damageable.ReceiveHP(this.m_Parent, -Description.SplashDamage); - // lastly, a special case: if the boss runs into certain breakables, he is stunned! - if ((damageable.GetSpecialDamageFlags() & IDamageable.SpecialDamageFlags.StunBossOnImpact) == IDamageable.SpecialDamageFlags.StunBossOnImpact) + // lastly, a special case: if the trampler runs into certain breakables, they are stunned! + if ((damageable.GetSpecialDamageFlags() & IDamageable.SpecialDamageFlags.StunOnTrample) == IDamageable.SpecialDamageFlags.StunOnTrample) { StunSelf(); } diff --git a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs index 74be3b09e..b892cbdfa 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Entity/IDamageable.cs @@ -26,16 +26,20 @@ public interface IDamageable /// Transform transform { get; } - //[Flags] + [Flags] public enum SpecialDamageFlags { None = 0, - StunBossOnImpact = 1 << 0, - // Adding another flag? Uncomment the [Flags] attribute! (It's commented out because - // the Unity editor doesn't behave well when a [Flags] enum has only one flag: it - // assumes that if you turn the flag on, you want ALL flags on, and stores the - // enum as -1. This means your prefabs would magically have any NEW flags you - // added later.) + UnusedFlag = 1 << 0, // does nothing; see comments below + StunOnTrample = 1 << 1, + NotDamagedByPlayers = 1 << 2, + + // The "UnusedFlag" flag does nothing. It exists to work around a Unity editor quirk involving [Flags] enums: + // if you enable all the flags, Unity stores the value as 0xffffffff (labeled "Everything"), meaning that not + // only are all the currently-existing flags enabled, but any future flags you added later would also be enabled! + // This is not future-proof and can cause hard-to-track-down problems, when prefabs magically inherit a new flag + // you just added. So we have the Unused flag, which should NOT do anything, and shouldn't be selected on prefabs. + // It's just there so that we can select all the "real" flags and not get it turned into "Everything" in the editor. } SpecialDamageFlags GetSpecialDamageFlags(); } diff --git a/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs b/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs index 03f093507..531efccb7 100644 --- a/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs +++ b/Assets/BossRoom/Scripts/Server/Game/Entity/ServerBreakableLogic.cs @@ -21,6 +21,7 @@ public class ServerBreakableLogic : NetworkBehaviour, IDamageable [SerializeField] Collider m_Collider; + [SerializeField] [Tooltip("Indicate which special interaction behaviors are needed for this breakable")] IDamageable.SpecialDamageFlags m_SpecialDamageFlags; @@ -50,6 +51,16 @@ public void ReceiveHP(ServerCharacter inflicter, int HP) { if (HP < 0) { + if (inflicter && !inflicter.IsNpc) + { + bool isNotDamagedByPlayers = (GetSpecialDamageFlags() & IDamageable.SpecialDamageFlags.NotDamagedByPlayers) == IDamageable.SpecialDamageFlags.NotDamagedByPlayers; + if (isNotDamagedByPlayers) + { + // a player tried to damage us, but we are immune to player damage! + return; + } + } + if (m_NetworkHealthState) { m_NetworkHealthState.HitPoints.Value = Mathf.Max(m_NetworkHealthState.HitPoints.Value + HP, 0); From 6ea71d2e76d6d59c1e100aea51195bcbb9a73215 Mon Sep 17 00:00:00 2001 From: eheimburg <74330250+eheimburg@users.noreply.github.com> Date: Thu, 8 Apr 2021 03:14:09 -0400 Subject: [PATCH 10/10] boost boss base-health from 100 to 200 --- Assets/BossRoom/GameData/Character/ImpBoss/BaseHP.asset | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/BossRoom/GameData/Character/ImpBoss/BaseHP.asset b/Assets/BossRoom/GameData/Character/ImpBoss/BaseHP.asset index af834102e..f33bba7e8 100644 --- a/Assets/BossRoom/GameData/Character/ImpBoss/BaseHP.asset +++ b/Assets/BossRoom/GameData/Character/ImpBoss/BaseHP.asset @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:f657f7081f4fb2c005104ef7612e7c8816ac8ce2aa6485b146767190c7264841 +oid sha256:d3026ee5a68e09d7653227c668997ab9b0b38255444254da1ffbfe025ebcf619 size 408