- type: entity
  name: explosive grenade
  description: Grenade that creates a small but devastating explosion.
  parent: [VolatileGrenadeBase, TimerGrenadeBase, BaseSyndicateContraband]
  id: ExGrenade
  components:
  - type: ExplodeOnTrigger
    keysIn:
    - timer
  - type: Explosive
    explosionType: Default
    maxIntensity: 10
    intensitySlope: 3
    totalIntensity: 120 # about a ~4 tile radius
    canCreateVacuum: false
  - type: TimerTrigger
    beepSound:
      path: "/Audio/Effects/beep1.ogg"
      params:
        volume: 5
    initialBeepDelay: 0
    beepInterval: 2 # 2 beeps total (at 0 and 2)

- type: entity
  name: flashbang
  description: Eeeeeeeeeeeeeeeeeeeeee.
  parent: [ FragileGrenadeBase, TimerGrenadeBase, BaseSecurityContraband ]
  id: GrenadeFlashBang
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/flashbang.rsi
  - type: FlashOnTrigger
    keysIn:
    - timer
    range: 7
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: "/Audio/Effects/flash_bang.ogg"
    positional: true
  - type: DeleteOnTrigger
    keysIn:
    - timer
  - type: SpawnOnTrigger
    keysIn:
    - timer
    proto: GrenadeFlashEffect
    predicted: true
  - type: Appearance
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/countdown.ogg
  - type: GuideHelp
    guides:
    - Security
    - Antagonists
  - type: Tag
    tags:
    - HandGrenade
    - GrenadeFlashBang

- type: entity
  id: GrenadeFlashEffect
  categories: [ HideSpawnMenu ]
  components:
    - type: PointLight
      enabled: true
      radius: 5
      energy: 8
      netsync: false
    - type: LightFade
      duration: 0.5
    - type: TimedDespawn
      lifetime: 0.5

# Tuned to be a general bomb that deals equipment damage without explicitly gibbing, however it will still gladly instakill anyone that mishandles it.
# One of the few syndie bombs that should punch holes in space.
- type: entity
  name: syndicate minibomb
  description: A syndicate-manufactured explosive used to stow destruction and cause chaos.
  parent: [VolatileGrenadeBase, TimerGrenadeBase, BaseSyndicateContraband]
  id: SyndieMiniBomb
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/syndgrenade.rsi
  - type: ExplosionResistance
    damageCoefficient: 0.1
  - type: TimerTrigger
    delay: 5
  - type: ExplodeOnTrigger
    keysIn:
    - timer
  - type: Explosive
    explosionType: Minibomb
    totalIntensity: 200
    intensitySlope: 30 #Will destroy the tile under it reliably, space 1-2 more to rods. Only does any significant damage in a 5-tile cross.
    maxIntensity: 60
  - type: Appearance
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/minibombcountdown.ogg
      params:
        volume: 12
  - type: StaticPrice
    price: 2000

- type: entity
  name: self destruct
  description: Go out on your own terms!
  parent: TimerGrenadeBase
  id: SelfDestructSeq
  categories: [ HideSpawnMenu ]
  components:
  - type: ExplodeOnTrigger
    keysIn:
    - timer
  - type: Explosive
    explosionType: Minibomb
    totalIntensity: 400
    intensitySlope: 30
    maxIntensity: 125
    deleteAfterExplosion: false
    repeatable: true
    canCreateVacuum: true
  - type: TimerTrigger
    delay: 4.5
    beepSound:
      path: /Audio/Effects/Grenades/SelfDestruct/SDS_Charge2.ogg
      params:
        volume: 30
    initialBeepDelay: 0
    beepInterval: 16
  - type: LightBehaviorOnTrigger
    behavior: activate
  - type: PointLight
    energy: 50
    radius: 0
    color: Red
    softness: 0
    falloff: 20
    mask: /Textures/Effects/LightMasks/double_cone.png
  - type: RotatingLight
    speed: 360
  - type: LightBehaviour
    behaviours:
    - !type:FadeBehaviour # have the radius start small and get larger as it starts to burn
      id: activate
      maxDuration: 5
      startValue: 1
      endValue: 2


- type: entity
  parent: [ FragileGrenadeBase, TimerGrenadeBase, BaseSyndicateContraband ]
  id: SingularityGrenade
  name: singularity grenade
  description: Grenade that simulates the power of a singularity, pulling things in a heap.
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/singularitygrenade.rsi
  - type: TimerTrigger
    delay: 3
    beepInterval: 0.46
    beepSound:
      path: /Audio/Effects/Grenades/Supermatter/smbeep.ogg
      params:
        volume: -5
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/Grenades/Supermatter/smbeep.ogg
      params:
        volume: -5
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: /Audio/Effects/Grenades/Supermatter/supermatter_start.ogg
      params:
        volume: 5
  - type: AnchorOnTrigger
    keysIn:
    - timer
    removeOnTrigger: true
  - type: TwoStageTrigger
    keysIn:
    - timer
    triggerDelay: 10.45
    components:
      - type: AmbientSound
        enabled: true
        volume: -5
        range: 14
        sound:
          path: /Audio/Effects/Grenades/Supermatter/supermatter_loop.ogg
      - type: GravityWell
        maxRange: 5
        minRange: 0.25
        baseRadialAcceleration: 25
        baseTangentialAcceleration: 5
        gravPulsePeriod: 0.03
      - type: SingularityDistortion
        intensity: 150
        falloffPower: 1.5
      - type: PointLight
        enabled: true
        color: "#ffaa44"
        energy: 8
        radius: 6
        softness: 1
        offset: "0, 0"
      - type: EmitSoundOnTrigger
        sound:
          path: /Audio/Effects/Grenades/Supermatter/supermatter_end.ogg
          params:
            volume: 5
        positional: true
        keysIn:
        - stageTwo
      - type: DeleteOnTrigger
        keysIn:
        - stageTwo
  - type: StaticPrice
    price: 1000

- type: entity
  name: whitehole grenade
  description: Grenade that repulses everything around for some time.
  parent: SingularityGrenade
  id: WhiteholeGrenade
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/whiteholegrenade.rsi
  - type: TimerTrigger
    delay: 3
    beepInterval: 0.69
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: /Audio/Effects/Grenades/Supermatter/whitehole_start.ogg
      params:
        volume: 5
  - type: AnchorOnTrigger
    keysIn:
    - timer
    removeOnTrigger: true
  - type: TwoStageTrigger
    triggerDelay: 11.14
    components:
      - type: AmbientSound
        enabled: true
        volume: -5
        range: 14
        sound:
          path: /Audio/Effects/Grenades/Supermatter/whitehole_loop.ogg
      - type: GravityWell
        maxRange: 7
        baseRadialAcceleration: -10
        baseTangentialAcceleration: -1
        gravPulsePeriod: 0.03
      - type: SingularityDistortion
        intensity: -200
        falloffPower: 1.5
      - type: PointLight
        enabled: true
        color: "#ffffff"
        energy: 8
        radius: 6
        softness: 1
        offset: "0, 0"
      - type: EmitSoundOnTrigger
        keysIn:
        - stageTwo
        sound:
          path: /Audio/Effects/Grenades/Supermatter/supermatter_end.ogg
          params:
            volume: 15
        positional: true
      - type: DeleteOnTrigger
        keysIn:
        - stageTwo
  - type: StaticPrice
    price: 1000

- type: entity
  name: the nuclear option
  description: Please don't throw it, think of the children.
  parent: TimerGrenadeBase
  id: NuclearGrenade
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/nukenade.rsi
  - type: TimerTrigger
    delay: 5
  - type: ExplodeOnTrigger
    keysIn:
    - timer
  - type: Explosive
    explosionType: Default
    totalIntensity: 20000 # ~15 tile radius.
    intensitySlope: 5
    maxIntensity: 50
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:TriggerBehavior
        keyOut: timer # immediately explode
      - !type:DoActsBehavior
        acts: ["Destruction"]
  - type: Appearance
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/countdown.ogg

- type: entity
  name: modular grenade
  description: A grenade casing. Requires a trigger and a payload.
  parent: BaseItem
  id: ModularGrenade
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/modular.rsi
    layers:
    - state: empty
      map: [ "enum.ConstructionVisuals.Layer" ]
  - type: Item
    size: Small
  - type: Tag
    tags:
    - HandGrenade
  - type: PayloadCase
  - type: Construction
    graph: ModularGrenadeGraph
    node: emptyCase
  - type: Damageable
  - type: Injurable
    damageContainer: Inorganic
  - type: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 50
      behaviors:
      - !type:TriggerBehavior
      - !type:DoActsBehavior
        acts: [ "Destruction" ]
  - type: Appearance
  - type: GenericVisualizer
    visuals:
      enum.ConstructionVisuals.Key:
        enum.ConstructionVisuals.Layer:
          emptyCase: { state: empty }
          wiredCase: { state: wired }
          caseWithTrigger: { state: no-payload }
          caseWithPayload: { state: no-trigger }
          grenade: { state: complete }
      enum.Trigger.TriggerVisuals.VisualState:
        enum.ConstructionVisuals.Layer:
          Primed: { state: primed }
          # Unprimed: <Use state determined by enum.ConstructionVisuals.Layer>
  - type: StaticPrice
    price: 75

- type: entity
  name: EMP grenade
  description: A grenade designed to wreak havoc on electronic systems.
  parent: [ImpactGrenadeBase, BaseSyndicateContraband]
  id: EmpGrenade
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/empgrenade.rsi
  - type: EmpOnTrigger
    keysIn:
    - trigger
    range: 5.5
    energyConsumption: 50000
  - type: DeleteOnTrigger
    keysIn:
    - trigger
  - type: StaticPrice
    price: 666 # 2000 for 3, I love fractions

- type: entity
  name: holy hand grenade
  description: O Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy.
  parent: [TimerGrenadeBase, BaseSyndicateContraband]
  id: HolyHandGrenade
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/holyhandgrenade.rsi
  - type: ExplodeOnTrigger
    keysIn:
    - timer
  - type: Explosive
    explosionType: Default # same as macrobomb
    totalIntensity: 3500
    intensitySlope: 15
    maxIntensity: 70
    canCreateVacuum: true
  - type: TimerTrigger
    delay: 3 # by canon
  - type: PointLight
    radius: 7
    energy: 3
    netsync: false
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/hallelujah.ogg
  - type: StaticPrice
    price: 10000

# Non-explosive "dummy" grenades to use as a distraction.

- type: entity
  name: trick grenade
  description: All the grenade without any of the boom.
  parent: TimerGrenadeBase
  id: GrenadeDummy
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/grenade.rsi
  - type: DeleteOnTrigger
    keysIn:
    - timer
  - type: SpawnOnTrigger
    keysIn:
    - timer
    proto: GrenadeFlashEffect
    predicted: true
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: /Audio/Effects/Emotes/parp1.ogg
    positional: true
  - type: Appearance
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/countdown.ogg

- type: entity
  name: syndicate trickybomb
  description: A syndicate-manufactured explosive used to make an excellent distraction.
  parent: [GrenadeDummy, BaseSyndicateContraband]
  id: SyndieTrickyBomb
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/syndgrenade.rsi
  - type: TimerTrigger
    delay: 5
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: /Audio/Effects/Emotes/parp1.ogg
    positional: true
  - type: Appearance
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/minibombcountdown.ogg
      params:
        volume: 12
  - type: StaticPrice
    price: 50
