//-----------------------------------------------------------------------------------------------
//Reset trap at start
IfSpawned
  tmpargument = ACTIONMG
  DoAction
  tmpargument = rand & 15 + 50		//Dont activate at start
  SetTime
  
//-----------------------------------------------------------------------------------------------
//Trap effects
KeepAction
IfTimeOut
  tmpargument = rand & 7 + 10
  SetTime
  tmpargument = [NONE]
  tmpdistance = BLAHENEMIES + BLAHFRIENDS
  SetTargetToWideBlahID
    tmpx = targetdistance
    tmpy = rand & 63 + 80			//Trigger range
    IfXIsLessThanY
      tmpx = targetz
      tmpy = selfz + 100
      IfXIsLessThanY		//This enables targets to fly or jump over the trap
        tmpargument = ACTIONMG
        DoAction
        tmpargument = 0
        PlaySound			//Play clinking
        tmpargument = 50
        SetTime			                //Need some time to reset
        
        //Deal damage to nearby stuff
        tmpargument = 1
        tmpx = 0
        tmpy = 0
        tmpdistance = SPAWNORIGIN
        SpawnParticle

  //Check for trapfinders to find it
  IfStateIs0			//Not detected yet
    IfTargetIsAPlayer			//Only for players
      tmpargument = [DISA]			//Does the target have disarm skill?
      IfTargetHasSkillID
        tmpx = targetdistance
        tmpy = 500			//Detect range
        IfXIsLessThanY
          tmpx = rand & 1280 + targetint	//0-5 + the characters intelligence
          tmpy = 4352			//need to be more than 17 points added together
          IfXIsMoreThanY
            tmpargument = 0
            SendMessageNear
            tmpargument = 1
            SetState			//Mark as detected
            tmpargument = 5
            tmpdistance = EXPDARE
            GiveExperienceToTarget		//Award some xp
            tmpargument = 1
            PlaySound				//Play sound effect
                        
            //Draw the floating text
            tmpdistance = 3         //Duration
            tmpargument = 1         //Message 8
            tmpturn = RED          //Message color
            DrawBillboard

//-----------------------------------------------------------------------------------------------
//Detected trap particles
IfStateIs1
  tmpargument = 0
  tmpx = selfx
  tmpy = selfy
  tmpdistance = selfz
  SpawnExactParticle

//-----------------------------------------------------------------------------------------------
End				// Finished with this character
//-----------------------------------------------------------------------------------------------
