Author Topic: A few questions about the use of shotgunPellets:  (Read 5380 times)

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
A few questions about the use of shotgunPellets:
« on: December 17, 2017, 12:43:28 pm »
I've been trying to create new equipment using the shotgunPellets: variable and have a few questions about how it operates.


(Question): By default shotgunPellets: has a value of 0.  Does giving this variable a value of 2 fire only two bullets or three?
(Answer): shotgunPellets: 2 fires only two bullets,  not two pellets in addition to the default bullet being fired by the weapon.


(Question): If the weapon has shotgunPellets: 5 but the ammo loaded into the weapon does not use the shotgunPellets: variable, will the ammo now fire multiple bullets?
(Answer): The shotgunPellets: variable on a weapon is overridden by that variable on that weapon's ammo, so the answer is that a weapon with shotgunPellets: will not cause standard ammo to fire multiple projectiles.


(Question): Do shotgunPellets: consume additional ammunition for each pellet fired?
(Answer): Regardless of how many pellets are fired, each shot only takes 1 unit of that weapon's ammo.


(Question): If the weapon/ammo type has a blastRadius: and is also using shotgunPellets: will each pellet produce an explosion where they hit?
(Answer): Each pellet does create an explosion at the impact location.
(Note): Make sure to set hitAnimation: to 0 so that the default explosion animation from X1.PCK is used.


(Question):  It appears shotgunPellets: are unaffected by the accuracyAimed: variable. Behaving the same at accuracyAimed: 60 as they do at 1000. Is there a way to control how far the pellets spread out when fired?
(Answer): The pellet spread behavior is automatically calculated using this method: "It's a linear dropoff of 5% per pellet applied sequentially, so one pellet is at 100% accuracy, one is 95%, one is 90% and so on until it bottoms out."
« Last Edit: December 21, 2017, 01:02:10 pm by The Martian »

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #1 on: December 20, 2017, 09:08:58 am »
Neat.



So the answer appears to be that unfortunately OpenXcom does not support explosive shotgunPellets: . . . or that I've coded this wrong.

It works fine in my tests. Make sure you're using an explosive damage type (2-incendiary, 3-explosive, 6-stun, 9-smoke). Because of the low amount of spread, it's difficult to tell it's shooting out multiple pellets, however the instant hit looks very cool. It also makes a very low accuracy shot into a pretty high accuracy shot.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #2 on: December 20, 2017, 10:52:05 am »
when you changed it to a blast radius weapon you probably forgot to adjust the hitSprite

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #3 on: December 21, 2017, 02:58:11 am »
when you changed it to a blast radius weapon you probably forgot to adjust the hitSprite

Thank you!  ^_^

That is exactly what my mistake was, after changing this code it now functions correctly:
Code: [Select]
    hitAnimation: 0
I'll edit my OP with the correct solution.

. . . it's difficult to tell it's shooting out multiple pellets, however the instant hit looks very cool. . .
Agreed, I'm eager to explore the potential of what kinds of equipment this can create.



( I have an additional question about the operation of shotgunPellets: )


(Question):  It appears shotgunPellets: are unaffected by the accuracyAimed: variable. Behaving the same at accuracyAimed: 60 as they do at 1000. Is there a way to control how far the pellets spread out when fired?

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #4 on: December 21, 2017, 05:25:34 am »
When using shotgunPellets, each individual shot is treated as an autoshot that skips its animation, but with one important change - each pellet is fired with less accuracy than the previous one to simulate spread. However, the amount of accuracy that each pellet loses is large, making it nearly an aimed shot + a 0% autoshot of the extra pellets. So with that 1000% accuracy, you're very likely to get one hit, but the rest are mostly luck.

If you use OXCE+, I wrote some code to configure this behavior , in order to make shotguns feel much more realistic. Both Piratez and X-Com Files make extensive use of it, if you want to see some examples in action.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #5 on: December 21, 2017, 06:15:31 am »
However, the amount of accuracy that each pellet loses is large, making it nearly an aimed shot + a 0% autoshot of the extra pellets.

not quite, it's a linear dropoff of 5% per pellet applied sequentially, so one pellet is at 100% accuracy, one is 95%, one is 90% and so on until it bottoms out.
i should probably add some random element to the dropoff or ruleset it or both.

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: A few questions about the use of shotgunPellets:
« Reply #6 on: December 21, 2017, 12:22:28 pm »
i should probably add some random element to the dropoff or ruleset it or both.

If you are planning to expand this part, why not just use OXCE+ version?  It has been very thoroughly tested and works perfectly.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #7 on: December 21, 2017, 12:56:06 pm »
it's a linear dropoff of 5% per pellet applied sequentially, so one pellet is at 100% accuracy, one is 95%, one is 90% and so on until it bottoms out.
Thank you for the information! ^_^

If you are planning to expand this part, why not just use OXCE+ version?  It has been very thoroughly tested and works perfectly.

If you use Ohartenstein23's excellent looking shotgun code please keep the current shotgun method as a togglable option. (From what I've read I believe shotgunBehavior: already controls this in OXCE+)

In my opinion it would be a shame not to have the option to play previously created Mods that use the current 5% linear dropoff method in their original state.

Just a thought. >_>
« Last Edit: December 21, 2017, 01:06:00 pm by The Martian »

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11408
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: A few questions about the use of shotgunPellets:
« Reply #8 on: December 21, 2017, 01:10:27 pm »
All mods will still work with this code.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #9 on: December 21, 2017, 01:36:54 pm »
The ability for all of the pellets to hit the same tile 100% of the time alone would be pretty useful.

Both shotgunSpread: and shotgunChoke: variables add a huge amount of customization and flexibility when creating multi-projectile weapons.

I would really like to see this feature added to standard
OpenXcom if possible.

All mods will still work with this code.
Excellent! 

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #10 on: December 21, 2017, 03:01:27 pm »
not quite, it's a linear dropoff of 5% per pellet applied sequentially, so one pellet is at 100% accuracy, one is 95%, one is 90% and so on until it bottoms out.
i should probably add some random element to the dropoff or ruleset it or both.

From reading ProjectileFlyBState, you have
Code: [Select]
_unit->getFiringAccuracy(_action.type, _action.weapon) / 100.0) - i * 5.0 - since you divide the firing accuracy by 100 here before subtracting the pellet number times 5, wouldn't that be -500% accuracy per pellet?

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: A few questions about the use of shotgunPellets:
« Reply #11 on: December 21, 2017, 08:32:38 pm »
seems you're right, that should be 0.05 for a 5% drop-off after normalization. but that being said it was an arbitrary number to begin with that i intended to tune to give me a decent spread. i got a decent spread to begin with, and never changed it.