OpenXcom Forum

OpenXcom Forks => OpenXcom Extended (OXCE) => OXCE Suggestions DONE => Topic started by: Nord on July 23, 2024, 06:32:54 pm

Title: [DONE][Suggestion] Power bonuses from firearm instead of ammo
Post by: Nord on July 23, 2024, 06:32:54 pm
I think that "damageBonus" must work when described in weapon definition. If clip have it too, then gun one must prevale.

In fact, it will be great to have overwriting for "power", so a special weapon using standart ammo can make more (or less) damage.

But "damageBonus" for clip seems unnecessary, while for weapon - logical.
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Meridian on July 23, 2024, 06:50:22 pm
Whether it is logical or not is arguable, I don't have any strong preference or opinion.

The fact however is that all such attributes currently work in a way that ammo attribute has a bigger priority than the weapon attribute.
Simply changing this (to work the other way around) would break existing mods.
If there is a different/better solution, I don't know.
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Delian on July 23, 2024, 07:21:26 pm
powerBonus is used on crafts. damageBonus is used on items.

In real life, all the power comes from the bullet, because bullet contains the chemicals that produce the power to propel the bullet. The gun doesn't produce any power.

In general, I disagree with this suggestion, because you can already write a yscript that changes damage based on what gun and ammo is used. There's also other possible solutions, for instance, simply have a stronger weapon use stronger ammo. Or don't have the weapon use an ammo item at all, in which case the power will only come from the weapon.
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Juku121 on July 23, 2024, 09:37:55 pm
In real life, all the power comes from the bullet, because bullet contains the chemicals that produce the power to propel the bullet. The gun doesn't produce any power.
Rifling, and generally long barrels; chamber and bore sizes, etc disagree. While the power is due to the round itself, the weapon can magnify that power, and not trivially. Otherwise, everyone would saw off their rifle barrels and go with less clumsy, more carry-convenient guns.


One solution would be to give weapons an attribute that allows them to modify round power, by either replacing, multiplying or flat addition to the ammo's value. I suppose it's already possible via y-scripts, though?
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Yankes on July 23, 2024, 10:17:39 pm
Rifling, and generally long barrels; chamber and bore sizes, etc disagree. While the power is due to the round itself, the weapon can magnify that power, and not trivially. Otherwise, everyone would saw off their rifle barrels and go with less clumsy, more carry-convenient guns.


One solution would be to give weapons an attribute that allows them to modify round power, by either replacing, multiplying or flat addition to the ammo's value. I suppose it's already possible via y-scripts, though?
Yes you can easy make global script that will multiply bullet power bonus based on "barrel".

If I recall correctly, script hook should be named `damageBonusBonusStats`.
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Nord on July 23, 2024, 10:25:12 pm
...
Simply changing this (to work the other way around) would break existing mods.
...
Yes, that's problem. Maybe flag-parameter in "vars" can do? Like "GunOverAmmo: true" will set gun in priority and vice versa.
powerBonus is used on crafts. damageBonus is used on items.
Oh, thanks. It's a typo, of course.

Quote
In general, I disagree with this suggestion, because you can already write a yscript that changes damage based on what gun and ammo is used.
It is possible, but will misguide player, as this changes not show changed damage in Ufopedia (sadly, almost no one really reads texts)
One solution would be to give weapons an attribute that allows them to modify round power, by either replacing, multiplying or flat addition to the ammo's value. I suppose it's already possible via y-scripts, though?
Yes, but "damageBonus" looks just as what you saying. For "power" defining ammo strength, and "Bonus" defining gun special properties, like barrel, etc.
In fact, i always thinked that it is just like so, and only today catched my mod working not as i expect. (right when debugging scripted power bonuses)
...
If I recall correctly, script hook should be named `damageBonusBonusStats`.
But will it show bonus in Ufopedia?
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Juku121 on July 23, 2024, 11:11:02 pm
But will it show bonus in Ufopedia?
Well, no, but a) perhaps one can also hook up the pedia 'power' stat to y-scripts? And b) you can make a fictional gun with whatever values for pedia display. Decouple it from ammo, too, if you wish. 
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Nord on July 23, 2024, 11:41:29 pm
a) doubt.
b) if nothing else, yes.

As an example of what i try to do, i want to make an universal battery for energy weapons, that will provide,  lets say, 33 shots for pistol, 25 for rifle and 20 for cannon, while each of this weapon have different damage.
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Nord on July 27, 2024, 12:39:38 pm
Will be great if "powerRangeThreshold" and "powerRangeReduction" will work in same manner too.
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Meridian on September 22, 2024, 09:24:31 pm
I'll check this next week.
Title: Re: [Suggestion] Power bonus for gun, not clip.
Post by: Finnik on September 27, 2024, 08:25:15 am
The good solution here is using y-scripts. I have 2 guns using same ammo, but one of those gun has greater power due to its longer barrel. Can be done with hitUnit script hook
Title: Re: [DONE][Suggestion] Power bonuses from firearm instead of ammo
Post by: Meridian on September 28, 2024, 07:39:39 pm
Done.

All weapons except firearms with ammo (incl. HWP weapons) remain unaffected:
- gunbutts: `meleePower` and `meleeBonus` unaffected
- environmentalCondition `weaponOrAmmo` items unaffected
- pre-battle explosions unaffected
- self-destruct power on corpses unaffected
- glow range on flares unaffected
- AI psi stuff unaffected


Power (`power`), power bonus (`damageBonus`), and power range reduction (`powerRangeReduction` and `powerRangeThreshold`) are affected.

All other attributes are unaffected, including:
- explosion radius unaffected... so make sure it is correctly defined by ammo power, power bonus, radius effectiveness, fixradius, fireblastcalc and other attributes
- damage type unaffected... so make sure it is correctly defined by ammo damage type
- and so on...

Ufopedia power and power bonus display updated.
Damage preview in Inventory updated.
Damage preview on crosshair updated.

Sample ruleset:

Code: [Select]
extraNerdyPediaInfoType: 2
items:
  - type: STR_HEAVY_CANNON
    ignoreAmmoPower: true     # default false
    power: 7
    damageBonus:
      flatHundred: 0.2

  - type: STR_TANK_ROCKET_LAUNCHER
    ignoreAmmoPower: true
    power: 42
Title: Re: [DONE][Suggestion] Power bonuses from firearm instead of ammo
Post by: Nord on September 29, 2024, 02:01:07 am
Oh, this is just wonderful. Thank you very much.