Fleet modding

Version

Please help with verifying or updating older sections of this article. At least some were last verified for version 2.8.

This article is for the PC version of Stellaris only.

This is a quick reference for the different aspects of scripting some fleet events, triggers etc.

## Fleet Orders

The list of known fleet orders, used to define the current fleet action (i.e. *has\_fleet\_order*, used in Conditions).

* *italics orders* - orders which are not studied or probably not working

## Fleet Locking

Fleet could be locked by `set_event_locked = yes` effect.

This will prevent any orders to this fleet. Don't forget to unlock it later.

## Code examples

Merge fleets

```
solar_system = {
	random_fleet_in_system = {
		limit = {
			is_ship_class = shipclass_military
			NOT = { is_same_value = root }
			owner = { is_same_empire = root.owner }
			fleet_power > 0
		}
		save_event_target_as = EXAMPLE_merge_fleet
	}
}
queue_actions = {
	find_random_fleet = {
		found_fleet = {
			merge_fleet = {
				target = event_target:EXAMPLE_merge_fleet
				allow_ftl = no
			}
		}
	}
}

```

* Note: Vanilla doesn't use this (plain) command at all. Mods using this are e.q. "Aggressive Crisis Engine" and "A Deadly Tempest".

Change fleet leader on army/transport fleets.
As simple leader assign to transport fleets is not working (as to military fleets) and furthermore the documented scope from ships to army unexpectedly is not working (possible bug), there is a workaround to solve this supposed scope problem.

```
# Just find the right army to the fleet to assign a leader to the appropriate army.
random_fleet_in_system = {
	limit = {
		exists = owner
		owner = { is_same_empire = event_target:EXAMPLE_empire }
		is_ship_class = shipclass_transport
		# NOT = { exists = leader }
	}
	owner = {
		random_owned_army = {
			limit = {
				exists = fleet
				fleet = { is_same_value = PREVPREVPREV }
				# NOT = { exists = leader }
			}
			assign_leader = event_target:EXAMPLE_leader
		}
	}
}

```

* Note: Vanilla doesn't use this (plain) at all, e.q. mod using this is "Decentralized Empires (Regentmaker)".

"Jump" fleet to the scope
Transfers fleet to the selected scope.

```
# Jumps to the capital scope.
fleet_event = {
    id = acemod_fleet.600
    hide_window = yes
    is_triggered_only = yes
    immediate = {
        set_location = {
            target = owner.capital_scope
            distance = 5
            angle = random
            direction = in_system
        }
        clear_orders = yes
        clear_fleet_actions = this
    }
}

```

Order colossus to fire on a planet in the same system

```
solar_system = {
	random_system_planet = {
		limit = {
			has_planet_flag = shroud_target
		}
		save_event_target_as = killtarget
	}
}
queue_actions = {
	if = {
		limit = {
			exists = event_target:killtarget
			}
		clear_orders = yes
		clear_fleet_actions = THIS # Colossus fleet scope
		find_closest_planet = {
			trigger = {
				id = schroud_target_1
				is_same_value = event_target:killtarget
			}
			found_planet = {
				move_to = this
				orbit_planet = this
				destroy_planet = this
			}
		}
	}
}

```

## References

1. ↑ Some samples of orders usage: https://gitlab.com/stellaris/irm/snippets/29660
2. ↑ *An example from FirePrince.*
3. ↑ *An example from OldEnt.*
4. ↑ *An example from OldEnt.*

**Modding**