Hello! Welcome to the fourth and last installment in our series about the defensive towers in the Riftbreaker. In the previous parts, we uncovered some of the mysteries behind the basic operations of all towers, as well as specifics regarding the sentinel towers and the artillery tower. In this part, we are going to cover two wildly different structures, representing what we call charged up firing and continuous weapons. The mode of operation of charged up weapons can be divided into two phases - charge and discharge. The Railgun Tower in The Riftbreaker is a perfect example of this. It fires an energy bolt once in a while that is followed by a lengthy cooldown period. This might seem disadvantageous at first, but the Railgun’s ability to pierce through multiple targets compensates for that. A look at the code will reveal more interesting things, check it out: [img]https://i.imgur.com/OdBEe6g.png[/img] [i]The Railgun Tower as seen in the EXOR Model Editor[/i] [code] TurretDesc { target "ground_unit" speed "300" find_type "farthest" aim_volume "SphericalAimVolume" range_min "0" range_max "50" aiming_range "60" aiming_cooldown "1" aiming_target_time "2" aiming_idle_angle "20" pitch "be_barrel" yaw "be_turret" check_target_visibility "1" } WeaponDesc weapon_definition "InstantWeaponDef" fire_rate "5" FirePattern burst_column_spacing "0" burst_rate "0" burst_rows "1" burst_column_angle "0" burst_columns "1" ammo_storage "energy" ammo_cost_per_fire "100" ammo_definition "InstantAmmoDef" blueprint "buildings/defense/tower_railgun_projectile" range "50" max_hits "32" width "3" height "3" on_enemy_hit_effect "effects/weapon_hit/tower_projectile_hit" on_world_hit_effect "effects/weapon_hit/tower_projectile_hit" collision_3d "destructible|ground_unit|shield" collision_block "world|world_blocker" DamagePattern Damage value "500" type "railgun" } [/code] [img]https://i.imgur.com/ee1usHr.gif[/img] [i]Pew, pew![/i] The first thing that is different from the other towers we’ve shown you is the aiming mechanism. In order to snipe as many enemies at once, the railgun chooses the farthest enemy as its primary target. We can tweak the size of the energy burst to ensure that targets on the sides will get hit as well. The only caveat is that we had to limit the maximum number of units that can be affected by the railgun to 32 because of performance reasons, but the massive amount of damage dealt by the tower should offset this drawback. Each shot fired by the railgun tower consumes a ton of energy. It is a steep cost, and in large numbers, they can generate massive power spikes. However, thanks to the burst operation mode and the lengthy cooldown between shots it is possible for your power plants to refill the deficits in your energy storage, at least to some degree. Balancing the fire rate, fire cost and damage is going to be one of our priorities in case of the towers operating under these principles. On the other side of the spectrum, we have continuous weapons. They operate on a completely different principle, turning on as soon as an enemy comes in range and staying on until there are no more targets in the area. An example of such a tower is the flamethrower tower. The principle here is quite simple - the tower incinerates the area in front of it, sweeping from side to side until there is nothing left. The fire does not deal a lot of damage outright, but it is spread over time, meaning that it will not instantly kill all enemies, but over time it will be devastating to large groups of smaller targets. [img]https://i.imgur.com/0rl0sUN.png[/img] [i]The Flamethrower Tower[/i] Spatial simulating of flame behavior is quite difficult, and the sweeping motion of the turret does not make it any easier. Our solution to this problem is to create three boxes of different sizes in front of the tower. The further the box is from the muzzle, the bigger it is. The visual effect is limited to the bounds of the box. Right now, the flames pass through the objects on their way. In the future, we will add a force feedback mechanism that will stop the flames when they meet a solid, physical object on their way. [img]https://i.imgur.com/tIKsbQb.gif[/img] [i]With debug options enabled you can see what the aiming process looks like in real time.[/i] The flamethrower towers use fuel as their ammunition. The turret fires continuously, which means it will consume some ammo every second. To avoid running out of ammunition you must build refineries that will turn non-renewable energy sources, such as biomass, into flammable fuel. That is all we have for the defensive towers series at the moment. We hope that this series of articles shed some light on how we create defensive systems. All of the towers we presented will require a lot of tweaking, but we hope that with your help we can make The Riftbreaker a game you want to play. Join our Discord! www.discord.gg/exorstudios Other social media: www.facebook.com/exorstudios www.twitter.com/exorstudios www.mixer.com/exor_studios www.twitch.tv/exorstudios