Skip to content

Commit

Permalink
added option to spawn damage numbers for all shootables; closes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
XaserAcheron committed May 21, 2017
1 parent 76187c8 commit c882a4c
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/cvarinfo.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ server int dam_font = 0;
server int dam_color = -1;
server int dam_spray = 0;
server int dam_physics = 0;
server bool dam_shootable = false;
server bool dam_enabled = true;
13 changes: 12 additions & 1 deletion src/menudef.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ OptionValue "DamPhysics"
1, "Float"
}

OptionValue "DamShootable"
{
0, "Monsters Only"
1, "All Shootable Objects"
}

OptionValue "DamEnabled"
{
0, "Disabled"
Expand Down Expand Up @@ -53,11 +59,16 @@ OptionMenu "DamNumsOptions"
{
Position -15
Title "DamNums Options"
Option "Mod Enabled" , "dam_enabled", "DamEnabled"
Option "Mod Enabled" , "dam_enabled" , "DamEnabled"
Option "Spawn Numbers For*", "dam_shootable", "DamShootable"
StaticText ""
StaticText "Number Display Settings", 1
Option "Font" , "dam_font" , "DamFonts"
Option "Color" , "dam_color" , "DamColors"
Option "Physics" , "dam_physics", "DamPhysics"
Option "Shotgun Spray", "dam_spray" , "YesNo"
StaticText ""
StaticText "Settings marked with an asterisk (*)", "Tan"
StaticText "will only take effect after changing", "Tan"
StaticText "maps or starting a new game.", "Tan"
}
14 changes: 11 additions & 3 deletions src/zscript/damnums/events.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DamNumEventHandler : StaticEventHandler
*/
override void WorldThingDamaged(WorldEvent e)
{
if (dam_enabled && e.thing && e.Thing.bISMONSTER && dam_spray && e.DamageType != 'Massacre')
if (dam_enabled && self.ShouldSpawn(e.Thing) && dam_spray && e.DamageType != 'Massacre')
{
// Since WorldThingDamaged is (oddly) called after the actor's officially dead,
// we need to account for the case where the actor's height has been quartered.
Expand All @@ -27,18 +27,26 @@ class DamNumEventHandler : StaticEventHandler
*/
override void WorldThingSpawned(WorldEvent e)
{
if (e.Thing && e.Thing.bISMONSTER)
if (self.ShouldSpawn(e.Thing))
{
DamNumCourier.Create(e.thing);
}
}
override void WorldThingRevived(WorldEvent e)
{
if (e.Thing && e.Thing.bISMONSTER)
if (self.ShouldSpawn(e.Thing))
{
DamNumCourier.Create(e.thing);
}
}

/*
* Determine if we should spawn/track a particular thing. Basically
* an easy abstraction for the dam_shootable parameter.
*/
bool ShouldSpawn(Actor thing) {
return thing && (thing.bIsMonster || (dam_shootable && thing.bShootable));
}
}

/*
Expand Down

0 comments on commit c882a4c

Please sign in to comment.