Page 1 of 1

How to control amount of damage done by flying debris?

Posted: 20 Jul 2012, 05:34
by Forboding Angel
I'm pretty sure it's really simple, I just can't remember :-(

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

Posted: 20 Jul 2012, 08:22
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

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

Posted: 20 Jul 2012, 17:06
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).

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

Posted: 12 Aug 2012, 04:55
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.

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

Posted: 12 Aug 2012, 05:02
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


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

Posted: 12 Aug 2012, 05:11
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?

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

Posted: 12 Aug 2012, 05:17
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.

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

Posted: 12 Aug 2012, 05:24
by Forboding Angel
Oh. That was a lot less complicated that I thought it would be. Thanks for the help and explanation.

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

Posted: 12 Aug 2012, 14:52
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.

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

Posted: 13 Aug 2012, 21:11
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