Commit fa5288d1 authored by Gerhard Stein's avatar Gerhard Stein

In Level teleportation now possible in Keen 5

parent 6ce89b06
......@@ -242,6 +242,7 @@ bool CMap::findHorizontalScrollBlocker(const int y)
// if it is found returns non-zero and places the
// coordinates of the first occurrence of the object
// in (xout,yout)
// TODO: Does not work in Galaxy. Adapt this function and for god sake remove m_objectlayer finally!
bool CMap::findObject(unsigned int obj, int *xout, int *yout)
{
unsigned int x,y;
......@@ -261,6 +262,7 @@ bool CMap::findObject(unsigned int obj, int *xout, int *yout)
return false;
}
// searches the map's tile layer for tile TILE.
// if it is found returns nonzero and places the
// coordinates of the first occurance of the tile
......
......@@ -42,11 +42,15 @@ struct InvokeFunctorEvent : CEvent
struct EventEndGamePlay : CEvent
{};
struct EventPlayerTeleportFromLevel : CEvent
{};
struct EventExitLevel : CEvent {
const uint16_t levelObject;
const bool sucess;
EventExitLevel(const uint16_t l, const bool s) : levelObject(l), sucess(s){}
const bool teleport;
EventExitLevel(const uint16_t l, const bool s, const bool t=false) :
levelObject(l), sucess(s), teleport(t){}
};
struct EventExitLevelWithFoot : CEvent {
......
......@@ -326,7 +326,14 @@ void CPlayGameGalaxy::process()
m_WorldMap.setActive(true);
m_LevelName = m_WorldMap.getLevelName();
m_WorldMap.loadAndPlayMusic();
eventContainer.add( new EventPlayerEndLevel(*ev) );
// Should only happen in Keen 5. This should trigger onmap teleportation
if(ev->teleport)
{
eventContainer.add( new EventPlayerTeleportFromLevel() );
}
eventContainer.pop_Event();
}
else if( EventExitLevelWithFoot *ev = eventContainer.occurredEvent<EventExitLevelWithFoot>() )
......
......@@ -1399,7 +1399,7 @@ void CPlayerLevel::processPressUp() {
const int x_mid = (x_left+x_right)/2;
const int up_y = getYUpPos()+(3<<STC);
const Uint32 tile_no = mp_Map->getPlaneDataAt(1, x_mid, up_y);
Uint32 tile_no = mp_Map->getPlaneDataAt(1, x_mid, up_y);
int flag = Tile[tile_no].behaviour;
// pressing a switch
......@@ -1449,15 +1449,20 @@ void CPlayerLevel::processPressUp() {
// entering a door
int flag_left = Tile[mp_Map->getPlaneDataAt(1, x_left, up_y)].behaviour;
if ( !m_EnterDoorAttempt && (flag_left == MISCFLAG_DOOR || flag_left == MISCFLAG_KEYCARDDOOR) )
if ( !m_EnterDoorAttempt &&
(flag_left == MISCFLAG_DOOR ||
flag_left == MISCFLAG_KEYCARDDOOR) )
{
//int var2 = mid_x * 256+96;
int flag_right = Tile[mp_Map->getPlaneDataAt(1, x_left+(1<<CSF), up_y)].behaviour;
tile_no = mp_Map->getPlaneDataAt(1, x_left+(1<<CSF), up_y);
int flag_right = Tile[tile_no].behaviour;
//if (flag2 == MISCFLAG_DOOR || flag2 == MISCFLAG_KEYCARDDOOR) var2-=256;
//if (getXPosition() == var2) {
if(flag_right == MISCFLAG_DOOR || flag_right == MISCFLAG_KEYCARDDOOR)
if(flag_right == MISCFLAG_DOOR ||
flag_right == MISCFLAG_KEYCARDDOOR)
{
if (flag == MISCFLAG_KEYCARDDOOR)
{
......@@ -1509,7 +1514,14 @@ void CPlayerLevel::processPressUp() {
else
{
mTarget = getPosition();
mTarget.y -= (1<<CSF);
// Illusion for going into the backgroung does not apply on teleporters
if(tile_no != 0x401)
{
mTarget.y -= (1<<CSF);
}
setAction(A_KEEN_ENTER_DOOR);
setActionSprite();
......@@ -1629,7 +1641,33 @@ void CPlayerLevel::processEnterDoor()
t = mp_Map->getPlaneDataAt(2, xmid, y1-(3<<CSF));
if (t == 0)
{
{
bool mustTeleportOnMap = false;
// Check if there is a teleporter. In Keen 5 there might be one!
if(g_pBehaviorEngine->getEpisode() == 5)
{
Uint32 teletile = mp_Map->getPlaneDataAt(1, xmid, y1);
if(teletile==0)
teletile = mp_Map->getPlaneDataAt(1, xmid, y1-(1<<CSF));
if(teletile==0)
teletile = mp_Map->getPlaneDataAt(1, xmid, y1-(2<<CSF));
if(teletile==0)
teletile = mp_Map->getPlaneDataAt(1, xmid, y1-(3<<CSF));
// Code for the teleport tile
if(teletile == 0x0401)
{
// There is one!
mustTeleportOnMap = true;
}
}
//level_state = 13;
//o->action = ACTION_KEENENTEREDDOOR;
// TODO: Figure out what this does
......@@ -1638,7 +1676,9 @@ void CPlayerLevel::processEnterDoor()
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
const std::string loading_text = g_pBehaviorEngine->getString("WORLDMAP_LOAD_TEXT");
EventContainer.add( new EventSendBitmapDialogMsg(*g_pGfxEngine->getBitmap("KEENTHUMBSUP"), loading_text, LEFT) );
g_pBehaviorEngine->m_EventList.add( new EventExitLevel(mp_Map->getLevel(), true) );
g_pBehaviorEngine->m_EventList.add( new EventExitLevel(mp_Map->getLevel(), true, mustTeleportOnMap) );
dontdraw = true;
m_Inventory.Item.m_gem.empty();
return;
......@@ -1840,6 +1880,8 @@ void CPlayerLevel::openDoorsTile()
}
/*
void CK_KeenHangThink(CK_object *obj)
......
......@@ -185,6 +185,19 @@ void CPlayerWM::process()
EventContainer.pop_Event();
}
if( EventContainer.occurredEvent<EventPlayerTeleportFromLevel>() )
{
// Find the spot of the teleportation destination
// TODO: This part is only meant for Episode 5. We should catch exception
// Whenever another episode tries to trigger this call.
int x,y;
mp_Map->findTile( 0x1A, &x, &y, 2);
moveToForce(x<<CSF, y<<CSF);
EventContainer.pop_Event();
}
m_camera.process();
m_camera.processEvents();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment