# 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: Destructible
    thresholds:
    - trigger:
        !type:DamageTrigger
        damage: 10
      behaviors:
      - !type:TriggerBehavior
  - type: ScatteringGrenade
  - type: OnUseTimerTrigger
    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: [ScatteringGrenadeBase, BaseC2ContrabandUnredeemable, RecyclableItemSteelMedium] # Frontier: BaseSecurityContraband<BaseC2ContrabandUnredeemable added RecyclableItemSteelMedium
  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
    sound:
      path: "/Audio/Machines/door_lock_off.ogg"

- type: entity
  parent: [ScatteringGrenadeBase, BaseC3SyndicateContraband] # Frontier: BaseSyndicateContraband<BaseC3SyndicateContraband
  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: OnUseTimerTrigger
    beepSound:
      path: "/Audio/Effects/beep1.ogg"
      params:
        volume: 5
    initialBeepDelay: 0
    beepInterval: 0.5
  - type: EmitSoundOnTrigger
    sound:
      path: "/Audio/Machines/door_lock_off.ogg"
  - type: StaticPrice
    price: 2500

- type: entity
  parent: [ScatteringGrenadeBase, BaseC3SyndicateContraband] # Frontier: BaseSyndicateContraband<BaseC3SyndicateContraband
  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
    sound:
      path: "/Audio/Items/bikehorn.ogg"

- type: entity
  parent: [SoapSyndie, ScatteringGrenadeBase, BaseC3SyndicateContraband] # Frontier: BaseSyndicateContraband<BaseC3SyndicateContraband
  id: SlipocalypseClusterSoap
  name: slipocalypse clustersoap
  description: Spreads small pieces of syndicate soap over an area upon landing on the floor.
  components:
  - type: WeaponCaseInsertable # Frontier
  - 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
    sound:
      path: "/Audio/Effects/flash_bang.ogg"
  - type: StaticPrice
    price: 1000

- type: entity
  parent: 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: NFBulletFoam # Frontier: use NF variant
    capacity: 30
    velocity: 30
  - type: OnUseTimerTrigger
    beepSound:
      path: "/Audio/Effects/beep1.ogg"
      params:
        volume: 5
    initialBeepDelay: 0
    beepInterval: 2
  - type: EmitSoundOnTrigger
    sound:
      path: "/Audio/Weapons/Guns/Gunshots/batrifle.ogg"
