View topic - [patch] dynamic damage based on range



All times are UTC + 1 hour


Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: 26 Mar 2007, 04:09 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
I thought this was a useful feature so I've made my first patch with some help from FLOZi.

It adds four new TDF tags, dynDamageExp, dynDamageMin, dynDamageInverted and dynDamageRange.

dynDamageExp=0 / >0
Exponent of the damage formula, 0 disables dynamic damage.
Defaults to 0. 1 means linear scaling.

edit:
dynDamageMin = 0 / >0
Minimum damage value. Disabled when set to 0.
ex: firstDamageValue = 500, dynDamageMin = 100, modifier will be 1/5

dynDamageInverted = 0 / 1
Inverts the curve (or line).

edit:
dynDamageRange = 0 / >0
If set it will use this value instead of the range value from the weapon in the calculation.

Formulas:
Damage = (1 - (1 / WeaponRange * TraveledDistance)^Exp * OrigDamage
Damage = OrigDamage - (1 - (1 / WeaponRange * TraveledDistance)^Exp * OrigDamage (inverted)

Graph:
Image
(clicky for a bigger picture)
x = distance, y = damage.
Red's the inverted one. This is with an exponent of 2.


Patch:
http://rattle.from-hell.net/spring/patc ... atch.patch

If there are any issues such as ugly code tell me. There are some problems left in when using an inverted curve. When a weapon is fired from maximum range it should do ~100% damage. Instead it was doing only ~77%. No idea why...


Last edited by rattle on 29 Mar 2007, 11:12, edited 2 times in total.

Top
 Offline Profile  
 
 Post subject:
PostPosted: 26 Mar 2007, 04:21 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
I still think it would be better to make local copies of the damage array in the weapon itself rather than altering defs which should remain static... even if it means extra work. :wink:


Top
 Offline Profile  
 
 Post subject:
PostPosted: 26 Mar 2007, 11:00 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
It's not a big deal to change that, however as I pointed out the damages array direclty affects everything which is related to damage (size of scars, size of muzzle flares, etc.). I am working with the original values, this is why I added a backup array.

Does anyone else think that this is bad idea?

edit: Hmm it seems that this doesn't work with beam lasers. :(


Top
 Offline Profile  
 
 Post subject:
PostPosted: 26 Mar 2007, 17:08 
Malcontent
User avatar

Joined: 27 Feb 2006, 22:04
Location: Hurrrrrr.
Nothing works with beam lasers >_>


Top
 Offline Profile  
 
 Post subject:
PostPosted: 26 Mar 2007, 17:43 
Game Developer
User avatar

Joined: 25 Jun 2006, 07:44
Location: Germany
Yeah, we're already used to that.


Top
 Offline Profile  
 
 Post subject:
PostPosted: 26 Mar 2007, 20:29 
User avatar

Joined: 04 May 2005, 14:09
Location: St. Paul, Minnesota, US (#64 at press time)
there should also be one like 10 - (10x)^(1/2) for if you want it to drop off quickly and then slowly.


Top
 Offline Profile  
 
 Post subject:
PostPosted: 26 Mar 2007, 22:03 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
I'm being stupid again, I've tested this on XTA's annihilator weapon, that's what I thought at least. I edited the wrong weapon in the end because of XTA's stupid naming system. :P

So nothing's wrong (I hope).


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 11:31 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
Still this doesn't get applied to beamlasers. Could someone tell me what method is called for beam lasers to do damage?


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 13:14 
Moderator

Joined: 22 Aug 2006, 15:19
Bonus points for making the tag accept arbitrary expressions in RPN, additional secret bonus for making it accept infix expressions, kudos for JITting them :)


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 20:33 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Suggestion:

Add another tag, dynDamageRange, which is used in the calculation. Default is weapon range. This improves the flexibility of the curves we can produce quite considerably.


Also, just checking, is the damage value automatically clamped after exceeding max range of the weapon? (to prevent -ve damages)


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 21:39 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
TraveledRange is limited to weaponDef->range, the damage would go into the negatives I think. I'll add the additional range tag.


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 21:46 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
I was going to suggest you always clamp it to dynDamageMin, meaning you can't deal -ve damage.


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 21:57 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
It is if dynDamageMin is defined.

Code:
if (weaponDef->dynDamageMin > 0)
   dynDamages[i] = max(weaponDef->damages[i] * weaponDef->dynDamageMin, dynDamages[i]);


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 22:06 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
I know, but i mean always do it - dynDamageMin defaults to 0, so if its not set otherwise the damage is clamped to 0, preventing issues with dealing -ve damage. :wink:


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 22:16 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
Hmm... what's -ve damage? :?
It's limited to "0" damage by default.
Code:
dynDamages[i] = max(0.0001f, dynDamages[i]);


If it ever goes into the negatives it will be 0.0001 anyway.


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 22:37 
Modeler
User avatar

Joined: 28 Apr 2005, 20:07
Location: Next to the girl with kaleidascope eyes
rattle wrote:
Hmm... what's -ve damage? :?


shortform for negative I belive


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 22:37 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
-ve = negative

And ok, was just checking. :-)


Top
 Offline Profile  
 
 Post subject:
PostPosted: 27 Mar 2007, 22:38 
Damned Developer
User avatar

Joined: 01 Jun 2006, 12:15
Location: Banned user for reason “Do not post pictures of people fucking cars”
That's good, I tend to forget things...


Top
 Offline Profile  
 
 Post subject:
PostPosted: 28 Mar 2007, 02:23 
Moderator
User avatar

Joined: 29 Apr 2005, 00:14
Location: #moddev - join it!
Damn, I totally missed this before - dynDamageMin might (would be for me, anyway) be better off as an integer value rather than a %... Simpler to calculate a % of the original damage as an integer than to calculate an integer as a % of the original, well, not exactly, but its juist nicer, to me, anyway. </rambling>

That's why i was suggesting what i was suggesting before, hadn't read it closely enough. :oops:

edit: also, could you upload the latest .patch for me to look over? :-)


Top
 Offline Profile  
 
 Post subject:
PostPosted: 28 Mar 2007, 03:52 
User avatar

Joined: 24 Oct 2006, 12:45
Location: Nebraska
This is a product of range and not flight-time, so high arc weapons won't be probably the best to use with this tag. Or am I missing something?

The first thought I had when reading about these new tags was for perhaps tank-vs-tank and battleship-vs-battleship duels. I like the inverse curve especially in that case.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 33 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.