bool CShelly::isNearby(CSpriteObject &theObject) { if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) mKeenAlignment = LEFT; else mKeenAlignment = RIGHT; const int objX = theObject.getXMidPos(); const int objY = theObject.getYMidPos(); const int shellyX = getXMidPos(); const int shellyY = getYMidPos(); mGoodJumpChance = false; if( objX < shellyX - CSF_DISTANCE_TO_JUMP || objX > shellyX + CSF_DISTANCE_TO_JUMP ) return false; if( objY < shellyY - CSF_DISTANCE_TO_JUMP || objY > shellyY + CSF_DISTANCE_TO_JUMP ) return false; mGoodJumpChance = true; } return true; }
bool CRoboRed::isNearby(CSpriteObject &theObject) { if( dynamic_cast<CPlayerLevel*>(&theObject) ) { mLookTimer++; if(mLookTimer < TIME_UNTIL_LOOK) return true; mLookTimer = 0; mKeenNearby = false; const int objX = theObject.getXMidPos(); const int roboX = getXMidPos(); const int dx = objX - roboX; if( theObject.getYDownPos() > getYUpPos() && theObject.getYUpPos() < getYDownPos() ) { if(getActionNumber(A_RED_PAUSE)) { if( theObject.getXMidPos() < getXMidPos() ) xDirection = LEFT; else xDirection = RIGHT; } if( std::abs(dx) < CSF_DISTANCE_TO_SHOOT ) { mKeenNearby = true; } } } return true; }
bool CTank::isNearby(CVorticonSpriteObject &theObject) { if( CPlayer *player = dynamic_cast<CPlayer*>(&theObject) ) { if( state == TANK_LOOK ) { // when time is up go back to moving if (timer > TANK_LOOK_TOTALTIME) { // decide what direction to go if(player->getXMidPos() < getXMidPos()) { movedir = LEFT; sprite = TANK_WALK_LEFT_FRAME; } else if(player->getXMidPos() > getXMidPos()) { movedir = RIGHT; sprite = TANK_WALK_RIGHT_FRAME; } state = TANK_WALK; animtimer = 0; timer = 0; } } } return true; }
bool CSparky::isNearby(CSpriteObject &theObject) { if( !getProbability(10) ) return false; if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) mKeenAlignment = LEFT; else mKeenAlignment = RIGHT; const int objX = theObject.getXMidPos(); const int objY = theObject.getYMidPos(); const int sparkyX = getXMidPos(); const int sparkyY = getYMidPos(); mGoodChargeChance = false; if( objX < sparkyX - CSF_DISTANCE_TO_FOLLOW || objX > sparkyX + CSF_DISTANCE_TO_FOLLOW ) return false; if( objY < sparkyY - CSF_DISTANCE_TO_FOLLOW || objY > sparkyY + CSF_DISTANCE_TO_FOLLOW ) return false; mGoodChargeChance = true; } return true; }
bool CThunderCloud::isNearby(CSpriteObject &theObject) { if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { const unsigned int cloudX = getXMidPos(); const unsigned int playXLeft = player->getXMidPos() - DIST_TO_AWAKE; const unsigned int playXRight = player->getXMidPos() + DIST_TO_AWAKE; if( playXLeft < cloudX && playXRight > cloudX ) { if( getActionStatus(A_CLOUD_ASLEEP) && getProbability(180) ) setAction(A_CLOUD_WAKING); } else { if( !getActionStatus(A_CLOUD_ASLEEP) ) { setAction(A_CLOUD_ASLEEP); setActionSprite(); return true; } } if( getActionStatus(A_CLOUD_WAKING) ) { if( player->getXMidPos() < getXMidPos() ) xDirection = LEFT; else xDirection = RIGHT; } if( getActionStatus(A_CLOUD_MOVING) ) { if( mpBolt == nullptr && player->getYMidPos() > getYMidPos() ) { const unsigned int playXStrikeLeft = player->getXMidPos() - DIST_TO_STRIKE; const unsigned int playXStrikeRight = player->getXMidPos() + DIST_TO_STRIKE; if( playXStrikeLeft < cloudX && playXStrikeRight > cloudX && (mTimer>TIME_TO_STRIKE_2 || (mSecondTry && mTimer>TIME_TO_STRIKE_1) ) ) { mTimer = 0; mSecondTry = !mSecondTry; setAction(A_CLOUD_STRIKING); playSound(SOUND_THUNDERCLOUD_STRIKE); mpBolt = new CThunderBolt( mp_Map, getXLeftPos() + (12<<STC), getYDownPos() + (32<<STC), mSprVar ); spawnObj( mpBolt ); } } } } return true; }
void CWaterMine::processMove() { performCollisions(); if(yDirection) { const Uint16 blockerUp = mp_Map->getPlaneDataAt(2, getXMidPos(), getYUpPos()); const Uint16 blockerDown = mp_Map->getPlaneDataAt(2, getXMidPos(), getYDownPos()); // If there is a blocker, block the Watermine if( blockerUp == 31 ) blockedu = true; if( blockerDown == 31 ) blockedd = true; // If the mine is really blocked, change the direction if(blockedd) yDirection = UP; else if(blockedu) yDirection = DOWN; if(yDirection == DOWN) moveDown(MINE_SPEED); else moveUp(MINE_SPEED); } else { const Uint16 blockerLeft = mp_Map->getPlaneDataAt(2, getXLeftPos(), getYMidPos()); const Uint16 blockerRight = mp_Map->getPlaneDataAt(2, getXRightPos(), getYMidPos()); // If there is a blocker, block the Watermine if( blockerLeft == 31 ) blockedl = true; if( blockerRight == 31 ) blockedr = true; // If the mine is really blocked, change the direction if(blockedl) xDirection = RIGHT; else if(blockedr) xDirection = LEFT; if(xDirection == LEFT) moveLeft(MINE_SPEED); else moveRight(MINE_SPEED); } }
bool CDevilSprite::isNearby(CSpriteObject &theObject) { if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int dx = player->getXMidPos() - getXMidPos(); const int dy = player->getYMidPos() - getYMidPos(); if( dx<0 ) xDirection = LEFT; else xDirection = RIGHT; if(getActionNumber(A_SPRITE_MOVE)) { int absdx = (dx<0) ? -dx : dx; int absdy = (dy<0) ? -dy : dy; if( absdx < CSF_MIN_DISTANCE_X_TO_LOOK && absdy < CSF_MIN_DISTANCE_Y_TO_LOOK ) { setAction(A_SPRITE_LOOK); mp_processState = &CDevilSprite::processLook; m_timer = SPRITE_LOOK_DELAY; } } } return true; }
void CBerkeloid::processMoving() { if(blockedd) moveUp(10); if( mTimer < BERKELOID_TIME ) { mTimer++; return; } else { mTimer = 0; } // Chance to throw a flame if( getProbability(20) ) { setAction( A_BERKELOID_THROW ); playSound( SOUND_BERKELOID_WINDUP ); CBerkFlame *flame = new CBerkFlame( getMapPtr(), getXMidPos(), getYUpPos(), xDirection ); gEventManager.add( new EventSpawnObject( flame ) ); return; } }
void CShelly::processSmoke() { mTimer++; if(mTimer < SMOKE_TIME) return; mTimer = 0; dead = true; // Spawn little explosion shards here! const int newX = getXMidPos(); const int newY = getYUpPos(); spawnObj( new CShellyFrags( getMapPtr(), 0, newX, newY, -100 ) ); spawnObj( new CShellyFrags( getMapPtr(), 0, newX, newY, -50 ) ); spawnObj( new CShellyFrags( getMapPtr(), 0, newX, newY, 50 ) ); spawnObj( new CShellyFrags( getMapPtr(), 0, newX, newY, 100 ) ); exists = false; }
bool CBlooguard::isNearby(CSpriteObject& theObject) { if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { const int objX = theObject.getXMidPos(); const int objY = theObject.getYMidPos(); const int blooguardX = getXMidPos(); const int blooguardY = getYMidPos(); // Code for setting player stunned here! if(mStubPlayer) { mStubPlayer = false; if(player->stun()) { player->m_camera.m_relcam.y = (8<<CSF); } return true; } mGoodClubChance = false; if( objX < blooguardX - CSF_DISTANCE_TO_CLUB || objX > blooguardX + CSF_DISTANCE_TO_CLUB ) return false; if( objY < blooguardY - CSF_DISTANCE_TO_CLUB || objY > blooguardY + CSF_DISTANCE_TO_CLUB ) return false; mGoodClubChance = true; } return true; }
bool CWormmouth::isNearby(CSpriteObject &theObject) { if(dead || theObject.dead ) return false; if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int playerX = player->getXMidPos(); const int playerY = player->getYMidPos(); const int wormmouthX = getXMidPos(); const int wormmouthY = getYMidPos(); if( getActionNumber(A_WORMMOUTH_LOOK) ) { if( playerX < wormmouthX && xDirection != LEFT ) mTurnAround = true; else if( playerX > wormmouthX && xDirection != RIGHT ) mTurnAround = true; } const int diffX = playerX - wormmouthX; const int diffY = playerY - wormmouthY; if( abs(diffX) < DIST_TO_EAT && abs(diffY) < DIST_TO_EAT && !getActionNumber(A_WORMMOUTH_EAT) ) { setAction(A_WORMMOUTH_EAT); playSound( SOUND_WORMOUTH_STRIKE ); } } return true; }
bool CBlueBird::isNearby(CSpriteObject &theObject) { if( !getProbability(20) ) return false; if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) xDirection = LEFT; else xDirection = RIGHT; if( player->getYMidPos() < getYMidPos() ) yDirection = UP; else yDirection = DOWN; // so the bottom of keen's box has to be >= 3 tiles above the bottom of the bird's box // and keen needs to be on the ground -> Quote by Lemm const int pYDown = player->getYDownPos(); const int bYDown = getYDownPos(); if( player->blockedd && pYDown <= bYDown-(3<<CSF) ) { setAction(A_EAGLE_FLYING); inhibitfall = true; } } return true; }
void CAmpton::processPoleSlide() { int l_x_l = getXLeftPos(); int l_x = getXMidPos(); int l_x_r = getXRightPos(); int l_y_mid = getYMidPos(); int l_y_down = getYDownPos(); // Move normally in the direction if( yDirection == UP ) { // Check for the upper side and don't let him move if the pole ends if( hitdetectWithTileProperty(1, l_x_l, l_y_mid) || hitdetectWithTileProperty(1, l_x, l_y_mid) || hitdetectWithTileProperty(1, l_x_r, l_y_mid) ) { moveUp( SLIDE_SPEED ); } else { yDirection = DOWN; } } else // Down { // Check for the upper side and don't let him move if the pole ends if( hitdetectWithTileProperty(1, l_x_l, l_y_down) || hitdetectWithTileProperty(1, l_x, l_y_down) || hitdetectWithTileProperty(1, l_x_r, l_y_down) ) { moveDown( SLIDE_SPEED ); } else { yDirection = UP; } } mTimer++; if(mTimer < UMOUNT_TIME) return; mTimer = 0; // Check for Floor here! const int fall1 = mp_Map->getPlaneDataAt(1, l_x, l_y_down+(1<<CSF)); //const int fall1 = mp_Map->getPlaneDataAt(1, l_x, l_y_down); const CTileProperties &TileProp1 = g_pBehaviorEngine->getTileProperties(1)[fall1]; const bool leavePole = (TileProp1.bup != 0); if(leavePole) { setAction(A_AMPTON_STOP_POLE); moveXDir(2*xDirection*WALK_SPEED); moveUp(1<<CSF); solid = true; blockedd = true; } }
bool CLick::isNearby(CObject &theObject) { if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int dx = player->getXMidPos() - getXMidPos(); if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) m_hDir = LEFT; else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) m_hDir = RIGHT; if(getActionNumber(A_LICK_LAND)) { int absdx = (dx<0) ? -dx : dx; if( absdx < CSF_MIN_DISTANCE_TO_BREATHE ) { setAction(A_LICK_BREATHE); playSound(SOUND_LICK_FIREBREATH); mp_processState = (void (CStunnable::*)()) (&CLick::processBreathe); m_timer = LICK_BREATHE_TIMER; } } } return true; }
void CGrabbiter::getTouchedBy(CSpriteObject& theObject) { if(getActionNumber(A_GRABBITER_NAPPING)) { return; } if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int diffX = getXMidPos()-player->getXMidPos(); player->moveXDir(-diffX/4); if(player->m_Inventory.Item.m_special.ep6.sandwich > 0) { player->m_Inventory.Item.m_special.ep6.sandwich--; // Show grabbiter message showMsg( g_pBehaviorEngine->getString("KEEN_GRABBITER_SLEEPY") ); setAction(A_GRABBITER_NAPPING); playSound(SOUND_GRABBITER_SLEEP); } else { // Sound play g_pSound->playSound(SOUND_GRABBITER_HUNGRY, PLAY_PAUSEALL); // Show grabbiter message showMsg( g_pBehaviorEngine->getString("KEEN_GRABBITER_HUNGRY") ); } } }
bool CMimrock::isNearby(CSpriteObject &theObject) { if(dead || theObject.dead || mTimer > 0 ) return true; if( !blockedd || getActionStatus(A_MIMROCK_JUMP) || getActionStatus(A_MIMROCK_BOUNCE) ) return true; if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int dx = player->getXMidPos() - getXMidPos(); if( dx>-CSF_DISTANCE_TO_FOLLOW_TOLERANCE && dx<+CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) { if( dx<0 ) xDirection = LEFT; else xDirection = RIGHT; if( !getProbability(40) ) return true; if( dx>-CSF_DISTANCE_TO_JUMP_TOLERANCE && dx<+CSF_DISTANCE_TO_JUMP_TOLERANCE ) { if( xDirection == -player->xDirection ) { setAction(A_MIMROCK_SIT); } else { yinertia = -JUMP_HEIGHT; mTimer = JUMP_TIME; setAction(A_MIMROCK_JUMP); } } else { if( xDirection == player->xDirection && !blockedr && !blockedl ) { setAction(A_MIMROCK_WALK); } else { setAction(A_MIMROCK_SIT); } } } } return true; }
bool CMadMushroom::isNearby(CSpriteObject &theObject) { if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) xDirection = LEFT; else xDirection = RIGHT; } return true; }
bool CArachnut::isNearby(CSpriteObject &theObject) { if( !getProbability(10) ) return false; if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { xDirection = ( player->getXMidPos() < getXMidPos() ) ? LEFT : RIGHT; yDirection = ( player->getYMidPos() < getYMidPos() ) ? UP : DOWN; } return true; }
bool CShikadiMaster::isNearby(CSpriteObject &theObject) { if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) mKeenAlignment = LEFT; else mKeenAlignment = RIGHT; mpPlayer = player; } return true; }
bool CDopeFish::isNearby(CSpriteObject &theObject) { if( dynamic_cast<CPlayerBase*>(&theObject) || dynamic_cast<CSchoolFish*>(&theObject) ) { const int objX = theObject.getXMidPos(); const int objY = theObject.getYMidPos(); const int fishX = getXMidPos(); const int fishY = getYMidPos(); 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 ) xDirection = LEFT; else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) xDirection = RIGHT; if( dy<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) yDirection = (rand()%5) ? UP : DOWN; else if( dy>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) yDirection = (rand()%5) ? DOWN : UP; if(getActionNumber(A_DOPEFISH_SWIM)) { int absdx = (dx<0) ? -dx : dx; int absdy = (dy<0) ? -dy : dy; if( absdx < CSF_MIN_DISTANCE_TO_CHARGE && absdy < CSF_MIN_DISTANCE_TO_CHARGE ) { setAction(A_DOPEFISH_EAT); mp_processState = &CDopeFish::processEat; m_eatTimer = DOPE_EAT_TIMER; } } } return true; }
bool CBobba::isNearby(CSpriteObject& theObject) { if( !getProbability(30) ) return false; if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) xDirection = LEFT; else xDirection = RIGHT; } return true; }
void CDopeFish::processBurp() { if(!m_burped && getActionStatus(A_DOPEFISH_BURPING)) { g_pSound->playSound(SOUND_DOPEFISH_BURP); CBubbles *Bubble = new CBubbles(mp_Map, 0, getXMidPos()+(1<<CSF), getYMidPos()+(1<<CSF), true); g_pBehaviorEngine->m_EventList.add( new EventSpawnObject( Bubble ) ); m_burped = true; } if(getActionStatus(A_DOPEFISH_BURP_FINISHED)) { setAction(A_DOPEFISH_SWIM); mp_processState = &CDopeFish::processSwim; } }
bool CSkypest::isNearby(CObject &theObject) { if(getActionStatus(A_SKYPEST_LICKEYES)) { if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int dx = player->getXMidPos() - getXMidPos(); if( dx<0 ) m_hDir = LEFT; else m_hDir = RIGHT; } } return true; }
bool CSpirogrip::isNearby(CSpriteObject &theObject) { if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) mKeenAlignmentX = LEFT; else mKeenAlignmentX = RIGHT; if( player->getYMidPos() < getYMidPos() ) mKeenAlignmentY = UP; else mKeenAlignmentY = DOWN; } return true; }
bool COrbatrix::isNearby(CSpriteObject &theObject) { if(!getActionStatus(A_ORBATRIX_FLOAT)) return true; if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( getProbability(600) ) { if( player->getXMidPos() < getXMidPos() ) xDirection = LEFT; else xDirection = RIGHT; } } return true; }
void CBobba::processSitting() { mTimer++; if(mTimer < SIT_TIME) return; mTimer = 0; setAction(A_BOBBA_SHOOT); playSound(SOUND_BOBBA_SHOOT); int x_coord = getXMidPos(); x_coord += (xDirection == LEFT) ? -(8<<STC) : +(8<<STC); CEnemyShot *fireball = new CEnemyShot(mp_Map, 0, x_coord, getYUpPos(), 0x2E76, xDirection, 0, 100, mSprVar); spawnObj( fireball ); }
bool CArachnut::isNearby(CSpriteObject &theObject) { if( !getProbability(80) ) return false; if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) ) { if( player->getXMidPos() < getXMidPos() ) xDirection = LEFT; else xDirection = RIGHT; if( player->getYMidPos() < getYMidPos() ) yDirection = UP; else yDirection = DOWN; } return true; }
bool CMimrock::isNearby(CObject &theObject) { if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int dx = player->getXMidPos() - getXMidPos(); if( dx>-CSF_DISTANCE_TO_FOLLOW_TOLERANCE && dx<+CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) { if( dx<0 ) m_hDir = LEFT; else m_hDir = RIGHT; setAction(A_MIMROCK_WALK); mp_processState = (void (CStunnable::*)()) &CMimrock::processWalk; } } return true; }
void CDevilSprite::processShoot() { m_timer--; if( m_timer == SPRITE_SHOOT_DELAY/2 ) { gSound.playSound(SOUND_SPRITE_SHOT); int x_coord = getXMidPos(); x_coord += (xDirection == LEFT) ? -(8<<STC) : +(8<<STC); CEnemyShot *Spark = new CEnemyShot(mpMap, 0, x_coord, getYMidPos()-(8<<STC), 0x3818, xDirection, 0, 100, 0); gEventManager.add( new EventSpawnObject( Spark ) ); } if( m_timer <= 0 ) { m_timer = SPRITE_MOVE_DELAY; setAction(A_SPRITE_MOVE); mp_processState = &CDevilSprite::processMove; } }
bool CLick::isNearby(CSpriteObject &theObject) { const bool odd = getProbability(80); if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) ) { const int dy = abs(player->getYMidPos() - getYMidPos()); const int dx = player->getXMidPos() - getXMidPos(); if( dy > CSF_MIN_DISTANCE_TO_BREATHE ) return false; if( dx<-CSF_DISTANCE_TO_FOLLOW_TOLERANCE && odd ) xDirection = LEFT; else if( dx>+CSF_DISTANCE_TO_FOLLOW_TOLERANCE && odd ) xDirection = RIGHT; if(getActionNumber(A_LICK_LAND)) { int absdx = (dx<0) ? -dx : dx; if( absdx < CSF_DISTANCE_TO_FOLLOW_TOLERANCE ) keenNear = true; else keenNear = false; if( absdx < CSF_MIN_DISTANCE_TO_BREATHE && odd ) { setAction(A_LICK_BREATHE); playSound(SOUND_LICK_FIREBREATH); m_timer = LICK_BREATHE_TIMER; } } } return true; }