# On Actions
# -----------------------

on_game_start = {
	events = {
		planetmega_global.1
		#planetmega_global.3
		#planetmega_global.4
		#planetmega_global.5
		#planetmega_global.6
		planetmega_global.7
	}
}
on_game_start_country = {
	events = {
		planetmega_global.30
		planetmega_global.31
		planetmega_global.32
		planetmega_global.33
	}
}

on_single_player_save_game_load = {
	events = {
		planetmega_global.2
		#planetmega_global.3
		planetmega_global.4
		planetmega_global.5
		planetmega_global.6
		planetmega_global.7
	}
}

#为了优化，但应保留两份
on_monthly_pulse = {
	events = {
		planetmega_global.3
	}
}
# on_monthly_pulse_country = {
# 	events = {
#       planetmega.90
# 		planetmega.106 #行政轴心
# 		planetmega.801 #主脑金字塔
# 		planetmega.401 #凝聚力T1
# 		planetmega_effect.93
#       planetmega.1101
# 	}
# }
# on_colony_monthly_pulse = {
# 	events = {
# 		planetmega.110 #采矿枢机
#       planetmega.111
# 		planetmega.921 #农田T2
# 		planetmega.926 #巢田T2
# 		planetmega.931 #超算
# 		planetmega.936 #脑联
#       planetmega.971 #全能
# 		planetmega_global.20
# 		planetmega_effect.81
# 	}
# }

#为了优化，但应保留两份
on_yearly_pulse = {
	events = {
		planetmega_global.4
        #planetmega.1120 #WIP
	}
}
# on_yearly_pulse_country = {
# 	events = {
# 		planetmega_global.14
# 		planetmega_global.28
#       planetmega_global.50
#       planetmega.938
# 		planetmega.1005
# 	}
# }
# on_colony_yearly_pulse = {
# 	events = {
# 		planetmega.951 #巨像
# 		planetmega.906 #堡垒T2
# 		planetmega_effect.82
# 	}
# }

on_bi_yearly_pulse = {
	events = {
        planetmega_global.5
	}
}
# on_bi_yearly_pulse_country = {
# 	events = {
# 		planetmega.1000
# 	}
# }

on_five_year_pulse = {
	events = {
        planetmega_global.6
	}
}

on_decade_pulse = {
	events = {
		planetmega_global.7
	}
}

on_press_begin = {
	events = {
		planetmega_global.34
	}
}

# Planet has been terraformed
# This = Planet
# From = Terraforming country
on_terraforming_complete = {
	events = {
		planetmega_mod.30
	}
}
# Planet has changed planet class in whatever way. Note that this is also called during galaxy creation in some places.
# This = Planet
on_planet_class_changed = {
	events = {
		planetmega_mod.30
	}
}

# Fired whenever a new owner is set for a planet, following a war or through trade
# This = colony scope
# From = Country scope (new owner)
# FromFrom = Country scope (previous owner, if any)
on_colony_transfer = {
	events = {
        planetmega.405
		planetmega.906
		planetmega_mod.40
	}
}

# A planets controller becomes a country not the same as the owner.
# Root = Planet
# From = Planet Owner
# FromFrom = Planet Controller (the one occupying)
on_planet_occupied = {
    events = {
        planetmega.403
    }
}

# A planets controller becomes the owner of the planet.
# Root = Planet
# From = Planet Owner
# FromFrom = Previous Planet Controller (the one who was occupying)
on_planet_returned = {
    events = {
        planetmega.403
        planetmega.906
    }
}

#FromFrom = Former Owner
#From = Country scope (new owner, so invalid)
#This = Planet scope
on_colony_ownerless = {
    events = {
        planetmega.403
    }
}

# Planet has reached 0 pops from orbital bombardment
# This = Planet
# From = Bombarder
on_colony_zero_pops = {
    events = {
        planetmega.409
    }
}

# Planet has reached 0 pops from collateral damage
# This = Planet
# From = Army owner
on_colony_zero_pops_ground_combat = {
    events = {
        planetmega.409
    }
}

# A pop has finished purging
# This = Planet scope
# From = Country
# FromFrom = Pop group
# local_pop_amount = variable of how many pops were purged
on_pop_purged = {
	events = {
		planetmega_pk.115
        planetmega.406
		planetmega.932
	}
}

# Pop Group is abducted by raiding stance
# This = Pop Group scope
# From = planet abducted from
on_pop_group_abducted = {
    events = {
        planetmega.407
    }
}

# Executed whenever a pop is killed due to bombardment damages
# This = Planet where the pop was bombed to death
# From = Country which is raining down fire and brimstone
# FromFrom = Biggest fleet bombarding the planet (the one we used the bombardment stance from)
# local_kill_pop_amount = amount of pop killed
on_pop_bombed_to_death = {
    events = {
        planetmega.408
    }
}

# A country has increased the level of a tech, use last_increased_tech trigger to check tech and level.
# This = Country
on_tech_increased = {
	events = {
		planetmega_global.12
		planetmega_global.15
		planetmega.1001
		planetmega_global.22
		planetmega_global.17
	}
}

# Triggers country_event for the attacker upon victory (before controller is switched)
# This = country, lead attacker
# From = country, planet owner
# FromFrom = colony
# 'Attacker' is the side that "IsHostile" to the planet controller. For example: spawned monster armies are attackers, but if they win and the player attempts to retake the planet, the player is the attacker
on_colony_attackers_win = {
	events = {
		planetmega_effect.6
	}
}

# Triggers country_event for the defender upon defeat
# This = country, planet owner
# From = country, attack leader
# FromFrom = colony
on_colony_defenders_lose = {
	events = {
		planetmega_effect.7
	}
}

#An army has been killed in ground combat
# This = owner
# From = army
# FromFrom = opponent
# FromFromFrom = colony
on_army_killed_in_combat = {
	events = {
		planetmega.1115
	}
}

# A fleet has entered a system | See also: on_fleet_auto_move_arrival
# Scope = Fleet
# From = System
on_entering_system_fleet = {
	events = {
		planetmega_effect.94
		planetmega_effect.95
		planetmega_effect.150
	}
}

# Executed right after country has established communications with another country. Always fires, even if comms are established with establish_communications_no_message
# This = Country which established the communications
# From = Country which communications were established with
on_post_communications_established_always_fire = {
	events = {
		planetmega.912
	}
}

# This = owner of ship 1 (combatant)
# From = owner of ship 2 (destroyed)
# FromFrom = ship 1
# FromFromFrom = ship 2
on_ship_destroyed_perp = {
	events = {
		#planetmega_pk.30
	}
}

# This = owner of ship 1 (destroyed)
# From = owner of ship 2 (combatant)
# FromFrom = ship 1
# FromFromFrom = ship 2
on_ship_destroyed_victim = {
	events = {
		planetmega_pk.999
		planetmega.1110
	}
}

# This = fleet
# Fires when a fleet exits combat (either because it won, lost, or any reason)
# This is fired once for every fleet that was in combat (which is not the case for on_space_battle_won/lost)
on_fleet_exit_battle = {
	events = {
		#planetmega.1102
		planetmega_effect.151
	}
}

# This = owner of fleet
# From = fleet
# FromFrom = planet (if any)
on_fleet_auto_move_arrival = {
	events = {
		planetmega_effect.152
	}
}

on_megastructure_built = {
    events = {
        planetmega_global.40 #notice
    }
}
on_megastructure_upgraded = {
    events = {
        planetmega_global.42 #notice (including aliens)
    }
}

# This = Fleet ( science vessel )
# From = Archaeological Site
on_arch_site_finished = {
	events = {
		planetmega.28
	}
}

# A country is created via create_country or create_rebels
# This = created country
# From = root of context where create_country/create_rebels happens
on_country_created = {
	events = {
		planetmega.1121
	}
}

#Scope: Ship Event
# A ship has been built
# Root = Ship
# From = Planet
on_ship_built = {
	events = {
		planetmega_effect.141
	}
}

#From = Planet/Starbase/Megastructure/Astral Rift scope
#This = Fleet scope
on_fleet_enter_orbit = {
	events = {
		planetmega_effect.8
	}
}

### component actions

## Dyson Gun
# THIS = Target System
# FROM = Megastructure
# SPACEOWNER = Target System owner
on_dyson_shoot_started = {
	events = {
		planetmega_global.23
	}
}
on_dyson_shoot = {
	events = {
		planetmega.907
		planetmega.952
	}
}
