Increasing all damage in the game

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Increasing all damage in the game

Post by Kzer-Za »

I want to increase damage for everything temporarily for testing purposes, so instead of editing the damage of actors, I think I should go with event handlers, right? I want everything to either deal max damage (better) or just double damage (worse, only if the first objective is too difficult to achieve). Is there a way to do it? I found on the forum that WorldThingDamaged is read-only.

I suppose for "double damage" I could just go with WorldThingSpawned and halve the health of everything spawned. But I still would like to try going for maxing the random damage. And besides, in case of the player halving the health does not take care of the health items, which in this case would give him "double" health.
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Increasing all damage in the game

Post by Apeirogon »

WorldThingDamaged "readonlynes" mean that you cant cancel damage, because its called after actor was damaged. In fact it returns amount of damage after taking into account all damage factors, armor, and etc. You still can damage actor from it.
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Increasing all damage in the game

Post by Kzer-Za »

Hm, I tried:

Code: Select all

Class PlugDamageHandler : EventHandler
{
	override void WorldThingDamaged(Worldevent event)
	{
		if (event.thing);
		{
			event.damage *= 2;
			Console.Printf("damage is %d",event.damage);
		}
	}
}
but I get the error

Code: Select all

Expression must be a modifiable value
And I tried changing the scope to "play", like you advised in the other topic, but then I get

Code: Select all

zscript.zsc, line 3: Can't change class scope in class PlugDamageHandler
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Increasing all damage in the game

Post by Kzer-Za »

Okay, I got around it by

Code: Select all

Class PlugDamageHandler : EventHandler
{
	override void WorldThingDamaged(Worldevent event)
	{
		if (event.thing);
		{
//			event.damage *= 2;
			event.thing.Health -= event.damage;
			Console.Printf("damage is %d",event.damage);
		}
	}
}
But that still only deals double damage. In the absence of anything better that will do, but I still would like to have max damage out of any random damage. For that, I suppose I still would need to somehow change every "Thing" in WorldThingSpawned, but for now I don't have any idea how.
User avatar
Enjay
 
 
Posts: 27160
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Re: Increasing all damage in the game

Post by Enjay »

Another way that the damage doubling could have been done would have been to define a custom skill level in MAPINFO ( https://zdoom.org/wiki/MAPINFO/Skill_definition ).

For the de-randomisation you would need something more cunning though.
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Increasing all damage in the game

Post by Kzer-Za »

It seems this way would be better for double damage at least, because I noticed that with the code above monsters become undying if their health is decreased below 0 as the result of setting Health directly.

But for some reason I don't see the new skill in the skill selection menu:

Code: Select all

skill test
{
	MonsterHealth = 0.5
	DamageFactor = 2.0
	FastMonsters
	EasyKey
	SpawnFilter = Nightmare
	DefaultSkill
	Name = "Test"
}
[/s]

Scratch that, I don't know what was the matter, but now I see it.
User avatar
Rachael
Posts: 13965
Joined: Tue Jan 13, 2004 1:31 pm
Preferred Pronouns: She/Her
Contact:

Re: Increasing all damage in the game

Post by Rachael »

If you're only doing it temporarily, CVars might be perfect for your use case.

sv_damagefactorplayer is multiplied on all players
sv_damagefactorfriendly is multiplied on all other +FRIENDLY actors
sv_damagefactormobj is multiplied on all remaining actors, including monsters and barrels

The CVars in question describe the victims of the damage, not the inflictors, so sv_damagefactorplayer 0 is equivalent to god mode.

Or if you want to see what it would be like if the monsters activated god mode for a change instead of you, you can do sv_damagefactormobj 0 ;)
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Increasing all damage in the game

Post by Kzer-Za »

Rachael wrote:sv_damagefactorplayer is multiplied on all players
sv_damagefactorfriendly is multiplied on all other +FRIENDLY actors
sv_damagefactormobj is multiplied on all remaining actors, including monsters and barrels
Oh, I think I'm gonna go with that :) No idea on getting max random damage seems to be implementable. But in the meantime I have also tried doubling the speed of everything, and the condition does not seem to work:

Code: Select all

Class PlugDamageHandler : EventHandler
{
	override void WorldThingSpawned(Worldevent event)
	{
		if (event.thing && event.thing.Speed > 0 && !event.thing.player);
		{
			event.thing.Speed *= 2;
			event.thing.vel *= 2;
			Console.Printf("Speed is %F",event.thing.Speed);
		}
	}
}
Despite the condition, the player's speed is also increased, and I get a lot of "Speed is 0.000000" in the console, which, I thought, I shouldn't.
Jarewill
 
 
Posts: 1854
Joined: Sun Jul 21, 2019 8:54 am

Re: Increasing all damage in the game

Post by Jarewill »

You just want to increase speed of monsters and projectiles, right?
Then how about trying something like this:

Code: Select all

		If(e.Thing.bIsMonster == true || e.Thing.bMissile == true)
		{
			e.Thing.Speed *= 2;
			e.Thing.vel *= 2;
			Console.Printf("Speed is %F",e.thing.Speed);
		}
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Increasing all damage in the game

Post by Kzer-Za »

Oh, I haven't thought about that :) Thanks!
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: Increasing all damage in the game

Post by Blue Shadow »

Kzer-Za wrote:

Code: Select all

if (event.thing && event.thing.Speed > 0 && !event.thing.player);
Remove that semicolon at the end of the line.
Kzer-Za
Posts: 521
Joined: Sat Aug 19, 2017 11:52 pm
Graphics Processor: nVidia (Modern GZDoom)

Re: Increasing all damage in the game

Post by Kzer-Za »

(Facepalm) Right! Thanks!
Post Reply

Return to “Scripting”