Modding, Mission Design, and Coding > The FRED Workshop

Collecting FRED tricks

<< < (3/4) > >>

0rph3u5:

--- Quote from: karajorma on April 16, 2019, 08:17:07 am ---Wait, what?

That definitely sounds like a bug rather than something you should be teaching people to do.

--- End quote ---

Yes, sounds like it. However it is more user error than a bug, as I have come to realize after 5 days of dealing with it.
Corrected the post above.

DefCynodont119:
Keep your event list organized and clear.


Rather then make a bunch of return to base objectives, you can make one and chain it to an event named something like "Mission RTB State" or something and have that event become true once any of your contextual ending events becomes true.

This makes it much easier to keep track of your mission's win/fail events and diagnose "unending mission" issues.

TopAce:
If you do that, you'll never have to worry about missing "You have left the area without authorization..." debriefings. Simply add "is-event-false-delay" 0 <RTB event name> as the stage's prerequisite. For the rest of the stages, use "is-event-true-delay" 0 <RTB event name> to make sure no miscellaneous stages will appear if the player deserts.

JSRNerdo:
Press `+e while in a debug build to access the event debug menu

With the event debug menu, you can see the status (true, false, permanently true/false) of every event in the mission and whether it's been triggered, when it's been triggered, and so on. It's incredibly useful if you have any SEXP-related bugs you can't quite figure out.

Turret-Pretend-To-Fire

Everyone's probably been here - you want to manually fire a turret at a ship, but FRED doesn't support that functionality in a SEXP. Well, now you can and all you need to do is an ugly hack!

You'll need to add an entry to fireball.tbl (preferably in a .tbm, with a custom unique ID) with the name of the entry being the muzzle flash effect for the weapon you want to fire, add a dummy ship to your mission (cloaked, invisible, does not move, only for calculations, we'll call it DummyBoi for now) and add a variable to your mission which we'll call TurDist for now.

This is what the event looks like:


--- Code: ---   ( when
      ( true )
      ( set-object-position
         "Dummyboy"
         ( get-object-x "FIRING=SHIP=HERE" "TURRET=NAME=HERE" )
         ( get-object-y "FIRING=SHIP=HERE" "TURRET=NAME=HERE" )
         ( get-object-z "FIRING=SHIP=HERE" "TURRET=NAME=HERE" )
      )
      ( set-object-facing
         "Dummyboy"
         ( get-object-x
            "TARGET=SHIP=HERE"
            "<none>"
            0
            0
            ( *
               ( /
                  ( distance-ship-subsystem
                     "TARGET=SHIP=HERE"
                     "FIRING=SHIP=HERE"
                     "TURRET=NAME=HERE"
                  )
                  BULLET=SPEED=HERE
               )
               ( get-object-speed-z
                  "TARGET=SHIP=HERE"
                  ( true )
               )
            )
         )
         ( get-object-y
            "TARGET=SHIP=HERE"
            "<none>"
            0
            0
            ( *
               ( /
                  ( distance-ship-subsystem
                     "TARGET=SHIP=HERE"
                     "FIRING=SHIP=HERE"
                     "TURRET=NAME=HERE"
                  )
                  BULLET=SPEED=HERE
               )
               ( get-object-speed-z
                  "TARGET=SHIP=HERE"
                  ( true )
               )
            )
         )
         ( get-object-z
            "TARGET=SHIP=HERE"
            "<none>"
            0
            0
            ( *
               ( /
                  ( distance-ship-subsystem
                     "TARGET=SHIP=HERE"
                     "FIRING=SHIP=HERE"
                     "TURRET=NAME=HERE"
                  )
                  BULLET=SPEED=HERE
               )
               ( get-object-speed-z
                  "TARGET=SHIP=HERE"
                  ( true )
               )
            )
         )
      )
      ( weapon-create
         "FIRING=SHIP=HERE"
         "GUN=TO=SHOOT=HERE"
         ( get-object-x "FIRING=SHIP=HERE" "TURRET=NAME=HERE" )
         ( get-object-y "FIRING=SHIP=HERE" "TURRET=NAME=HERE" )
         ( get-object-z "FIRING=SHIP=HERE" "TURRET=NAME=HERE" )
         ( get-object-pitch "Dummyboy" )
         ( get-object-bank "Dummyboy" )
         ( get-object-heading "Dummyboy" )
         "TARGET=SHIP=HERE"
      )
         ( explosion-effect
            ( get-object-x
               "FIRING=SHIP=HERE"
               "TURRET=NAME=HERE"
               -10
            )
            ( get-object-y
               "FIRING=SHIP=HERE"
               "TURRET=NAME=HERE"
               -10
            )
            ( get-object-z
               "FIRING=SHIP=HERE"
               "TURRET=NAME=HERE"
               -10
            )
            0
            0
            55
            1
            1
            0
            "Custom Fireball 2"
            203
         )
   )

--- End code ---

And one that works with arguments:


--- Code: ---   ( when-argument
      ( any-of
         "turretXYZ"
         "turretYXZ"
         "turretZYX"
      )
      ( not
         ( is-subsystem-destroyed-delay
            "FIRING=SHIP=HERE"
            "<argument>"
            0
         )
      )
      ( when
         ( true )
         ( set-object-position
            "Dummyboy"
            ( get-object-x
               "FIRING=SHIP=HERE"
               "<argument>"
            )
            ( get-object-y
               "FIRING=SHIP=HERE"
               "<argument>"
            )
            ( get-object-z
               "FIRING=SHIP=HERE"
               "<argument>"
            )
         )
         ( set-object-facing
            "Dummyboy"
            ( get-object-x
               "TARGET=SHIP=HERE"
               "<none>"
               0
               0
               ( *
                  ( /
                     ( distance-ship-subsystem
                        "TARGET=SHIP=HERE"
                        "FIRING=SHIP=HERE"
                        "<argument>"
                     )
                     BULLET=SPEED=HERE
                  )
                  ( get-object-speed-z
                     "TARGET=SHIP=HERE"
                     ( true )
                  )
               )
            )
            ( get-object-y
               "TARGET=SHIP=HERE"
               "<none>"
               0
               0
               ( *
                  ( /
                     ( distance-ship-subsystem
                        "TARGET=SHIP=HERE"
                        "FIRING=SHIP=HERE"
                        "<argument>"
                     )
                     BULLET=SPEED=HERE
                  )
                  ( get-object-speed-z
                     "TARGET=SHIP=HERE"
                     ( true )
                  )
               )
            )
            ( get-object-z
               "TARGET=SHIP=HERE"
               "<none>"
               0
               0
               ( *
                  ( /
                     ( distance-ship-subsystem
                        "TARGET=SHIP=HERE"
                        "FIRING=SHIP=HERE"
                        "<argument>"
                     )
                     BULLET=SPEED=HERE
                  )
                  ( get-object-speed-z
                     "TARGET=SHIP=HERE"
                     ( true )
                  )
               )
            )
         )
         ( weapon-create
            "FIRING=SHIP=HERE"
            "GUN=TO=SHOOT=HERE"
            ( get-object-x
               "FIRING=SHIP=HERE"
               "<argument>"
            )
            ( get-object-y
               "FIRING=SHIP=HERE"
               "<argument>"
            )
            ( get-object-z
               "FIRING=SHIP=HERE"
               "<argument>"
            )
            ( get-object-pitch "Dummyboy" )
            ( get-object-bank "Dummyboy" )
            ( get-object-heading "Dummyboy" )
            "TARGET=SHIP=HERE"
         )
         ( explosion-effect
            ( get-object-x
               "FIRING=SHIP=HERE"
               "<argument>"
               -10
            )
            ( get-object-y
               "FIRING=SHIP=HERE"
               "<argument>"
               -10
            )
            ( get-object-z
               "FIRING=SHIP=HERE"
               "<argument>"
               -10
            )
            0
            0
            55
            1
            1
            0
            "Custom Fireball 2"
            203
         )
      )
   )

--- End code ---

JSRNerdo:
Turret pretend to fire has been updated to no longer need the turdist variable.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version