- type: entityTable
  id: BasicCalmEventsTable
  table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
    children:
    - id: AnomalySpawn
    - id: BluespaceArtifact
    - id: BluespaceLocker
    - id: BreakerFlip
    - id: BureaucraticError
    - id: ClericalError
    - id: CockroachMigration
    - id: GasLeak
    - id: GreytideVirus
    - id: IonStorm # its calm like 90% of the time smh
    - id: KudzuGrowth
    - id: MassHallucinations
    - id: MimicVendorRule
    - id: MouseMigration
    - id: PowerGridCheck
    - id: RandomSentience
    - id: SlimesSpawnHorde
    - id: SolarFlare
    - id: SnakeSpawnHorde
    - id: SpiderClownSpawnHorde
    - id: SpiderSpawnHorde
    - id: VentClog

- type: entityTable
  id: BasicAntagEventsTable
  table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
    children:
    - id: ClosetSkeleton
    - id: KingRatMigration
    - id: RevenantSpawn
    - !type:NestedSelector
      tableId: DerelictBorgEventTable

- type: entityTable
  id: ModerateAntagEventsTable
  table: !type:AllSelector # we need to pass a list of rules, since rules have further restrictions to consider via StationEventComp
    children:
    - id: DragonSpawn
    - id: NinjaSpawn
    - id: ParadoxCloneSpawn
    - id: SleeperAgents
    - id: ZombieOutbreak
    - id: LoneOpsSpawn
    - id: WizardSpawn
    - !type:NestedSelector
      tableId: DerelictBorgEventTable

- type: entityTable
  id: DerelictBorgEventTable #For Derelict Borg spawns
  table: !type:GroupSelector
    children:
    - !type:GroupSelector # Standard NT Borgs
      weight: 85
      children:
        - id: DerelictEngineerCyborgSpawn
        - id: DerelictGenericCyborgSpawn
        - id: DerelictJanitorCyborgSpawn
        - id: DerelictMedicalCyborgSpawn
        - id: DerelictMiningCyborgSpawn
    - !type:GroupSelector # Other Borgs
      weight: 15
      children:
        - id: DerelictSyndicateAssaultCyborgSpawn

- type: entity
  id: BaseStationEvent
  parent: BaseGameRule
  abstract: true
  components:
  - type: GameRule
    delay:
      min:  10
      max:  20

- type: entity
  id: BaseStationEventShortDelay
  parent: BaseGameRule
  abstract: true
  components:
  - type: GameRule
    delay:
      min:  10
      max:  20

- type: entity
  id: BaseStationEventLongDelay
  parent: BaseGameRule
  abstract: true
  components:
  - type: GameRule
    delay:
      min:  40
      max:  60

- type: entity
  id: AnomalySpawn
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncementColor: "#18abf5"
    startAudio:
      path: /Audio/Announcements/announce.ogg
    weight: 8
    duration: 35
  - type: AnomalySpawnRule

- type: entity
  id: BluespaceArtifact
  parent: BaseStationEventShortDelay
  components:
  - type: GameRule
    delay:
      min:  30
      max:  30
  - type: StationEvent
    startAnnouncementColor: "#18abf5"
    startAudio:
      path: /Audio/Announcements/announce.ogg
    weight: 8
    duration: 35
  - type: BluespaceArtifactRule

- type: entity
  id: BluespaceLocker
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 2
    reoccurrenceDelay: 5
    earliestStart: 1
    duration: 1
  - type: BluespaceLockerRule

- type: entity
  id: BreakerFlip
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 7
    duration: 1
    minimumPlayers: 15
  - type: BreakerFlipRule

- type: entity
  id: BureaucraticError
  parent: BaseGameRule
  components:
  - type: StationEvent
    startAnnouncement: station-event-bureaucratic-error-announcement
    minimumPlayers: 25
    weight: 3
    duration: 1
  - type: BureaucraticErrorRule
    ignoredJobs:
    - StationAi
    - ResearchAssistant
    - MedicalIntern
    - SecurityCadet
    - TechnicalAssistant

- type: entity
  id: ClericalError
  parent: BaseGameRule
  components:
  - type: StationEvent
    startAnnouncement: station-event-clerical-error-announcement
    minimumPlayers: 15
    weight: 5
    duration: 1
  - type: ClericalErrorRule

- type: entity
  parent: BaseGameRule
  id: ClosetSkeleton
  components:
  - type: StationEvent
    weight: 5
    duration: 1
    minimumPlayers: 10
  - type: RandomEntityStorageSpawnRule
    prototype: MobSkeletonCloset

- type: entity
  parent: BaseGameRule
  id: DragonSpawn
  components:
  - type: StationEvent
    weight: 6.5
    earliestStart: 40
    reoccurrenceDelay: 20
    minimumPlayers: 20
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: MobDragon
  - type: DragonRule
  - type: AntagObjectives
    objectives:
    - CarpRiftsObjective
    - DragonSurviveObjective
  - type: AntagSelection
    agentName: dragon-round-end-agent-name
    definitions:
    - spawnerPrototype: SpawnPointGhostDragon
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleDragon
  - type: DynamicRuleCost
    cost: 75

- type: entity
  parent: BaseGameRule
  id: NinjaSpawn
  components:
  - type: StationEvent
    weight: 6
    duration: null
    earliestStart: 30
    reoccurrenceDelay: 20
    minimumPlayers: 30
  - type: SpaceSpawnRule
  - type: AntagLoadProfileRule
  - type: AntagObjectives
    objectives:
    - StealResearchObjective
    - DoorjackObjective
    - SpiderChargeObjective
    - TerrorObjective
    - MassArrestObjective
    - NinjaSurviveObjective
  - type: AntagSelection
    agentName: ninja-round-end-agent-name
    definitions:
    - spawnerPrototype: SpawnPointGhostSpaceNinja
      min: 1
      max: 1
      pickPlayer: false
      startingGear: SpaceNinjaGear
      roleLoadout:
      - RoleSurvivalSpaceNinja
      briefing:
        text: ninja-role-greeting
        color: Green
        sound: /Audio/Misc/ninja_greeting.ogg
      components:
      - type: SpaceNinja
      - type: NpcFactionMember
        factions:
        - Syndicate
      - type: AutoImplant
        implants:
        - DeathAcidifierImplant
      - type: RandomMetadata
        nameSegments:
        - NamesNinjaTitle
        - NamesNinja
        nameFormat: name-format-ninja
      mindRoles:
      - MindRoleNinja
  - type: DynamicRuleCost
    cost: 75

- type: entity
  parent: BaseGameRule
  id: ParadoxCloneSpawn
  components:
  - type: StationEvent
    weight: 5
    duration: null
    earliestStart: 20
    reoccurrenceDelay: 20
    minimumPlayers: 15
  - type: ParadoxCloneRule
    objectiveBlacklist:
      tags:
      - ParadoxCloneObjectiveBlacklist
  - type: AntagObjectives
    objectives:
    - ParadoxCloneKillObjective
    - ParadoxCloneLivingObjective
  - type: AntagRandomSpawn # TODO: improve spawning so they only start in maints
  - type: AntagSelection
    agentName: paradox-clone-round-end-agent-name
    definitions:
    - spawnerPrototype: SpawnPointGhostParadoxClone
      min: 1
      max: 1
      pickPlayer: false
      startingGear: ParadoxCloneGear
      roleLoadout:
      - RoleSurvivalVoxTank # give vox something to breath in case they don't get a copy
      briefing:
        text: paradox-clone-role-greeting
        color: lightblue
        sound: /Audio/Misc/paradox_clone_greeting.ogg
      mindRoles:
      - MindRoleParadoxClone
  - type: DynamicRuleCost
    cost: 50

- type: entity
  parent: BaseGameRule
  id: RevenantSpawn
  components:
  - type: StationEvent
    weight: 7.5
    duration: 1
    earliestStart: 45
    minimumPlayers: 20
  - type: RandomSpawnRule
    prototype: MobRevenant

- type: entity
  parent: BaseWizardRule
  id: WizardSpawn
  components:
  - type: StationEvent
    weight: 1 # rare
    duration: 1
    earliestStart: 30
    reoccurrenceDelay: 60
    minimumPlayers: 30
  - type: AntagSelection
    agentName: wizard-round-end-name
    definitions:
    - spawnerPrototype: SpawnPointGhostWizard
      min: 1
      max: 1
      playerRatio: 1
      pickPlayer: false
      startingGear: WizardBlueGear
      roleLoadout:
      - RoleSurvivalExtended
      briefing:
        text: wizard-role-greeting
        color: Turquoise
        # TODO: Need Wizard Start sound
        #sound: "/Audio/Ambience/Antag/wizard_start.ogg"
      # TODO: WizardComp as needed
      components:
      - type: NpcFactionMember
        factions:
        - Wizard
      - type: RandomMetadata
        nameSegments:
        - NamesWizardFirst
        - NamesWizardLast
        nameFormat: name-format-wizard
      mindRoles:
      - MindRoleWizard

# disabled until event is rewritten to be more interesting
#- type: entity
#  id: FalseAlarm
#  parent: BaseGameRule
#  components:
#  - type: StationEvent
#    weight: 15
#    duration: 1
#  - type: FalseAlarmRule

- type: entity
  id: GasLeak
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-gas-leak-start-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    endAnnouncement: station-event-gas-leak-end-announcement
    weight: 8
  - type: GasLeakRule

- type: entity
  id: KudzuGrowth
  parent: BaseStationEventLongDelay
  components:
  - type: StationEvent
    earliestStart: 15
    minimumPlayers: 15
    weight: 7
    duration: 240
  - type: KudzuGrowthRule

- type: entity
  id: PowerGridCheck
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    weight: 5
    startAnnouncement: station-event-power-grid-check-start-announcement
    endAnnouncement: station-event-power-grid-check-end-announcement
    startAudio:
      path: /Audio/Announcements/power_off.ogg
      params:
        volume: -4
    duration: 60
    maxDuration: 120
  - type: PowerGridCheckRule

- type: entity
  parent: BaseGameRule
  id: SolarFlare
  components:
  - type: StationEvent
    weight: 8
    startAnnouncement: station-event-solar-flare-start-announcement
    endAnnouncement: station-event-solar-flare-end-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    duration: 120
    maxDuration: 240
  - type: SolarFlareRule
    onlyJamHeadsets: true
    affectedChannels:
    - Common
    extraChannels:
    - Command
    - Engineering
    - Medical
    - Science
    - Security
    - Service
    - Supply
    extraCount: 2
    lightBreakChancePerSecond: 0.0003
    doorToggleChancePerSecond: 0.001

- type: entity
  id: VentClog
  parent: BaseStationEventLongDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-clog-start-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    earliestStart: 15
    minimumPlayers: 15
    weight: 5
    duration: 60
  - type: VentClogRule

# Critters

- type: entity
  id: SlimesSpawnHorde
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-horde-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    earliestStart: 20
    minimumPlayers: 15
    weight: 5
    duration: 5
    maxDuration: 20
  - type: VentHordeRule
    table: !type:GroupSelector
      rolls: 4, 8
      children:
      - id: MobAdultSlimesBlueAngry
      - id: MobAdultSlimesGreenAngry
      - id: MobAdultSlimesYellowAngry

- type: entity
  id: SnakeSpawnHorde
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-horde-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    earliestStart: 20
    minimumPlayers: 15
    weight: 5
    duration: 5
    maxDuration: 20
  - type: VentHordeRule
    table: !type:GroupSelector
      rolls: 4, 8
      children:
      - id: MobPurpleSnake
      - id: MobSmallPurpleSnake
      - id: MobCobraSpace

- type: entity
  id: SpiderSpawnHorde
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-horde-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    earliestStart: 20
    minimumPlayers: 15
    weight: 5
    duration: 5
    maxDuration: 20
  - type: VentHordeRule
    table: !type:GroupSelector
      rolls: 4, 8
      children:
      - id: MobGiantSpiderAngry

- type: entity
  id: SpiderClownSpawnHorde
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAnnouncement: station-event-vent-creatures-start-horde-announcement
    startAudio:
      path: /Audio/Announcements/attention.ogg
    earliestStart: 20
    minimumPlayers: 20
    weight: 1.5
    duration: 5
    maxDuration: 20
  - type: VentHordeRule
    table: !type:GroupSelector
      rolls: 4, 8
      children:
      - id: MobClownSpider

- type: entity
  id: ZombieOutbreak
  parent: BaseGameRule
  components:
  - type: StationEvent
    earliestStart: 90
    minimumPlayers: 40
    weight: 1 # Zombies was happening basically every single survival round, so now it's super rare
    duration: 1
    occursDuringRoundEnd: false
  - type: ZombieRule
  - type: AntagSelection
    definitions:
    - prefRoles: [ InitialInfected ]
      max: 3
      playerRatio: 10
      blacklist:
        components:
        - ZombieImmune
        - AntagImmune
      briefing:
        text: zombie-patientzero-role-greeting
        color: Plum
        sound: "/Audio/Ambience/Antag/zombie_start.ogg"
      components:
      - type: PendingZombie #less time to prepare than normal
        minInitialInfectedGrace: 300
        maxInitialInfectedGrace: 450
      - type: ZombifyOnDeath
      - type: IncurableZombie
      - type: InitialInfected
      mindRoles:
      - MindRoleInitialInfected
  - type: DynamicRuleCost
    cost: 200

- type: entity
  parent: BaseNukeopsRule
  id: LoneOpsSpawn
  components:
  - type: StationEvent
    earliestStart: 35
    weight: 5.5
    minimumPlayers: 20
    duration: null # LoneOpsSpawn needs an infinite duration so that it inherits the NukeOpsRule things of an actually appropriate end screen (not always "Neutral outcome!") and... ending the game if the station is nuked.
  - type: RuleGrids
  - type: LoadMapRule
    gridPath: /Maps/Shuttles/ShuttleEvent/striker.yml
  - type: NukeopsRule
    roundEndBehavior: Nothing
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointLoneNukeOperative
      min: 1
      max: 1
      pickPlayer: false
      startingGear: SyndicateLoneOperativeGearFull
      roleLoadout:
      - RoleSurvivalNukie
      components:
      - type: NukeOperative
      - type: RandomMetadata
        nameSegments:
        - NamesSyndicatePrefix
        - NamesSyndicateNormal
        nameFormat: name-format-nukie-generic
      - type: NpcFactionMember
        factions:
        - Syndicate
      mindRoles:
      - MindRoleLoneops
  - type: DynamicRuleCost
    cost: 75

- type: entity
  parent: BaseTraitorRule
  id: SleeperAgents
  components:
  - type: StationEvent
    earliestStart: 30
    weight: 8
    minimumPlayers: 15
    maxOccurrences: 1 # can only happen once per round
    startAnnouncement: station-event-communication-interception
    startAudio:
      path: /Audio/Announcements/intercept.ogg
    duration: null # the rule has to last the whole round not 1 second
    occursDuringRoundEnd: false
  - type: AlertLevelInterceptionRule
  - type: AntagSelection
    definitions:
    - prefRoles: [ TraitorSleeper ]
      fallbackRoles: [ Traitor ]
      min: 1
      max: 2
      playerRatio: 10
      blacklist:
        components:
        - AntagImmune
      mindRoles:
      - MindRoleTraitorSleeper

- type: entity
  id: MassHallucinations
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 7
    duration: 150
    maxDuration: 300
    reoccurrenceDelay: 30
  - type: MassHallucinationsRule
    minTimeBetweenIncidents: 0.1
    maxTimeBetweenIncidents: 300
    maxSoundDistance: 7
    sounds:
      collection: Paracusia

- type: entity
  parent: BaseGameRule
  id: IonStorm
  components:
  - type: StationEvent
    weight: 8
    reoccurrenceDelay: 20
    duration: 1
  - type: IonStormRule

- type: entity
  id: MimicVendorRule
  parent: BaseGameRule
  components:
  - type: StationEvent
    earliestStart: 0
    minimumPlayers: 20
    maxOccurrences: 1 # this event has diminishing returns on interesting-ness, so we cap it
    weight: 5
  - type: MobReplacementRule

- type: entity
  id: GreytideVirus
  parent: BaseStationEventShortDelay
  components:
  - type: StationEvent
    startAudio:
      path: /Audio/Announcements/attention.ogg
    weight: 5
    minimumPlayers: 25
    reoccurrenceDelay: 20
  - type: GreytideVirusRule
    accessGroups:
    - Cargo
    - Command
    - Engineering
    - Research
    - Security
    - Service
    blacklist:
    - External # don't space everything

- type: entity
  parent: BaseGameRule
  id: SmugglerStashVariationPass
  components:
  - type: StationEvent
    earliestStart: 0
    duration: 1
    minimumPlayers: 1
    maxOccurrences: 2
    weight: 10
  - type: RandomSpawnRule
    prototype: RandomSatchelSpawner

- type: entity
  parent: BaseGameRule
  id: DerelictEngineerCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerEngineeringBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictEngineeringCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictGenericCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictJanitorCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerJanitorBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictJanitorCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictMedicalCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerMedicalBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictMedicalCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictMiningCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 15
    reoccurrenceDelay: 20
    minimumPlayers: 4
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerMiningBorgDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictMiningCyborg
      min: 1
      max: 1
      pickPlayer: false

- type: entity
  parent: BaseGameRule
  id: DerelictSyndicateAssaultCyborgSpawn
  components:
  - type: StationEvent
    weight: 2.5
    earliestStart: 25
    reoccurrenceDelay: 20
    minimumPlayers: 15
    duration: null
  - type: SpaceSpawnRule
    spawnDistance: 0
  - type: AntagSpawner
    prototype: PlayerBorgSyndicateDerelictGhostRole
  - type: AntagSelection
    definitions:
    - spawnerPrototype: SpawnPointGhostDerelictSyndicateAssaultCyborg
      min: 1
      max: 1
      pickPlayer: false
