OpenXcom Forum

Contributions => Programming => Topic started by: Meridian on August 12, 2014, 04:28:16 pm

Title: [Missing feature?] Base Defences - Damage range
Post by: Meridian on August 12, 2014, 04:28:16 pm
Hello,

reading the code (BaseDefenseState.cpp, line 190), I didn't find any range for the damage of base defence facilities.

I am also not sure if the range is 50-150% or 0-200% (in the original xcom). If someone knows, please post it here. If nobody knows, I will try to make a patch, which takes the value from the TFTDDamage configuration setting.

Or, if somebody would like to implement it instead of me, feel free.

UPDATE: pull request is here: https://github.com/SupSuper/OpenXcom/pull/937

Regards,
Meridian

PS: more info here: https://www.ufopaedia.org/index.php?title=Talk:Base_Defense_Measures
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: moriarty on August 12, 2014, 09:47:30 pm
I'm not sure the base defense damage follows the same rules as the battlescape damage... AFAIK, it was never clear if it does so in the original.

What does Warboy say? I think there is nobody who knows the original game code better than him.

For that matter, what about craft weapon damage?
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Warboy1982 on August 13, 2014, 02:48:31 am
i wasn't as intimate with the game code when i made the base defence screen, so there may indeed be inconsistencies. i'll have a dig around and see what i come up with.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: chi.code on August 17, 2014, 05:26:15 am

Base defence always seemed quite useless to me, either you 100% won by repelling the UFO, or you are playing normal battle.
So why invest in defences, I will have to have a squadron there anyway.

How about adding an option so that damage done during air-defence phase results in less and/or wounded alien troops (but same loot), would it make sense (as mod or adv option)?
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Solarius Scorch on August 17, 2014, 01:50:01 pm
How about adding an option so that damage done during air-defence phase results in less and/or wounded alien troops (but same loot), would it make sense (as mod or adv option)?

There was an XComUtil option which did this. It was useful.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Dioxine on August 18, 2014, 05:39:03 pm
Same loot as from undamaged UFO sounds cheaty-cheaty, please play nice :)

But +1 in general (It was tackled in greater detail here: https://openxcom.org/forum/index.php?topic=2780.0 )
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Meridian on August 20, 2014, 09:17:50 pm
I'm not sure the base defense damage follows the same rules as the battlescape damage... AFAIK, it was never clear if it does so in the original.

What does Warboy say? I think there is nobody who knows the original game code better than him.

For that matter, what about craft weapon damage?

Craft weapon damage is already randomized.
(50-100% when XCOM shoots at UFO; 0-100% when UFO shoots at XCOM)
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Warboy1982 on August 23, 2014, 09:38:51 pm
all sorted.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Meridian on August 24, 2014, 07:58:37 am
all sorted.

Thanks.
So the original had 50-150%?
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: neube on August 24, 2014, 03:14:52 pm
For that matter, what about craft weapon damage?

Craft weapon damage is already randomized.
(50-100% when XCOM shoots at UFO; 0-100% when UFO shoots at XCOM)

I'm not sure if Moriarty meant what Meridian answered to, but maybe this:

What about the damage the Battleship sustained before reaching the base defences? Shouldn't it stack with the base defences if my Avengers were just one shot short of getting it cooked?

And, for that matter, does the UFO damage taken actually carry over between fights with different X-Com craft (supposing the fight was not of the 2+ vs 1 minimise-until-simultaneous type?)?
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Solarius Scorch on August 24, 2014, 04:23:34 pm
And, for that matter, does the UFO damage taken actually carry over between fights with different X-Com craft (supposing the fight was not of the 2+ vs 1 minimise-until-simultaneous type?)?

Yes. I damaged a Battleship over Europe and later downed it with a craft launched from a US base when the UFO approached it. It went down fast.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: neube on August 24, 2014, 04:43:07 pm
Does the damage sustained during a dogfight carry over to a base defence, though? If someone had a definite answer, that would be a good place to start doing the "less base-raid crew alive" mod ;).
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: RSSwizard on August 25, 2014, 12:16:34 am
Slightly off topic question but . . .
The Damage Randomization code . . .
Is it a straight linear roll or is it a "two dice" roll?


Original XCOM 1 always used a linear roll . . . Rand * (2 * Damage)

However TFTD used a double roll . . . Damage * (Rand + Rand)


So like if you have a Plasma Pistol it would do Rand * (52x2) possible damage, but if you used the TFTD method it would do (52 * Rand) + (52 * Rand).

This is the reason the damage values were usually so uniform in TFTD, it wasnt because it was restricted to 50-150% (though Explosion damage always was).


I very much like and prefer the double roll precision from TFTD and im wondering if thats what you guys are using from the "TFTD style" damage dice rolls.

If so is there any way to Mod this as a normal change without doing any kind of actual cpp coding?
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Meridian on August 25, 2014, 08:42:30 am
Slightly off topic question but . . . The Damage Randomization code . . .  Is it a straight linear roll or is it a "two dice" roll?

I very much like and prefer the double roll precision from TFTD and im wondering if thats what you guys are using from the "TFTD style" damage dice rolls.
If so is there any way to Mod this as a normal change without doing any kind of actual cpp coding?

It's a single roll:
1. Firing guns:
  int dmgRng = Options::TFTDDamage ? 50 : 100;
  int min = power * (100 - dmgRng) / 100;
  int max = power * (100 + dmgRng) / 100;
  const int rndPower = RNG::generate(min, max);
2. Firing craft weapons:
a) xcom
  int damage = RNG::generate(p->getDamage() / 2, p->getDamage());
b) aliens
  int damage = RNG::generate(0, _ufo->getRules()->getWeaponPower());
3. Firing base defences:
  _ufo->setDamage(_ufo->getDamage() + (dmg / 2 + RNG::generate(0, dmg)));

Can't be modded afaik, requires some coding first...
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: moriarty on August 26, 2014, 10:07:53 am
Slightly off topic question but . . .
The Damage Randomization code . . .
Is it a straight linear roll or is it a "two dice" roll?


Original XCOM 1 always used a linear roll . . . Rand * (2 * Damage)

However TFTD used a double roll . . . Damage * (Rand + Rand)


So like if you have a Plasma Pistol it would do Rand * (52x2) possible damage, but if you used the TFTD method it would do (52 * Rand) + (52 * Rand).

This is the reason the damage values were usually so uniform in TFTD, it wasnt because it was restricted to 50-150% (though Explosion damage always was).


I very much like and prefer the double roll precision from TFTD and im wondering if thats what you guys are using from the "TFTD style" damage dice rolls.

If so is there any way to Mod this as a normal change without doing any kind of actual cpp coding?

Do you mean for craft damage? I don't know about that, but for weapon damage there's the "TFTD damage rules" advanced option that does exactly what you want.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Meridian on August 26, 2014, 01:17:51 pm
Do you mean for craft damage? I don't know about that, but for weapon damage there's the "TFTD damage rules" advanced option that does exactly what you want.

He meant damage in general (all types).

The "TFTD damage rule" does NOT do exactly what he wants. It changes the damage range, but it is still a "single roll", not "double roll"... as illustrated by the code snippets I have posted earlier.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Falko on August 26, 2014, 01:39:35 pm
should be easy enough to change IMHO
but are there any sources for the double dice calculation?
from https://www.ufopaedia.org/index.php?title=Damage
Quote
Random Weapon Range
    This is the random number roll that alters how much damage is to be dealt. For EU firearms, a value between 0% and 200% is rolled, while TFTD weapons and EU explosives will perform a 50% to 150% roll. However in TFTD, damage from all sources has been equalized to 50-150%.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Meridian on August 26, 2014, 05:16:44 pm
should be easy enough to change IMHO
but are there any sources for the double dice calculation?
from https://www.ufopaedia.org/index.php?title=Damage

I don't know if there are any sources... I don't even know if TFTD is really doing "double roll" or not... I guess RSSwizard should answer this question... i.e. from where he has this information.
(I have only answered that OpenXcom is not doing "double roll" anywhere at the moment)

And yes, it is easy to change... once it is confirmed.
Title: Re: [Missing feature?] Base Defences - Damage range
Post by: Dioxine on August 26, 2014, 05:17:55 pm
"Double dice" basically means a Gaussian curve; 0-200% damage with a gaussian curve would indeed yield more predictable results... but I'm not sure if that makes for a better gameplay, i like my rnd :) Certainly it is a much better solution that single-dice 50-150%, though. afaik all dice rolls use simple (rnd) function.