OpenXcom Forum
Modding => Help => Topic started by: The Martian 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 (https://www.ufopaedia.org/index.php/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."
-
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.
-
when you changed it to a blast radius weapon you probably forgot to adjust the hitSprite
-
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:
hitAnimation: 0
I'll edit my OP (https://openxcom.org/forum/index.php/topic,5887.msg90563.html#msg90563) 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?
-
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 (https://openxcom.org/forum/index.php/topic,4834.msg69314.html#msg69314), 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.
-
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.
-
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.
-
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. >_>
-
All mods will still work with this code.
-
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! (https://openxcom.org/forum/Themes/InsidiousV1-k/images/post/thumbup.gif)
-
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 _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?
-
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.