Commit b94b4ab6 authored by Gerhard Stein's avatar Gerhard Stein

Underwater AI improved

parent a5c8a5ad
......@@ -62,7 +62,7 @@ void CSpriteObject::setScrPos( int px, int py )
// This used for objects that only can trigger, when it's really worth to do so.
bool CSpriteObject::calcVisibility()
{
int &visibility = g_pBehaviorEngine->getPhysicsSettings().misc.visibility;
int visibility = g_pBehaviorEngine->getPhysicsSettings().misc.visibility;
SDL_Rect gameres = g_pVideoDriver->getGameResolution().SDLRect();
......
......@@ -104,6 +104,7 @@ void CMapPlayGalaxy::process(const bool msgboxactive)
if( theOtherObj != p_Object )
{
p_Object->isNearby(*theOtherObj);
if( p_Object->hitdetect(*theOtherObj) )
p_Object->getTouchedBy(*theOtherObj);
}
......
......@@ -113,7 +113,7 @@ void CCouncilMember::getTouchedBy(CSpriteObject &theObject)
// When Keen touches the Council Member exit the level and add one to the council list
//if( typeid(theObject) == typeid(CPlayerLevel) )
if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
{
int &rescuedelders = player->m_Inventory.Item.m_special.ep4.elders;
......
......@@ -7,6 +7,7 @@
#include "CDopeFish.h"
#include "engine/galaxy/ai/ep4/CPlayerDive.h"
#include "engine/galaxy/ai/ep4/CSchoolFish.h"
#include "CBubbles.h"
namespace galaxy
......@@ -20,8 +21,9 @@ const int A_DOPEFISH_BURP_FINISHED = 6;
const int DOPE_SPEED = 30;
const int DOPE_BITE_SPEED = 60;
const int CSF_MIN_DISTANCE_TO_CHARGE = 6<<CSF;
const int CSF_MIN_DISTANCE_TO_CHARGE = 1<<CSF;
const int CSF_DISTANCE_TO_FOLLOW_TOLERANCE = 2<<CSF;
const int CSF_DISTANCE_TO_FOLLOW = 20<<CSF;
const int DOPE_EAT_TIMER = 50;
......@@ -38,7 +40,8 @@ m_burped(false)
bool CDopeFish::isNearby(CSpriteObject &theObject)
{
if( dynamic_cast<CPlayerBase*>(&theObject) )
if( dynamic_cast<CPlayerBase*>(&theObject) ||
dynamic_cast<CSchoolFish*>(&theObject) )
{
const int objX = theObject.getXMidPos();
const int objY = theObject.getYMidPos();
......@@ -47,6 +50,16 @@ bool CDopeFish::isNearby(CSpriteObject &theObject)
const int dx = objX - fishX;
const int dy = objY - fishY;
if( objX < fishX - CSF_DISTANCE_TO_FOLLOW ||
objX > fishX + CSF_DISTANCE_TO_FOLLOW )
return false;
if( objY < fishY - CSF_DISTANCE_TO_FOLLOW ||
objY > fishY + CSF_DISTANCE_TO_FOLLOW )
return false;
if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
m_hDir = LEFT;
else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE )
......@@ -83,7 +96,8 @@ void CDopeFish::getTouchedBy(CSpriteObject &theObject)
if(CPlayerBase *Player = dynamic_cast<CPlayerBase*>(&theObject))
{
Player->getEaten();
if( getActionNumber(A_DOPEFISH_EAT) )
Player->getEaten();
}
}
......
......@@ -13,7 +13,7 @@ namespace galaxy {
#define A_MINE_MOVE 0
#define A_MINE_EXPLODE 1
const int MINE_SPEED = 10;
const int MINE_SPEED = 20;
CWaterMine::CWaterMine(CMap *pmap, const Uint16 foeID, Uint32 x, Uint32 y, const bool vertical) :
CGalaxySpriteObject(pmap, foeID, x, y)
......
......@@ -357,11 +357,6 @@ void blitMaskedSprite(SDL_Surface *dst, SDL_Surface *src, Uint32 color)
*/
void CSprite::drawSprite( const Uint16 x, const Uint16 y, const Uint8 alpha )
{
if(m_alpha != 255)
{
printf("Hey\n");
}
g_pVideoDriver->mDrawTasks.add( new DrawSpriteTask( this, x, y, alpha ) );
}
......
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