Important Message

You are browsing the archived Lancers Reactor forums. You cannot register or login.
The content may be outdated and links may not be functional.


To get the latest in Freelancer news, mods, modding and downloads, go to
The-Starport

**Tutorial** Advanced fuses

Here you find the different tutorials on editing and MODing Freelancer

Dev

Post Thu Aug 31, 2006 9:07 pm

**Tutorial** Advanced fuses

Zomg, another tutorial from me. Fuses are actually very interesting things, so hopefully this tutorial will shed some light on the strange things you can do with them.

Fuses are defined in fuse.ini or one of the related fuse files, and start with a [Fuse tag. Everything from there to the next [Fuse tag belongs to that fuse. The subject of this tutorial will be a TIE fighter I put together. Its wings are destructible, and when the ship is destroyed the wings will thrown off at random while the ship itself spins. Furthermore, how long it takes the ship to die varies. Also, if you kill the TIE fighter by shooting off a wing, that wing will always break off. Lastly, as the fighter takes damage there is a random chance that weapons or even the engines of the ship will be destroyed.

Here is the shiparch entry for the ship, for later reference:

[Ship
...
nickname = tie_fighter
...
hit_pts = 1000
fuse = tie_fighter_break_internals1, 0, 650
fuse = tie_fighter_break_internals2, 0, 400
fuse = tie_fighter_death_spin, 0, 1
...

[CollisionGroup
obj = zomgbayz1
separable = true
debris_type = debris_vanish
separation_explosion = explosion_small_ship_breakoff
hit_pts = 10000
root_health_proxy = true

[CollisionGroup
obj = port_wing
separable = true
parent_impulse = 250.000000
child_impulse = 250.000000
mass = 30.000000
debris_type = debris_fighter_piece
type = Port_Wing
hit_pts = 1000
fuse = tie_fighter_port_wing_break, 0, 1
root_health_proxy = true

[CollisionGroup
obj = starboard_wing
separable = true
parent_impulse = 250.000000
child_impulse = 250.000000
mass = 30.000000
debris_type = debris_fighter_piece
type = Starboard_Wing
hit_pts = 1000
fuse = tie_fighter_starboard_wing_break, 0, 1
root_health_proxy = true

The engine hardpoint is attached to the zomgbayz1 group; this will come into play later (the zomgbayz1 group is also linked to the ball part of the .sur file, with Root being the crossbar piece; the wings are themselves). Note that all groups will transfer damage to the root object (root_health_proxy = true); the fuse is set up with this in mind.

===================
On to the mighty fuse definition, which is actually quite a few fuses that work together. First off, the internal damage fuses:

[fuse
name = tie_fighter_break_internals1
lifetime = 0
death_fuse = false

[destroy_hp_attachment
at_t = 0, 3
hardpoint = HpWeapon01
hardpoint = HpWeapon02
hardpoint = HpCM01
fate = disappear

First off, some explanation of what the parameters mean.

-name = <name>
This is referenced in shiparch; for example, if you look in the shiparch definition above, tie_fighter_break_internals1 will run when the root object reaches between 0 and 650 health.

- lifetime = <time>
The lifetime of the fuse is measured in seconds; a lifetime of 0 means that all things in the fuse happen at the same time. You may be able to provide a range for lifetime (lifetime = <time1>, <time2> such as with debris, but it is not necessary.

- death_fuse = <true, false>
If true, the fuse will continue to run even if the ship is technically killed. If false, the fuse will terminate when the ship is destroyed.

- [destroy_hp_attachment
This event will destroy an attached piece of equipment at the hardpoint specified.

- at_t = <time> OR <time>, <time>
The event will occur at the given time (or within the given range of times). The time here always runs from 0 to 1, with 0 being the start of the fuse and 1 being the end. However, you can set the time to be greater than 1 if you want; nothing set to run at a time greater than 1 will actually run, though. What am I doing here, then? There is an even chance of the event running between times 0 and 3, but the event will only execute between times 0 and 1. In other words, there is a 2/3 chance that the event will not run at all. In other words, the fuse has random behavior, which is exactly what I want in this case.

- hardpoint = <hardpoint_name>
The hardpoint name refers to an actual hardpoint in the ship's .cmp file. The piece of equipment mounted on this hardpoint will be destroyed, if there is one (if not, nothing happens). You can set multiple hardpoints, in which case the game will randomly pick one of them to destroy. You may also say hardpoint = random, in which case the game will pick one of any of the ship's hardpoints.

- fate = <type>
The two fate types are "disappear" and "debris"; if it disappears, it just sort of vanishes. If it debris, it will break off the ship. You set the debris type of the equipment or ship part with debris_type = in the appropriate.ini file (for example, a weapon's debris type would be set in its definition in weapon_equip.ini). Debris type refers to a [Debris definition (usually in explosions.ini). See my tutorial on advanced explosions for more info on that.

--------------
[fuse
name = tie_fighter_break_internals2
lifetime = 0
death_fuse = false

[destroy_hp_attachment
at_t = 0, 3
hardpoint = HpWeapon01
hardpoint = HpWeapon02
hardpoint = HpCM01
fate = disappear

[destroy_group
at_t = 0, 5
group_name = zomgbayz1
fate = debris

The next fuse, which runs when the fighter gets more damaged. In addition to randomly breaking off a piece of equipment, there is a 1/5 chance that the group zomgbayz1 will be destroyed. As I mentioned before, the HpEngine01 hardpoint of the TIE fighter is attached to zomgbayz1; if zomgbayz1 is destroyed, the fighter will lose its only engine hardpoint and become immobilized.

The game will likely let you provide multiple group names, in which case it would randomly choose from among them when deciding what to destroy; however, I have not had a reason to try this.


------------------
[fuse
name = tie_fighter_death_spin
lifetime = 2
death_fuse = true

[destroy_group
at_t = 1
group_name = zomgbayz1
fate = disappear

[destroy_hp_attachment
at_t = 0
hardpoint = HpWeapon01
fate = disappear

[destroy_hp_attachment
at_t = 0
hardpoint = HpWeapon02
fate = disappear

[destroy_hp_attachment
at_t = 0
hardpoint = HpCM01
fate = disappear

[ignite_fuse
at_t = 0
fuse = tie_fighter_port_wing_fuse
fuse_t = 0

[ignite_fuse
at_t = 0
fuse = tie_fighter_starboard_wing_fuse
fuse_t = 0

[tumble
at_t = 0
ang_drag_scale = 0.300000
turn_throttle_z = 0.700000, 0.950000
turn_throttle_x = 0.000000, 0.100000
turn_throttle_y = 0.000000, 0.100000
throttle = 1.000000, 1.000000

[destroy_root
at_t = 0.1, 1

Edit: oh noez, the post length zomgbayz got me. The rest is in the first reply to the thread.

Edited by - Dev on 8/31/2006 10:09:03 PM

Dev

Post Thu Aug 31, 2006 9:08 pm

The death fuse is considerably beefier than the damage fuses, and runs when the ship is between 0 and 1 hit points (dead, essentially). Note that death_fuse is set to true; in other words, this fuse will run even when the ship is technically killed.

First off, you can see that all the weapons are destroyed at the start of the fuse to simulate all the weapon systems going offline as the ship breaks up; the engines are not destroyed until the end, which is necessary for the tumble to actually do anything.

The [ignite_fuse is new. This allows you to run any other fuse you want; however, don't try running more than one instance of the same fuse simultaneously, as the game will hate on you. As with any fuse, a fuse called this way is run as though it was attached to the root part of the ship.

- fuse = <fuse name>
The name of the fuse you want to run.

- fuse_t = <value>
I honestly have no idea what this does, nor have I observed much difference by altering it. It may do something, but I haven't had any problems leaving it at 0.

We will get to the wing fuses shortly.

The [tumble block is also new.

- ang_drag_scale = <value>
I don't really know what this does, either. death_comm, which also features a tumble, uses 0.3, and it seems to work. Offhand I would guess it does exactly what it says, scaling the angular drag of the ship by this much; if so, 0.3 would in theory allow the tumbling ship to turn over three times faster, though the game may handle tumbling in such a way that this makes sense.

- turn_throttle_x, y and z = <min>, <max>
min and max are on a scale of 0 to 1; these are how hard the ship turns around the given axes (in this case, it's mostly roll). I don't know how the game decides what direction the ship will roll. It could be that the range is actually from -1 to 1, but that is total conjecture.

- throttle = <min>, <max>
This is the throttle of the main engine, meaning it determines how fast the ship moves forward while tumbling.


Lastly, the all-important [destroy_root. When this event happens, the ship is destroyed; its death explosion happens and it is no more (though I should note that NPCs may randomly run death_comm at this point). In this case I have it happen between times 0.1 and 1; given that the lifetime of the fuse is 2 seconds, this means the ship is actually destroyed between 0.2 and 2 seconds.



----------------
Now for a look at one of the wing fuses, which gets called at the start of the death spin fuse (the starboard wing fuses is exactly the same in structure). This is actually two fuses, with the first calling the second.

[fuse
name = tie_fighter_port_wing_fuse
lifetime = 0

[ignite_fuse
at_t = 0, 3
fuse = tie_fighter_port_wing_death
fuse_t = 0

As you can see, there is a 1/3 chance that tie_fighter_port_wing_death will run. As a side note, if you don't specify death_fuse, it will default to false.


[fuse
name = tie_fighter_port_wing_death
lifetime = 0

[start_effect
at_t = 1
effect = gf_continuous_sparks
hardpoint = DpPort_wing
ori_offset = 0, 90, 0
pos_offset = 0, 0, 0
attached = true

[destroy_group
at_t = 1
group_name = port_wing
fate = debris

If that 1/3 chance happens, the wing is destroyed and a spark effect is placed at the hardpoint DpPort_wing; this hardpoint is placed right at the joint where the wing attaches.

[start_effect has the following parameters:

- effect = <effect_name>
The name is a reference to an [Effect, defined in effects.ini or a related effect file.

- hardpoint = <hardpoint_name>
Like before, the hardpoint refers to a hardpoint on the ship; you can specify multiple hardpoints to let the game randomly choose, or you can say hardpoint = random to randomly choose between all hardpoints.

- ori_offset = <x_angle>, <y_angle>, <z_angle>
How the effect is rotated relative to the hardpoint. The angles are in degrees, and by default they are all 0.

- pos_offset = <x_offset>, <y_offset>, <z_offset>
How the effect is positioned relative to the hardpoint. By default all offsets are 0.

- attached = <true, false>
If true, the effect will stay connected to the hardpoint until the effect ends or the ship dies. If false, the effect will not be attached to the hardpoint (I believe it continues along the same path it was traveling when it was created).


----------------
But what about the fuses that were connected to the wings in shiparch.ini? The exist to ensure that when the wings break off, a spark effect will be generated. However, there is some subtlety going on. First off, because damage to a wing will also damage the root ship, and since the wing and root have the same amount of health, killing a wing will also kill the ship. So, the death fuse of the ship will run automatically. Also, when a piece is destroyed it will break off on its own, so the fuse does not need to take care of that.

[fuse
name = tie_fighter_port_wing_break
lifetime = 0

[start_effect
effect = gf_continuous_sparks
hardpoint = DpPort_wing
at_t = 1
ori_offset = 0, 90, 0
attached = true

The effect is the same as the one in the tie_fighter_port_wing_death fuse. The starboard wing has a similar fuse that is structurally the same.


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

There are some other fuse events that can prove useful. For example, this is a nifty one:

[damage_root
at_t = 0
damage_type = absolute
hitpoints = 2400

- damage_type = <type>
I have only seen absolute; I'm not sure if there are other types or what they might do.

- hitpoints = <amount>
How many hit points the root ship loses.

You could make destructible parts not transfer damage to the root object and instead give them fuses that call damage_root; it may be useful in certain cirumstances. Or you could randomly have a fuse give a ship extra damage.

Another similar one is [damage_group:

[damage_group
group_name = Li_star_wing_lod1
at_t = 0.100000
damage_type = absolute
hitpoints = 50

It works like damage_root except that you can specify the group you want to damage. I think there may be one that lets you damage attachments; just guessing, it would likely be [damage_hp_attachment, and you would specify the hardpoint by one or more hardpoint = <hardpoint_name> lines.


Anyway, that's it for this tutorial. Hopefully you learned something you didn't know before.

Post Mon Sep 04, 2006 4:53 am

- fate = <type>
The two fate types are "disappear" and "debris"

There is a third one which is "loot". This will spawn the given equipment to space in a lootcrate and can then be looted.

Dev

Post Mon Sep 04, 2006 9:55 pm

Awesome, thanks for the addition.

Return to Freelancer Editing Tutorial Forum