# ScatteringGrenade is intended for grenades that spawn entities, especially those with timers
- type: entity
  abstract: true
  parent: BaseItem
  id: ScatteringGrenadeBase
  components:
  - type: Appearance
  - type: ContainerContainer
    containers:
      cluster-payload: !type:Container
  - type: Damageable
    damageContainer: Inorganic
  - type: ScatteringGrenade
  - type: TriggerOnUse
  - type: TimerTrigger
    delay: 3
  - type: Tag
    tags:
    - HandGrenade
  - type: Fixtures
    fixtures:
      fix1:
        shape: !type:PhysShapeCircle
          radius: 0.2
        density: 20 # derived from base_item
        mask:
        - ItemMask
        restitution: 0.3
        friction: 0.2

- type: entity
  parent: [FragileGrenadeBase, ScatteringGrenadeBase, BaseSecurityContraband]
  id: ClusterBang
  name: clusterbang
  description: Can be used only with flashbangs. Explodes several times.
  components:
  - type: ScatteringGrenade
    whitelist:
      tags:
      - GrenadeFlashBang
    distance: 6
    velocity: 6
  - type: ClusterGrenadeVisuals
    state: base
  - type: Sprite
    sprite: Objects/Weapons/Grenades/clusterbang.rsi
    state: base-0

- type: entity
  parent: ClusterBang
  id: ClusterBangFull
  name: clusterbang
  description: Launches three flashbangs after the timer runs out.
  suffix: Full
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/clusterbang.rsi
    layers:
    - state: icon
      map: ["enum.TriggerVisualLayers.Base"]
  - type: ScatteringGrenade
    whitelist:
      tags:
      - GrenadeFlashBang
    fillPrototype: GrenadeFlashBang
    distance: 6
    velocity: 6
  - type: TimerTriggerVisuals
    primingSound:
      path: /Audio/Effects/countdown.ogg
  - type: GenericVisualizer
    visuals:
      enum.Trigger.TriggerVisuals.VisualState:
        enum.ConstructionVisuals.Layer:
          Primed: { state: primed }
          Unprimed: { state: icon }
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: "/Audio/Machines/door_lock_off.ogg"
    positional: true

- type: entity
  parent: [VolatileGrenadeBase, ScatteringGrenadeBase, BaseSyndicateContraband]
  id: ClusterGrenade
  name: clustergrenade
  description: Why use one grenade when you can use three at once!
  components:
  - type: Sprite
    sprite: Objects/Weapons/Grenades/clusterbomb.rsi
    layers:
    - state: icon
      map: ["enum.TriggerVisualLayers.Base"]
  - type: ScatteringGrenade
    fillPrototype: ExGrenade
    distance: 4
  - type: TimerTrigger
    beepSound:
      path: "/Audio/Effects/beep1.ogg"
      params:
        volume: 5
    initialBeepDelay: 0
    beepInterval: 0.5
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: "/Audio/Machines/door_lock_off.ogg"
    positional: true
  - type: StaticPrice
    price: 2500

- type: entity
  parent: [FragileGrenadeBase, ScatteringGrenadeBase, BaseSyndicateContraband]
  id: ClusterBananaPeel
  name: cluster banana peel
  description: Splits into 6 explosive banana peels after throwing, guaranteed fun!
  components:
  - type: Sprite
    sprite: Objects/Specific/Hydroponics/banana.rsi
    state: produce
  - type: ScatteringGrenade
    fillPrototype: TrashBananaPeelExplosive
    capacity: 6
    delayBeforeTriggerContents: 20
  - type: LandAtCursor
  - type: DamageOnLand
    damage:
      types:
        Blunt: 10
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: "/Audio/Items/bikehorn.ogg"
    positional: true

- type: entity
  parent: [SoapSyndie, ScatteringGrenadeBase, BaseSyndicateContraband]
  id: SlipocalypseClusterSoap
  name: slipocalypse clustersoap
  description: Spreads small pieces of syndicate soap over an area upon landing on the floor.
  components:
  - type: Sprite
    sprite: Objects/Specific/Janitorial/soap.rsi
    layers:
    - state: syndie-4
  - type: ScatteringGrenade
    fillPrototype: SoapletSyndie
    capacity: 30
    delayBeforeTriggerContents: 60
    randomDistance: true
    randomThrowDistanceMax: 3
  - type: LandAtCursor
  - type: DamageOnLand
    damage:
      types:
        Blunt: 10
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: "/Audio/Effects/flash_bang.ogg"
    positional: true
  - type: StaticPrice
    price: 1000

- type: entity
  parent: [FragileGrenadeBase, ScatteringGrenadeBase]
  id: GrenadeFoamDart
  name: foam dart grenade
  description: Releases a bothersome spray of foam darts that cause severe welching.
  components:
  - type: Sprite
    sprite: Objects/Fun/Foam/foam_grenade.rsi
    layers:
    - state: icon
      map: ["Base"]
    - state: primed
      map: ["enum.TriggerVisualLayers.Base"]
  - type: ScatteringGrenade
    fillPrototype: BulletFoam
    capacity: 30
    velocity: 30
  - type: TimerTrigger
    beepSound:
      path: "/Audio/Effects/beep1.ogg"
      params:
        volume: 5
    initialBeepDelay: 0
    beepInterval: 2
  - type: EmitSoundOnTrigger
    keysIn:
    - timer
    sound:
      path: "/Audio/Weapons/Guns/Gunshots/batrifle.ogg"
    positional: true
