Commit 31b5c9fe authored by Gerhard Stein's avatar Gerhard Stein

more adaptations to the new class based AI System

parent e461e7ce
......@@ -221,13 +221,9 @@ void CMapLoader::addWorldMapObject(unsigned int t, Uint16 x, Uint16 y, int episo
{
if (!m_NessieAlreadySpawned)
{
CObject *nessie = new CObject(mp_map);
nessie->spawn(x<<CSF, y<<CSF, OBJ_NESSIE, 3);
nessie->onscreen = true;
nessie->solid = false;
CMessie *messie = new CMessie(mp_map, x<<CSF, y<<CSF);
m_NessieAlreadySpawned = true;
mp_objvect->push_back(nessie);
mp_objvect->push_back(messie);
}
mp_map->m_objectlayer[x][y] = NESSIE_PATH;
}
......
......@@ -28,14 +28,13 @@
CPlayer::CPlayer(const char &Episode, short &Level, char &Difficulty,
bool *mp_level_completed, stOption *mp_option,
std::vector<CObject*> &m_Object, CMap &map) :
CObject(&map),
CObject(&map, 0, 0),
m_episode(Episode),
m_level(Level),
m_difficulty(Difficulty),
pjumpupspeed_decrease(g_pBehaviorEngine->getPhysicsSettings().player.defaultjumpupdecreasespeed),
m_Ankhshield(CObject(&map)),
m_Ankhshield(CObject(&map,0,0)),
mp_levels_completed(mp_level_completed),
mp_map(NULL),
mp_option(mp_option),
mp_StatusScr(NULL)
{
......@@ -152,8 +151,8 @@ bool CPlayer::scrollTriggers()
int px, py, left, up, right, down, speed;
bool scrollchanged=false;
Uint16& scroll_x = mp_map->m_scrollx;
Uint16& scroll_y = mp_map->m_scrolly;
Uint16& scroll_x = mp_Map->m_scrollx;
Uint16& scroll_y = mp_Map->m_scrolly;
if (pdie) return scrollchanged;
......@@ -167,50 +166,50 @@ bool CPlayer::scrollTriggers()
speed = g_pCamera->getScrollSpeed();
// left-right scrolling
if(px > right && scroll_x < mp_map->m_maxscrollx)
if(px > right && scroll_x < mp_Map->m_maxscrollx)
{
do{
px = (getXPosition()>>STC)-scroll_x;
mp_map->scrollRight();
}while(px > right+speed && scroll_x < mp_map->m_maxscrollx);
mp_Map->scrollRight();
}while(px > right+speed && scroll_x < mp_Map->m_maxscrollx);
scrollchanged = true;
}
else if(px < left && scroll_x > 32)
{
do{
px = (getXPosition()>>STC)-scroll_x;
mp_map->scrollLeft();
mp_Map->scrollLeft();
}while(px < left-speed && scroll_x > 32);
scrollchanged = true;
}
// up-down scrolling
if (py > down && scroll_y < mp_map->m_maxscrolly)
if (py > down && scroll_y < mp_Map->m_maxscrolly)
{
do{
py = (getYPosition()>>STC)-scroll_y;
mp_map->scrollDown();
}while(py > down+speed && scroll_y < mp_map->m_maxscrolly);
mp_Map->scrollDown();
}while(py > down+speed && scroll_y < mp_Map->m_maxscrolly);
scrollchanged = true;
}
else if ( py < up && scroll_y > 32 )
{
do{
py = (getYPosition()>>STC)-scroll_y;
mp_map->scrollUp();
mp_Map->scrollUp();
}while(py < up-speed && scroll_y > 32);
scrollchanged = true;
}
// This will always snap correctly to the edge
while(scroll_x < 32)
mp_map->scrollRight();
while(scroll_x > mp_map->m_maxscrollx)
mp_map->scrollLeft();
mp_Map->scrollRight();
while(scroll_x > mp_Map->m_maxscrollx)
mp_Map->scrollLeft();
while(scroll_y < 32)
mp_map->scrollDown();
while(scroll_y > mp_map->m_maxscrolly)
mp_map->scrollUp();
mp_Map->scrollDown();
while(scroll_y > mp_Map->m_maxscrolly)
mp_Map->scrollUp();
return scrollchanged;
}
......
......@@ -38,7 +38,7 @@ public:
std::vector<CObject*> &m_Object, CMap &map);
void setDatatoZero();
void setDefaultStartValues();
void setMapData(CMap *p_map){ mp_map=p_map; }
void setMapData(CMap *p_map){ mp_Map=p_map; }
void setupforLevelPlay();
bool getLevelTrigger();
......@@ -178,7 +178,6 @@ public:
std::string hintstring;
bool hintused;
CMap *mp_map;
stOption *mp_option;
private:
......
......@@ -36,7 +36,7 @@ void CPlayer::getgoodies()
bool CPlayer::getGoodie(int px, int py)
{
std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties();
Uint16 tile = mp_map->at(px, py);
Uint16 tile = mp_Map->at(px, py);
char behaviour = TileProperty[tile].behaviour;
if (behaviour>0 && behaviour<31)
......@@ -45,8 +45,8 @@ bool CPlayer::getGoodie(int px, int py)
(TileProperty[tile].behaviour > 17 && TileProperty[tile].behaviour < 22) ||
(TileProperty[tile].behaviour == 27 || TileProperty[tile].behaviour == 28) ) // All pickupable items
{ // pick up the goodie, i.e. erase it from the map
mp_map->changeTile(px, py, TileProperty[tile].chgtile);
if (TileProperty[tile].animationtime) mp_map->deAnimate(px, py);
mp_Map->changeTile(px, py, TileProperty[tile].chgtile);
if (TileProperty[tile].animationtime) mp_Map->deAnimate(px, py);
}
else if (TileProperty[tile].behaviour == 1) // Lethal (Deadly) Behavoir
{ // whoah, this "goodie" isn't so good...
......@@ -195,7 +195,7 @@ void CPlayer::riseBonus(int spr, int x, int y)
{
if (mp_option[OPT_RISEBONUS].value)
{
/*CObject GotPointsObj(mp_map);
/*CObject GotPointsObj(mp_Map);
GotPointsObj.spawn(x<<CSF, y<<CSF, OBJ_GOTPOINTS, m_episode);
GotPointsObj.sprite = spr;
mp_object->push_back(GotPointsObj);*/
......@@ -237,14 +237,14 @@ bool CPlayer::showGameHint(int mpx, int mpy)
if(m_episode == 1)
{
if(mp_map->at(mpx, mpy) >= 435 && mp_map->at(mpx, mpy) <= 438)
if(mp_Map->at(mpx, mpy) >= 435 && mp_Map->at(mpx, mpy) <= 438)
{
// it's a garg statue
mp_map->setTile(mpx, mpy, 434, true);
mp_Map->setTile(mpx, mpy, 434, true);
}
else // It's a yorp statue.. or something else
{
mp_map->setTile(mpx, mpy, 315, true);
mp_Map->setTile(mpx, mpy, 315, true);
}
hintstring = "EP1_YSIYM_LVL" + itoa(m_level);
......@@ -254,7 +254,7 @@ bool CPlayer::showGameHint(int mpx, int mpy)
// Keen 2 seems to have a bug with those tiles.
// On other parts on the map they can be triggered
// This small condition should fix that bug
int t = mp_map->at(mpx, mpy+1);
int t = mp_Map->at(mpx, mpy+1);
if(t != 429) return false;
// make the switch stop glowing
......@@ -269,8 +269,8 @@ bool CPlayer::showGameHint(int mpx, int mpy)
default:
return false;
}
mp_map->setTile(mpx, mpy+1, 432,true);
mp_map->deAnimate(mpx<<STC, (mpy+1)<<STC);
mp_Map->setTile(mpx, mpy+1, 432,true);
mp_Map->deAnimate(mpx<<STC, (mpy+1)<<STC);
}
hintused = true;
return true;
......@@ -333,28 +333,28 @@ std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTilePropertie
take_keycard(doortile);
// erase door from map
if (m_episode==3) chgtotile = mp_map->at(mpx-1, mpy);
else chgtotile = TileProperty[mp_map->at(mpx ,mpy)].chgtile;
if (m_episode==3) chgtotile = mp_Map->at(mpx-1, mpy);
else chgtotile = TileProperty[mp_Map->at(mpx ,mpy)].chgtile;
if(TileProperty[mp_map->at(mpx ,mpy-1)].behaviour>1 &&
TileProperty[mp_map->at(mpx ,mpy-1)].behaviour<6 ) // This happens because, sometimes the player opens the door
if(TileProperty[mp_Map->at(mpx ,mpy-1)].behaviour>1 &&
TileProperty[mp_Map->at(mpx ,mpy-1)].behaviour<6 ) // This happens because, sometimes the player opens the door
{ // from a lower part.
mp_map->setTile(mpx, mpy-1, chgtotile);
mp_Map->setTile(mpx, mpy-1, chgtotile);
tilefix=1;
}
if(TileProperty[mp_map->at(mpx ,mpy)].behaviour>1 &&
TileProperty[mp_map->at(mpx ,mpy)].behaviour<6) // This happens because, sometimes the player opens the door
if(TileProperty[mp_Map->at(mpx ,mpy)].behaviour>1 &&
TileProperty[mp_Map->at(mpx ,mpy)].behaviour<6) // This happens because, sometimes the player opens the door
{ // from a lower part.
mp_map->setTile(mpx, mpy, chgtotile); // upper?
mp_Map->setTile(mpx, mpy, chgtotile); // upper?
}
if(TileProperty[mp_map->at(mpx, mpy+1)].behaviour>1 &&
TileProperty[mp_map->at(mpx, mpy+1)].behaviour<6) // This happens because, sometimes the player opens the door
if(TileProperty[mp_Map->at(mpx, mpy+1)].behaviour>1 &&
TileProperty[mp_Map->at(mpx, mpy+1)].behaviour<6) // This happens because, sometimes the player opens the door
{ // from a lower part.
mp_map->setTile(mpx, mpy+1, chgtotile); // When he stands in front of the door!
mp_Map->setTile(mpx, mpy+1, chgtotile); // When he stands in front of the door!
}
// replace the door tiles with a door object, which will do the animation
/*CObject doorobj(mp_map);
/*CObject doorobj(mp_Map);
doorobj.spawn(mpx<<CSF,(mpy-tilefix)<<CSF, OBJ_DOOR, m_episode);
doorobj.sprite = doorsprite;
......
......@@ -175,7 +175,7 @@ void CPlayer::dieanim() // Bad word for that. It's the entire die code
// is it time to start flying off the screen?
if (!pdietillfly)
{ // time to fly off the screen
if (((getYPosition()>>(CSF-4))+96 > mp_map->m_scrolly) && (getYPosition()>(16<<(CSF-4))))
if (((getYPosition()>>(CSF-4))+96 > mp_Map->m_scrolly) && (getYPosition()>(16<<(CSF-4))))
{ // player has not reached top of screen
// make player fly up
moveUp(-PDIE_RISE_SPEED);
......@@ -316,23 +316,23 @@ void CPlayer::TogglePogo_and_Switches(const bool &platextending)
{
my = (getYPosition()+i)>>CSF;
t = mp_map->at(mx, my);
t = mp_Map->at(mx, my);
// check for extending-platform switch
if (t==TILE_SWITCH_UP || t==TILE_SWITCH_DOWN )
{
// Flip the switch!
g_pSound->playStereofromCoord(SOUND_SWITCH_TOGGLE, PLAY_NOW, getXPosition()>>STC);
if ( mp_map->at(mx, my) == TILE_SWITCH_DOWN )
mp_map->changeTile(mx, my, TILE_SWITCH_UP);
if ( mp_Map->at(mx, my) == TILE_SWITCH_DOWN )
mp_Map->changeTile(mx, my, TILE_SWITCH_UP);
else
mp_map->changeTile(mx, my, TILE_SWITCH_DOWN);
mp_Map->changeTile(mx, my, TILE_SWITCH_DOWN);
// figure out where the platform is supposed to extend at
// (this is coded in the object layer...
// high byte is the Y offset and the low byte is the X offset,
// and it's relative to the position of the switch.)
Uint16 bridge = mp_map->getObjectat(mx, my);
Uint16 bridge = mp_Map->getObjectat(mx, my);
if (bridge==0) // Uh Oh! This means you have enabled a tantalus ray of the ship
{
......@@ -349,8 +349,7 @@ void CPlayer::TogglePogo_and_Switches(const bool &platextending)
int platy = my + pyoff;
// spawn a "sector effector" to extend/retract the platform
CObject *platobject = new CObject(mp_map);
platobject->spawn(mx<<CSF,my<<CSF,OBJ_SECTOREFFECTOR, m_episode);
CSectorEffector *platobject = new CSectorEffector(mp_Map, mx<<CSF,my<<CSF);
platobject->ai.se.type = SE_EXTEND_PLATFORM;
platobject->ai.se.platx = platx;
platobject->ai.se.platy = platy;
......@@ -635,7 +634,7 @@ CPhysicsSettings &PhysicsSettings = g_pBehaviorEngine->getPhysicsSettings();
int xleft = getXLeftPos();
int ydown = getYDownPos();
behaviour = TileProperty[mp_map->at(xleft>>CSF, ydown>>CSF)].behaviour;
behaviour = TileProperty[mp_Map->at(xleft>>CSF, ydown>>CSF)].behaviour;
if( behaviour>=2 && behaviour<=5 )
blockedu = true; // This workaround prevents the player from falling through doors.
......@@ -653,8 +652,8 @@ CPhysicsSettings &PhysicsSettings = g_pBehaviorEngine->getPhysicsSettings();
// Check if player is on ice
if(!pjumping && !ppogostick)
{
int ice = TileProperty[mp_map->at(getXLeftPos()>>CSF, (ydown+1)>>CSF)].bup;
ice |= TileProperty[mp_map->at(getXRightPos()>>CSF, (ydown+1)>>CSF)].bup;
int ice = TileProperty[mp_Map->at(getXLeftPos()>>CSF, (ydown+1)>>CSF)].bup;
ice |= TileProperty[mp_Map->at(getXRightPos()>>CSF, (ydown+1)>>CSF)].bup;
if(!blockedl && !blockedr)
{
if(ice == 2) psemisliding = true;
......@@ -700,7 +699,7 @@ CPhysicsSettings &PhysicsSettings = g_pBehaviorEngine->getPhysicsSettings();
if (pfalling || pjumping) psliding=0;
// If he falls to the ground even being god, kill him
if( (Uint16)getYDownPos() > ((mp_map->m_height)<<CSF) )
if( (Uint16)getYDownPos() > ((mp_Map->m_height)<<CSF) )
kill(true);
}
......@@ -749,7 +748,7 @@ void CPlayer::raygun()
if (pdir==RIGHT) xdir = getXRightPos()+xinertia;
else xdir = getXLeftPos()+xinertia;
CRay *rayobject = new CRay(mp_map, xdir, ydir, pdir, OBJ_PLAYER, m_index);
CRay *rayobject = new CRay(mp_Map, xdir, ydir, pdir, OBJ_PLAYER, m_index);
mp_object->push_back(rayobject);
}
......@@ -933,20 +932,20 @@ void CPlayer::checkSolidDoors()
int my2 = getYDownPos()>>CSF;
std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties();
if( (TileProperty[mp_map->at(mx1 ,mymid)].behaviour>1 &&
TileProperty[mp_map->at(mx1 ,mymid)].behaviour<6 ) ) {
if( (TileProperty[mp_Map->at(mx1 ,mymid)].behaviour>1 &&
TileProperty[mp_Map->at(mx1 ,mymid)].behaviour<6 ) ) {
blockedl = true; }
if( (TileProperty[mp_map->at(mx2 ,mymid)].behaviour>1 &&
TileProperty[mp_map->at(mx2 ,mymid)].behaviour<6 ) ) {
if( (TileProperty[mp_Map->at(mx2 ,mymid)].behaviour>1 &&
TileProperty[mp_Map->at(mx2 ,mymid)].behaviour<6 ) ) {
blockedr = true; }
if( (TileProperty[mp_map->at(mxmid ,my1)].behaviour>1 &&
TileProperty[mp_map->at(mxmid ,my1)].behaviour<6 ) ) {
if( (TileProperty[mp_Map->at(mxmid ,my1)].behaviour>1 &&
TileProperty[mp_Map->at(mxmid ,my1)].behaviour<6 ) ) {
blockedd = true; }
if( (TileProperty[mp_map->at(mxmid ,my2)].behaviour>1 &&
TileProperty[mp_map->at(mxmid ,my2)].behaviour<6 ) ) {
if( (TileProperty[mp_Map->at(mxmid ,my2)].behaviour>1 &&
TileProperty[mp_Map->at(mxmid ,my2)].behaviour<6 ) ) {
blockedu = true; }
}
......
......@@ -72,11 +72,11 @@ int CPlayer::getNewObject()
// get level/object marker beneath player
xb = getXMidPos()>>STC;
yb = getYMidPos()>>STC;
lvl = mp_map->getObjectat(xb>>4, yb>>4);
lvl = mp_Map->getObjectat(xb>>4, yb>>4);
if (!lvl)
{
yb = (getYPosition()>>CSF)+8;
lvl = mp_map->getObjectat(xb>>4, yb>>4);
lvl = mp_Map->getObjectat(xb>>4, yb>>4);
}
return lvl;
}
......@@ -92,7 +92,7 @@ bool CPlayer::isWMSolid(int xb, int yb)
int level_coordinates;
// Now check if the levels must block the player
level_coordinates = mp_map->getObjectat(xb>>CSF, yb>>CSF);
level_coordinates = mp_Map->getObjectat(xb>>CSF, yb>>CSF);
if (level_coordinates & 0x8000)
{
......@@ -194,7 +194,7 @@ void CPlayer::UnmountNessie()
for(dx=-1 ; dx <= 1 ; dx++)
{
// If NESSIE_LAND_OBJ was found, than put the player there!
if(mp_map->getObjectat(x+dx, y+dy) == NESSIE_LAND)
if(mp_Map->getObjectat(x+dx, y+dy) == NESSIE_LAND)
{
// Look for the Nessie object
std::vector<CObject>::iterator obj = mp_object->begin();
......@@ -204,7 +204,7 @@ void CPlayer::UnmountNessie()
{
// Check if the there are no blocked tiles there!
std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties();
CTileProperties &Tile = TileProperty[mp_map->at(x+dx, y+dy)];
CTileProperties &Tile = TileProperty[mp_Map->at(x+dx, y+dy)];
if( !Tile.bdown and !Tile.bup and
!Tile.bleft and !Tile.bright )
{
......
......@@ -4,8 +4,8 @@
#include "CTank.h"
#include "CRay.h"
CGuardRobot::CGuardRobot(CMap *p_map) :
CTank(p_map)
CGuardRobot::CGuardRobot(CMap *p_map, Uint32 x, Uint32 y) :
CTank(p_map, x, y)
{
// first time initilization
// state = TANK_WALK;
......
......@@ -19,8 +19,11 @@ enum nessie_actions{
void nessie_find_next_checkpoint(int o);
CMessie::CMessie(CMap *p_map, Uint32 x, Uint32 y) :
CObject(p_map,x,y)
{}
CObject(p_map, x, y)
{
onscreen = true;
solid = false;
}
void CMessie::process()
{
......
......@@ -10,7 +10,7 @@
#include "../../../common/CObject.h"
class CMessie : CObject
class CMessie : public CObject
{
public:
CMessie(CMap *p_map, Uint32 x, Uint32 y);
......
......@@ -11,7 +11,7 @@
CRay::CRay(CMap *p_map, Uint32 x, Uint32 y,
direction_t dir, object_t byType, size_t byID) :
CObject(p_map),
CObject(p_map, x, y),
m_Direction(dir)
{
m_type = OBJ_RAY;
......
......@@ -13,7 +13,7 @@
class CRisingPoints : public CObject
{
public:
CRisingPoints(CMap *p_map);
CRisingPoints(CMap *p_map, Uint32 x, Uint32 y);
void process();
private:
};
......
......@@ -13,7 +13,7 @@
class CRope : public CObject
{
public:
CRope(CMap *p_map);
CRope(CMap *p_map, Uint32 x, Uint32 y);
};
#endif /* CROPE_H_ */
......@@ -26,7 +26,7 @@ enum sector_effector_type{
class CSectorEffector : public CObject
{
public:
CSectorEffector(CMap *p_map);
CSectorEffector(CMap *p_map, Uint32 x, Uint32 y);
};
#endif /* SE_H_ */
......@@ -13,7 +13,7 @@
class CSoundWave : public CObject
{
public:
CSoundWave(CMap *p_map);
CSoundWave(CMap *p_map, Uint32 x, Uint32 y);
};
#endif /* CSOUNDWAVE_H_ */
......@@ -69,7 +69,7 @@ unsigned int rnd(void);
class CTank : public CObject
{
public:
CTank(CMap *p_map);
CTank(CMap *p_map, Uint32 x, Uint32 y);
virtual void process();
bool CanMoveLeft();
......@@ -105,7 +105,7 @@ protected:
class CGuardRobot : public CTank
{
public:
CGuardRobot(CMap *p_map);
CGuardRobot(CMap *p_map, Uint32 x, Uint32 y);
void process();
private:
};
......
......@@ -30,8 +30,8 @@ MOTHER_HURT, MOTHER_DEAD
#define MOTHER_HURT_FRAME 91
#define MOTHER_DEAD_FRAME 92
CVortiMom::CVortiMom(CMap *p_map) :
CObject(p_map)
CVortiMom::CVortiMom(CMap *p_map, Uint32 x, Uint32 y) :
CObject(p_map, x, y)
{}
//void CObjectAI::mother_ai( CObject& object, bool hardmode )
......
......@@ -13,7 +13,7 @@
class CVortiMom : CObject
{
public:
CVortiMom(CMap *p_map);
CVortiMom(CMap *p_map, Uint32 x, Uint32 y);
};
#endif /* CVORTIMOM_H_ */
......@@ -23,8 +23,8 @@ enum ninja_actions{
unsigned int rnd(void);
CVortiNinja::CVortiNinja(CMap *p_map) :
CObject(p_map)
CVortiNinja::CVortiNinja(CMap *p_map, Uint32 x, Uint32 y) :
CObject(p_map, x, y)
{}
//void CObjectAI::ninja_ai(CObject &object, bool hardmode)
......
......@@ -13,7 +13,7 @@
class CVortiNinja : CObject
{
public:
CVortiNinja(CMap *p_map);
CVortiNinja(CMap *p_map, Uint32 x, Uint32 y);
};
#endif /* CVORTININJA_H_ */
#ifndef __CVORTICON__
#define __CVORTICON__
#include "../../../common/CObject.h"
#include "../../../common/CPlayer.h"
#include <vector>
......@@ -96,3 +99,5 @@ private:
std::vector<CPlayer> &m_Player;
};
#endif //__CVORTICON__
......@@ -31,7 +31,7 @@ BABY_JUMP_BIG, BABY_JUMP_SMALL
CVortikid::CVortikid( CMap *p_map, std::vector<CPlayer> &mp_vec_Player,
Uint32 x, Uint32 y ) :
CObject(p_map)
CObject(p_map, x, y)
{}
//void CObjectAI::baby_ai(CObject &object, int episode, bool hard)
......
......@@ -110,7 +110,7 @@ bool CPlayGameVorticon::loadGameState()
// Load completed levels
m_SavedGame.readDataBlock( (byte*)(mp_level_completed));
m_Player[0].mp_map = &m_Map;
m_Player[0].setMapData(&m_Map);
while(m_Player[0].scrollTriggers()); // Scroll to the right position on the map
m_Map.drawAll();
......
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