# SPDX-FileCopyrightText: 2025 Aiden <28298836+Aidenkrz@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Aidenkrz <aiden@djkraz.com>
# SPDX-FileCopyrightText: 2025 Aviu00 <93730715+Aviu00@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 GoobBot <uristmchands@proton.me>
# SPDX-FileCopyrightText: 2025 Ilya246 <57039557+Ilya246@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 Ilya246 <ilyukarno@gmail.com>
# SPDX-FileCopyrightText: 2025 SolsticeOfTheWinter <solsticeofthewinter@gmail.com>
# SPDX-FileCopyrightText: 2025 TheBorzoiMustConsume <197824988+TheBorzoiMustConsume@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 gluesniffler <159397573+gluesniffler@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 gus <august.eymann@gmail.com>
# SPDX-FileCopyrightText: 2025 loltart <159829224+loltart@users.noreply.github.com>
# SPDX-FileCopyrightText: 2025 loltart <lo1tartyt@gmail.com>
#
# SPDX-License-Identifier: AGPL-3.0-or-later

- type: entity
  parent: Traitor
  id: TraitorMidround
  components:
  - type: StationEvent
    earliestStart: 30
    weight: 8
    minimumPlayers: 15
    maxOccurrences: 1
    startAnnouncement: station-event-communication-interception
    startAudio:
      path: /Audio/Announcements/intercept.ogg
    duration: null
    occursDuringRoundEnd: false
    chaos:
      Hostile: 100
      Medical: 100
      Death: 100
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 400
  - type: AlertLevelInterceptionRule
  - type: AntagSelection
    selectionTime: PostPlayerSpawn
    definitions:
    - prefRoles: [ Traitor ]
      min: 1
      max: 2
      playerRatio: 10
      blacklist:
        components:
        - AntagImmune
        - CommandStaff
      lateJoinAdditional: true
      mindRoles:
      - MindRoleTraitor
  - type: Tag
    tags:
      - MidroundAntag

# Midround Changelings
- type: entity
  parent: Changeling
  id: ChangelingMidround
  components:
  - type: StationEvent
    earliestStart: 20
    weight: 4
    minimumPlayers: 15
    maxOccurrences: 1
    startAnnouncement: station-event-communication-interception
    startAudio:
      path: /Audio/Announcements/intercept.ogg
    duration: null
    occursDuringRoundEnd: false
    chaos:
      Hostile: 150
      Medical: 150
      Death: 150
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 600
  - type: AlertLevelInterceptionRule
  - type: AntagSelection
    selectionTime: PostPlayerSpawn
    agentName: changeling-roundend-name
    definitions:
    - prefRoles: [ Changeling ]
      min: 1
      max: 2
      playerRatio: 10
      blacklist:
        components:
        - CommandStaff
        - AntagImmune
        - BibleUser
      lateJoinAdditional: true
      mindRoles:
      - MindRoleChangeling
  - type: Tag
    tags:
      - MidroundAntag

# Midround Heretics
- type: entity
  parent: Heretic
  id: HereticMidround
  components:
  - type: StationEvent
    earliestStart: 20
    weight: 3
    minimumPlayers: 30
    maxOccurrences: 1
    startAnnouncement: station-event-communication-interception
    startAudio:
      path: /Audio/Announcements/intercept.ogg
    duration: null
    occursDuringRoundEnd: false
    chaos:
      Hostile: 200
      Medical: 150
      Death: 200
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 500
  - type: AlertLevelInterceptionRule
  - type: AntagSelection
    selectionTime: PostPlayerSpawn
    agentName: heretic-roundend-name
    definitions:
    - prefRoles: [ Heretic ]
      max: 2
      min: 1
      playerRatio: 15
      blacklist:
        components:
        - CommandStaff
        - AntagImmune
        - BibleUser
      startingGear: Heretictmidround
      lateJoinAdditional: true
      jobBlacklist: [ Chaplain ] # GOOBSTATION
      mindRoles:
      - MindRoleHeretic
  - type: Tag
    tags:
      - MidroundAntag

# Midround Revolutionaries
- type: entity
  parent: Revolutionary
  id: RevolutionaryMidround
  components:
  - type: StationEvent
    earliestStart: 20
    weight: 3
    minimumPlayers: 30
    maxOccurrences: 1
    duration: null
    occursDuringRoundEnd: false
    chaos:
      Hostile: 250
      Medical: 250
      Death: 250
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 900
  - type: AntagSelection
    selectionTime: PostPlayerSpawn
    definitions:
    - prefRoles: [ HeadRev ]
      max: 3
      playerRatio: 15
      blacklist:
        components:
        - AntagImmune
        - CommandStaff
      briefing:
        text: head-rev-role-greeting
        color: CornflowerBlue
        sound: "/Audio/Ambience/Antag/headrev_start.ogg"
      startingGear: HeadRevGear
      components:
      - type: Revolutionary
      - type: HeadRevolutionary
      mindRoles:
      - MindRoleHeadRevolutionary
  - type: Tag
    tags:
      - MidroundAntag

# Skeleton Spawn
- type: entity
  parent: BaseGameRule
  id: SkeletonMidround
  components:
  - type: StationEvent
    weight: 5
    duration: 1
    minimumPlayers: 15
    chaos:
      Hostile: 40
      Medical: 40
      Death: 40
    eventType: Chaotic
  - type: GameRule
    chaosScore: 150
  - type: RandomEntityStorageSpawnRule
    prototype: MobSkeletonCloset
  - type: Tag
    tags:
      - MidroundAntag

# Blob Midround
- type: entity
  parent: BaseGameRule
  id: BlobMidround
  components:
  - type: StationEvent
    weight: 1
    earliestStart: 45
    minimumPlayers: 50
    duration: null
    maxOccurrences: 1
    chaos:
      Hostile: 400
      Medical: 400
      Death: 400
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 1100
  - type: BlobSpawnRule
    carrierBlobProtos:
    - SpawnPointGhostBlobRat
    playersPerCarrierBlob: 30
    maxCarrierBlob: 1
  - type: Tag
    tags:
      - MidroundAntag

- type: entity
  parent: BaseGameRule
  id: FloorGoblinMidRound
  components:
  - type: StationEvent
    weight: 15
    earliestStart: 15
    minimumPlayers: 15
    maxOccurrences: 2
    eventType: Neutral
  - type: GameRule
    chaosScore: 20
  - type: VentCrittersRule
    max: 1
    table: !type:GroupSelector
      children:
      - id: MobFloorGoblin
  - type: Tag
    tags:
    - MidroundAntag

- type: entity
  parent: BaseGameRule
  id: GreyTideAntagMidround
  components:
  - type: StationEvent
    weight: 3
    duration: null
    earliestStart: 20
    minimumPlayers: 40
    chaos:
      Hostile: 50
      Combat: 20
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 220
  - type: AntagSpawner
    prototype: MobHumanGreyTide
  - type: AntagSelection
    agentName: ghost-role-information-grey-tide-name
    definitions:
    - spawnerPrototype: SpawnPointGhostGreyTide
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleSoloAntagonist
      briefing:
        text: grey-tide-role-greeting
        color: Red
        sound: /Audio/_Goobstation/Music/the_gray_tide_song.ogg
  - type: AntagRandomSpawn # TODO replace with MaintsSpawnRuleComponent once mapped
  - type: AntagObjectives
    objectives:
    - GrayTideKillEveryoneObjective

- type: entity
  parent: BaseGameRule
  id: TunnelClownMidround
  components:
  - type: StationEvent
    weight: 4
    duration: null
    earliestStart: 15
    minimumPlayers: 20
    chaos:
      Hostile: 15
      Combat: 20
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 280
  - type: AntagSpawner
    prototype: MobHumanTunnelClown
  - type: AntagSelection
    agentName: ghost-role-information-tunnel-clown-name
    definitions:
    - spawnerPrototype: SpawnPointGhostTunnelClown
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleSoloAntagonist
      briefing:
        text: tunnel-clown-role-greeting
        color: Pink
        sound: /Audio/_Goobstation/Misc/clownalwayswinsshort.ogg
  - type: AntagRandomSpawn # TODO replace with MaintsSpawnRuleComponent once mapped
  - type: AntagObjectives
    objectives:
    - TunnelClownProtectMaintenanceObjective

- type: entity
  parent: BaseGameRule
  id: SingulothKnightsMidround
  components:
  - type: StationEvent
    weight: 2.5
    duration: null
    earliestStart: 45
    minimumPlayers: 50
    chaos:
      Hostile: 75
      Combat: 40
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 420
  - type: AntagSpawner
    prototype: MobHumanSingulothKnight
  - type: AntagSelection
    agentName: ghost-role-information-Singuloth-Knight-name
    definitions:
    - spawnerPrototype: SpawnPointGhostSingulothKnight
      min: 3
      max: 3
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleFreeAgent
      briefing:
        text: Singuloth-Knight-role-greeting
        color: Red
        sound: /Audio/_Goobstation/Misc/singulothknight_greeting.ogg
  - type: AntagRandomSpawn
  - type: AntagObjectives
    objectives:
    - SingulothKnightPreachObjective
    - SingulothKnightSingularityObjective
    - SingulothKnightTeslaObjective

- type: entity
  parent: BaseGameRule
  id: DarkLordMidround
  components:
  - type: StationEvent
    weight: 2
    duration: null
    earliestStart: 30
    minimumPlayers: 30
    chaos:
      Death: 100
      Combat: 85
      Hostile: 40
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 550
  - type: AntagSpawner
    prototype: MobHumanDarkLord
  - type: AntagSelection
    agentName: ghost-role-information-dark-lord-name
    definitions:
    - spawnerPrototype: SpawnPointGhostDarkLord
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleSoloAntagonist
      briefing:
        text: dark-lord-role-greeting
        color: Red
        sound: /Audio/_Goobstation/Misc/darklord_greeting.ogg
  - type: AntagRandomSpawn
  - type: AntagObjectives
    objectives:
    - HijackShuttleObjective
    - KillRandomHeadObjective
    - DarkLordDuelObjective

- type: entity # Only has a chance to spawn whenever dark lord spawns
  parent: BaseGameRule
  id: ChosenOneMidround
  components:
  - type: GameRule
    chaosScore: 50
  - type: AntagSpawner
    prototype: MobHumanChosenOne
  - type: AntagSelection
    agentName: ghost-role-information-chosen-one-name
    definitions:
    - spawnerPrototype: SpawnPointGhostChosenOne
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleNeutral
      briefing:
        text: chosen-one-role-greeting
        color: Green
        sound: /Audio/_Goobstation/Misc/darklord_greeting.ogg
  - type: AntagRandomSpawn
  - type: AntagObjectives
    objectives:
    - ChosenOneKillDarkLordObjective

- type: entity
  parent: BaseGameRule
  id: MimeAssassinMidround
  components:
  - type: StationEvent
    weight: 4
    duration: null
    earliestStart: 30
    minimumPlayers: 30
    chaos:
      Hostile: 40
      Combat: 50
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 300
  - type: AntagSpawner
    prototype: MobHumanMimeAssassin
  - type: AntagSelection
    agentName: ghost-role-information-mime-Assassin-name
    definitions:
    - spawnerPrototype: SpawnPointGhostMimeAssassin
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleSoloAntagonist
      briefing:
        text: mime-Assassin-role-greeting
        color: Red
        sound: /Audio/Misc/thief_greeting.ogg
  - type: AntagRandomSpawn
  - type: AntagObjectives
    objectives:
    - KillRandomHeadObjective
    - KillRandomHeadObjective
    - KillRandomHeadObjective
    - EscapeShuttleObjective

- type: entity
  parent: BaseGameRule
  id: DarkPriestMidround
  components:
  - type: StationEvent
    weight: 3
    duration: null
    earliestStart: 30
    minimumPlayers: 30
    chaos:
      Death: 60
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 350
  - type: AntagSpawner
    prototype: MobHumanDarkPriest
  - type: AntagSelection
    agentName: ghost-role-information-dark-priest-name
    definitions:
    - spawnerPrototype: SpawnPointGhostDarkPriest
      min: 1
      max: 1
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleFreeAgent
      briefing:
        text: dark-priest-role-greeting
        color: Purple
        sound: /Audio/_Goobstation/Heretic/Ambience/Antag/Heretic/heretic_gain.ogg
  - type: AntagRandomSpawn
  - type: AntagObjectives
    objectives:
    - DarkPriestProtectObjective
    - DarkPriestHireApprentice
    - KillRandomPersonObjective
    - EscapeShuttleObjective

- type: entity
  parent: BaseGameRule
  id: VoxRaidersMidround
  components:
  - type: AntagObjectives
    objectives:
    - EscapeThiefShuttleObjective
  - type: AntagRandomObjectives
    sets:
    - groups: ThiefBigObjectiveGroups
      prob: 0.7
      maxPicks: 2
    - groups: ThiefObjectiveGroups
      maxPicks: 15
    maxDifficulty: 2
  - type: StationEvent
    earliestStart: 35
    weight: 2.5
    minimumPlayers: 50
    duration: 1
    chaos:
      Hostile: 300
      Medical: 200
      Death: 300
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 800
  - type: AntagSpawner
    prototype: MobVoxRaider
  - type: RuleGrids
  - type: LoadMapRule
    gridPath: /Maps/_Goobstation/Shuttles/VoxRaiderShuttle.yml
  - type: AntagSelection
    agentName: ghost-role-information-vox-raider-name
    definitions:
    - spawnerPrototype: SpawnPointGhostVoxRaider
      min: 3
      max: 4
      pickPlayer: false
      mindRoles:
      - MindRoleGhostRoleTeamAntagonist
      briefing:
        text: vox-raider-role-greeting
        color: Purple
        sound: /Audio/Misc/thief_greeting.ogg


- type: entity
  id: ClownGoblinMigration
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 15
    earliestStart: 15
    minimumPlayers: 15
    maxOccurrences: 2
    eventType: Neutral
  - type: GameRule
    chaosScore: 0
  - type: VentCrittersRule
    max: 1
    table:
      id: MobClownGoblin
  - type: Tag

# Slasher
- type: entity
  parent: BaseGameRule
  id: SlasherSpawn
  components:
  - type: StationEvent
    weight: 3
    duration: null
    earliestStart: 30
    minimumPlayers: 30
    chaos:
      Hostile: 40
      Combat: 40
      Death: 40
    eventType: HostilesSpawn
  - type: GameRule
    chaosScore: 600
  - type: AntagRandomSpawn
  - type: AntagLoadProfileRule
    speciesOverride: Human
    speciesOverrideBlacklist:
    - Yowie
    - IPC
    - Diona
    - Harpy
    - Plasmaman
  - type: AntagObjectives
    objectives:
    - SlasherSurviveObjective
    - SlasherAbsorbSoulsObjective
  - type: AntagSelection
    selectionTime: PostPlayerSpawn
    agentName: slasher-round-end-agent-name
    definitions:
    - spawnerPrototype: SpawnPointGhostSlasher
      min: 1
      max: 1
      pickPlayer: false
      startingGear: SlasherGear
      briefing:
        text: slasher-role-greeting
        color: Red
        sound: /Audio/_Goobstation/Effects/Slasher/SlasherIntro.ogg
      mindRoles:
      - MindRoleSlasher
      components:
      - type: Slasher
      - type: SlasherSummonMachete
      - type: SlasherStaggerArea
      - type: SlasherRegenerate
      - type: SlasherPossession
      - type: SlasherBloodTrail
      - type: SlasherIncorporeal
      - type: SlasherSoulSteal
      - type: SlasherSummonMeatSpike
      - type: BreathingImmunity
      - type: GunBlocked
        PopupText: slasher-cannot-use-guns # Seems to be broken inside AntagSelection
      - type: WeakToHoly
      - type: NightVision
        activateSound: null
        deactivateSound: null
      - type: Hunger
        baseDecayRate: 0
      - type: Thirst
        baseDecayRate: 0
      - type: MobThresholds
        thresholds:
          0: Alive
          150: Dead
      - type: RandomMetadata
        nameSegments:
        - NamesSlasherTitle
        - NamesSlasher
        nameFormat: name-format-slasher
  - type: Tag
    tags:
    - MidroundAntag

# Santa

- type: entity
  id: SantaClausSpawn
  parent: BaseGameRule
  components:
  - type: StationEvent
    weight: 1
    earliestStart: 3
    minimumPlayers: 10
    maxOccurrences: 1
    eventType: Neutral
  - type: GameRule
    chaosScore: 100
  - type: VentCrittersRule # like a chimney
    max: 1
    table:
      id: SantaClaus
