Author Topic: Change ship class after secondary fired  (Read 2686 times)

0 Members and 1 Guest are viewing this topic.

Offline SF-Junky

  • 29
  • Bread can mold, what can you do?
Change ship class after secondary fired
Hello,

what I am trying to is to construct a mission event that changes the player's ship class after the player fired secondary weapon bank 3. I tried to accomplish this by using the secondary-fired-since SEXP and, of course, the change-ship-class SEXP (see code tag below).

But this doesn't work.

My next approach would've been to use the secondary-ammo-pct SEXP I see in FRED. The problem here is that I cannot use it (it's locked grey).
A brute way would be to just use the secondaries-depleted SEXP, but I'd really like to avoid that.

Any ideas? I know there must be some way to do this, because in BP2 they have this computer voice telling you "bank # empty". So it's not that the game code couldn't handle such things.

I'm using the latest nightly build from July 15. But I also tried with 3.7.2 RC3.

Code: [Select]
$Formula: ( when
   ( secondary-fired-since
      "Alpha 1"
      3
      60000
   )
   ( change-ship-class
      "GTF Falcon"
      "Alpha 1"
   )
)
+Name: Event name
+Repeat Count: 1
+Interval: 1

 

Offline Axem

  • 211
Re: Change ship class after secondary fired
Using secondary-fired since should work since I did exactly what you're trying to do in JAD 2.21. I think the time to check since firing should be in the range of 10-100ms or so, I believe. Check out the mission in FRED to see how I did it (mission 5b!). Hopefully it won't be too messy to read... ;)

 

Offline AdmiralRalwood

  • 211
  • The Cthulhu programmer himself!
    • Skype
    • Steam
    • Twitter
Re: Change ship class after secondary fired
My next approach would've been to use the secondary-ammo-pct SEXP I see in FRED. The problem here is that I cannot use it (it's locked grey).
You can't use it by itself; you have to use it as an argument to, say, a < SEXP.

SEXPs aren't greyed out because they're unusable, they're greyed out because they make no sense in the current context (in this case, because it returns a number, not a boolean).


As for the reason your secondary-fired-since isn't working:
Code: [Select]
   ( secondary-fired-since
      "Alpha 1"
      3
      60000
   )
It counts from the first bay being 0, so 3 would be the fourth secondary bay, which obviously doesn't exist. Sadly, this is mentioned in the help for the secondary-ammo-pct SEXP but not the help for the secondary-fired-since SEXP.
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 Dragon

  • Citation needed
  • 212
  • The sky is the limit.
Re: Change ship class after secondary fired
Well, not so "obviously", but merely probably. :) You can have four secondary banks if you so chose, even for the player. That said, "GTF" implies a fighter, and those rarely come with 4 banks.

  

Offline SF-Junky

  • 29
  • Bread can mold, what can you do?
Re: Change ship class after secondary fired
It counts from the first bay being 0, so 3 would be the fourth secondary bay, which obviously doesn't exist. Sadly, this is mentioned in the help for the secondary-ammo-pct SEXP but not the help for the secondary-fired-since SEXP.
Ah, that was it. It works now. Once again I thank the community for their help! :)