Exemple #1
0
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;
}
Exemple #2
0
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;
}
Exemple #3
0
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;
	}

}
Exemple #4
0
void CPlatform::getTouchedBy(CSpriteObject &theObject)
{
	if( CPlayerLevel *player = dynamic_cast<CPlayerLevel*>(&theObject) )
	{
		const int m_py2 = player->getYDownPos();
		const int m_y2 = getYUpPos()+(4<<STC);
		if( m_py2 <= m_y2 && !player->supportedbyobject && !player->m_jumpdownfromobject )
		{
			mp_CarriedPlayer = player;
			player->supportedbyobject = 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);
	}
}
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 );
    
}
Exemple #7
0
bool CFoob::isNearby(CVorticonSpriteObject &theObject)
{
    if(CPlayer *player = dynamic_cast<CPlayer*>(&theObject))
    {
        if ( (player->getYDownPos() >= getYUpPos()-(2<<CSF)) &&
             (player->getYDownPos() <= getYDownPos()+(1<<CSF)) )
        {
            onsamelevel = true;
            SpookedByWho = player->m_index;
        }

        if(state == FOOB_SPOOK)
        {
            mSpriteIdx = FOOB_SPOOK_FRAME;

            if (spooktimer > FOOB_SPOOK_SHOW_TIME)
            {
                state = FOOB_FLEE;
                OffOfSameLevelTime = 0;
                // run away from the offending player

                if (player->getXPosition() < getXPosition())
                    dir = RIGHT;
                else
                    dir = LEFT;

                // in hard mode run TOWARDS the player (he's deadly in hard mode)
                if (gBehaviorEngine.mDifficulty == HARD)
                {
                    dir = (dir==LEFT) ? RIGHT : LEFT;
                }

            }
            else spooktimer++;
        }
    }
    
    return true;
}
void CGuardRobot::process()
{
	switch(state)
	{
	case LOOK:
		// animation
		if (animtimer > LOOK_ANIM_TIME)
		{
			frame ^= 1;
			animtimer = 0;
		}
		else
			animtimer++;

		sprite = LOOK_FRAME + frame;

		// when time is up go back to moving
		if (timer > LOOK_TOTALTIME)
		{
			timetillcanfire = (rnd()%(MAX_TIME_TILL_CAN_FIRE-MIN_TIME_TILL_CAN_FIRE))+MIN_TIME_TILL_CAN_FIRE;
			timetillcanfirecauseonsamelevel = TIME_BEFORE_FIRE_WHEN_SEE;
			firetimes = 0;
			state = WALK;
			frame = 0;
			animtimer = 0;
			timer = 0;
			dist_to_travel = TRAVELDIST;
		}
		else
			timer++;

		break;

	case WALK:
		// hover animation
		if (animtimer > WALK_ANIM_TIME)
		{
			if (frame>=3) frame=0;
			else frame++;
			animtimer = 0;
		} else animtimer++;

		if (movedir==LEFT)
			sprite = WALK_LEFT_FRAME + frame;
		else
			sprite = WALK_RIGHT_FRAME + frame;

		// if we're about to, or just did, fire a volley, don't move
		if (!hardmode)
		{
			if (pausetime)
			{
				pausetime--;
				return;
			}
		}
		else
			pausetime = 0;

		// are we firing a volley?
		if (firetimes)
		{
			// is it time to fire the next shot in the volley?
			if (!timetillnextshot)
			{
				CRay *newobject;
				if (onscreen)
					playSound(SOUND_TANK_FIRE);
				if (movedir==RIGHT)
					newobject = new CRay(mp_Map,getXRightPos()+(8<<STC), getYUpPos()+(5<<STC), RIGHT);
				else
					newobject = new CRay(mp_Map,getXPosition(), getYUpPos()+(5<<STC), LEFT);
				newobject->setOwner(OBJ_GUARDROBOT, m_index);
				newobject->sprite = ENEMYRAYEP2;

				m_ObjectVect.push_back(newobject);

				timetillnextshot = TIME_BETWEEN_SHOTS;
				if (!--firetimes)
				{
					pausetime = FIRE_PAUSE_TIME;
				}
			}
			else
			{
				timetillnextshot--;
			}

			// don't move when firing except on hard mode
			if (hardmode)
				return;

		}
		else
		{  // not firing a volley
			if (!timetillcanfire)
			{
				guard_fire();
			}
			else
			{
				timetillcanfire--;
			}

		}

		turnaroundtimer = 0;

		if (movedir==LEFT)
		{  // move left
			if (!blockedl)
			{
				xinertia = -WALK_SPEED;
				dist_to_travel--;
			}
			else
			{
				frame = 0;
				timer = 0;
				animtimer = 0;
				state = LOOK;
				movedir = RIGHT;
			}
		}
		else
		{  // move right
			sprite = WALK_RIGHT_FRAME + frame;
			if (!blockedr)
			{
				xinertia = WALK_SPEED;
				dist_to_travel--;
			}
			else
			{
				frame = 0;
				timer = 0;
				animtimer = 0;
				state = LOOK;
				movedir = LEFT;
			}
		}
		break;
	default : break;
	}
}
Exemple #9
0
void CTank::process()
{
	switch(state)
	{
	case TANK_WALK: // Walk in a direction
	{
		// is keen on same level?
		if (movedir==LEFT)
		{  // move left
			sprite = TANK_WALK_LEFT_FRAME + frame;
			xinertia = -TANK_WALK_SPEED;
			if( blockedl )
			{
				movedir = RIGHT;
				frame = 0;
				timer = 0;
				animtimer = 0;
				state = TANK_TURN;
			}

			dist_to_travel--;
		}
		else
		{  // move right
			sprite = TANK_WALK_RIGHT_FRAME + frame;
			xinertia = TANK_WALK_SPEED;
			if ( blockedr )
			{
				movedir = LEFT;
				frame = 0;
				timer = 0;
				animtimer = 0;
				state = TANK_TURN;
			}

			dist_to_travel--;
		}

		// walk animation
		if (animtimer > TANK_WALK_ANIM_TIME)
		{
			if (frame>=3) frame=0;
			else frame++;
			animtimer = 0;
		} else animtimer++;

		if(dist_to_travel==0)
		{
			frame = 0;
			timer = 0;
			animtimer = 0;
			state = TANK_WAIT;
		}
	default: break;
	}
	break;

	case TANK_WAIT:
		if ( (timer > TANK_PREPAREFIRE_TIME) ||
				(timer > TANK_PREPAREFIRE_TIME_FAST && hardmode) )
		{
			timer = 0;
			state = TANK_FIRE;
		}
		else
			timer++;

		break;

	case TANK_TURN:
		// If it gets stuck somewhere turn around
		sprite = TANK_LOOK_FRAME + frame;
		// animation
		if (animtimer > TANK_LOOK_ANIM_TIME)
		{
			frame ^= 1;
			animtimer = 0;
		} else animtimer++;

		// when time is up go back to moving
		if (timer > TANK_LOOK_TOTALTIME)
		{
			// decide what direction to go
			state = TANK_WALK;
			animtimer = 0;
			timer = 0;
		} else timer++;
		break;
	case TANK_FIRE:
	{
		int height_top = g_pBehaviorEngine->getPhysicsSettings().tankbot.shot_height_from_top<<STC;
		if(height_top!=0)
		{
			CRay *newobject;
			if (onscreen)
				playSound(SOUND_TANK_FIRE);
			if (movedir==RIGHT)
				newobject = new CRay(mp_Map, getXMidPos(), getYUpPos()+height_top, RIGHT);
			else
				newobject = new CRay(mp_Map, getXMidPos(), getYUpPos()+height_top, LEFT);
			newobject->setOwner(OBJ_TANK, m_index);
			newobject->setSpeed(108);
			newobject->sprite = ENEMYRAY;
			newobject->canbezapped = true;
			m_Object.push_back(newobject);
		}

		state = TANK_WAIT_LOOK;
		frame = 0;
		timer = 0;
		animtimer = 0;
		dist_to_travel = TANK_MINTRAVELDIST + (rnd()%10)*(TANK_MAXTRAVELDIST-TANK_MINTRAVELDIST)/10;
	}
	break;

	case TANK_WAIT_LOOK:
		// Happens after Robot has fired
		if ( timer > TANK_WAITAFTER_FIRE )
		{
			timer = 0;
			state = TANK_LOOK;
		}
		else
			timer++;

		break;

	case TANK_LOOK:
		sprite = TANK_LOOK_FRAME + frame;
		// animation
		if (animtimer > TANK_LOOK_ANIM_TIME)
		{
			frame ^= 1;
			animtimer = 0;
		} else animtimer++;

		// when time is up go back to moving
		if (timer > TANK_LOOK_TOTALTIME)
		{
			// decide what direction to go

			if(m_Player[0].getXMidPos() < getXMidPos())
			{
				movedir = LEFT;
				sprite = TANK_WALK_LEFT_FRAME;
			}
			else if(m_Player[0].getXMidPos() > getXMidPos())
			{
				movedir = RIGHT;
				sprite = TANK_WALK_RIGHT_FRAME;
			}
			state = TANK_WALK;
			animtimer = 0;
			timer = 0;
		} else timer++;
		break;
	}
}
Exemple #10
0
void CAmpton::processWalking()
{
  //play tic toc sound
  if(getActionStatus(A_AMPTON_WALK))    
    playSound(SOUND_AMPTONWALK0);
  else if(getActionStatus(A_AMPTON_WALK+1))    
    playSound(SOUND_AMPTONWALK1);
  
  
  int l_x_l = getXLeftPos();
  int l_x_r = getXRightPos();
  int l_w = getXRightPos() - getXLeftPos();
  int l_h = getYDownPos() - getYUpPos();
  int l_y = getYMidPos();
  int l_x_mid = getXMidPos();    
  
  if ( (l_x_mid & 0x1FF) <= WALK_SPEED) 
  {
    if(hitdetectWithTilePropertyRectRO(31, l_x_mid, l_y, l_w, l_h, 1<<CSF))
    {
      setAction(A_AMPTON_FLIP_SWITCH);
    }
    
    if(hitdetectWithTilePropertyRectRO(1, l_x_mid, l_y, l_w, l_h, 1<<CSF))
    {
      if( getProbability(600) )
      //if (rand() < 0xC4)
      {
	bool polebelow = hitdetectWithTilePropertyHor(1, l_x_l, l_x_r, getYDownPos(), 1<<CSF);
	bool poleabove = hitdetectWithTilePropertyHor(1, l_x_l, l_x_r, getYUpPos(), 1<<CSF); 
	
	if( getProbability(400) )
	//if (rand() < 0x80) 
	  poleabove = false;
	else 
	  polebelow = false;
	
	//climb up
	if (poleabove) 
	{
	  setAction(A_AMPTON_START_POLE);
	  yDirection = UP;
	  return;
	}	  
	else if (polebelow) 
	{
	  setAction(A_AMPTON_START_POLE);
	  yDirection = DOWN;
	  return;
	}
      }
    }
  }
  
  // Move normally in the direction
  if( xDirection == RIGHT )
  {
    moveRight( WALK_SPEED );
  }
  else
  {
    moveLeft( WALK_SPEED );
  }   
}
// Process the touching of certain tile, like items and hazards...
void CPlayerBase::processLevelMiscFlagsCheck()
{
	// Item which are taken must go into a data structure
	// animation should also be triggered

	stItemGalaxy &m_Item = m_Inventory.Item;

	int l_x = getXLeftPos();
	int l_y = getYUpPos();
	int l_w = getXRightPos() - getXLeftPos();
	int l_h = getYDownPos() - getYUpPos();


	// Deadly hazards! Here Keen dying routine will be triggered
	if(hitdetectWithTilePropertyRect(3, l_x, l_y, l_w, l_h, 2<<STC))
	{
		kill();
        return;
	}

	// Another property of the tiles may kill keen, also in god mode
	std::vector<CTileProperties> &Tile = g_pBehaviorEngine->getTileProperties(1);
	// TODO: Workaround! It seems that the deadly tiles are 17 tiles behind. Not sure, why!
	const int tileIDl = mp_Map->getPlaneDataAt(1, l_x, (l_y+l_h)+(1<<STC));
	const int tileIDr = mp_Map->getPlaneDataAt(1, l_x+l_w, (l_y+l_h)+(1<<STC));
	if(Tile[tileIDl].bup == 9 && Tile[tileIDr].bup == 9 )
	{
	    if(!m_Cheatmode.god)
	    {
		kill(true);
	    }
	}


	if(hitdetectWithTilePropertyRect(4, l_x, l_y, l_w, l_h, 2<<STC))
	{
	  int dropanimation_sprite = 215;	  
	  const int ep = g_pBehaviorEngine->getEpisode();
	  
	  if(ep == 5)
	  {
	    dropanimation_sprite = 225;
	  }
	  else if(ep == 6)
	  {
	    dropanimation_sprite = 224;
	  }	    
	  
	  const int lc_x = l_x>>CSF;
	  const int lc_y = l_y>>CSF;
	  mp_Map->setTile( lc_x, lc_y, 0, true, 1 );
	  CItemEffect *iEffect = new CItemEffect(mp_Map, 0, lc_x<<CSF, lc_y<<CSF, dropanimation_sprite, ANIMATE);
	  g_pBehaviorEngine->m_EventList.spawnObj( iEffect );
	  m_Item.m_drops++;
	  
	  if(m_Item.m_drops >= 100)
	  {
	    m_Item.m_drops = 0;
	    getAnotherLife(lc_x, lc_y, true, true);
	  }
	  
	  g_pSound->playSound( SOUND_GET_DROP );
	}
// let's have keen be able to pick up goodies
void CPlayer::getgoodies()
{
	if( getGoodie((getXLeftPos())>>CSF, (getYUpPos())>>CSF) ) return;     		// Upper-Left
	else if(getGoodie((getXRightPos())>>CSF, (getYUpPos())>>CSF) ) return; 		// Upper-Right