//-----------------------------------------------------------------------------------------------
//Reset trap at start
IfSpawned
  tmpargument = ACTIONMG
  DoAction
  tmpx = 500		//Dont activate at start

//-----------------------------------------------------------------------------------------------
//Trap effects
KeepAction
SetTargetToNearestLifeform

  //Check for rouges to find it
  tmpargument = [DISA]			//Does the target have disarm skill?
  IfTargetHasSkillID
    IfTargetIsAPlayer			//Only for players
      tmpx = targetdistance
      tmpy = 500			//Detect range
      IfXIsLessThanY
        tmpargument = 0			//Not detected yet
        IfContentIs
          IfTimeOut
            tmpx = rand & 1280 + targetint	//0-5 + the characters intelligence
            tmpy = 3840				//need to be more than 15 points added together
            IfXIsMoreThanY
              tmpargument = 0
              SendMessageNear
              tmpargument = 1
              SetContent			//Mark as detected
              tmpargument = 5
              tmpdistance = EXPDARE
              GiveExperienceToTarget		//Award some xp
              tmpargument = 1
              PlaySound				//Play sound effect

//Special occasions the trap is not to activate
tmpx = targetdistance
IfTargetIsSelf
  tmpx = 500			//Don't activate

tmpy = rand % 65 + 55			//Trigger range
IfXIsLessThanY
  IfStateIs0
    tmpx = targetz
    tmpy = selfz + 100
    IfXIsLessThanY		//This enables targets to fly or jump over the trap
      tmpargument = ACTIONMG
      DoAction
      tmpargument = 0
      tmpdistance = rand & 3600 + 10000
      PlaySound			//Play clinking
      tmpargument = 1
      SetState			//Trap is activated
      tmpargument = 50
      SetTime			//Need some time to reset
      tmpargument = rand & 1024 + 512 // 2-6 damage
      tmpdistance = DAMAGEPOKE
      DamageTarget

//-----------------------------------------------------------------------------------------------
//Reset trap
IfTimeOut
  tmpargument = 50
  SetTime
  tmpargument = 0
  SetState			//Ready trap state

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

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