示例#1
0
void AutoShot::waiting()
{
    const int ep = g_pBehaviorEngine->getEpisode();
    if(ep > 4)
    {
        if(sprite < mBaseSprite + mNumAnimSprites + 1)
            sprite++;
        else
        {
            sprite = mBaseSprite;
            dontdraw = true;
        }
    }
    
    if( mTimer < WAIT_TIME )
    {
        mTimer++;
        return;
    }

  if(m_Pos != origin)
  {
    moveToForce(origin);  
    onslope = blockedd = blockedl = blockedr = blockedu = false;
  }
  
  dontdraw = false;
  sprite = mBaseSprite;
  mTimer = 0;
  processState = &AutoShot::flying;
  
  if(ep == 4)
  {
      playSound(SOUND_DARTGUN_SHOOT);
  }
  else if(ep == 5)
  {
      playSound(SOUND_ROBORED_SHOOT); // Yeah, it is the same sound!
  }
  else // keen 6
  {
      playSound(SOUND_AUTOGUN);
  }  
  
  dontdraw = false;
}
示例#2
0
void CShikadiMaster::processTeleporting()
{
    if(!mpPlayer)
	return;
    
    mTimer++;
    if(mTimer < TIME_UNTIL_TELEPORTED)
	return;
    
    mTimer = 0;
    
    
/*
 
	int xpos_0, ypos_0, tx, ty, tx2, ty2, tries;
	int _far *t;

	xpos_0 = o->xpos;
	ypos_0 = o->ypos;

	GetNewObj(1);
	new_object->xpos = o->xpos;
	new_object->ypos = o->ypos;
	o->xmove = 0x30;
	CheckGround(new_object,ACTION_MASTERSPARKS0);

	GetNewObj(1);
	new_object->xpos = o->xpos;
	new_object->ypos = o->ypos;
	o->xmove = -0x30;
	CheckGround(new_object,ACTION_MASTERSPARKS0);
	*/

	playSound(SOUND_MASTERTELE);

	int triesLeft = 10;

	while (triesLeft > 0) 
	{
	    const unsigned int tx = ((rand()%(mp_Map->m_width<<CSF))/8 + mpPlayer->getXMidPos() - (0x10<<STC))>>CSF;
	    const unsigned int ty = ((rand()%(mp_Map->m_height<<CSF))/8 + mpPlayer->getYUpPos() - (0x10<<STC))>>CSF;
	    
	    if (ty < 2 || tx < 2 || mp_Map->m_width-5 < tx || mp_Map->m_height-5 < ty) 
	    {
		rand();
	        triesLeft--;
		continue;
	    }

	    const int testBoxX1 = (tx - 1)<<CSF;
	    const int testBoxX2 = (tx + 4)<<CSF;
	    const int testBoxY1 = (ty - 1)<<CSF;
	    const int testBoxY2 = (ty + 4)<<CSF;
	    
	    std::vector<CTileProperties> &Tile = g_pBehaviorEngine->getTileProperties(1);
	    
	    bool allow_teleport = true;
	    
	    for (int newy = testBoxY1; newy <= testBoxY2; newy += (1<<CSF) ) 
	    {
			for (int newx = testBoxX1; newx <= testBoxX2; newx += (1<<CSF) )
			{
				const int tile = mp_Map->getPlaneDataAt(1, newx, newy);				
				auto &prop = Tile[tile];
				
				if ( (prop.behaviour & 0x80) || 
				    prop.bup || prop.bright || 
				    prop.bleft || prop.bdown )
				{
				  // don't spawn inside a tile, or behind a hidden tile
				  triesLeft--;
				  allow_teleport = false;
				  break;			  
				}
			}
			
			if(!allow_teleport)  break;			
	    }
	    
	    if(!allow_teleport)  continue;
	    
	    // make it through previous nested loop == succesful tele
	    //KeenXVel = KeenYVel = 0;
	    moveToForce(tx<<CSF, ty<<CSF);
	    setAction(A_MASTER_STAND);
	    return;
	}

	// couldn't find a suitable spawn point, so reset to default master behaviour
	rand();
	
	setAction(A_MASTER_STAND);
	/*Rand();
	o->action = ACTION_MASTER0;
	o->xpos = xpos_0 - 1; o->ypos = ypos_0;
	KeenXVel = 1; KeenYVel = 0;
	return; 
 
	*/
}