diff --git a/ISSUES.txt b/ISSUES.txt index 2f0541d..f55f1fd 100644 --- a/ISSUES.txt +++ b/ISSUES.txt @@ -1,6 +1,4 @@ DOOMLAB ISSUE LIST ---------------------------- -> Pickups don't have player effects yet -> Player isn't affected by projectile damage -> Mancubus attacks don't spawn two fireballs at the right locations -> Arch-vile attacks freeze the game due to an error in a reference \ No newline at end of file +> Player isn't affected by projectile damage (sometimes) +> Mancubus attacks don't spawn two fireballs at the right locations \ No newline at end of file diff --git a/Resources/doomlab_pcvr.pack b/Resources/doomlab_pcvr.pack index 096bbf8..3792cf0 100644 Binary files a/Resources/doomlab_pcvr.pack and b/Resources/doomlab_pcvr.pack differ diff --git a/Resources/doomlab_quest.pack b/Resources/doomlab_quest.pack index 4db626f..47c3ca2 100644 Binary files a/Resources/doomlab_quest.pack and b/Resources/doomlab_quest.pack differ diff --git a/src/BuildInfo.gen.cs b/src/BuildInfo.gen.cs index edabd01..d7e4849 100644 --- a/src/BuildInfo.gen.cs +++ b/src/BuildInfo.gen.cs @@ -5,7 +5,7 @@ namespace NEP.DOOMLAB { static partial class BuildInfo { - public const int Epoch = 1696290645; - public const string GitCommit = "c7c1a8d5f23edda0ff1eb93fb09f3858a76eab00"; + public const int Epoch = 1696388323; + public const string GitCommit = "e3d709ccd82c35ee53f9fa51cbf7e4ccb56d8112"; } } \ No newline at end of file diff --git a/src/DoomPlayer.cs b/src/DoomPlayer.cs index 9c03358..8585f44 100644 --- a/src/DoomPlayer.cs +++ b/src/DoomPlayer.cs @@ -26,6 +26,8 @@ public void TouchSpecialThing(Mobj special) { SoundType sound = SoundType.sfx_itemup; + var playerHealth = Mobj.player.playerHealth; + switch(special.sprite) { case Data.SpriteNum.SPR_ARM1: @@ -35,12 +37,36 @@ public void TouchSpecialThing(Mobj special) break; case Data.SpriteNum.SPR_BON1: + playerHealth.curr_Health += 0.1f; + + if(playerHealth.curr_Health < 0 && playerHealth.deathIsImminent) + { + playerHealth.LifeSavingDamgeDealt(); + } break; case Data.SpriteNum.SPR_BON2: break; case Data.SpriteNum.SPR_SOUL: + playerHealth.curr_Health = 10f; + + if(playerHealth.curr_Health < 0 && playerHealth.deathIsImminent) + { + playerHealth.LifeSavingDamgeDealt(); + } + + sound = SoundType.sfx_getpow; + break; + + case Data.SpriteNum.SPR_MEGA: + playerHealth.curr_Health = 10f; + + if(playerHealth.curr_Health < 0 && playerHealth.deathIsImminent) + { + playerHealth.LifeSavingDamgeDealt(); + } + sound = SoundType.sfx_getpow; break; @@ -63,19 +89,39 @@ public void TouchSpecialThing(Mobj special) break; case Data.SpriteNum.SPR_STIM: + playerHealth.curr_Health += 1f; + + if(playerHealth.curr_Health < 0 && playerHealth.deathIsImminent) + { + playerHealth.LifeSavingDamgeDealt(); + } + + sound = SoundType.sfx_getpow; break; case Data.SpriteNum.SPR_MEDI: + playerHealth.curr_Health += 5f; + + if(playerHealth.curr_Health < 0 && playerHealth.deathIsImminent) + { + playerHealth.LifeSavingDamgeDealt(); + } + + sound = SoundType.sfx_getpow; break; case Data.SpriteNum.SPR_PINV: + playerHealth.SetHealthMode((int)Player_Health.HealthMode.Invincible); + sound = SoundType.sfx_getpow; break; case Data.SpriteNum.SPR_PSTR: + playerHealth._rigManager.avatar._strengthLower = 1000f; sound = SoundType.sfx_getpow; break; case Data.SpriteNum.SPR_PINS: + sound = SoundType.sfx_getpow; break; case Data.SpriteNum.SPR_SUIT: @@ -83,9 +129,11 @@ public void TouchSpecialThing(Mobj special) break; case Data.SpriteNum.SPR_PMAP: + sound = SoundType.sfx_getpow; break; case Data.SpriteNum.SPR_PVIS: + sound = SoundType.sfx_getpow; break; case Data.SpriteNum.SPR_CLIP: diff --git a/src/Info/ActionTable.cs b/src/Info/ActionTable.cs index 40f0818..b3602e0 100644 --- a/src/Info/ActionTable.cs +++ b/src/Info/ActionTable.cs @@ -35,7 +35,16 @@ public static void A_BFGsound(Mobj mobj){} public static void A_FireBFG(Mobj mobj){} public static void A_BFGSpray(Mobj mobj){} public static void A_Explode(Mobj mobj){ mobj.brain.A_Explode(); } - public static void A_Pain(Mobj mobj){ mobj?.brain.A_Pain(); } + public static void A_Pain(Mobj mobj) + { + if(mobj == Mobj.player) + { + return; + } + + mobj.brain.A_Pain(); + } + public static void A_PlayerScream(Mobj mobj){ } public static void A_Fall(Mobj mobj){ mobj.brain.A_Fall(); } public static void A_XScream(Mobj mobj){ mobj.brain.A_XScream(); } diff --git a/src/Main.cs b/src/Main.cs index 1081066..e6b187c 100644 --- a/src/Main.cs +++ b/src/Main.cs @@ -15,17 +15,15 @@ using BoneLib.BoneMenu.Elements; using BoneLib.BoneMenu; -using SLZ.Marrow.Warehouse; -using UnityEngine.SearchService; namespace NEP.DOOMLAB { public static class BuildInfo { public const string Name = "DOOMLAB"; // Name of the Mod. (MUST BE SET) - public const string Description = ""; // Description for the Mod. (Set as null if none) - public const string Author = ""; // Author of the Mod. (MUST BE SET) - public const string Company = null; // Company that made the Mod. (Set as null if none) + public const string Description = "Hell has encroached into MythOS. Pick up Doomguy's skills and slay endless demons."; // Description for the Mod. (Set as null if none) + public const string Author = "Not Enough Photons, adamdev"; // Author of the Mod. (MUST BE SET) + public const string Company = "Not Enough Photons"; // Company that made the Mod. (Set as null if none) public const string Version = "0.0.1"; // Version of the Mod. (MUST BE SET) public const string DownloadLink = null; // Download Link for the Mod. (Set as null if none) } diff --git a/src/Mobj/MobjBrain.cs b/src/Mobj/MobjBrain.cs index 613b470..60adb6d 100644 --- a/src/Mobj/MobjBrain.cs +++ b/src/Mobj/MobjBrain.cs @@ -81,22 +81,24 @@ public bool Move() } - if(mobj.rigidbody.SweepTest(Vector3.up * -0.5f + mobj.transform.forward, out RaycastHit hit, 0.1f)) + if(Physics.BoxCast(mobj.transform.position + Vector3.up * 0.5f, new Vector3(0.25f, 0.25f, 0.075f), mobj.transform.forward, out RaycastHit hit, mobj.transform.rotation, 1f)) { - if(hit.collider) + Mobj other = hit.collider.GetComponent(); + + if (other != null) { - if(hit.collider.bounds.size.magnitude > mobj.collider.size.magnitude) + if (other.flags.HasFlag(MobjFlags.MF_CORPSE)) { - return false; + Physics.IgnoreCollision(mobj.collider, other.collider); } - - Mobj other = hit.collider.GetComponent(); - - if(other != null && other.flags.HasFlag(MobjFlags.MF_CORPSE)) + else { - return true; + return false; } + } + if(hit.collider) + { return false; } } @@ -287,11 +289,11 @@ public void NewChaseDir() public bool CheckObstructedByBreakable() { - Vector3 origin = mobj.transform.position + Vector3.up; + Vector3 origin = mobj.transform.position + Vector3.up * 0.5f; Vector3 direction = mobj.transform.forward; Ray ray = new Ray(origin, direction); - if(Physics.Raycast(ray, out RaycastHit hit, 1.5f)) + if(Physics.Raycast(ray, out RaycastHit hit, 2f)) { Prop_Health destructible = hit.collider.GetComponentInParent(); ObjectDestructable objectDestructable = hit.collider.GetComponentInParent(); @@ -312,11 +314,11 @@ public bool CheckObstructedByBreakable() public bool CheckObstructedByBreakable(out Prop_Health destructibleProp) { - Vector3 origin = mobj.transform.position + Vector3.up; + Vector3 origin = mobj.transform.position + Vector3.up * 0.5f; Vector3 direction = mobj.transform.forward; Ray ray = new Ray(origin, direction); - if(Physics.Raycast(ray, out RaycastHit hit, 1.5f)) + if(Physics.Raycast(ray, out RaycastHit hit, 2f)) { Prop_Health destructible = hit.collider.GetComponentInParent(); destructibleProp = destructible; @@ -333,11 +335,11 @@ public bool CheckObstructedByBreakable(out Prop_Health destructibleProp) public bool CheckObstructedByBreakable(out ObjectDestructable destructibleProp) { - Vector3 origin = mobj.transform.position + Vector3.up; + Vector3 origin = mobj.transform.position + Vector3.up * 0.5f; Vector3 direction = mobj.transform.forward; Ray ray = new Ray(origin, direction); - if(Physics.Raycast(ray, out RaycastHit hit, 1.5f)) + if(Physics.Raycast(ray, out RaycastHit hit, 2f)) { ObjectDestructable objectDestructable = hit.collider.GetComponentInParent(); destructibleProp = objectDestructable; @@ -359,7 +361,12 @@ public bool CheckMeleeRange() return false; } - if (Vector3.Distance(mobj.transform.position, mobj.target.transform.position) > (mobj.info.radius / 32f) + 1.75f) + if (Vector3.Distance(mobj.transform.position, mobj.target.transform.position) > 2f) + { + return false; + } + + if(!CheckSight(mobj.target)) { return false; } @@ -454,23 +461,14 @@ public bool CheckSight(Mobj other) if (Physics.Raycast(ray, out RaycastHit hit, 20)) { Mobj hitMobj = hit.collider.GetComponent(); - Prop_Health breakableTypeOne = hit.collider.GetComponentInParent(); - ObjectDestructable breakableTypeTwo = hit.collider.GetComponentInParent(); if(hitMobj != null && hitMobj == other) { return true; } - - // If breakable, try to destroy it - if(breakableTypeOne != null || breakableTypeTwo != null) - { - return true; - } - - return false; } + MelonLogger.Msg("Can see target"); return true; } @@ -587,7 +585,7 @@ public void A_Chase() return; } - if (mobj.info.meleeState != StateNum.S_NULL && CheckObstructedByBreakable()) + if (mobj.info.meleeState != StateNum.S_NULL && CheckMeleeRange() || CheckObstructedByBreakable()) { MelonLogger.Msg("Melee state"); if (mobj.info.attackSound != SoundType.sfx_None) @@ -1080,12 +1078,6 @@ public void A_Scream() public void A_Pain() { - // for now - if(mobj == Mobj.player) - { - return; - } - if (mobj.info.painSound != SoundType.sfx_None) { SoundManager.Instance.PlaySound(mobj.info.painSound, mobj.transform.position, false); @@ -1130,8 +1122,8 @@ public void A_VileChase() corpse.SetState(info.raiseState); mobj.collider.center = Vector3.zero; - mobj.collider.center = Vector3.up * (mobj.height / 32f) / 2f; - mobj.collider.size = new Vector3(mobj.radius / 32f, mobj.height / 32f, mobj.radius / 32f); + mobj.collider.center = Vector3.up * (info.height / 32f) / 2f; + mobj.collider.size = new Vector3(info.radius / 32f, info.height / 32f, info.radius / 32f); corpse.flags = info.flags; corpse.health = info.spawnHealth; corpse.target = null; @@ -1169,6 +1161,11 @@ public void A_Fire() return; } + if(!mobj.brain.CheckSight(dest)) + { + return; + } + mobj.transform.position = dest.transform.position; } @@ -1205,13 +1202,13 @@ public void A_VileAttack() if(mobj.target == Mobj.player) { - Mobj.player.playerHealth.TAKEDAMAGE(2f); - Mobj.player.playerHealth._rigManager.physicsRig.rbKnee.AddForce(Vector3.up * 300f, ForceMode.Impulse); + Mobj.player.playerHealth.TAKEDAMAGE(7f); + Mobj.player.playerHealth._rigManager.physicsRig.rbKnee.AddForce(Vector3.up * 450f, ForceMode.Impulse); } else { MobjInteraction.DamageMobj(mobj.target, mobj, mobj, 20); - mobj.rigidbody.AddForce(Vector3.up * 350f); + mobj.rigidbody.AddForce(Vector3.up * mobj.target.info.mass * 10f); } var fire = mobj.tracer; diff --git a/src/Mobj/MobjCollisionEvents.cs b/src/Mobj/MobjCollisionEvents.cs index 9c0ac77..1ab061f 100644 --- a/src/Mobj/MobjCollisionEvents.cs +++ b/src/Mobj/MobjCollisionEvents.cs @@ -12,12 +12,10 @@ public class MobjCollisionEvents : MonoBehaviour public MobjCollisionEvents(System.IntPtr ptr) : base(ptr) { } private Mobj mobj; - private RigidbodyProjectile rigidbodyProjectile; private void Awake() { mobj = GetComponent(); - rigidbodyProjectile = gameObject.AddComponent(); } private void OnCollisionEnter(Collision collision) @@ -35,7 +33,15 @@ private void OnCollisionEnter(Collision collision) if(mobj.flags.HasFlag(MobjFlags.MF_MISSILE)) { - ExplodeMissile(mobj, other); + if(collision.collider.gameObject.layer == LayerMask.NameToLayer("Player") + || collision.collider.gameObject.layer == LayerMask.NameToLayer("Feet")) + { + ExplodeMissile(mobj, Mobj.player); + } + else + { + ExplodeMissile(mobj, other); + } } if(mobj.flags.HasFlag(MobjFlags.MF_SKULLFLY)) @@ -45,6 +51,16 @@ private void OnCollisionEnter(Collision collision) mobj.rigidbody.drag = 10f; mobj.SetState(mobj.info.spawnState); MobjInteraction.CheckThing(other, mobj); + + if(collision.collider.gameObject.layer == LayerMask.NameToLayer("Player") + || collision.collider.gameObject.layer == LayerMask.NameToLayer("Feet")) + { + MobjInteraction.CheckThing(Mobj.player, mobj); + } + else + { + MobjInteraction.CheckThing(other, mobj); + } } } @@ -74,5 +90,4 @@ private void ExplodeMissile(Mobj missile, Mobj hitMobj) } } } - } \ No newline at end of file diff --git a/src/Mobj/MobjInteraction.cs b/src/Mobj/MobjInteraction.cs index 67edd58..a78021a 100644 --- a/src/Mobj/MobjInteraction.cs +++ b/src/Mobj/MobjInteraction.cs @@ -81,6 +81,7 @@ public static bool CheckThing(Mobj thing, Mobj tmThing) float damage = ((DoomGame.RNG.P_Random() % 8) + 1) * tmThing.info.damage; DamageMobj(thing, tmThing, tmThing.target, damage); + MelonLogger.Msg(thing.name); return true; } @@ -202,6 +203,11 @@ public static bool RadiusAttackIterator(Mobj thing, Mobj spot, Mobj source, floa return false; } + if(thing == Mobj.player) + { + DamageMobj(Mobj.player, spot, source, (damage / 10) - distance); + } + if (thing.brain == null) { return false; @@ -234,6 +240,7 @@ public static void DamageMobj(Mobj target, Mobj inflictor, Mobj source, float da if(target == Mobj.player) { + MelonLogger.Msg("Damaging player"); Mobj.player.playerHealth.TAKEDAMAGE(damage); } else diff --git a/src/Mobj/MobjManager.cs b/src/Mobj/MobjManager.cs index 5e4bb86..fad8742 100644 --- a/src/Mobj/MobjManager.cs +++ b/src/Mobj/MobjManager.cs @@ -42,8 +42,7 @@ public Mobj SpawnMobj(Vector3 position, MobjType type, float angle = 0f) if(mobj.flags.HasFlag(MobjFlags.MF_SHOOTABLE) || mobj.flags.HasFlag(MobjFlags.MF_COUNTKILL)) { - var trpSphere = new GameObject(); - trpSphere.transform.parent = mobj.transform; + var trpSphere = mobjBase.transform.GetChild(0).gameObject; trpSphere.AddComponent(); } @@ -65,6 +64,8 @@ public Mobj SpawnMobj(Vector3 position, MobjType type, float angle = 0f) mobj.collider.center = Vector3.up * (mobj.height / 32f) / 2f; mobj.collider.size = new Vector3(mobj.radius / 32f, mobj.height / 32f, mobj.radius / 32f); + ImpactProperties impactProperties = mobjBase.GetComponent(); + if (!mobj.flags.HasFlag(MobjFlags.MF_SOLID)) { mobj.collider.enabled = false; @@ -88,6 +89,11 @@ public Mobj SpawnMobj(Vector3 position, MobjType type, float angle = 0f) mobj.gameObject.AddComponent(); } + if(mobj.flags.HasFlag(MobjFlags.MF_NOBLOOD)) + { + impactProperties.enabled = false; + } + if(mobj.type == MobjType.MT_SKULL) { mobj.gameObject.AddComponent(); diff --git a/src/Mobj/MobjProxy.cs b/src/Mobj/MobjProxy.cs index 52580aa..f260a6d 100644 --- a/src/Mobj/MobjProxy.cs +++ b/src/Mobj/MobjProxy.cs @@ -1,6 +1,8 @@ using UnityEngine; using SLZ.AI; +using SLZ.Bonelab; +using SLZ.Data; namespace NEP.DOOMLAB.Entities { @@ -13,35 +15,19 @@ public MobjProxy(System.IntPtr ptr) : base(ptr) { } private Mobj mobj; private AIBrain aiBrain; - private TriggerRefProxy triggerRefProxy; private SphereCollider sphereCollider; + private TriggerRefProxy triggerRefProxy; private void Awake() { - gameObject.name = "TriggerRefProxy"; - transform.localPosition = Vector3.zero; - mobj = GetComponentInParent(); - if(GetComponent()) - { - return; - } - - aiBrain = mobj.gameObject.AddComponent(); - triggerRefProxy = gameObject.AddComponent(); - sphereCollider = gameObject.AddComponent(); + sphereCollider = GetComponent(); } private void Start() { - sphereCollider.isTrigger = true; - sphereCollider.radius = 5f; - - // has to be set. otherwise, other NPCs won't target us - gameObject.layer = LayerMask.NameToLayer("Trigger"); - - InitializeRefProxy(); + } private void OnEnable() @@ -54,16 +40,6 @@ private void OnDisable() Mobj.OnDeath -= (mobj) => OnAIBrainDeath(); } - private void InitializeRefProxy() - { - triggerRefProxy.triggerType = TriggerRefProxy.TriggerType.Npc; - triggerRefProxy.npcType = TriggerRefProxy.NpcType.FordShortHair; - triggerRefProxy.root = mobj.gameObject; - triggerRefProxy.chestTran = mobj.transform; - triggerRefProxy.targetHead = mobj.rigidbody; - triggerRefProxy._aiManager = aiBrain; - } - private void OnAIBrainDeath() { aiBrain.onNPC_DeathDelegate?.Invoke(aiBrain); diff --git a/src/Patches/DamagePatches.cs b/src/Patches/DamagePatches.cs index 0b73b34..e8656a5 100644 --- a/src/Patches/DamagePatches.cs +++ b/src/Patches/DamagePatches.cs @@ -1,4 +1,5 @@ -using NEP.DOOMLAB.Entities; +using MelonLoader; +using NEP.DOOMLAB.Entities; using NEP.DOOMLAB.Game; using NEP.DOOMLAB.Sound; using SLZ.Combat; @@ -71,4 +72,56 @@ public static void Postfix(Collision c, float impulse, float relVelSqr) } } } + + [HarmonyLib.HarmonyPatch(typeof(ImpactSFX))] + [HarmonyLib.HarmonyPatch(nameof(ImpactSFX.BluntAttack))] + public static class BluntPatch + { + public static void Postfix(float impulse, Collision c) + { + Mobj hitMobj = c.collider.GetComponent(); + + if (hitMobj != null) + { + if (!hitMobj.flags.HasFlag(MobjFlags.MF_NOBLOOD)) + { + MobjManager.Instance.SpawnMobj(c.contacts[0].point, Data.MobjType.MT_BLOOD); + } + else + { + MobjManager.Instance.SpawnMobj(c.contacts[0].point, Data.MobjType.MT_PUFF); + } + + hitMobj.rigidbody.AddForce(c.impactForceSum, ForceMode.Impulse); + MobjInteraction.DamageMobj(hitMobj, Mobj.player, Mobj.player, impulse); + SoundManager.Instance.PlaySound(SoundType.sfx_punch, c.contacts[0].point, false); + } + } + } + + [HarmonyLib.HarmonyPatch(typeof(StabSlash))] + [HarmonyLib.HarmonyPatch(nameof(StabSlash.OnCollisionEnter))] + public static class StabPatch + { + public static void Postfix(Collision c) + { + Mobj hitMobj = c.collider.GetComponent(); + + if (hitMobj != null && c.impulse.magnitude > 0.35f) + { + if (!hitMobj.flags.HasFlag(MobjFlags.MF_NOBLOOD)) + { + MobjManager.Instance.SpawnMobj(c.contacts[0].point, Data.MobjType.MT_BLOOD); + } + else + { + MobjManager.Instance.SpawnMobj(c.contacts[0].point, Data.MobjType.MT_PUFF); + } + + hitMobj.rigidbody.AddForce(c.impactForceSum, ForceMode.Impulse); + MobjInteraction.DamageMobj(hitMobj, Mobj.player, Mobj.player, c.impulse.sqrMagnitude * 0.95f); + SoundManager.Instance.PlaySound(SoundType.sfx_punch, c.contacts[0].point, false); + } + } + } } diff --git a/src/Patches/NPCPatches.cs b/src/Patches/NPCPatches.cs index 8ce4bb5..f4f7f3d 100644 --- a/src/Patches/NPCPatches.cs +++ b/src/Patches/NPCPatches.cs @@ -6,30 +6,17 @@ using NEP.DOOMLAB.Entities; using MelonLoader; +using PuppetMasta; namespace NEP.DOOMLAB.Patches { - [HarmonyPatch(typeof(TriggerRefProxy), nameof(TriggerRefProxy.Awake))] - public static class TRPPatches + [HarmonyLib.HarmonyPatch(typeof(SubBehaviourSensors))] + [HarmonyLib.HarmonyPatch(nameof(SubBehaviourSensors.AddThreat))] + public static class BehaviourBaseNavPatches4 { - public static void Postfix(TriggerRefProxy __instance) + public static void Postfix(TriggerRefProxy trp, float threat) { - Mobj proxyMobj = __instance.gameObject.AddComponent(); - proxyMobj.flags ^= MobjFlags.MF_SHOOTABLE; - } - } - - [HarmonyPatch(typeof(AIBrain), nameof(AIBrain.Awake))] - public static class AIBrainPatches - { - public static void Postfix(AIBrain __instance) - { - __instance.onNPC_DeathDelegate += new System.Action(Test); - } - - public static void Test(AIBrain brain) - { - MelonLogger.Msg(brain.name); + MelonLoader.MelonLogger.Msg("Add threat: " + trp.name + " Threat: " + threat); } } } diff --git a/src/WAD/WADManager.cs b/src/WAD/WADManager.cs index 417459f..14be337 100644 --- a/src/WAD/WADManager.cs +++ b/src/WAD/WADManager.cs @@ -1,10 +1,7 @@ using UnityEngine; using System.IO; -using System.Linq; using System.Collections.Generic; -using HarmonyLib; -using MelonLoader; namespace NEP.DOOMLAB.WAD {