Commit 52731608 authored by Gerhard Stein's avatar Gerhard Stein

Rope on Map now works

parent 0a4a7e83
......@@ -9,6 +9,7 @@
#include "CPlayerWM.h"
#include "engine/galaxy/common/ai/CFlag.h"
#include <engine/galaxy/ep6/ai/CRope.h>
#include "common/CBehaviorEngine.h"
#include "sdl/input/CInput.h"
#include "sdl/sound/CSound.h"
......@@ -38,7 +39,8 @@ m_animation_time(1),
m_animation_ticker(0),
m_cantswim(false),
waveTimer(0),
swimming(false)
swimming(false),
mUsedGrapplingHook(false)
{
m_ActionBaseOffset = actionoffset;
......@@ -48,6 +50,7 @@ swimming(false)
walkBaseFrame = sprite;
wavingBaseFrame = walkBaseFrame + 22;
swimBaseFrame = walkBaseFrame + 24;
climbBaseFrame = walkBaseFrame + 37;
m_basesprite = walkBaseFrame;
performCollisions();
......@@ -245,14 +248,56 @@ void CPlayerWM::processMoving()
else if(m_basesprite == walkBaseFrame)
movespeed = 50;
else
movespeed = 0;
movespeed = 0;
bool walking=false;
bool bleft, bright, bup, bdown;
// This will trigger between swim and walkmode
checkforSwimming(bleft, bright, bup, bdown);
// This will make Keen climb in
direction_t climbDir;
if( checkforClimbing(climbDir) )
{
// Check if Keen has a hook, but
if(!mUsedGrapplingHook)
{
if(m_Inventory.Item.m_special.ep6.hook > 0)
{
m_Inventory.Item.m_special.ep6.hook--;
mUsedGrapplingHook = true;
int y = getYMidPos();
int x = getXMidPos();
x = x>>CSF; y = y>>CSF;
x = x<<CSF; y = (y-1)<<CSF;
g_pBehaviorEngine->m_EventList.spawnObj(new CRope(mp_Map, 0, x, y));
}
else
{
// Tell the player he cannot climb yet
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
EventContainer.add( new EventSendBitmapDialogMsg(
g_pGfxEngine->getBitmap(29), "Too tall cliff!", RIGHT) );
moveYDir(-(climbDir<<CSF)/2);
}
}
if(mUsedGrapplingHook)
{
xDirection = CENTER;
yDirection = climbDir;
mProcessPtr = &CPlayerWM::processClimbing;
m_basesprite = climbBaseFrame;
waveTimer = 0;
return;
}
}
// In Episode 5 and 6 there are teleporters. Verify those teleporters and elevators
if(g_pBehaviorEngine->getEpisode() >= 5)
......@@ -359,6 +404,32 @@ void CPlayerWM::processMoving()
}
}
void CPlayerWM::processClimbing()
{
moveYDir(yDirection*30);
sprite = m_basesprite + m_animation%2;
direction_t climbDir;
if( checkforClimbing(climbDir) )
{
if(yDirection != climbDir)
{
mProcessPtr = &CPlayerWM::processMoving;
m_basesprite = walkBaseFrame;
waveTimer = 0;
moveYDir(-climbDir<<CSF);
return;
}
}
}
const int RIDE_SPEED = 32;
void CPlayerWM::processRiding()
......@@ -943,6 +1014,29 @@ void CPlayerWM::checkforSwimming(bool &bleft, bool &bright, bool &bup, bool &bdo
}
}
bool CPlayerWM::checkforClimbing(direction_t &climbDir)
{
const int y = getYMidPos();
const int x = getXMidPos();
const int info = mp_Map->getPlaneDataAt(2, x, y);
// from top
if(info == 0x0F)
{
climbDir = UP;
return true;
}
else if(info == 0x10)
{
climbDir = DOWN;
return true;
}
return false;
}
/**
* This performs the animation when player is walking on the map
*/
......
......@@ -27,6 +27,7 @@ public:
void process();
void processMoving();
void processClimbing();
void processWaving();
// Episode 4 only. When Keen is riding on the foot
......@@ -46,6 +47,9 @@ public:
void startLevel(Uint16 object);
void finishLevel(const int object);
// Checks if Keen in CK6 can climb
bool checkforClimbing(direction_t &climbDir);
void checkforSwimming(bool &bleft, bool &bright, bool &bup, bool &bdown);
void performWalkingAnimation(bool walking);
......@@ -55,6 +59,7 @@ private:
Uint16 m_basesprite;
Uint16 m_teleportanibasetile;
Uint16 walkBaseFrame;
Uint16 climbBaseFrame;
Uint16 wavingBaseFrame;
Uint16 swimBaseFrame;
direction_t m_looking_dir;
......@@ -68,6 +73,7 @@ private:
int elevator_frames;
int waveTimer;
bool swimming;
bool mUsedGrapplingHook;
std::vector<bool> mLevelDone;
......
......@@ -22,6 +22,7 @@
#include "ai/CNospike.h"
#include "ai/COrbatrix.h"
#include "ai/CFleex.h"
#include "ai/CRope.h"
#include "engine/galaxy/common/ai/CPlayerWM.h"
#include "engine/galaxy/common/ai/CPlayerLevel.h"
......@@ -142,8 +143,7 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x,
case 0x0B: p_newfoe = new galaxy::CBlooglet(&Map, foe, 0x208A, true, x, y); break;
case 0x0C: p_newfoe = new galaxy::CBlooglet(&Map, foe, 0x2120, true, x, y); break;
case 0x0D: p_newfoe = new galaxy::CBlooglet(&Map, foe, 0x21B6, true, x, y); break;
case 0x0E: p_newfoe = new galaxy::CBlooglet(&Map, foe, 0x208A, true, x, y); break;
case 0x0E: p_newfoe = new galaxy::CBlooglet(&Map, foe, 0x208A, true, x, y); break;
case 0x13: if( difficulty < NORMAL ) break; // not sure here
case 0x12:
......@@ -299,7 +299,9 @@ CGalaxySpriteObject* CMapLoaderGalaxyEp6::addFoe(CMap &Map, word foe, size_t x,
case CFlag::FOE_ID:
p_newfoe = new galaxy::CFlag(&Map, loc, loc, false);
break;
case CRope::FOE_ID:
p_newfoe = new galaxy::CRope(&Map, foe, x, y); break;
default:
break;
......
#include "CRope.h"
#include <engine/galaxy/common/ai/CPlayerBase.h>
/*
$1B9EW #Keen throw rope
......@@ -15,20 +16,21 @@ namespace galaxy
enum ROPE_ACTION
{
A_GIK_ACTIVE = 0,
A_GIK_THROWN = 1,
A_GIK_INVISIBLE = 2
A_ROPE_ACTIVE = 0,
A_ROPE_THROWN = 1
};
const int THROW_TIME = 10;
CRope::CRope(CMap* pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxyActionSpriteObject(pmap, foeID, x, y)
CGalaxyActionSpriteObject(pmap, foeID, x, y),
mTimer(0)
{
mActionMap[A_GIK_ACTIVE] = (void (CGalaxyActionSpriteObject::*)()) &CRope::processActive;
mActionMap[A_GIK_THROWN] = (void (CGalaxyActionSpriteObject::*)()) &CRope::processThrown;
mActionMap[A_GIK_INVISIBLE] = (void (CGalaxyActionSpriteObject::*)()) &CRope::processHidden;
mActionMap[A_ROPE_ACTIVE] = (void (CGalaxyActionSpriteObject::*)()) &CRope::processActive;
mActionMap[A_ROPE_THROWN] = (void (CGalaxyActionSpriteObject::*)()) &CRope::processThrown;
setupGalaxyObjectOnMap(0x1C16, A_GIK_ACTIVE);
setupGalaxyObjectOnMap(0x1C16, A_ROPE_THROWN);
}
......@@ -39,19 +41,20 @@ void CRope::processActive()
void CRope::processThrown()
{
mTimer++;
if(mTimer < THROW_TIME)
return;
mTimer = 0;
setAction(A_ROPE_ACTIVE);
}
void CRope::processHidden()
{
}
void CRope::getTouchedBy(CSpriteObject& theObject)
{
if(dead || theObject.dead)
return;
}
......
......@@ -9,15 +9,19 @@ namespace galaxy
class CRope : public CGalaxyActionSpriteObject
{
public:
static const unsigned int FOE_ID = 201;
CRope(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y);
void processActive();
void processThrown();
void processHidden();
void getTouchedBy(CSpriteObject &theObject);
void process();
private:
int mTimer;
};
};
......
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