Commit c5bf2acc authored by Gerhard Stein's avatar Gerhard Stein

Solved several mixed issues of AIs and Keen itself

parent 2f520f95
......@@ -265,16 +265,25 @@ bool CSpriteObject::turnAroundOnCliff( int x1, int x2, int y2 )
{
std::vector<CTileProperties> &TileProperty = g_pBehaviorEngine->getTileProperties();
// This is a special case for foes which can turn around when they walk over an edge before they fall
if( !TileProperty[mp_Map->at((x1-(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup ||
!TileProperty[mp_Map->at((x2+(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup )
const int floor = TileProperty[mp_Map->at((x1)>>CSF, (y2+(1<<STC))>>CSF)].bup;
const int cliffleft = TileProperty[mp_Map->at((x1-(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
const int cliffright = TileProperty[mp_Map->at((x2+(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
if(floor != 1)
return 0;
if( !cliffleft && xDirection == LEFT )
{
blockedl = TileProperty[mp_Map->at((x2+(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
blockedr = TileProperty[mp_Map->at((x1-(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
return 1;
}
if( !cliffright && xDirection == RIGHT )
{
blockedr = TileProperty[mp_Map->at((x1-(1<<STC))>>CSF, (y2+(1<<STC))>>CSF)].bup;
return 2;
}
return 0;
}
......
......@@ -29,7 +29,6 @@ CPhysicsSettings::CPhysicsSettings()
// Pogo values
player.pogoforce_x = 30;
misc.visibility = 3;
misc.ctspace_ammo = 100;
misc.ctspace_keys = 1;
}
......@@ -46,10 +45,12 @@ void CPhysicsSettings::loadGameConstants(int episode, byte* data)
// Galaxy Engine
fallspeed_increase = 7;
max_fallspeed = 175; // Factor 2.5 to the original assembly it is
misc.visibility = 7;
}
else
{
// Vorticon Engine
misc.visibility = 3;
fallspeed_increase = 4;
max_fallspeed = 104;
......
......@@ -529,18 +529,19 @@ CGalaxySpriteObject* CMapLoaderGalaxy::addFoe(CMap &Map, word foe, size_t x, siz
case 46:
// This is the Lick
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
if( g_pBehaviorEngine->mDifficulty >= HARD )
p_newfoe = new galaxy::CSkypest(&Map, foe, x, y);
break;
case 47:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty > 1 )
if( g_pBehaviorEngine->mDifficulty >= NORMAL )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
case 48:
// This is the Lick
if( g_pBehaviorEngine->mDifficulty > 2 )
if( g_pBehaviorEngine->mDifficulty >= HARD )
p_newfoe = new galaxy::CLick(&Map, foe, x, y);
break;
......
......@@ -47,7 +47,8 @@ CPlayerLevel::CPlayerLevel(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y,
CInventory &l_Inventory, stCheat &Cheatmode) :
CPlayerBase(pmap, foeID, x, y, ObjectPtrs, facedir, l_Inventory, Cheatmode),
m_jumpdownfromobject(false),
mPlacingGem(false)
mPlacingGem(false),
mPoleGrabTime(0)
{
mActionMap[A_KEEN_STAND] = (void (CPlayerBase::*)()) &CPlayerLevel::processStanding;
mActionMap[A_KEEN_QUESTION] = (void (CPlayerBase::*)()) &CPlayerLevel::processStanding;
......@@ -437,8 +438,9 @@ void CPlayerLevel::processLookingDown()
}
if ( m_playcontrol[PA_Y] <= 0 || m_playcontrol[PA_X] != 0 || (state.jumpIsPressed && !state.jumpWasPressed)
|| (state.pogoIsPressed && !state.pogoWasPressed))
if ( m_playcontrol[PA_Y] <= 0 || m_playcontrol[PA_X] != 0
|| (state.jumpIsPressed && !state.jumpWasPressed)
|| (state.pogoIsPressed && !state.pogoWasPressed))
{
setAction(A_KEEN_STAND);
yDirection = 0;
......@@ -455,6 +457,8 @@ void CPlayerLevel::processLookingDown()
m_jumpdown = jumpdowntile;
supportedbyobject = false;
blockedd = false;
yinertia = 0;
xinertia = 0;
setAction(A_KEEN_FALL);
playSound( SOUND_KEEN_FALL );
}
......@@ -1546,7 +1550,7 @@ void CPlayerLevel::performPoleHandleInput()
if( py < 0 )
{
// First check player pressed shoot button
if( m_playcontrol[PA_FIRE] )
if( m_playcontrol[PA_FIRE] && !m_fire_recharge_time )
{
m_fire_recharge_time = FIRE_RECHARGE_TIME;
setActionForce(A_KEEN_POLE_SHOOTUP);
......@@ -1559,7 +1563,7 @@ void CPlayerLevel::performPoleHandleInput()
else if( py > 0 )
{
// First check player pressed shoot button
if( m_playcontrol[PA_FIRE] )
if( m_playcontrol[PA_FIRE] && !m_fire_recharge_time )
{
m_fire_recharge_time = FIRE_RECHARGE_TIME;
setActionForce(A_KEEN_POLE_SHOOTDOWN);
......@@ -1571,7 +1575,7 @@ void CPlayerLevel::performPoleHandleInput()
else
{
// First check player pressed shoot button
if( m_playcontrol[PA_FIRE] )
if( m_playcontrol[PA_FIRE] && !m_fire_recharge_time )
{
m_fire_recharge_time = FIRE_RECHARGE_TIME;
setActionForce(A_KEEN_POLE_SHOOT);
......
......@@ -72,7 +72,7 @@ void CArachnut::getTouchedBy(CSpriteObject &theObject)
void CArachnut::process()
{
performCollisions();
processFalling();
performGravityLow();
if( blockedl )
xDirection = RIGHT;
......
......@@ -160,7 +160,7 @@ void CBlueBird::getTouchedBy(CSpriteObject &theObject)
void CBlueBird::process()
{
performCollisions();
processFalling();
performGravityLow();
if( blockedl )
xDirection = RIGHT;
......
......@@ -241,7 +241,7 @@ void CBounder::process()
{
// Bounce
performCollisions();
processFalling();
performGravityMid();
(this->*mp_processState)();
......
......@@ -43,7 +43,7 @@ m_timer(0)
void CCouncilMember::processWalking()
{
performCollisions();
processFalling();
performGravityLow();
// Check if there is a cliff and move him back in case
......
......@@ -85,7 +85,7 @@ void CEgg::getTouchedBy(CSpriteObject &theObject)
void CEgg::process()
{
processFalling();
performGravityLow();
performCollisions();
......
......@@ -24,7 +24,11 @@ const int CSF_MIN_DISTANCE_TO_BREATHE = 2<<CSF;
const int CSF_DISTANCE_TO_FOLLOW_TOLERANCE = 2<<CSF;
const int LICK_HOP_X_SPEED = 50;
const int LICK_HOP_Y_SPEED = 50;
const int LICK_BREATHE_TIMER = 100;
const int LICK_HOP_TIME = 20;
const int LICK_LAND_TIME = 20;
CLick::CLick(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CStunnable(pmap, foeID, x, y),
......@@ -36,16 +40,24 @@ m_timer(0)
mActionMap[A_LICK_STUNNED] = &CStunnable::processGettingStunned;
setupGalaxyObjectOnMap(0x2FC6, A_LICK_HOP);
xDirection = LEFT;
}
void CLick::process()
{
performCollisions();
performGravityMid();
if( blockedl )
xDirection = RIGHT;
else if( blockedr )
xDirection = LEFT;
(this->*mp_processState)();
if(!processActionRoutine())
exists = false;
processFalling();
}
void CLick::getTouchedBy(CSpriteObject &theObject)
......@@ -76,17 +88,21 @@ void CLick::getTouchedBy(CSpriteObject &theObject)
bool CLick::isNearby(CSpriteObject &theObject)
{
if( !getProbability(80) )
return false;
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
const int dy = abs(player->getYMidPos() - getYMidPos());
const int dx = player->getXMidPos() - getXMidPos();
if( getProbability(80) )
{
if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
xDirection = LEFT;
else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
xDirection = RIGHT;
}
if( dy > CSF_MIN_DISTANCE_TO_BREATHE )
return false;
if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
xDirection = LEFT;
else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
xDirection = RIGHT;
if(getActionNumber(A_LICK_LAND))
{
......@@ -113,27 +129,36 @@ void CLick::processHop()
else if(xDirection == LEFT)
moveLeft(LICK_HOP_X_SPEED);
if(blockedd)
m_timer--;
if( m_timer <= 0 )
{
setAction( A_LICK_LAND );
m_timer = LICK_LAND_TIME;
}
}
void CLick::processLand()
{
// After a moment he might hop again
setAction( A_LICK_HOP );
yinertia = -100;
blockedd = false;
m_timer--;
if(blockedd && m_timer <= 0)
{
setAction( A_LICK_HOP );
m_timer = LICK_HOP_TIME;
yinertia = -LICK_HOP_Y_SPEED;
}
}
void CLick::processBreathe()
{
// Breathe for a brief moment
m_timer--;
if(getActionStatus(A_LICK_HOP+2))
if(getActionStatus(A_LICK_HOP+2) || m_timer <= 0)
{
m_timer = LICK_HOP_TIME;
setAction( A_LICK_HOP );
yinertia = -LICK_HOP_Y_SPEED;
}
}
......
......@@ -14,8 +14,8 @@ namespace galaxy
const int A_MUSHROOM_BOUNCE = 0;
const int MUSHROOM_LOW_INERTIA = 85;
const int MUSHROOM_HIGH_INERTIA = 212;
const int MUSHROOM_LOW_INERTIA = 60;
const int MUSHROOM_HIGH_INERTIA = 148;
CMadMushroom::CMadMushroom(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y) :
CGalaxySpriteObject(pmap, foeID, x, y),
......
......@@ -92,7 +92,7 @@ void CMimrock::processBounce()
void CMimrock::process()
{
performCollisions();
processFalling();
performGravityLow();
(this->*mp_processState)();
......
......@@ -39,6 +39,12 @@ m_timer(0)
setupGalaxyObjectOnMap(0x2012, A_SLUG_MOVE);
xDirection = LEFT;
CSprite &rSprite = g_pGfxEngine->getSprite(sprite);
performCollisions();
processMove( 0, rSprite.m_bboxY1-rSprite.m_bboxY2 );
if(!processActionRoutine())
exists = false;
}
......@@ -47,12 +53,8 @@ m_timer(0)
void CPoisonSlug::processCrawling()
{
performCollisions();
processFalling();
// Check if there is a cliff
performCliffStop(m_Action.velX<<1);
//performCliffStop(m_Action.velX<<1);
if( m_timer < SLUG_MOVE_TIMER )
......@@ -77,9 +79,13 @@ void CPoisonSlug::processCrawling()
// Move normally in the direction
if( xDirection == RIGHT )
{
moveRight( m_Action.velX<<1 );
}
else
{
moveLeft( m_Action.velX<<1 );
}
}
......@@ -120,14 +126,16 @@ int CPoisonSlug::checkSolidD( int x1, int x2, int y2, const bool push_mode )
{
turnAroundOnCliff( x1, x2, y2 );
return CSpriteObject::checkSolidD(x1, x2, y2, push_mode);
return CGalaxySpriteObject::checkSolidD(x1, x2, y2, push_mode);
}
void CPoisonSlug::process()
{
performCollisions();
processFalling();
if(!blockedd)
performGravityMid();
(this->*mp_processState)();
......@@ -137,7 +145,7 @@ void CPoisonSlug::process()
xDirection = LEFT;
if(!processActionRoutine())
exists = false;
exists = false;
}
}
......@@ -32,7 +32,9 @@ void CSlugSlime::getTouchedBy(CSpriteObject &theObject)
void CSlugSlime::process()
{
processFalling();
performCollisions();
performGravityLow();
if(!processActionRoutine())
exists = false;
......
......@@ -50,19 +50,13 @@ bool CTreasureEater::isNearby(CSpriteObject &theObject)
if( !getProbability(80) )
return false;
// TODO: identify one item and try to get it!
/*if( getActionNumber(A_SMIRKY_LOOK) )
{
}*/
// identify one item and try to get it!
/*if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
{
if( player->getXMidPos() < getXMidPos() )
xDirection = LEFT;
else
xDirection = RIGHT;
}*/
return true;
}
......@@ -178,7 +172,9 @@ void CTreasureEater::checkForItem()
void CTreasureEater::process()
{
performCollisions();
processFalling();
if(!inhibitfall)
performGravityMid();
checkForItem();
......
......@@ -160,7 +160,7 @@ void CWormmouth::process()
if( getActionNumber(A_WORMMOUTH_MOVE) || getActionNumber(A_WORMMOUTH_STUNNED) )
{
performCollisions();
processFalling();
performGravityLow();
}
(this->*mp_processState)();
......
......@@ -33,6 +33,7 @@ void CButler::process()
if (movedir==LEFT)
{ // move left
xDirection = LEFT;
sprite = BUTLER_WALK_LEFT_FRAME + frame;
if (!blockedl )
{
......@@ -49,6 +50,7 @@ void CButler::process()
}
else
{ // move right
xDirection = RIGHT;
sprite = BUTLER_WALK_RIGHT_FRAME + frame;
if (!blockedr )
{
......
......@@ -34,6 +34,7 @@ void CTank::process()
// is keen on same level?
if (movedir==LEFT)
{ // move left
xDirection = LEFT;
sprite = TANK_WALK_LEFT_FRAME + frame;
xinertia = -TANK_WALK_SPEED;
if( blockedl )
......@@ -49,6 +50,7 @@ void CTank::process()
}
else
{ // move right
xDirection = RIGHT;
sprite = TANK_WALK_RIGHT_FRAME + frame;
xinertia = TANK_WALK_SPEED;
if ( blockedr )
......
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