How to control amount of damage done by flying debris?

How to control amount of damage done by flying debris?

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

How to control amount of damage done by flying debris?

Post by Forboding Angel »

I'm pretty sure it's really simple, I just can't remember :-(
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: How to control amount of damage done by flying debris?

Post by knorke »

function UnitPreDamaged(... weaponDefID ...)
if weaponDefID == -1 then return newDamageByDebris end

iirc debris only does damage when SFX.EXPLODE and/or SXF.FIRE
damage amount, radius etc is hardcoded somewhere here https://github.com/spring/spring/tree/d ... rojectiles
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: How to control amount of damage done by flying debris?

Post by Google_Frog »

Change all HP and damage values by the same factor. The only (iirc) unchanged thing is debris damage so you're set (well fall damage is unchanged too but that is default off).
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to control amount of damage done by flying debris?

Post by Forboding Angel »

Code: Select all

function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, attackerID, attackerDefID, attackerTeam)
		if weaponDefID == -1 then
			return 0
		end
	end
Works correctly, but whever the debris hits, infolog prints this:
InfoLog wrote:[f=0000712] Warning: UnitPreDamaged(): 1st value returned should be a number (newDamage)
As I said it works correctly, but this spammy bit kinda sucks.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: How to control amount of damage done by flying debris?

Post by knorke »

Code: Select all

function gadget:UnitPreDamaged(unitID, unitDefID, unitTeam, damage, paralyzer, weaponDefID, attackerID, attackerDefID, attackerTeam)
      if weaponDefID and weaponDefID == -1 then
         return 0
      end
return damage
   end

User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to control amount of damage done by flying debris?

Post by Forboding Angel »

That's it? Derp. Thanks.

Could you explain why for the not-so-learned in the room (aka, me)? Well I suppose what I mean is, why is that necessary? Is this common as in something that is done often or is this a special case for one reason or another?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: How to control amount of damage done by flying debris?

Post by knorke »

That's it?
acuelly is untested but something like that.

when there is no return, function returns nil.
nil isnt a number, so instead just pass old damage.
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: How to control amount of damage done by flying debris?

Post by Forboding Angel »

Oh. That was a lot less complicated that I thought it would be. Thanks for the help and explanation.
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

Re: How to control amount of damage done by flying debris?

Post by zwzsg »

The odd thing is, I've seen some other gadgets using the UnitPreDamaged callins, that don't retun anything explicitely in most case, and yet they didn't cause that warning.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: How to control amount of damage done by flying debris?

Post by knorke »

yes, me too but maybe was confusion with UnitDamaged.
also there is paralyzer, maybe return that too.

Code: Select all

return damage, paralyzer
Post Reply

Return to “Game Development”