Author Topic: Player Warp to Target?  (Read 6449 times)

0 Members and 1 Guest are viewing this topic.

Re: Player Warp to Target?
The tactical warp feature is unbelievably useful in combat. Through trial and error, I am refining it for balance, to avoid completely trivializing dogfights. The ability to warp to a friendly capship during an escort mission is also limitlessly useful - as is the ability to subspace-jump nearly instantly into ideal bombing position. FREDing missions to work in tandem with that feature should be a lot of fun.

There are three more features I would like to implement, before I release a copy-pastable SEXP-based tactical warpdrive:

- Currently it only affects the player, and I want to expand that behavior to all of Alpha wing. The SEXPing to do it may be a little lengthy.

- Some sort of HUD thing that indicates how long until the subspace drive is recharged. Perhaps gratuitous digging around in Blue Planet's files will be productive.

- Once all the objectives are complete, the drive needs to switch off of tactical mode so the player can do the traditional Alt-J to end the mission.
"Obviously the meson bomb is a form of cat-toast-device, with the buttered toast inverted, so that the cat and toast both fly in the direction of gravity much faster than expected. By introducing artificial gravity, a pair of cat-toast perpetual motion accelerator units can be made to collide with one another, and they produce an unimaginably devastating explosion. Both cats are named 'Meson'."

 - Wikileaks 2383

  

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Player Warp to Target?
- Once all the objectives are complete, the drive needs to switch off of tactical mode so the player can do the traditional Alt-J to end the mission.
In this case, a simple addition to the tactical jump SEXP to specifically check that the jump-out condition isn't satisfied. For instance, create an event called, say, "Jump out condition" and chain it to another event that gives you the actual "jump out" directive; then checking whether or not "Jump out condition" has been completed lets you know whether or not the player's non-local subspace drive should be enabled. Then you add this to the "and" at the top of the tactical jump SEXP (right-click on the "and" SEXP and use "add operator" to make it check more than two conditions simultaneously):
Code: [Select]
      ( not
         ( is-event-true-delay
            "Jump out condition"
            0
         )
      )
Finally, in the "Jump out condition" event itself, change the "do-nothing" to an "alter-ship-flag" to give the player their subspace drive back.
Ph'nglui mglw'nafh Codethulhu GitHub wgah'nagl fhtagn.

schrödinbug (noun) - a bug that manifests itself in running software after a programmer notices that the code should never have worked in the first place.

When you gaze long into BMPMAN, BMPMAN also gazes into you.

"I am one of the best FREDders on Earth" -General Battuta

<Aesaar> literary criticism is vladimir putin

<MageKing17> "There's probably a reason the code is the way it is" is a very dangerous line of thought. :P
<MageKing17> Because the "reason" often turns out to be "nobody noticed it was wrong".
(the very next day)
<MageKing17> this ****ing code did it to me again
<MageKing17> "That doesn't really make sense to me, but I'll assume it was being done for a reason."
<MageKing17> **** ME
<MageKing17> THE REASON IS PEOPLE ARE STUPID
<MageKing17> ESPECIALLY ME

<MageKing17> God damn, I do not understand how this is breaking.
<MageKing17> Everything points to "this should work fine", and yet it's clearly not working.
<MjnMixael> 2 hours later... "God damn, how did this ever work at all?!"
(...)
<MageKing17> so
<MageKing17> more than two hours
<MageKing17> but once again we have reached the inevitable conclusion
<MageKing17> How did this code ever work in the first place!?

<@The_E> Welcome to OpenGL, where standards compliance is optional, and error reporting inconsistent

<MageKing17> It was all working perfectly until I actually tried it on an actual mission.

<IronWorks> I am useful for FSO stuff again. This is a red-letter day!
* z64555 erases "Thursday" and rewrites it in red ink

<MageKing17> TIL the entire homing code is held up by shoestrings and duct tape, basically.

 

Offline gershom

  • 24
Re: Player Warp to Target?
Did you ever get this working? I need something similar to this for my project. I'm currently experimenting with the one from the tutorial, but having yours to work from would save a lot of trial and error.

 
Re: Player Warp to Target?
Did you ever get this working? I need something similar to this for my project. I'm currently experimenting with the one from the tutorial, but having yours to work from would save a lot of trial and error.

I did, yes. I used a variable (Warp-Attack-Config) to tell the drive which event to run, when it goes to calculate coordinates for the player's subspace exit point. Those coordinates are contained in three more variables, Player-Destination-X, Player-Destination-Y, and Player-Destination-Z.

To make this distinction, it checks to see if there is a warp in progress (determined by variable), and if any one of a list of valid targets is currently targeted by the player, and if the player is facing them. If true, it sets another variable (Warp-Target) equal to the name of the player's current target, and sets Warp-Attack-Config to 1. If this event is false, warp-attack-config just stays at zero.

If warp-attack-config is 0 (false), it sets the player destination XYZ variables equal to the player's current position, plus 5000 meters in the Z direction. That part is fairly straightforward.

If warp-attack-config is 1 (true), it takes the distance to the player's target, subtracts 2500 meters, and uses the result in place of the 5000 meter forward jump calculation above. So if you are 7700 meters from your target, the attack warp instead warps you forward 5200 meters.

During the recharging sequence, I also set warp-attack-config to 0 (false), in case it became true. Otherwise, it would try to get attack-configuration coordinates every single time, even if you are warping away from things.

Unfortunately, with ambition being ambitious, almost as soon as I had a semi-working prototype, I expanded the system to include not just tactical warps, but all kinds of other special abilities for fighters, emulating the stuff that the Blue Planet team did in missions like One Future and The Sword Itself. The tactical warp system has now ballooned into a myriad of 34 different events (and still counting, as I keep adding systems).

The Manticore has been my guinea-pig for testing the system, and it's a lot of fun.
"Obviously the meson bomb is a form of cat-toast-device, with the buttered toast inverted, so that the cat and toast both fly in the direction of gravity much faster than expected. By introducing artificial gravity, a pair of cat-toast perpetual motion accelerator units can be made to collide with one another, and they produce an unimaginably devastating explosion. Both cats are named 'Meson'."

 - Wikileaks 2383