Author Topic: Player Beam Weapons  (Read 4011 times)

0 Members and 1 Guest are viewing this topic.

Heya,  I'm pretty new to the whole in depth modding thing, but I've been playing Freespace on and off for at least 10 years (it's a good game I hear). 

Anyways, I playing around with some things in preparation for making a cool new campaign.  One of the premises I am holding for the campaign is that you get to pilot larger vessels on occasion.  Naturally when it comes to piloting a larger vessel you're going to want to use some beam weapons!  I pretty much figured out through existing tables in such how to give the player control of beam weapons from primary firing points (my test model is a modified Aeolus with various turret fixtures replaced with primary and secondary points).  One big thing I couldn't figure out is how to make the timer for the beam (or any primary weapon for that matter) show up.  I have some workarounds in mind, but in any circumstance I would like to display a timer much like for the secondaries. 

My biggest question is this:  making a beam weapon for use as a secondary.  My motivation for this is for the player to be able to choose between torpedoes a variety of missiles and anti-fighter beams for secondary weapons depending on how they want to deal with other capital ships and fighter/bomber threats.  My initial thought was to have the beam be a heat seeking "missile" with a near instantaneous turn to and approach to its target (in essence acting the same way you would expect a beam to).  However I haven't had much luck.  If you guys have any ideas or inspirations for a mock beam like weapon for secondaries or how to make a secondary beam weapon that would be great.  I'll include my rough attempt at a secondary weapon beam below (mainly copied from AAAh).

Code: [Select]
$Name:                          Zapper
$Model File:                    none ; laser1-1.pof
@Laser Bitmap:                  laserglow01
@Laser Color: 136, 243, 249
@Laser Length: 0.0
@Laser Head Radius: 0.60
@Laser Tail Radius: 0.60
$Mass:                          100.0
$Velocity:                      1000.0          ;; speed of the weapon (initially) -- may or may not change
$Fire Wait:                     5.5             ;; in seconds
$Damage:                        14 ;; NOTE: for beam weapons this is kind of a "continuous" damage applied every few fractions of a second that the beam is on.
$Armor Factor:                  1.0
$Shield Factor:                 1.0
$Subsystem Factor:              1.0
$Lifetime:                      40.0            ;; How long this thing lives
$Energy Consumed:               0.00            ;; Energy used when fired
$Cargo Size:                    0.0            ;; Amount of space taken up in weapon cargo
$Homing:                        YES
+Type: HEAT
+Turn Time: 0.01
+View Cone: 180.0
$LaunchSnd:                     124             ;; The sound it makes when fired
$ImpactSnd:                     88             ;; The sound it makes when it hits something
+Weapon Range: 1500 ;; Limit to range at which weapon will actively target object
$Flags:                         ("Big Ship" "beam" "player allowed")
$Icon:                          icongun05
$Anim:                          LoadGun07
$Impact Explosion:              ExpMissileHit1
$Impact Explosion Radius:       10.0
$BeamInfo:
+Type: 3 ;; 0 - 4 are valid #'s
+Life:   2.5 ;; how long it lasts once the beam is actually firing
+Warmup:   1500 ;; warmup time in ms
+Warmdown: 1200 ;; warmdown time in ms
+Radius:   20.0 ;; muzzle glow radius in meters
+PCount: 12 ;; particles spewed every interval
+PRadius: 1.2 ;; particle radius
+PAngle: 65.0 ;; angle of the random "cone" where the particles are generated
+PAni: particleexp01 ;; particle ani
+Miss Factor: 1.5 1.6 1.7 1.8 2.0 ;; magic # - higher == miss more (only really applicable to type 0 and type 3 beams)
+BeamSound: 149 ;; the looping beam-firing sound
+WarmupSound: 151 ;; associated warmup sound
+WarmdownSound: 161 ;; associated warmdown sound
+Muzzleglow: thrusterglow01 ;; muzzle glow bitmap
+Shots: 3 ;; only used for TYPE 3 beams
+ShrinkFactor: 0.0 ;; what percentage of lifetime where beam starts shrinking (0.1 == 10% life left)
+ShrinkPct: 0.0 ;; what percentage of max width we subtract per second
$Section: ;; one section of the beam (you can have up to 5)
+Width: 2.0 ;; width of the section
+Texture: beam-white ;; texture for this section
+RGBA Inner: 255 255 255 255 ;; rgba values (only for non-textured beam compiles)
+RGBA Outer: 150 150 150 10 ;; rgba values (only for non-textured beam compiles)
+Flicker: 0.1 ;; how much it flickers (0.0 to 1.0)
+Zadd: 2.0 ;; hehe
$Section: ;; one section of the beam
+Width: 6.0 ;; width of the section
+Texture: beam-dblue2 ;; texture for this section
+RGBA Inner: 160 160 0 255 ;; rgba values (only for non-textured beam compiles)
+RGBA Outer: 60 60 0 10 ;; rgba values (only for non-textured beam compiles)
+Flicker: 0.1 ;; how much it flickers (0.0 to 1.0)
+Zadd: 1.0 ;; hehe
$Section: ;; one section of the beam
+Width: 8.0 ;; width of the section
+Texture: beam-dblue ;; texture for this section
+RGBA Inner: 255 0 0 255 ;; rgba values (only for non-textured beam compiles)
+RGBA Outer: 60 0 0 10 ;; rgba values (only for non-textured beam compiles)
+Flicker: 0.4 ;; how much it flickers (0.0 to 1.0)
+Zadd: 0.0 ;; hehe

 
If memory serves the original Shivan Super Laser mounted on the Lucifer in the retail FS1 was a secondary weapon masked as a beam. Check out the the Shivan Super Laser in weapons.tbl for retail FS1 That might be a good place to start.
The Irresponsible Captain Nathan
http://steamcommunity.com/id/IrresponsibleCaptNathan/
Team Leader - Star Wars Original Trilogy Mod
http://www.moddb.com/mods/star-wars-the-original-trilogy-mod

 
Unfortunately it is a primary and not even a beam (just a REALLY fat and loooooooooooong laser), but thanks for the suggestion.

Code: [Select]
#Primary Weapons
...
$Name: Shivan Super Laser
$Model File: none
@Laser Bitmap: laserglow01
@Laser Glow: 2_laserglow03
@Laser Color: 250, 30, 30
@Laser Length: 0.1
@Laser Head Radius: 0.30
@Laser Tail Radius: 0.30
$Mass: 100.0
$Velocity: 1000.0
$Fire Wait: 10.0
$Damage: 15000
$Armor Factor: 1.0
$Shield Factor: 1.0
$Subsystem Factor: 1.0
$Lifetime: 30.0
$Energy Consumed: 0.30
$Cargo Size: 0.0
$Homing: NO
$LaunchSnd: 114
$ImpactSnd: 85
$Flags: ( "Big Ship" "Huge" )
$Trail:
 +Start Width: 40.0
 +End Width: 20.0
 +Start Alpha: 1.0
 +End Alpha: 0.0
 +Max Life: 5.0
 +Bitmap: MissileTrail02
$Icon: icon_banshee
$Anim: banshee
$Impact Explosion: none

 

Offline Nyctaeus

  • The Slavic Engineer
  • 212
  • My "FS Ships" folder is 582gb.
    • Minecraft
    • Exile
I'm not sure if this is actually possible due to engine limitations. As far as I know it's possible to make secondary weapon looking like laser or something, but... Beam? Well, I must admit this is something that I never tried.
« Last Edit: March 11, 2016, 07:46:49 pm by Betrayal »
Exile | Shadow Genesis | Inferno | Series Resurrecta  | DA Profile | P3D Profile

Proud owner of NyctiShipyards. Remember - Nyx will fix it!

All of my assets including models, textures, skyboxes, effects may be used under standard CC BY-NC 4.0 license.

 
Right, yeah, that's kinda the conclusion I came to after trying to figure it out myself.

Would still be interested to know if there is a way to display a timer for primary weapons.

 

Offline Dragon

  • Citation needed
  • 212
  • The sky is the limit.
There isn't, but it's probably easier to implement in code than making secondary slots accept beams. :) Ask on the SCP board, chances are somebody will be interested enough to look into it.

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
Play around with $substitute, one of the most powerful and dangerous features in tabling!

Or see if you can have the secondary launch an invisible missile that detonates instantly and spawns a beam with the 'spawn' flag.

Play Blue Planet's capship command missions and Lepanto's Battle Captains missions which handle beams (differently than you want to, but maybe in a way that's useful).

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
One big thing I couldn't figure out is how to make the timer for the beam (or any primary weapon for that matter) show up.  I have some workarounds in mind, but in any circumstance I would like to display a timer much like for the secondaries. 

The easy workaround would be to make it drain the entire weapons energy (I remember the White Star beam working similar in TBP if I recall correctly, although that one could be linked with the rest of the primaries), so the weapon energy gauge can work as a reload counter (drawback of course that it shuts down all other weapons too).

A better solution would be to make it a ballistic weapon with an ammo count of X and then use the "set-primary-ammo" SEXP to reload it on a rate you are comfortable with. (which can also be scalled depending on the weapon energy gauge with some variable work). This would of course require it to be implimented on a per mission basis but if you create a mission file with the base structure in it and start from that instead of starting from scratch each time you should be good. It can also be disable in case of ship class change via "is-ship-class".

Or see if you can have the secondary launch an invisible missile that detonates instantly and spawns a beam with the 'spawn' flag.

That seems to a a very good solution...

Another more work intensive would be to make some events based on the possible load-outs (via "has-secondary-weapon") and then procceed from there with events triggered through the secondary weapon count (via "<" or ">" and "get-secondary-ammo") which then use "weapon-create" to spawn the weapon you desire. You could also in case of energy weapon secondaries use the a similar approach to above to reload the weapon.
« Last Edit: March 12, 2016, 05:39:32 am by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 
Ask on the SCP board

I think I will do that, but I'm going to see what I can jerry-rig first (which should also expose more things for me to ask I imagine).

Play around with $substitute, one of the most powerful and dangerous features in tabling!

From what I tried with substitute it seems like beams have the same issue they as when they are used as secondaries; namely the beam warm-up never triggers.

Or see if you can have the secondary launch an invisible missile that detonates instantly and spawns a beam with the 'spawn' flag.

That seems like it works quite well!  I'll need to make sure I have a way to orient the spawn towards the target which I think I can do with targeting flags and such. 

It works just as well for primaries!


Play Blue Planet's capship command missions and Lepanto's Battle Captains missions which handle beams (differently than you want to, but maybe in a way that's useful).

The Blue Planet one gave me the idea in the first place.  I have not tried Lepantos yet, but will keep that in mind for further inspiration.

The things you said...

From what I've worked on with primary beams and gun energy it doesn't work as well as one would hope.  The beam subtracts its '$energy consumed' value continuously throughout the lifetime of the beam which would allow the user to stutter shoot their beams at low energy which in my mind doesn't make sense for anti-cap beams. 

However, I think if I combine yours and Battuta's ideas together I can make it work.  I can make an instant tracer shot of sorts (It would need to be nontrivial so that the player obtains the correct lead indicator for the beam range) that can drain a large flat amount of energy and will spawn the beam accordingly.  With luck the player wouldn't know any difference between that and just firing beams normally.  That would also allow me to auto-aim the beam as well (I think/hope) since it seems that '$Autoaim FOV' doesn't work for beams.

If need be I will try out sexping a hard reload of sorts, but I will attempt the more optimistic approach first.

Thanks everyone for the suggestions and help so far!

 

Offline 0rph3u5

  • 211
  • Oceans rise. Empires fall.
Or see if you can have the secondary launch an invisible missile that detonates instantly and spawns a beam with the 'spawn' flag.

That seems like it works quite well!  I'll need to make sure I have a way to orient the spawn towards the target which I think I can do with targeting flags and such. 

It works just as well for primaries!


Did you apply the $spawn_angle-parameter and the "inherit parent target"-flag? I don't know if "inherit parent traget" will work on primaries and dumbfires but I made a "splits into 5 smaller torpedoes"-torpedo once (cant find the data right now) and there they were worked as expected (the "child"-missiles spawned in a cone ahead of missile and homed on the target you had locked on with the aspect seeking "parent"-missile)
« Last Edit: March 12, 2016, 11:17:51 am by 0rph3u5 »
"As you sought to steal a kingdom for yourself, so must you do again, a thousand times over. For a theft, a true theft, must be practiced to be earned." - The terms of Nyrissa's curse, Pathfinder: Kingmaker

==================

"I am Curiosity, and I've always wondered what would become of you, here at the end of the world." - The Guide/The Curious Other, Othercide

"When you work with water, you have to know and respect it. When you labour to subdue it, you have to understand that one day it may rise up and turn all your labours into nothing. For what is water, which seeks to make all things level, which has no taste or colour of its own, but a liquid form of Nothing?" - Graham Swift, Waterland

"...because they are not Dragons."

 
Did you apply the $spawn_angle-parameter and the "inherit parent target"-flag?

Yeah, that was my plan, I just threw in a default 10 beams per shot at any angle just to see how beams as spawns worked and thought it was amusing.

 
Preliminary results using the "ghost missile" method:


The are a couple issues (aside from them being overpowered, which can be changed).  The major issue is that the beams remain static when they fire.  The secondary points on the ship in the video (and likely on most cap ships I will be using this on) do not have forward facing fire points so I can't exactly inherit the speed of the ship/ghost weapon.  It doesn't look toooo bad on this video because the beam has not startup and ends quickly, but using an AAAh/f or any normally spaced beam would be very strange looking. Secondary issue is that the '$consumed energy' flag doesn't apply to the tracer missile (less important and I might be doing something wrong, not sure).


 

Offline Droid803

  • Trusted poster of legit stuff
  • 213
  • /人 ◕ ‿‿ ◕ 人\ Do you want to be a Magical Girl?
    • Skype
    • Steam
I'm using a slightly different approach for essentially the same desired goal:
I have a locked beam turret on the ship, and a dummy (ghost) missile equipped.

Using sexps in FRED (or a script), you can detect when the dummy missile is launched and then call a Fire-Beam.

Secondaries never consume energy. If you want to drain energy (in set chunks) you can use a dummy ballistic primary instead. Note that this doesn't so much as show a "timer" for how long the beam can be fired for, but rather "number of charges", as in, how many times you can fire the beam.

Here's the sexp method if you want to know how I have it set up:
Code: [Select]
$Formula: ( when
   ( and
      ( !=
         @s7_shots[3]
         ( primary-ammo-pct "Alpha 1" 0 )
      )
      ( = @IS_TURRET[0] 7 )
   )
   ( fire-beam-at-coordinates
      "Alpha 1"
      "Turret07"
      0
      0
      0
      ( true )
   )
   ( modify-variable
      @s7_shots[3]
      ( primary-ammo-pct "Alpha 1" 0 )
   )
)
+Name: cs7-detect_fire
+Repeat Count: -1
+Trigger Count: 3
+Interval: 12

There's an SEXP I call at the start of the mission which sets @s7_shots[3] = primary-ammo-pct "Alpha 1" 0
The first primary bank (carrying a 0-lifetime ballistic primary) is then linked to turret07 (a beam turret) which is fired upon the game noticing a difference between the amount of ammunition remaining, and what that value was the last time it checked.
If there's a difference, fire one beam, and then set store ammunition value back to the amount of ammo left.

Trigger Count is set to the number of times the beam can be fired in total in the mission (in this case, 5)
Interval is the Fire Wait time of the beam in question, of which the dummy primary (or secondary) has the same fire wait - the minimum amount of time you must wait before firing the beam again.
(´・ω・`)
=============================================================