Author Topic: How hard would it be to . . variable weapon damage  (Read 5443 times)

0 Members and 1 Guest are viewing this topic.

How hard would it be to . . variable weapon damage
I'm wondering, some universes have lasers and the like whose damage decreases with range. How hard or not hard would it be to implement something like that?

I was thinking like a . . . percentage modifier or something, say in milliseconds or seconds where each second the damage is modified by that amount.

So if something had like
Lifetime: 2.0
Velocity: 500
Damage: 100
*Damage Mult(per second): 0.45

     After one second of lifetime, and at 500 metres it would only do 55 damage. At the extreme range of around 1000 metres it would only do 10 damage. Or would it be . .. 25ish damage, hmmn. Anyway, not sure how much use their would be in Freespace but it might make some interesting weapons. One could even either give a negative mofier (-0.45) or depending how it worked, maybe like (1.45) and the weapon damage would actually increase so it dealt more damage at range and very little in close.

 

Offline Mobius

  • Back where he started
  • 213
  • Porto l'azzurro Dolce Stil Novo nella fantascienza
    • Skype
    • Twitter
    • The Lightblue Ribbon | Cultural Project
Re: How hard would it be to . . variable weapon damage
Hey, I like this idea...I'd really like to see the effects of such feature on the Maxim...
The Lightblue Ribbon

Inferno: Nostos - Alliance
Series Resurrecta: {{FS Wiki Portal}} -  Gehenna's Gate - The Spirit of Ptah - Serendipity (WIP) - <REDACTED> (WIP)
FreeSpace Campaign Restoration Project
A tribute to FreeSpace in my book: Riflessioni dall'Infinito
My interviews: [ 1 ] - [ 2 ] - [ 3 ]

 
Re: How hard would it be to . . variable weapon damage
The WC team outta have something like this with their Particle cannon
Fun while it lasted.

Then bitter.

 

Offline colecampbell666

  • I See Dead Pictures
  • 212
  • Evolution and ascension.
Re: How hard would it be to . . variable weapon damage
And also, have each shot do slightly different damage.

First problem would be easy.

if distance = x-y
       decrease damage z%

Second, just add a variable of 2-5% or something.
Gettin' back to dodgin' lasers.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: How hard would it be to . . variable weapon damage
Excellent! Have a diff for me by the end of the week and I'll see about getting it commited.

The SCP team leave this idea entirely in colecampbell's hands. Shout at him and not us if it isn't implemented.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline colecampbell666

  • I See Dead Pictures
  • 212
  • Evolution and ascension.
Re: How hard would it be to . . variable weapon damage
I can't code, I'm just throwing ideas out. Christ...
Gettin' back to dodgin' lasers.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: How hard would it be to . . variable weapon damage
Then don't patronise those of us who can code by telling us it's easy when you don't really have any idea. There is very little that annoys some of the coders on the team than that.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline colecampbell666

  • I See Dead Pictures
  • 212
  • Evolution and ascension.
Re: How hard would it be to . . variable weapon damage
Sorry.
Gettin' back to dodgin' lasers.

 

Offline Solatar

  • 211
Re: How hard would it be to . . variable weapon damage
First, let it be known...I do not claim this is easy...

Any of the coders want to chime in about how this might/could be done? Could a hackish solution be put in place where when damage is calculated it multiplies $damage by $armor, $shield, or $subsystem and then optionally multiplies it by a random number generated between two extremes? or something...(this would be for the random damage multiplier)

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: How hard would it be to . . variable weapon damage
Code: [Select]
[quote author=Solatar link=topic=53785.msg1087780#msg1087780 date=1210551159]Any of the coders want to chime in about how this might/could be done?[/quote]

Absolutely. Yes, it would be pretty easy. Karajorma should not be harassing cole or presuming to speak for the entire team.

In weapon.h:
[code]float damage_per_second;

In weapon.cpp:
Code: [Select]
if(optional_string("$Damage Per Second:")) {
stuff_float(&wip->damage_per_second);
}


Wherever damage is applied, you change
Code: [Select]
wip->damage
to
Code: [Select]
wip->damage+((float)(timestamp()-wp->creation_time)/1000.0f)*wip->damage_per_second;
There's more future-oriented ways of doing it, but that's the minimum. Oh, and you need to init the dps var to 0 when you init the weapon_info struct:

Code: [Select]
wip->damage_per_second = 0.0f;[/code]
« Last Edit: May 11, 2008, 11:10:13 pm by WMCoolmon »
-C

 

Offline Backslash

  • 29
  • Bring Our Might To Bear
Re: How hard would it be to . . variable weapon damage
I did some work on this a few months ago, actually mostly to do with beams, but the concept could probably be migrated without too much trouble.

With beams this was once upon a time implemented as +Attenuation.  Time was irrelevant since beams get there instantly, so distance was the factor.  Apparently Attenuation no longer works in the code, but I'm working on fixing and expanding it.  So!  This is how it would work.  Let's call the Attenuation value in the table N for short.
If N is 0, the beam behaves as it does now... no change in damage at all.
If N is 1, the beam starts out at full damage, and ramps down until at maximum range it is zero damage.
If N is between 0 and 1, the beam starts out at full damage, and then at N*range it begins ramping down until at maximum range it is zero damage.

With me so far?  Now let's add a crazy additional twist!
If N is -1, the beam starts out at ZERO damage, and ramps up until at maximum range it is at maximum damage.
If N is between -1 and 0, the beam starts out at zero damage, and ramps up until at N*range it hits maximum damage, and remains maximum damage until maximum range.

Does that make sense?  Would you like me to post the graphs I made?

I've got this nearly finished for beams, just need more testing to make sure I did the maths right.  After that it is only a matter of applying the changes to non-beam weapons (and adding the setting since before only beams had +Attenuation)... give me a week or two.

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: How hard would it be to . . variable weapon damage
Absolutely. Yes, it would be pretty easy. Karajorma should not be harassing cole or presuming to speak for the entire team.

Ah but it solves two problems if I do.

1. It stops people posting annoying "It's easy" comments
2. People crawl out of the woodwork to prove it's easy and code features that otherwise they would have ignored in order to prove me wrong. This is exactly why I did the same thing the last time someone said a feature was easy. :p
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
Re: How hard would it be to . . variable weapon damage
1. It stops people posting annoying "It's easy" comments

It also cuts down on the flow of ideas, and alienates people who try to be helpful.

2. People crawl out of the woodwork to prove it's easy and code features that otherwise they would have ignored in order to prove me wrong. This is exactly why I did the same thing the last time someone said a feature was easy. :p

I've got a broken hand right now. You'll pardon me if I'm not thrilled to hear that I just wasted my time because you wanted to be a lazy jackass.
-C

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: How hard would it be to . . variable weapon damage
1. It stops people posting annoying "It's easy" comments

It also cuts down on the flow of ideas, and alienates people who try to be helpful.

Posting "It's easy" contributes nothing. It's just post count +1. Unless someone has looked at the code they are in no position to comment on how easy a feature is to add because often easy sounding ideas turn out to be incredibly difficult to actually add.

And cole has been here long enough that he should be aware of that fact.

Quote
I've got a broken hand right now. You'll pardon me if I'm not thrilled to hear that I just wasted my time because you wanted to be a lazy jackass.

Nowt to do with me. I had no idea that Backslash was already working on something similar. If you decided to implement the code without checking if another coder was already doing something similar that's not my fault. If you decided to implement the code with your broken hand just to rub my nose in how easy it actually is then it sucks to be you but again is your fault.

Simple fact is that certain people here on HLP won't respond to a help request even when asked repeatedly (Wanderer for instance has been asking about that paging in question for days) but would crawl over broken glass with their flies unzipped to prove someone wrong. If you were foolish enough to be the latter then maybe you should ask yourself why it mattered to you so much.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Backslash

  • 29
  • Bring Our Might To Bear
Re: How hard would it be to . . variable weapon damage
Technically in cole's case he was only saying the math was easy.  Really though, I'd like to encourage the thinking things through ... there's a big difference between a noob going "lol curved beamz is easy why isn't it done yet" (and yes, I hate that), vs somebody posting "the concept seems easy, here's the maths I came up with".

Even us coders (well, at least me ;)) can think something is easy before really looking into it.

...as for the help requests, no idea where everyone else is this week, seems quieter than usual.  RL does come up from time to time I guess.  I knew nothing about the question so didn't answer...

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: How hard would it be to . . variable weapon damage
Technically in cole's case he was only saying the math was easy.  Really though, I'd like to encourage the thinking things through ... there's a big difference between a noob going "lol curved beamz is easy why isn't it done yet" (and yes, I hate that), vs somebody posting "the concept seems easy, here's the maths I came up with".

The maths in this case though was towards the easier end of the scale. I'd be worried if the coder who handled the request couldn't come up with the maths to do it. Had it involved trig or tensors or something that would be much more valid.


That said there are other considerations that haven't been mentioned. For instance suppose you have something like the maxim fired by AI fighters at something the player is close to. The weapons hit, set off a big impact effect and then do no visible damage because the damage has attenuated away to next to nothing. That's going to look mighty odd.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline colecampbell666

  • I See Dead Pictures
  • 212
  • Evolution and ascension.
Re: How hard would it be to . . variable weapon damage
And cole has been here long enough that he should be aware of that fact.
Actually, I've never seen that before. I've seen one person post "it's easy" and they were left alone.
Gettin' back to dodgin' lasers.

 

Offline Wanderer

  • Wiki Warrior
  • 211
  • Mostly harmless
Re: How hard would it be to . . variable weapon damage
Varied damage might be something worth considering... Sorta like adjusting damage to 'simulate' a chance hit to a vulnerable spot... Sorta like ye good olde RPGs do it (with criticals) :P

I could even write it but as it seems like my diffs have snowballs chance in hell to get into SVN anytime soon i doubt i bother to do it
Do not meddle in the affairs of coders for they are soggy and hard to light

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Re: How hard would it be to . . variable weapon damage
Having the environment cause damage attenuation itself is also worth considering. For instance in atmospheric missions a ballistic weapon could be expected to suffer from attenuation while in space the same weapon wouldn't be affected.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline blowfish

  • 211
  • Join the cult of KILL MY ROUTER!!!!!!!!!!1
Re: How hard would it be to . . variable weapon damage
And cole has been here long enough that he should be aware of that fact.
Actually, I've never seen that before. I've seen one person post "it's easy" and they were left alone.

Who was that person?

I know that I don't speak for the team, but personally I think it is ok for someone to say that something is relatively easy if they know how to code and have actually looked at the source to determine whether adding that feature is, in fact, easy.  Though at that point they might as well code it themself.