//Explode in magic
IfKilled
  tmpargument = 1
  SendMessageNear
  GoPoof
  SpawnPoof
  
//Catch on fire
IfAttacked
  GetDamageType
  tmpx = tmpargument
  tmpy = DAMAGEFIRE
  IfXIsEqualToY
    tmpargument = 2
    tmpdistance = rand % 50
    SpawnAttachedParticle
    tmpdistance = rand % 50
    SpawnAttachedParticle
    tmpdistance = rand % 50
    SpawnAttachedParticle
    tmpdistance = rand % 50
    SpawnAttachedParticle
    tmpdistance = rand % 50
    SpawnAttachedParticle

  
//Flying Mode
SetTargetToRider
  Run
  tmpargument = ACTIONWA		  //
  DoAction				  //

  //Set fly height. 
  //50 + 10% per rider intelligence
  tmpargument = targetint > 8
  tmpargument = tmpargument*5
  tmpargument = tmpargument + 50
  SetFlyHeight
  
  //Set Speed
  //20% + 2% per rider intelligence
  tmpargument = targetint > 7
  tmpargument = tmpargument + 20
  SetSpeedPercent
  
  tmpargument = 0
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  SpawnExactParticle
Else
  Stop
  tmpargument = 0
  SetFlyHeight

//Buckle the rider and stop flying
IfAttacked
  tmpargument = 0
  SetFlyHeight
  tmpargument = 50
  SetTime
  tmpargument = 1
  SetState
  tmpargument = ACTIONJB		  //
  DoActionOverride				  //
  KeepAction				  //

// Make it lie on floor
IfDropped				
  KeepAction				  //
  tmpargument = 50
  SetTime
  tmpargument = 1
  SetState
IfGrabbed
  tmpargument = 0
  SetState
  SetTime

IfTimeOut
  IfStateIs1
    tmpargument = 10
    SetBumpHeight
  Else    
    tmpargument = 0
    SetBumpHeight
  
// ZZ> This function makes an item fall to the floor when spawned
IfSpawned				//
  tmpargument = ACTIONJB		  //
  DoAction				  //
  KeepAction				  //
  IfHeld
    SetTargetToWhoeverIsHolding
    SetOwnerToTarget
 
IfHitGround				// Make a sound
  tmpargument = 0		  //
  PlaySound				  //
IfNotDropped
  tmpargument = 2
  SendMessageNear
IfTakenOut
  SetTargetToWhoeverIsHolding
  SetOwnerToTarget
  IfTargetIsAPlayer
    tmpargument = 4
    SendMessageNear
    
//IfNotPutAway
//  tmpargument = 3         //No longer needed, this is handled by the sourcecode now...
//  SendMessageNear

End					// All done
