Page 1 of 1

Damage Per Second Map v2

Posted: Sat Mar 03, 2018 10:25 pm
by DTDsphere
OLD THREAD: viewtopic.php?f=42&t=54317

Hello, I've been learning code at Uni and I decided to give this project another go. This time it actually tells you the damage per second.
This is great for when making gameplay mods as you can see how powerful your weapons and items actually are!

Download Here

Screenshots: (links not embeds because some dickhead admin thought it would be a good idea to disable the [img] tag)
https://i.imgur.com/Se7qTV0.png
https://i.imgur.com/yVGIobr.png

Code: Select all

#include "zcommon.acs"
int tic = 0; //Clock for displaying DPS
int second = 0; //Internal clock for Average DPS(Damage Per 10 Seconds)
int dmgDealt = 0; //Value for Damage Dealt each tic (realtime)
int dmgSecond = 0; //Value for Damage Dealt each second
int dmgTenSeconds = 0; //Value for Damage Dealt each 10 seconds
int xtextbox = 1.0; //xPosition for text e.g. "title: timer, damage"
int ytextbox = 0.15; //yPosition for text e.g. "title: timer, damage"

////////////////
//Total Damage//
////////////////
Script 1 OPEN
{
	SetFont("CONFONT");
	
	//Damage dealt is the difference between the Cyberdemon's max health (999999) and current health.
	dmgDealt = 999999 - GetActorProperty(1,APROP_Health);
	
	/*1 Total Damage Title*/ HUDMessageBold (s:"Total damage:           ";HUDMSG_PLAIN,1,CR_RED,xtextbox,ytextbox,0,1);
	/*2 Total Damage Value*/ HUDMessageBold (d:dmgDealt;HUDMSG_PLAIN,2,CR_RED,xtextbox,ytextbox,0,1);
	
	//Check every tic
	Delay (1);
	Restart;
}

///////
//DPS//
///////
Script 2 OPEN
{
	SetFont("CONFONT");

	//If Cyberdemon isn't at Max Health (999999), don't activate timer and initalise everything
	If (GetActorProperty(1,APROP_Health) == 999999)
	{
		/*3 DPS Title & init Timer*/ 	HUDMessageBold (s:"\nDPS: 70", s:"        ";HUDMSG_PLAIN,3,CR_ORANGE,xtextbox,ytextbox,0,1);
		/*4 Init DPS Value*/ 			HUDMessageBold (s:"\n0";HUDMSG_PLAIN,4,CR_ORANGE,xtextbox,ytextbox,0,1);
	
		//Check every tic
		Delay(1);
		Restart;
	}
	
	//Update every two seconds
	If (tic <= 0)
		{
		//Reset timer back to 70
		tic = tic + 70;
		
		//DPS equals half the value of the total difference between real-time damage and the damage from 2 seconds ago
		/*4 True DPS Value*/ HUDMessageBold(s:"\n", d:(dmgDealt-dmgSecond)/2;HUDMSG_PLAIN,4,CR_ORANGE,xtextbox,ytextbox,0,1);
		
		//Damage from 2 seconds ago is now refreshed with the current real-time damage value to be compared again in 2 seconds from now
		dmgSecond = dmgDealt;
		}
	
	//If Else statement to keep timer value 2 digits long e.g. display 09 instead of 9
	/*3 DPS Title & true Timer*/ If (tic < 10)	{ HUDMessageBold (s:"\nDPS: 0", d:tic, s:"        ";HUDMSG_PLAIN,3,CR_ORANGE,xtextbox,ytextbox,0,1); }
	/*3 DPS Title & true Timer*/ Else 			{ HUDMessageBold (s:"\nDPS: ",  d:tic, s:"        ";HUDMSG_PLAIN,3,CR_ORANGE,xtextbox,ytextbox,0,1); }
	
	//Check every tic while taking 1 from timer
	Delay(1);
	tic = tic - 1;
	Restart;
}

/////////////////////////////////////////////
//Average DPS (Damage dealt per 10 seconds)//
/////////////////////////////////////////////
Script 3 OPEN
{
	SetFont("CONFONT");
	
	//If Cyberdemon isn't at Max Health, don't activate timer
	If (GetActorProperty(1,APROP_Health) == 999999)
	{
		/*6 Avg DPS Title & init Timer*/ 	HUDMessageBold (s:"\n\nAverage DPS: 10        ";HUDMSG_PLAIN,6,CR_GOLD,xtextbox,ytextbox,0,1);
		/*5 Init Avg DPS Value*/ 			HUDMessageBold (s:"\n\n0";HUDMSG_PLAIN,5,CR_GOLD,xtextbox,ytextbox,0,1);
		Delay(1);
		Restart;
	}
	
	//Update every 10 seconds
	If (second <= 0)
	{
		//Reset timer back to 10
		second = second + 10;
		
		/*5 True Avg DPS Value*/ HUDMessageBold (s:"\n\n", d:(dmgDealt-dmgTenSeconds)/10;HUDMSG_PLAIN,5,CR_GOLD,xtextbox,ytextbox,0,1); //The difference between current damage and damage from 10 seconds ago
		
		//Damage from 10 seconds ago is now refreshed with the current real-time damage value to be compared again in 10 seconds from now
		dmgTenSeconds = dmgDealt;
	}
	
	//Keep timer value 2 digits long e.g. display 09 instead of 9.
	/*3 Avg DPS Title & true Timer*/ If (second < 10) { HUDMessageBold (s:"\n\nAverage DPS: 0", d:second, s:"        ";HUDMSG_PLAIN,6,CR_GOLD,xtextbox,ytextbox,0,1); } //Title and true timer
	/*3 Avg DPS Title & true Timer*/ Else { 			HUDMessageBold (s:"\n\nAverage DPS: " , d:second, s:"        ";HUDMSG_PLAIN,6,CR_GOLD,xtextbox,ytextbox,0,1); } //Title and true timer
	
	//Check every second (35 tics) while taking 1 from timer
	Delay(35);
	second = second - 1;
	Restart;
}

////////////////
//Reset button//
////////////////
Script 4 (void)
{
	SetFont("CONFONT");
	
	//Kill and replace Cyberdemon
	Thing_Damage (1, 999999);
	Spawn ("CyberdemonDPS", 0, 0, 0, 1, 192);
	Spawn ("TeleportFog", 0, 0, 0, 0, 0);
	
	//Reset internal timer and damage values
	tic = 70;
	second = 10;
	dmgSecond = 0;
	dmgTenSeconds = 0;
	
	//Terminate and restart Script 2 and 3 to keep them in sync
	ACS_Terminate (2,0);
	ACS_Terminate (3,0);
	Delay (1);
	ACS_Execute (2,0,0,0,0);
	ACS_Execute (3,0,0,0,0);
	
	//Reset external damage value to 0
	HUDMessageBold (s:"\n0";HUDMSG_PLAIN,4,CR_ORANGE,xtextbox,ytextbox,0,1);
	HUDMessageBold (s:"\n\n0";HUDMSG_PLAIN,5,CR_GOLD,xtextbox,ytextbox,0,1);
}

Re: Damage Per Second Map v2

Posted: Mon Mar 05, 2018 6:40 am
by DTDsphere
Heya,
I've updated this WAD file since the creation of this thread. If you managed to download it early on, please redownload. Thanks!

There will be no more updates.

EDIT:
I just have to do a simple fix to the text overlapping each other when using something other than the default message scaling.

Re: Damage Per Second Map v2

Posted: Thu Mar 29, 2018 6:58 pm
by kinker31
So, I decided to test the map on Russian Overkill...
And let's just say some of the weapons were able to breach the 1M hitpoint limit and kill the cyberdemon.
Especially with the Minelobber's 'Nuclear Disco'.
Like I said, it was a great map.

Re: Damage Per Second Map v2

Posted: Wed Apr 04, 2018 6:03 am
by DTDsphere
kinker31 wrote:So, I decided to test the map on Russian Overkill...
And let's just say some of the weapons were able to breach the 1M hitpoint limit and kill the cyberdemon.
Especially with the Minelobber's 'Nuclear Disco'.
Like I said, it was a great map.
I think breaking the 1M hitpoint limit speaks for itself.

EDIT: Updated from today. Functionally identical but added a bit of polish.

Re: Damage Per Second Map v2

Posted: Wed Apr 04, 2018 12:13 pm
by GeneralDelphox
This is nice. I hope someone could implement it as a HUD addon.

Re: Damage Per Second Map v2

Posted: Fri Sep 28, 2018 9:08 pm
by popguy12
GeneralDelphox wrote:This is nice. I hope someone could implement it as a HUD addon.
That would be cool.

also, isnt there a way to make the cyberdemon invincible? or would that break the dps counter?

Re: Damage Per Second Map v2

Posted: Sun Sep 30, 2018 11:06 pm
by Tango
this seems extremely useful, can't wait to try this out on my own mod. thanks so much for making and sharing :D

Re: Damage Per Second Map v2

Posted: Mon Oct 01, 2018 1:43 am
by ramon.dexter
Great, this really eases up testing of custom damage in wepons and projectiles!

Re: Damage Per Second Map v2

Posted: Mon Oct 01, 2018 7:56 am
by m8f
Thanks for making this! One more tool to modder's development kit.
GeneralDelphox wrote:This is nice. I hope someone could implement it as a HUD addon.
damage-log.pk3
(1.51 KiB) Downloaded 73 times
Three CVars to control:
dl_x, dl_y: text position on the screen.
dl_log: if set to true, all damage events are logged to console in CSV format: Source,Target,Value (off by default).