- type: entity
  parent: [ SimpleSpaceMobBase, FlyingMobBase, BaseSlicingRefinable, MobNightVision, BaseMobDestructible ]
  id: BaseMobDragon
  suffix: ""
  name: space dragon
  description: A flying leviathan, loosely related to space carps.
  abstract: true
  components:
  - type: Bloodstream
    bloodReferenceSolution:
      reagents:
      - ReagentId: Blood
        Quantity: 650
  - type: GhostRole
    allowMovement: true
    allowSpeech: true
    makeSentient: true
    name: ghost-role-information-space-dragon-name
    description: ghost-role-information-space-dragon-description
    rules: ghost-role-information-space-dragon-rules
    mindRoles:
    - MindRoleGhostRoleTeamAntagonist
    raffle:
      settings: default
  - type: GhostTakeoverAvailable
  - type: HTN
    rootTask:
      task: XenoCompound
    blackboard:
      NavInteract: !type:Bool
        true
      NavPry: !type:Bool
        true
      NavSmash: !type:Bool
        true
  - type: NpcFactionMember
    factions:
    - Dragon
  - type: Speech
    speechVerb: LargeMob
  - type: CombatMode
  - type: MobMover
  - type: InputMover
  - type: MovementSpeedModifier
    baseWalkSpeed: 3
    baseSprintSpeed: 5
    baseWeightlessModifier: 1.5
  - type: RandomSprite
    available:
    - enum.DamageStateVisualLayers.Base:
        alive: Rainbow
  - type: Sprite
    sprite: Mobs/Aliens/Carps/dragon.rsi
    noRot: true
    layers:
    - map: [ "enum.DamageStateVisualLayers.Base" ]
      state: alive
    - map: [ "enum.DamageStateVisualLayers.BaseUnshaded" ]
      state: alive-unshaded
      shader: unshaded
  - type: Appearance
  - type: DamageStateVisuals
    states:
      Alive:
        Base: alive
        BaseUnshaded: alive-unshaded
      Critical:
        Base: crit
      Dead:
        Base: dead
        BaseUnshaded: dead-unshaded
  - type: Physics
    bodyType: KinematicController
  - type: Fixtures
    fixtures:
      fix1:
        shape:
          !type:PhysShapeCircle
          radius: 0.40
        density: 100
        mask:
        - FlyingMobMask
        layer:
        - FlyingMobLayer
  - type: MobState
  - type: MobStateActions
    actions:
      Critical:
      - ActionCritSuccumb
      - ActionCritLastWords
  - type: MobThresholds
    thresholds:
      0: Alive
      450: Critical
      500: Dead
  - type: SlowOnDamage
    speedModifierThresholds:
      250: 0.7
      400: 0.5
  # disable taking damage from fire, since its a fire breathing dragon
  - type: Flammable
    damage:
      types: {}
  - type: StatusEffects # Overwriting basesimplemob to remove flash, getting flashed as dragon just feelsbad
    allowed:
    - Electrocution
    - Pacified
    - Adrenaline
  - type: Temperature
  - type: TemperatureDamage
    heatDamageThreshold: 2400
  - type: Metabolizer
    solutionOnBody: false
    updateInterval: 0.25
    metabolizerTypes: [ Dragon ]
    stages: [ Digestion, Bloodstream ]
  - type: ToolRefinable
    refineResult:
    - id: FoodMeatDragon
      amount: 2
  - type: InteractionPopup
    successChance: 0.25 # It's no goose, but you better smell like carp.
    interactSuccessString: petting-success-dragon
    interactFailureString: petting-failure-dragon
    interactFailureSound:
      path: /Audio/Animals/space_dragon_roar.ogg
    soundPerceivedByOthers: false # A 75% chance for a loud roar would get old fast.
  - type: MeleeWeapon
    altDisarm: false
    soundHit:
      path: /Audio/Weapons/Xeno/alien_claw_flesh3.ogg
    damage:
      types:
        Piercing: 15
        Slash: 15
  - type: Devourer
    foodPreferenceWhitelist:
      components:
      - HumanoidProfile
    stomachStorageWhitelist:
      components:
      - MobState
    chemical: Ichor
    healRate: 7.5
    whitelist:
      components:
      - MobState
      - Door
      - Wall
  - type: Tag
    tags:
    - CannotSuicide
    - DoorBumpOpener
    - StunImmune
  - type: Puller
    needsHands: false
  - type: RandomMetadata
    nameSegments:
    - NamesDragon
    - NamesDragonTitle
    nameFormat: name-format-dragon
  - type: Grammar
    attributes:
      proper: true
  - type: NameIdentifier
    group: null  # Strips the numeric identifier from the dragon's name, since they already have randomly-generated names anyway
  - type: Prying
    pryPowered: true
    force: true
    speedModifier: 2.5 # fast because dragon strong
    useSound:
      path: /Audio/Items/crowbar.ogg

- type: entity
  parent: BaseMobDragon
  id: MobDragon
  components:
  - type: Dragon
    spawnRiftAction: ActionSpawnRift
  - type: GhostRole
    mindRoles:
    - MindRoleDragon
  - type: ActionGrant
    actions:
    - ActionDragonsBreath
  - type: GuideHelp
    guides:
    - MinorAntagonists

- type: entity
  parent: BaseMobDragon
  id: MobDragonDungeon
  suffix: Dungeon
  components:
  - type: GhostRole
    description: ghost-role-information-space-dragon-dungeon-description
    rules: ghost-role-information-space-dragon-dungeon-rules
    raffle:
      settings: default
  - type: SlowOnDamage
    speedModifierThresholds:
      100: 0.7
  - type: MobThresholds
    thresholds:
      0: Alive
      200: Dead
  # less meat spawned since it's a lot easier to kill
  - type: ToolRefinable
    refineResult:
    - id: FoodMeatDragon
  - type: MeleeWeapon
    damage:
      types:
        Piercing: 12

- type: entity
  parent: BaseAction
  id: ActionSpawnRift
  name: Summon Carp Rift
  description: Summons a carp rift that will periodically spawns carps.
  components:
  - type: Action
    useDelay: 1
    priority: 3
  - type: Sprite
    sprite: Interface/Actions/carp_rift.rsi
    layers:
    - state: icon
  - type: InstantAction
    event: !type:DragonSpawnRiftActionEvent

- type: entity
  parent: BaseAction
  id: ActionDevour
  name: "[color=red]Devour[/color]"
  description: Attempt to break a structure with your jaws or swallow a creature.
  components:
  - type: Action
    itemIconStyle: BigAction
    priority: 1
  - type: Sprite
    sprite: Interface/Actions/devour.rsi
    layers:
    - state: icon
      map: ["enum.ActionVisuals.Icon"]
    - state: icon-on
      map: ["enum.ActionVisuals.IconToggled"]
      visible: false
  - type: TargetAction
  - type: EntityTargetAction
    canTargetSelf: false
    whitelist:
      components:
      - MobState
      - Door
      - Wall
    event: !type:DevourActionEvent

- type: entity
  parent: BaseAction
  id: ActionDragonsBreath
  name: "[color=orange]Dragon's Breath[/color]"
  description: Spew out flames at anyone foolish enough to attack you!
  components:
  - type: Action
    useDelay: 5
    # TODO: actual sprite and iconOn
    itemIconStyle: BigAction
    priority: 2
    sound: !type:SoundPathSpecifier
      path: /Audio/Animals/space_dragon_breath.ogg
  - type: Sprite
    sprite: Objects/Weapons/Guns/Projectiles/magic.rsi
    layers:
    - state: fireball
  - type: TargetAction
    checkCanAccess: false
    range: 0
  - type: WorldTargetAction
    event: !type:ProjectileSpellEvent
      prototype: ProjectileDragonsBreath
      projectileSpeed: 5

- type: entity
  parent: Smoke
  id: BloodSmoke
  name: smoke
  categories: [ HideSpawnMenu ]
  components:
  - type: Smoke
    spreadAmount: 3
    duration: 2
  - type: Sprite
    sprite: Effects/chemsmoke.rsi
    state: chemsmoke_white
