**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
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