// ZZ> This function makes an item fall to the floor when spawned
IfScoredAHit
  SetTargetToRider
    tmpargument = 30
    tmpdistance = EXPROLEPLAY
    GiveExperienceToTarget
IfSpawned				// General stuff
  SetTurnModeToWatch
  MakeAmmoKnown
  tmpx = selfx - 200
  tmpy = selfy
  ClearWaypoints
  AddWaypoint
IfDismounted				// Turn it west
  tmpx = selfx - 200
  tmpy = selfy
  ClearWaypoints
  AddWaypoint
IfHealed				// Drop the rider
  SetTargetToRider
    DropWeapons
    tmpx = 15
    tmpy = 0
    AccelerateTarget
IfMounted
  IfAmmoOut
    GetState // NOP
    SetTargetToRider
      IfTargetIsAPlayer
        tmpargument = 1
        SendMessageNear
  Else
    SetTargetToRider
      IfTargetIsAPlayer
        tmpargument = 0
        SendMessageNear
        tmpargument = 5
        tmpdistance = 12500
        PlaySound
IfUsed					// Set number of shells to drop
  tmpargument = 8
  SetContent
  tmpargument = 0
  SetTime
  // Play the machine gun sound
  IfAmmoOut
    tmpargument = 0
    StopSound
    tmpargument = 3
    tmpdistance = 11025
    PlaySoundLooped
    tmpargument = 2
    SetState
  Else
    tmpargument = 0
    tmpdistance = 11025
    PlaySoundLooped
    tmpargument = 1
    SetState
// Firing state
IfStateIs1
  IfTimeOut
    // Down the count
    tmpargument = 0
    GetContent
    tmpargument = tmpargument - 1
    SetContent
    // Check ammo
    IfAmmoOut
      tmpargument = 0
      StopSound
      tmpargument = 2
      SetState
    // Drop a shell
    Else
      tmpx = selfx
      tmpy = selfy
      tmpdistance = selfz
      tmpargument = 3
      SpawnExactParticle
    // Do again in 9 frames
    tmpargument = 9
    SetTime
    // Stop sounds
    tmpargument = 0
    IfContentIs
      StopSound
      SetState
      // Do an echo
      tmpargument = 2
      tmpdistance = 11025
      PlaySound
// Whirring state
IfStateIs2
  IfTimeOut
    // Down the count
    tmpargument = 0
    GetContent
    tmpargument = tmpargument - 1
    SetContent
    // Do again in 9 frames
    tmpargument = 9
    SetTime
    // Stop sounds
    tmpargument = 0
    IfContentIs
      SetState
      tmpargument = 3
      StopSound
      // Do the hum out
      tmpargument = 4
      tmpdistance = 11025
      PlaySound
End					// All done
