Skip to content

Commit

Permalink
Changelog (almost done here!)
Browse files Browse the repository at this point in the history
- Fixed an issue with a null reference on the Arch-Vile's flame attack
- Fixed a bug in the Arch-Vile's resurrection check where we weren't using the base info to reset values
- Player is affected by projectile damage (somewhat)
- Some pickups work!
- Improved enemy movement
- Added impact properties to the enemies
- Added support for blunt and punch attacks on enemies
- Fixed an error with A_Pain() on the player causing a null reference
  • Loading branch information
adamd3v committed Oct 4, 2023
1 parent e3d709c commit 482f4ae
Show file tree
Hide file tree
Showing 15 changed files with 199 additions and 108 deletions.
6 changes: 2 additions & 4 deletions ISSUES.txt
Original file line number Diff line number Diff line change
@@ -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
> Player isn't affected by projectile damage (sometimes)
> Mancubus attacks don't spawn two fireballs at the right locations
Binary file modified Resources/doomlab_pcvr.pack
Binary file not shown.
Binary file modified Resources/doomlab_quest.pack
Binary file not shown.
4 changes: 2 additions & 2 deletions src/BuildInfo.gen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
}
48 changes: 48 additions & 0 deletions src/DoomPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;

Expand All @@ -63,29 +89,51 @@ 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:
sound = SoundType.sfx_getpow;
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:
Expand Down
11 changes: 10 additions & 1 deletion src/Info/ActionTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(); }
Expand Down
8 changes: 3 additions & 5 deletions src/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
73 changes: 35 additions & 38 deletions src/Mobj/MobjBrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mobj>();

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<Mobj>();

if(other != null && other.flags.HasFlag(MobjFlags.MF_CORPSE))
else
{
return true;
return false;
}
}

if(hit.collider)
{
return false;
}
}
Expand Down Expand Up @@ -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<Prop_Health>();
ObjectDestructable objectDestructable = hit.collider.GetComponentInParent<ObjectDestructable>();
Expand All @@ -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<Prop_Health>();
destructibleProp = destructible;
Expand All @@ -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<ObjectDestructable>();
destructibleProp = objectDestructable;
Expand All @@ -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;
}
Expand Down Expand Up @@ -454,23 +461,14 @@ public bool CheckSight(Mobj other)
if (Physics.Raycast(ray, out RaycastHit hit, 20))
{
Mobj hitMobj = hit.collider.GetComponent<Mobj>();
Prop_Health breakableTypeOne = hit.collider.GetComponentInParent<Prop_Health>();
ObjectDestructable breakableTypeTwo = hit.collider.GetComponentInParent<ObjectDestructable>();

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;
}

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -1169,6 +1161,11 @@ public void A_Fire()
return;
}

if(!mobj.brain.CheckSight(dest))
{
return;
}

mobj.transform.position = dest.transform.position;
}

Expand Down Expand Up @@ -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;
Expand Down
23 changes: 19 additions & 4 deletions src/Mobj/MobjCollisionEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Mobj>();
rigidbodyProjectile = gameObject.AddComponent<RigidbodyProjectile>();
}

private void OnCollisionEnter(Collision collision)
Expand All @@ -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))
Expand All @@ -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);
}
}
}

Expand Down Expand Up @@ -74,5 +90,4 @@ private void ExplodeMissile(Mobj missile, Mobj hitMobj)
}
}
}

}
Loading

0 comments on commit 482f4ae

Please sign in to comment.