Commit 0002f165 authored by Gerhard Stein's avatar Gerhard Stein

Satelite is now working as expected

parent 850bab1e
......@@ -40,7 +40,8 @@ m_animation_ticker(0),
m_cantswim(false),
waveTimer(0),
swimming(false),
mUsedGrapplingHook(false)
mUsedGrapplingHook(false),
mounted(false)
{
m_ActionBaseOffset = actionoffset;
......@@ -217,6 +218,14 @@ void CPlayerWM::process()
*/
void CPlayerWM::processWaving()
{
if(mounted)
{
mProcessPtr = &CPlayerWM::processMoving;
m_basesprite = walkBaseFrame;
waveTimer = 0;
return;
}
waveTimer++;
if( g_pInput->getHoldedCommand(IC_UP) || g_pInput->getHoldedCommand(IC_DOWN) ||
g_pInput->getHoldedCommand(IC_LEFT) || g_pInput->getHoldedCommand(IC_RIGHT) ||
......@@ -241,6 +250,14 @@ void CPlayerWM::processWaving()
*/
void CPlayerWM::processMoving()
{
// Only happens in Keen6 when keening is hanging on the satelite
if(mounted)
{
sprite = 181;
return;
}
// Check if the player is swimming or walking and setup the proper speed
int movespeed;
if(m_basesprite == swimBaseFrame)
......@@ -1110,4 +1127,10 @@ void CPlayerWM::performSwimmingAnimation()
playSwimSound();
}
void CPlayerWM::setMounted(const bool value)
{
mounted = value;
}
}
......@@ -54,6 +54,8 @@ public:
void performWalkingAnimation(bool walking);
void performSwimmingAnimation();
void setMounted(const bool value);
private:
Uint16 m_basesprite;
......@@ -74,8 +76,9 @@ private:
int waveTimer;
bool swimming;
bool mUsedGrapplingHook;
bool mounted;
std::vector<bool> mLevelDone;
std::vector<bool> mLevelDone;
void (CPlayerWM::*mProcessPtr)();
};
......
......@@ -31,7 +31,7 @@ public:
void getTouchedBy(CSpriteObject &theObject);
private:
int mTimer;
int mTimer;
};
};
......
......@@ -108,7 +108,10 @@ void CRocket::processFlying()
speed.x = -MOVE_SPEED;
}
mpCarriedPlayer->moveDir(speed);
if(mpCarriedPlayer != nullptr)
{
mpCarriedPlayer->moveDir(speed);
}
moveDir(speed);
}
......@@ -119,10 +122,22 @@ void CRocket::getTouchedBy(CSpriteObject& theObject)
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
setAction(A_ROCKET_FLY);
mpCarriedPlayer = player;
mpCarriedPlayer->solid = false;
mpCarriedPlayer->dontdraw = true;
if(player->m_Inventory.Item.m_special.ep6.rocketKeycard > 0)
{
setAction(A_ROCKET_FLY);
mpCarriedPlayer = player;
mpCarriedPlayer->solid = false;
mpCarriedPlayer->dontdraw = true;
}
else
{
// Tell the player he cannot climb yet
CEventContainer& EventContainer = g_pBehaviorEngine->m_EventList;
EventContainer.add( new EventSendBitmapDialogMsg(
g_pGfxEngine->getBitmap(29), "I need a keycard \nfor that Rocket", RIGHT) );
player->moveYDir((1<<CSF)/2);
}
}
}
......
#include "CSatelite.h"
#include <engine/galaxy/common/ai/CPlayerBase.h>
#include <engine/galaxy/common/ai/CPlayerWM.h>
/*
$1C70W #Keen hang from satelite
$1C8EW #Sateleite
$1CACW #Sateleite
$1CCAW #Sateleite
......@@ -14,22 +16,28 @@ namespace galaxy
const int MOVE_SPEED = 40;
const int TILES_UNTIL_UNMOUNT = 8;
CSatelite::CSatelite(CMap* pmap, const Uint16 foeID, const Uint32 x, const Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y),
CMoveTarget(m_Pos, xDirection, yDirection)
CMoveTarget(m_Pos, xDirection, yDirection),
mpCarriedPlayer(nullptr),
mTilesUntilumount(0)
{
solid = false;
setupGalaxyObjectOnMap(0x1C8E, 0);
m_Pos = target;
fetchInitialDir(xDirection, yDirection, *mp_Map);
detectNextTarget(target, xDirection, yDirection);
}
void CSatelite::processFlying()
{
{
int xBlockPos = target.x - getXPosition();
int yBlockPos = target.y - getYPosition();
......@@ -41,20 +49,35 @@ void CSatelite::processFlying()
const Uint16 object = mp_Map->getPlaneDataAt(2, target.x, target.y);
VectorD2<int> speed(xBlockPos, yBlockPos);
moveDir(speed);
moveDir(speed);
// Happens when the rocket find a place where to stop
/*if(object == 0x6A || object == 0x69)
{
VectorD2<int> newPlayerPos = m_Pos;
newPlayerPos.y = getYDownPos()+(1<<CSF);
mpCarriedPlayer->moveToForce(newPlayerPos);
mpCarriedPlayer->solid = true;
mpCarriedPlayer->dontdraw = false;
mpCarriedPlayer = nullptr;
}*/
mTilesUntilumount++;
if(mpCarriedPlayer != nullptr && mTilesUntilumount >= TILES_UNTIL_UNMOUNT)
{
const Uint16 spot1 = mp_Map->getPlaneDataAt(2, target.x, target.y+(1<<CSF) );
const Uint16 spot2 = mp_Map->getPlaneDataAt(2, target.x+(1<<CSF), target.y);
// Positions where keen migh mount or land
if(spot1 == 0x2D || spot2 == 0x2C)
{
VectorD2<int> newPlayerPos = target;
if(spot1 == 0x2D)
{
newPlayerPos.y = target.y+(1<<CSF);
}
if(spot2 == 0x2C)
{
newPlayerPos.x = target.x+(1<<CSF);
}
mTilesUntilumount = 0;
mpCarriedPlayer->solid = true;
mpCarriedPlayer->moveToForce(newPlayerPos);
mpCarriedPlayer->setMounted(false);
mpCarriedPlayer = nullptr;
}
}
if(object == 0x59)
{
......@@ -91,22 +114,49 @@ void CSatelite::processFlying()
}
moveDir(speed);
if(mpCarriedPlayer != nullptr)
{
mPlayerPos = m_Pos;
mPlayerPos.x += (16<<STC);
mPlayerPos.y = getYDownPos()-(4<<STC);
mpCarriedPlayer->moveTo(mPlayerPos);
}
}
void CSatelite::getTouchedBy(CSpriteObject& theObject)
{
/*if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
if( CPlayerWM *player = dynamic_cast<CPlayerWM*>(&theObject) )
{
setAction(A_ROCKET_FLY);
}*/
if(mpCarriedPlayer == nullptr)
{
if(mTilesUntilumount >= TILES_UNTIL_UNMOUNT)
{
mpCarriedPlayer = player;
mpCarriedPlayer->setMounted(true);
mpCarriedPlayer->solid = false;
mTilesUntilumount = 0;
}
}
}
}
bool CSatelite::calcVisibility()
{
return true;
}
void CSatelite::process()
{
if(!processActionRoutine())
exists = false;
if(mTilesUntilumount >= TILES_UNTIL_UNMOUNT)
{
mTilesUntilumount = TILES_UNTIL_UNMOUNT;
}
processFlying();
}
......
......@@ -2,7 +2,7 @@
#define CSATELITE_H
#include <engine/galaxy/common/CGalaxySpriteObject.h>
#include <engine/galaxy/common/ai/CMoveTarget.h>
#include <engine/galaxy/common/ai/CPlayerBase.h>
#include <engine/galaxy/common/ai/CPlayerWM.h>
namespace galaxy
{
......@@ -16,10 +16,10 @@ public:
/**
* When it is moving normally
*/
void processSitting();
void processFlying();
bool calcVisibility();
void process();
/**
......@@ -27,7 +27,9 @@ public:
*/
void getTouchedBy(CSpriteObject &theObject);
private:
CPlayerBase *mpCarriedPlayer;
CPlayerWM *mpCarriedPlayer;
int mTilesUntilumount;
VectorD2<int> mPlayerPos;
};
};
......
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