aliens

Author Topic: [Documentation] Spray Waypoints Explanation  (Read 10400 times)

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
[Documentation] Spray Waypoints Explanation
« on: July 15, 2018, 12:09:57 am »
TL;DR: Hold CTRL+SHIFT while clicking to auto shot to spray and pray when it's enabled.

The newest release of OXCE+ includes a bit of code I wrote for "spray" autoshot attacks, and since it uses some keyboard shortcuts/mechanics not used anywhere else, I wanted to provide an explanation for how it works.  First off, under the hood the engine is using waypoints similar to those placed for firing a blaster bomb, then placing the shots from an autoshot attack spaced out evenly along this waypoint path as if you were able to separately click the firing position for each shot.  That attack looks like this:



The laser rifle from that demonstration has the following lines added to its ruleset:
Code: [Select]
items:
  - type: STR_LASER_RIFLE
    autoShots: 10
    sprayWaypoints: 2
In addition, once the auto shot is selected, I am holding the CTRL+SHIFT keys in order to start placing the waypoints; if I had not, the autoshot would have just fired all 10 shots at the first location clicked.  The second waypoint clicked did not need CTRL+SHIFT held as it automatically fires the attack when the maximum number of waypoints is reached.  If you have the confirm fire mode option turned on, then you will need to click one more time anywhere to start the attack.  As with the blaster bomb waypoints, right-clicking will remove the last one placed.

With this code, it is possible to have more than two waypoints:



The laser rifle from that demonstration has sprayWaypoints increased to 3 from 2.  As before, the attack automatically fires once I place the last waypoint.  If you'd rather stop before the last waypoint, holding CTRL+SHIFT while clicking to place the final waypoint that you desire will execute the attack with only that many waypoints.  In this example I stop at 2 waypoints even though 3 are available:



For modders: the default value of sprayWaypoints is 0, which means this behavior is disabled on that particular weapon.  In order to turn it on, you must give a weapon more than 0 sprayWaypoints.
« Last Edit: July 17, 2018, 12:44:33 pm by Meridian »

Offline SIMON BAILIE

  • Commander
  • *****
  • Posts: 672
    • View Profile
Re: Spray Waypoints Explanation
« Reply #1 on: July 15, 2018, 12:39:49 am »
Brilliant, this reminds of the full auto function for the heavy laser from ufo extender:

https://www.ufopaedia.org/index.php/UFOextender

ps: Will this work for TFTD as well?
« Last Edit: July 15, 2018, 12:41:40 am by SIMON »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: Spray Waypoints Explanation
« Reply #2 on: July 15, 2018, 01:23:09 am »
Yes, this will work for TFTD on any weapons that are modded to use it.

Offline SIMON BAILIE

  • Commander
  • *****
  • Posts: 672
    • View Profile
Re: Spray Waypoints Explanation
« Reply #3 on: July 15, 2018, 01:26:39 am »
Yep I wasn't sure so that'll be nice for say the gauss rifle.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #4 on: July 27, 2018, 02:17:50 pm »
I'm not able to use more than 2 waypoints. Even when the weapon is set to do more waypoints, as soon as the second waypoint is set, it begins firing.

Code: [Select]
  - type: STR_HEAVY_AUTO_LASER
    power: 75
    accuracyAuto: 70
    tuAuto: 78
    autoShots: 8
    sprayWaypoints: 3

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 8597
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #5 on: July 27, 2018, 02:21:55 pm »
I'm not able to use more than 2 waypoints. Even when the weapon is set to do more waypoints, as soon as the second waypoint is set, it begins firing.

1. Ctrl+Shift+click for first waypint
2. normal click for waypoints in the middle
3. Ctrl+Shift+click for last waypoint

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #6 on: July 27, 2018, 02:44:02 pm »
I'll add to that; you only need to CTRL+SHIFT+click for the first waypoint, the rest can just be normal click unless you want to end waypoint selection early.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #7 on: July 27, 2018, 03:22:50 pm »
Thanks. I was trying to hold ctrl+shift the whole time.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #8 on: August 08, 2018, 05:11:30 am »
I am getting a strange bug in which the soldier turns while firing, but continues to fire at the same spot. Is anyone else getting this issue?

It seems to be happening on weapons with arcing shot. Another problem I am getting with arcing shot and spray waypoints is very frequently the soldier ceases firing and claims there is no viable trajectory. This happens sometimes when there is a viable trajectory, such as while flying in the open field and trying to shoot (literally) the broad side of a barn.
« Last Edit: August 08, 2018, 05:23:52 am by The Reaver of Darkness »

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #9 on: August 08, 2018, 05:27:39 am »
This feature is not supported for arcing weapons for the same reasons that you cannot force-fire arcing weapons.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #10 on: August 08, 2018, 07:39:36 am »
I was about to ask why you can't force-fire arcing weapons when I realized perhaps why: Making the displayed shot travel on the correct arc is much simpler than solving its hit position repeatedly for every possible position along the arc. It can probably be done, but you'd have to make the game solve calculus equations on the fly, and that takes a programmer with a good grasp of calculus.

The other bug, however (each shot goes toward the same target) could be partially resolved by simply having the weapon progressively target each waypoint: ie. if the weapon fires 8 shots and has 4 waypoints, it would fire twice at each waypoint. With sufficiently low shot accuracy, the player may never realize this is what the weapon is doing.

Offline ohartenstein23

  • Commander
  • *****
  • Posts: 1931
  • Flamethrowers fry cyberdisk circuits
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #11 on: August 08, 2018, 01:38:08 pm »
I'm not getting the bug you mention, and the code does progressively target "waypoints" - just before firing it takes the waypoints you defined and interpolates between them for each shot to get a new target for each bullet.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #12 on: August 09, 2018, 12:36:34 am »
I'm glad to hear it does that. But I am definitely getting the bug and I don't know why.

Here's a video of it happening:

I'm using Extended+ 3.10b (v2018-07-21).

I've attached my mod. I'm not using any other mods.



- - - - - -

I also think the shot should not stop completely as soon as a single trajectory fails; rather it should continue attempting all of them until it runs out of shots.
« Last Edit: August 09, 2018, 12:38:28 am by The Reaver of Darkness »

KZad Bhat

  • Guest
Re: [Documentation] Spray Waypoints Explanation
« Reply #13 on: August 09, 2018, 10:22:54 am »
Reaver, you're using an arcing weapon. ohartstein already told you that sweep fire doesn't support arcing weapons. Seems you made it work . . . kind of . . . and this is what happens.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1510
    • View Profile
Re: [Documentation] Spray Waypoints Explanation
« Reply #14 on: August 09, 2018, 02:03:08 pm »
Yes but ohartstein said that he is not getting this bug. I want to not get it, too!

I'm not getting the bug you mention, and the code does progressively target "waypoints" - just before firing it takes the waypoints you defined and interpolates between them for each shot to get a new target for each bullet.