예제 #1
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;
}
예제 #2
0
void CIceChunk::smash()
{
	if (onscreen)
	{
	    if(!silent)
		playSound(SOUND_CHUNKSMASH);
	    
	    silent = true;
	    CIceBit *chunk;

		// upleft
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), -1, -1);
		spawnObj(chunk);

		// upright
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), 1, -1);
		spawnObj(chunk);

		// downleft
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), -1, 1);
		spawnObj(chunk);

		// downright
		chunk = new CIceBit(mp_Map, getXPosition(), getYPosition(), 1, 1);
		spawnObj(chunk);
	}
	exists = false;
}
예제 #3
0
void CAutoRay::process()
{
	if( (mp_Map->getAnimtiletimer()%GUNFIRE_TIMER) == 0 )
	{
		unsigned int x,y;
		CRay *NewRay;
		x = getXPosition();
		y = getYPosition();

		if (m_type==VERTICAL)
		{
            NewRay = new CRay(mp_Map, x+(4<<STC), y+(1<<CSF), CENTER, DOWN, getSpriteVariantId(), OBJ_AUTORAY_V, m_index, 124);
			NewRay->sprite = RAY_VERT_EP3;
			NewRay->m_VertDir = DOWN;
		}
		else
		{
            NewRay = new CRay(mp_Map, x+(1<<CSF), y+(4<<STC), CENTER, DOWN, getSpriteVariantId(), OBJ_AUTORAY, m_index, 124);
			NewRay->sprite = ENEMYRAYEP3;
			NewRay->m_HorDir = RIGHT;
		}
		spawnObj(NewRay);

		if(!silent)
		{
		    playSound(SOUND_TANK_FIRE);
		    silent = true;
		}		
	}
}
예제 #4
0
void CRoboRed::processShoot()
{
  // Shoot many times.  
  if(mTimer%16 == 0)
  {
    playSound(SOUND_ROBORED_SHOOT);
    
    direction_t newXDir = xDirection<0 ? LEFT : RIGHT;
    direction_t newYDir = swapYDir ? UP : DOWN;    
    swapYDir = !swapYDir;
    int newX = 	xDirection == RIGHT ? getXRightPos() : getXLeftPos();
    int newY = 	getYPosition() + 0x300;
    spawnObj( new CRedShot( getMapPtr(), 
							     0, 
							     newX, newY,
							     newXDir, newYDir ) );
  }
				
  mTimer++;
  if(mTimer < TIME_SHOOTING)
    return;
  
  mTimer = 0;
  
  setAction(A_RED_PAUSE);
}
예제 #5
0
void COrbatrix::getTouchedBy(CSpriteObject& theObject)
{
    if(dead || theObject.dead)
        return;

    // Was it a bullet, make it zap/zot
    if( dynamic_cast<CBullet*>(&theObject) )
    {
        setAction(A_ORBATRIX_FLOAT);
        theObject.dead = true;
        return;
    }
    
    if( CPlayerBase *player = dynamic_cast<CPlayerBase*>(&theObject) )
    {
        if(!mGivesKey)
        {
            // Only kill Keen, if Orbatrix bounces
            if(getActionNumber(A_ORBATRIX_BOUNCE))
            {
                player->kill();
            }
        }
        else
        {
            stItemGalaxy &Item = player->m_Inventory.Item;
            Item.m_gem.red++;
            spawnObj(new CItemEffect(mp_Map, 0, getXPosition(), getYPosition(), got_sprite_item_pics[2][2], FADEOUT));
            dead = true;
            exists = false;
        }
    }
}
예제 #6
0
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;
}
예제 #7
0
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 );
    
}
예제 #8
0
// the ice cannon itself
void CIceCannon::process()
{
	// keep spawner object invisible and properly positioned
	if( mTimer >= GUNFIRE_TIMER_EP1 )
	{
		int newpos_x = getXPosition();
		int newpos_y = getYPosition();
		if(vector_x > 0) newpos_x += 512;
		CIceChunk *chunk = new CIceChunk(mp_Map, newpos_x, newpos_y,vector_x, vector_y);
		if(!silent)
		{
		    playSound(SOUND_CANNONFIRE);
		    silent = true;
		}

		spawnObj(chunk);
		mTimer = 0;
	}
	else
	{
	    mTimer++;
	}
}
예제 #9
0
void CSpriteItem::getTouchedBy(CSpriteObject &theObject)
{
	if( CPlayerBase* pPlayer = dynamic_cast<CPlayerBase*>(&theObject) )
	{
		const int ep = g_pBehaviorEngine->getEpisode();
		stItemGalaxy &Item = pPlayer->m_Inventory.Item;
		
		int epOff = 0;
		if(ep == 5)
		{
		  epOff = -5;
		}
		else if(ep == 6)
		{
		  epOff = -1;
		}
		  
		int relBase = m_basesprite+epOff;		

		/// Calculate the right animation.
		// Point items
		Uint32 newanimsprite = got_sprite_item_pics[ep-4][0];
		if( relBase >= 103 && relBase <= 113 )
		{
			newanimsprite = got_sprite_item_pics[ep-4][4+(relBase-103)/2];
			switch(relBase)
			{
			case 103: Item.m_points += 100;	break;
			case 105: Item.m_points += 200;	break;
			case 107: Item.m_points += 500;	break;
			case 109: Item.m_points += 1000;	break;
			case 111: Item.m_points += 2000;	break;
			case 113: Item.m_points += 5000;	break;
			default: break;
			}
			g_pSound->playSound( SOUND_GET_BONUS );
		}
		
		// Check for the extra life
		if ( relBase == 115 )
		{
			newanimsprite = got_sprite_item_pics[ep-4][10];
			Item.m_lifes++;
			g_pSound->playSound( SOUND_EXTRA_LIFE );
		}		
		
		// keycard (Keen 5 only)
		if( ep == 5 && m_basesprite >= 105 && m_basesprite <= 106 )
		{
			Item.m_keycards++;
			newanimsprite = 231;
			g_pSound->playSound( SOUND_GET_CARD );
		}
				

		// Now add the stuff to the inventory
		if(ep == 5)
		{
		  epOff = -4;
		}
		else
		{
		  epOff = 0;
		}
		  
		relBase = m_basesprite+epOff;
		
		// raygun
		if( relBase >= 127 && relBase <= 128 )
		{
			Item.m_bullets += 5;
			newanimsprite = got_sprite_item_pics[ep-4][11];
			g_pSound->playSound( SOUND_GET_AMMO );
		}
		

		if( relBase >= 118 && relBase <= 125 )
		{
			switch(relBase)
			{
			case 118: case 119:
				Item.m_gem.red++;
				break;
			case 120: case 121:
				Item.m_gem.yellow++;
				break;
			case 122: case 123:
				Item.m_gem.blue++;
				break;
			case 124: case 125:
				Item.m_gem.green++;
				break;
			default:
				break;
			}
			g_pSound->playSound( SOUND_GET_GEM );
		}
		
        spawnObj(new CItemEffect(mp_Map, 0, getXPosition(), getYPosition(), newanimsprite, FADEOUT));

		exists = false;
	}
}
void CVorticonElite::process()
{
	if (mHealthPoints <= 0 && state != VORTELITE_DYING)
	{
		animtimer = 0;
		frame = 0;
		state = VORTELITE_DYING;
		dying = true;

		if (onscreen)
			playSound(SOUND_VORT_DIE);
	}

	if(state == VORTELITE_CHARGE)
	{
		m_speed = CHARGE_SPEED;
	}
	else if(state == VORTELITE_WALK)
	{
		m_speed = WALK_SPEED;
	}

	reprocess: ;
	switch(state)
	{
	case VORTELITE_CHARGE:
	case VORTELITE_WALK:

		if (movedir==LEFT)
		{  // move left
			sprite = VORTELITE_WALK_LEFT_FRAME + frame;
			if (!blockedl)
			{
				xinertia = -m_speed;
			}
			else
			{
				movedir = RIGHT;

				// if we only traveled a tiny amount before hitting a wall, we've
				// probably fallen into a small narrow area, and we need to try
				// to jump out of it
				if (dist_traveled < VORTELITE_TRAPPED_DIST && !mp_Map->m_Dark && blockedd)
				{
					initiatejump();
					goto reprocess;
				}
                else if(mp_Map->m_Dark)
                {
                    dist_traveled = 0;
                }
			}
		}
		else
		{  // move right
			sprite = VORTELITE_WALK_RIGHT_FRAME + frame;
			if (!blockedr)
			{
				xinertia = m_speed;
			}
			else
			{
				movedir = LEFT;

				// if we only traveled a tiny amount before hitting a wall, we've
				// probably fallen into a small narrow area, and we need to try
				// to jump out of it
				if (dist_traveled < VORTELITE_TRAPPED_DIST && !mp_Map->m_Dark && blockedd)
				{
					initiatejump();
					goto reprocess;
				}
                else if(mp_Map->m_Dark)
                {
                    dist_traveled = 0;
                }
            }
		}

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

	case VORTELITE_JUMP:
		if (movedir == RIGHT)
		{ if (!blockedr) moveRight(m_speed); }
		else
		{ if (!blockedl) moveLeft(m_speed); }

		if (blockedd && yinertia >= 0)
		{  // The Vorticon Has landed after the jump!
			state = VORTELITE_WALK;
			goto reprocess;
		}

		break;
	case VORTELITE_ABOUTTOFIRE:
		if (movedir==RIGHT)
		{ sprite = VORTELITE_FIRE_RIGHT_FRAME; }
		else
		{ sprite = VORTELITE_FIRE_LEFT_FRAME; }
		if (timer > VORTELITE_HOLD_GUN_OUT_TIME)
		{
			timer = 0;
			state = VORTELITE_FIRED;

			CRay *newobject;
			if (movedir==RIGHT)
                newobject = new CRay(mp_Map, getXRightPos()+1, getYPosition()+(9<<STC), RIGHT, CENTER, getSpriteVariantId());
			else
                newobject = new CRay(mp_Map, getXLeftPos()-1, getYPosition()+(9<<STC), LEFT, CENTER, getSpriteVariantId());
			newobject->setOwner( m_type, m_index);
			newobject->sprite = ENEMYRAYEP2;
			// don't shoot other vorticon elite
			spawnObj(newobject);

			if (onscreen)
				playSound(SOUND_KEEN_FIRE);
		}
		else timer++;
		break;
	case VORTELITE_FIRED:
		if (movedir==RIGHT)
		{ sprite = VORTELITE_FIRE_RIGHT_FRAME; }
		else
		{ sprite = VORTELITE_FIRE_LEFT_FRAME; }

		if (timer > VORTELITE_HOLD_GUN_AFTER_FIRE_TIME)
		{
			timer = 0;
			frame = 0;
			timesincefire = 0;
			state = VORTELITE_WALK;
		}
		else timer++;
		break;
	case VORTELITE_DYING:
		sprite = VORTELITE_DYING_FRAME;
		if (animtimer > VORTELITE_DIE_ANIM_TIME)
		{
			sprite = VORTELITE_DEAD_FRAME;
			dead = true;
		}
		else
		{
			animtimer++;
		}
		break;
	default: break;
	}
}
// 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);
      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 );
	}