Commit dad16e02 authored by Gerhard Stein's avatar Gerhard Stein

Berkeloid is in!

parent b8bf0b60
......@@ -9,8 +9,8 @@
(c)2009-2012 Tulip
Released under GNU/GPL
Release v0.4.0-Beta2
Build: WIN32
Release v0.4.0-Beta3
Build: LINUX64
**********************************************
Welcome to Commander Genius!
......@@ -191,7 +191,7 @@ F+I+X Restore Restores the settings as they were in the first time. Use thi
The game can be saved from the menu at any time. Keen will be saved at the exact position it was left.
(unlike in the original game which only allowed save on the map).
In Keen 4 this feature is not avialable
In Keen 4 this feature is not avaalable
- FAQ -
......
......@@ -43,6 +43,7 @@
#include "engine/galaxy/ai/ep4/CSkypest.h"
#include "engine/galaxy/ai/ep4/CMimrock.h"
#include "engine/galaxy/ai/ep4/CEgg.h"
#include "engine/galaxy/ai/ep4/CBerkeloid.h"
#include "engine/galaxy/ai/ep4/CBlueBird.h"
#include "engine/galaxy/ai/ep4/CThunderCloud.h"
......@@ -382,11 +383,13 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
}
}
// Neuronal-stunner
if( foe == 68 )
{
p_newfoe = new galaxy::CSpriteItem(&Map, foe, x, y, m_ObjectPtr, 127);
}
// Gems
for( Uint32 i=57 ; i<=60 ; i++ )
{
if( foe == i )
......@@ -519,6 +522,12 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
break;
case 50:
//This is the CBerkeloid
p_newfoe = new galaxy::CBerkeloid(&Map, foe, x, y);
break;
case 71:
// Watermine vertical
p_newfoe = new galaxy::CWaterMine(&Map, foe, x, y, true);
......
/*
* CBerkeloid.cpp
*
* Created on: 16.07.2012
* Author: gerstong
*/
#include "CBerkeloid.h"
#include "engine/galaxy/ai/CPlayerLevel.h"
#include "engine/galaxy/ai/CBullet.h"
#include "misc.h"
namespace galaxy {
const int A_BERKELOID_MOVING = 0;
const int A_BERKELOID_THROW = 4;
const int BERKELOID_TIME = 5;
CBerkeloid::CBerkeloid(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y),
mTimer(0),
mpProcessState(NULL)
{
mActionMap[A_BERKELOID_MOVING] = &CBerkeloid::processMoving;
mActionMap[A_BERKELOID_THROW] = &CBerkeloid::processThrowing;
setupGalaxyObjectOnMap(0x2AF8, A_BERKELOID_MOVING);
inhibitfall = true;
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
processActionRoutine();
}
void CBerkeloid::setActionForce(const size_t ActionNumber)
{
CGalaxySpriteObject::setActionForce(ActionNumber);
if( mActionMap.find(ActionNumber) != mActionMap.end() )
mpProcessState = mActionMap[ActionNumber];
else
setActionForce(0); // This might happen, when the action-map is incomplete
}
void CBerkeloid::getTouchedBy(CSpriteObject &theObject)
{
if(theObject.dead )
return;
if( CBullet *bullet = dynamic_cast<CBullet*>(&theObject) )
{
bullet->setAction(A_KEENSHOT_IMPACT);
bullet->playSound( SOUND_SHOT_HIT );
bullet->dead = true;
}
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
player->kill();
}
}
bool CBerkeloid::isNearby(CSpriteObject &theObject)
{
if( !getProbability(80) )
return false;
if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
if( player->getXMidPos() < getXMidPos() )
m_hDir = LEFT;
else
m_hDir = RIGHT;
}
return true;
}
void CBerkeloid::processMoving()
{
if( mTimer < BERKELOID_TIME )
{
mTimer++;
return;
}
else
{
mTimer = 0;
}
// Chance to throw a flame
if( getProbability(60) )
{
setAction( A_BERKELOID_THROW );
playSound( SOUND_BERKELOID_WINDUP );
CBerkFlame *flame = new CBerkFlame( getMapPtr(), getXMidPos(), getYUpPos(), m_hDir );
g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( flame ) );
return;
}
}
void CBerkeloid::processThrowing()
{
if( getActionStatus(A_BERKELOID_MOVING) )
setAction(A_BERKELOID_MOVING);
}
void CBerkeloid::process()
{
processFalling();
performCollisions();
(this->*mpProcessState)();
if( blockedl )
m_hDir = RIGHT;
else if(blockedr)
m_hDir = LEFT;
processActionRoutine();
}
////////////////////////////////// End of Berkeloid //////////////////////////////////
/*
*
* Flame Part of the Berkeloid
*
*/
const int A_FLAME_THROWN = 0;
const int A_FLAME_LANDED = 2;
const int FLAME_INERTIAX = 150;
CBerkFlame::CBerkFlame(CMap *pmap, Uint32 x, Uint32 y, direction_t dir) :
CGalaxySpriteObject(pmap, 0, x, y),
mpProcessState(NULL)
{
mActionMap[A_FLAME_THROWN] = &CBerkFlame::processThrown;
mActionMap[A_FLAME_LANDED] = &CBerkFlame::processLanded;
m_hDir = dir;
xinertia = FLAME_INERTIAX;
setupGalaxyObjectOnMap(0x2CD8, A_FLAME_THROWN);
}
void CBerkFlame::setActionForce(const size_t ActionNumber)
{
CGalaxySpriteObject::setActionForce(ActionNumber);
if( mActionMap.find(ActionNumber) != mActionMap.end() )
mpProcessState = mActionMap[ActionNumber];
else
setActionForce(0); // This might happen, when the action-map is incomplete
}
void CBerkFlame::getTouchedBy(CSpriteObject &theObject)
{
if(theObject.dead )
return;
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
player->kill();
}
}
void CBerkFlame::processThrown()
{
if(blockedd)
setAction(A_FLAME_LANDED);
// Move normally in the direction
if( m_hDir == RIGHT )
moveRight( xinertia );
else
moveLeft( xinertia );
xinertia--;
}
void CBerkFlame::processLanded()
{
}
void CBerkFlame::process()
{
processFalling();
performCollisions();
(this->*mpProcessState)();
processActionRoutine();
}
} /* namespace galaxy */
/*
* CBerkeloid.h
*
* Created on: 16.07.2012
* Author: gerstong
*/
#ifndef CBERKELOID_H_
#define CBERKELOID_H_
#include "engine/galaxy/CGalaxySpriteObject.h"
namespace galaxy {
class CBerkeloid : public CGalaxySpriteObject
{
public:
CBerkeloid(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y);
// When something touches the firing guy
void getTouchedBy(CSpriteObject &theObject);
void setActionForce(const size_t ActionNumber);
// Check if some objects being near around need attention.
bool isNearby(CSpriteObject &theObject);
// Will make him move/float around
void processMoving();
// Will throw fire
void processThrowing();
// Happens every LPS. Here the AI is handled
void process();
private:
int mTimer;
void (CBerkeloid::*mpProcessState)();
std::map< size_t, void (CBerkeloid::*)() > mActionMap;
};
class CBerkFlame : public CGalaxySpriteObject
{
public:
CBerkFlame(CMap *pmap, Uint32 x, Uint32 y, direction_t dir);
void setActionForce(const size_t ActionNumber);
// When something touches the fire
void getTouchedBy(CSpriteObject &theObject);
// Will make him move/float around
void processThrown();
// Will throw fire
void processLanded();
// Happens every LPS. Here the AI is handled
void process();
private:
void (CBerkFlame::*mpProcessState)();
std::map< size_t, void (CBerkFlame::*)() > mActionMap;
};
} /* namespace galaxy */
#endif /* CBERKELOID_H_ */
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