UT_INVALID  = 0;
UT_PLAYER   = 1;
UT_DIAMOND  = 2;
UT_BOUNCY   = 3;
UT_CRATE    = 4;
UT_BULLET   = 5;
UT_SPIKES_N = 6;
UT_REDNINJA = 7;
UT_DEBRIS   = 8;
UT_NUMBER_INDICATOR = 9;
UT_ENEMY_BULLET     = 10;
UT_HEALTH_POTION    = 11;
UT_BUTTON_RED       = 12;
UT_BUTTON_GREEN     = 13;
UT_BUTTON_BLUE      = 14;
UT_BUTTON_YELLOW    = 15;
UT_ARROW_N          = 16;
UT_ARROW_S          = 17;
UT_ARROW_W          = 18;
UT_ARROW_E          = 19;
UT_DOOR_N           = 20;
UT_DOOR_S           = 21;
UT_DOOR_W           = 22;
UT_DOOR_E           = 23;
UT_BLUENINJA        = 24;
UT_GIANT_NINJA      = 25;
UT_FIREBALL         = 26;
UT_CANNON_FIRE_N    = 27;
UT_CANNON_FIRE_S    = 28;
UT_CANNON_FIRE_W    = 29;
UT_CANNON_FIRE_E    = 30;
UT_CANNON_WATER_N   = 31;
UT_CANNON_WATER_S   = 32;
UT_CANNON_WATER_W   = 33;
UT_CANNON_WATER_E   = 34;
UT_CANNON_EARTH_N   = 35;
UT_CANNON_EARTH_S   = 36;
UT_CANNON_EARTH_W   = 37;
UT_CANNON_EARTH_E   = 38;
UT_CANNON_AIR_N     = 39;
UT_CANNON_AIR_S     = 40;
UT_CANNON_AIR_W     = 41;
UT_CANNON_AIR_E     = 42;
UT_SPIKES_S         = 43;
UT_SPIKES_W         = 44;
UT_SPIKES_E         = 45;
UT_FISH             = 46;
UT_SAMURAI          = 47;
UT_SAVESPOT_N       = 48;
UT_BOUNCY_S         = 49;
UT_BOUNCY_W         = 50;
UT_BOUNCY_E         = 51;
UT_DEMON            = 52;
UT_DEMON_CHIN       = 53;
UT_SKULL_SHOT       = 54;
UT_SAVESPOT_S       = 55;
UT_SAVESPOT_W       = 56;
UT_SAVESPOT_E       = 57;
UT_EXPLOSION_SMALL  = 58;
UT_EXPLOSION_BIG    = 59;
UT_BAT_N            = 60;
UT_BAT_S            = 61;
UT_BAT_W            = 62;
UT_BAT_E            = 63;
UT_MP_POTION        = 64;
UT_TOKEN            = 65;
UT_FREE_BAT         = 66;
UT_GHOST            = 67;
UT_POWERUP          = 68;
UT_POTION_FULL      = 69;
UT_WATER_POWER      = 70;
UT_SQUID            = 71;
      
UE_UNKNOWN        = 0;
UE_WORLD_TURNED   = 1;
UE_BLOCKED        = 2;
UE_BLOCKED_LEFT   = 3;
UE_BLOCKED_RIGHT  = 4;
UE_HURT           = 5;
UE_DIE            = 6;
UE_START_FALLING  = 7;
UE_LAND           = 8;
UE_CUSTOM         = 9;
UE_ENTER_WATER    = 10;
UE_LEAVE_WATER    = 11;
UE_REMOVE         = 12;

function WaitForUnitEvent( Event )
  g_LastUnitEvent = -1;
  while ( g_LastUnitEvent ~= Event ) do
    coroutine.yield( 1 );
    --_ALERT( "Event not set yet (" .. g_LastUnitEvent .. "/" .. Event .. ")" );
  end
  --_ALERT( "Event set" );
end

function Message( Text )
  g_MessageConfirmed = false;
  ShowMessage( Text );
  while ( not g_MessageConfirmed ) do
    coroutine.yield( 1 );
  end
end

function ExplodeDebris( X, Y )
  for i = 1,10 do 
    SpawnUnit( X, Y, UT_DEBRIS );
  end
end

function WaitForRestrictView()
  g_ViewRestricted = false;
  while ( not g_ViewRestricted ) do
    coroutine.yield( 1 );
  end
end

function BossMusic()
  PlayMusic( "The Electric Shindig2 - Aaron P.ogg" );
end

function GameMusic( Type )
  if ( Type == 0 ) then
    PlayMusic( "Tonight - Aaron P.ogg" );
  elseif ( Type == 1 ) then
    PlayMusic( "Craig Stern - Exploring the Depths.ogg" );
  elseif ( Type == 2 ) then
    PlayMusic( "Craig Stern - The Sorcerer's Tower.ogg" );
  elseif ( Type == 3 ) then
    PlayMusic( "Jorge Boscan - 06 - Between Mirrors.ogg" );
  end
end

function Walk( X, Y )
  g_PlayerRelativeMoveDone = false;
  PlayerRelativeMove( X, Y );
  while ( not g_PlayerRelativeMoveDone ) do
    coroutine.yield( 1 );
  end
end