state setpickupflags
 ifactor SUPERATOM
 {
  setactor[THISACTOR].pal 16
 }
 else
 ifactor SUPERSHIELD
 {
  setactor[THISACTOR].pal 24
 }
 else
 {
  getactor[THISACTOR].pal ACTORNATURALPAL
 }
 getactor[THISACTOR].yvel lotagsav
 setactor[THISACTOR].yvel 0
 getactor[THISACTOR].zvel ACTORFLAGS
 setactor[THISACTOR].zvel 0
 changespritestat THISACTOR 1
 sleeptime 0 
//
 ifvarand ACTORFLAGS 1 // Makes Pickup Completely Invisible [cstat 32768]
 {
  getactor[THISACTOR].cstat TEMP
  ifvarand TEMP 32768
  {
  }
  else
  {
   addvar TEMP 32768
   setactor[THISACTOR].cstat TEMP
  }
 }
//
 ifvarand ACTORFLAGS 2 // Silent Pickup For Players [no sounds, screen flashes or messages] // combine with 4 to create silent pickup for both
 {
 }
//
 ifvarand ACTORFLAGS 4 // Silent Pickup For Monsters [no sounds or messages] // combine with 2 to create silent pickup for both
 {
 }
//
 ifvarand ACTORFLAGS 8 // Player cannot pickup object // Combine with 16 to make an ungrabbable item // Combine with 16 to make an ungrabbable item
 {
 }
//
 ifvarand ACTORFLAGS 16 // Monster cannot pickup object [only affects things monsters can normally pick up] // Combine with 8 to make an ungrabbable item
 {
 }
//
 ifvarand ACTORFLAGS 32 // Inverses Fall Properties [items that normally fall will hover/float, items that normally float/hover will fall]
 {
 }

 ifvarand ACTORFLAGS 64
 {
 }
//
 ifvarand ACTORFLAGS 128 // Object is worth double[2x] the normal pickup amount // combine with 256 to make octopule[8x] the normal amount
 {
 }
//
 ifvarand ACTORFLAGS 256 // Object is worth quadruple[4x] the normal pickup amount // combine with 128 to make octopule[8x] the normal amount
 {
 }
//
 ifvarand ACTORFLAGS 512 // Grabbing the object triggers special effects [i.e. spawning objects/monsters, activating objects/forcefields, opening/unlocking doors, etc. Set "yvel" to the lotag of the activator/forcefield/respawn sprites]
 {
 }
//
 ifvarand ACTORFLAGS 1024 // Makes pickup invisible to all but the Nightvision Goggles & Mercury VR Visor
 {
  ifvarand ACTORFLAGS 2048
  {
   subvar ACTORFLAGS 1024
  }
  else
  ifvarand ACTORFLAGS 2049
  {
   subvar ACTORFLAGS 1024
  }
  else
  ifvarand ACTORFLAGS 1
  {
   subvar ACTORFLAGS 1024
  }
  else
  {
   getactor[THISACTOR].cstat TEMP
   ifvarand TEMP 32768
   {
   }
   else
   {
    addvar TEMP 32768
    setactor[THISACTOR].cstat TEMP
   }
  }
 }
//
 ifvarand ACTORFLAGS 2048 // Makes pickup invisible to all but the Mercury VR Visor
 {
  getactor[THISACTOR].cstat TEMP
  ifvarand ACTORFLAGS 1
  {
   subvar ACTORFLAGS 2048
  }
  else
  {
   getactor[THISACTOR].cstat TEMP
   ifvarand TEMP 32768
   {
   }
   else
   {
    addvar TEMP 32768
    setactor[THISACTOR].cstat TEMP
   }
  }
 }
//
 ifvarand ACTORFLAGS 4096 // Object is booby-trapped, but still gives you the pickup
 {
 }
//
 ifvarand ACTORFLAGS 8192 // Object is booby-trapped, and will NOT give you the pickup value at all
 {
 }

 ifvarand ACTORFLAGS 16384 // ?
 {
 }

 ifvarand ACTORFLAGS 32768 // ?
 {
 }
ends

state checkitemflags
  changespritestat THISACTOR 1
  sleeptime 0
  ifvarand ACTORFLAGS 1 // Completely Invisible
  {
   getactor[THISACTOR].cstat TEMP
   ifvarand TEMP 32768
   {
   }
   else
   {
    addvar TEMP 32768
    setactor[THISACTOR].cstat TEMP
   }
  }
  else
  ifvarand ACTORFLAGS 1024 // Invisible except for NV Goggles & VR Visor
  {
   ifvare NIGHTVISION 1
   {
    getactor[THISACTOR].cstat TEMP
    ifvarand TEMP 32768
    {
     subvar TEMP 32768
     setactor[THISACTOR].cstat TEMP
    }
    else
    {
    }
   }
   else
   {
    getactor[THISACTOR].cstat TEMP
    ifvarand TEMP 32768
    {
    }
    else
    {
     addvar TEMP 32768
     setactor[THISACTOR].cstat TEMP
    }
   }
  }
  else
  ifvarand ACTORFLAGS 2048 // Invisible except for VR Visor
  {
   ifvare CHARACTERSELECTED? 4
   {
    ifvare NIGHTVISION 1
    {
     getactor[THISACTOR].cstat TEMP
     ifvarand TEMP 32768
     {
      subvar TEMP 32768
      setactor[THISACTOR].cstat TEMP
     }
     else
     {
     }
    }
    else
    {
     getactor[THISACTOR].cstat TEMP
     ifvarand TEMP 32768
     {
     }
     else
     {
      addvar TEMP 32768
      setactor[THISACTOR].cstat TEMP
     }
    }
   }
   else
   {
    getactor[THISACTOR].cstat TEMP
    ifvarand TEMP 32768
    {
    }
    else
    {
     addvar TEMP 32768
     setactor[THISACTOR].cstat TEMP
    }
   }
  }
  ifvare CHARACTERSELECTED? 4
  {
   ifvare NIGHTVISION 1
   {
    ifvarand ACTORFLAGS 4096
    {
     setactor[THISACTOR].pal 6
    }
    else
    ifvarand ACTORFLAGS 8192
    {
     setactor[THISACTOR].pal 6
    }
    else
    {
     setactor[THISACTOR].pal ACTORNATURALPAL
    }
   }
   else
   {
    setactor[THISACTOR].pal ACTORNATURALPAL
   }
  }
  else
  {
   setactor[THISACTOR].pal ACTORNATURALPAL
  }
//
  getactor[THISACTOR].cstat TEMP
  ifvarand TEMP 1024 { } else { addvar TEMP 1024 }
  setactor[THISACTOR].cstat TEMP
  
ends

state fallflags
 ifvarand ACTORFLAGS 32
 {
  // state moveitem
 }
 else
 {
  // ifvarvarn SPRITEID-HOLDING THISACTOR fall
  // state moveitem
  fall
 }
ends

state fallflags2
 ifvarand ACTORFLAGS 32
 {
//  ifvarvarn SPRITEID-HOLDING THISACTOR fall
//  state moveitem
  fall
 }
 else
 {
//  state moveitem
 }
ends

state setknockback_player

 getuserdef[THISACTOR].god temp
 ifvare temp 1 break
 ifvarg INVULNTIME 0 break
 ifvarg DEATHSWITCHDELAY 0 break

 getplayer[THISACTOR].posx mx
 getplayer[THISACTOR].posy my
 getactor[THISACTOR].x x
 getactor[THISACTOR].y y

 subvarvar mx x
 subvarvar my y
 getangle knockbackang mx my
 setvar knockback 10
 ifvare CHARACTERSELECTED? 1 { sound DUKE_LAND_HURT } ifvare CHARACTERSELECTED? 5 { sound WANG_LONGTERM_PAIN6 }

ends

