Ejemplo n.º 1
0
VOID LaserUpdate()
{
	LaserCurrentFrame++;
	if (LaserCurrentFrame == LASER_MAX_FRAME) LaserCurrentFrame = 0;
	for (int i = 0; i < MAX_LASER_NUM; i++)
		if (m_laser[i].used)
		{
			m_laser[i].pos.x -= ScorePerFrame * 4;
		}

	if (!LaserGenerate)
	{
		bool LaserJudge = TRUE;
		for (int i = 0; i < 10; i++)
		{
			if (!(CoinPosition[i][0] >= WNDWIDTH + COIN_SIZE || CoinPosition[i][0] + COIN_SIZE * 6 <= WNDWIDTH))
			{
				LaserJudge = FALSE;
				break;
			}
		}
		if (LaserJudge)
		{
			int roll = GetRandomInt(0, LaserRandom);
			if (roll == 0)
			{
				LaserAxis++;
				if (LaserAxis == MAX_LASER_NUM) LaserAxis = 0;
				int length = GetRandomInt(WNDHEIGHT / 5, WNDHEIGHT / 5 * 3);
				int position = GetRandomInt(0, WNDHEIGHT - length - 60);
				m_laser[LaserAxis] = CreateLaser(WNDWIDTH, position, 39, 43, 18, 1, length, !m_hero.invincible);
				LaserGenerate = 200;
			}
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CNPC_Combine_Cannon::Spawn( void )
{
	Precache();

	/// HACK:
	SetModel( "models/combine_soldier.mdl" );

	// Setup our ancillary beams but keep them hidden for now
	CreateLaser();
	CreateAncillaryBeams();

	m_iAmmoType = GetAmmoDef()->Index( "CombineHeavyCannon" );

	SetHullType( HULL_HUMAN );
	SetHullSizeNormal();

	UTIL_SetSize( this, Vector( -16, -16 , 0 ), Vector( 16, 16, 64 ) );

	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_NOT_STANDABLE );
	SetMoveType( MOVETYPE_FLY );
	m_bloodColor		= DONT_BLEED;
	m_iHealth			= 10;
	m_flFieldOfView		= DOT_45DEGREE;
	m_NPCState			= NPC_STATE_NONE;

	if( HasSpawnFlags( SF_STARTDISABLED ) )
	{
		m_fEnabled = false;
	}
	else
	{
		m_fEnabled = true;
	}

	CapabilitiesClear();
	CapabilitiesAdd( bits_CAP_INNATE_RANGE_ATTACK1 | bits_CAP_SIMPLE_RADIUS_DAMAGE );

	m_HackedGunPos = Vector ( 0, 0, 0 ); 

	AddSpawnFlags( SF_NPC_LONG_RANGE | SF_NPC_ALWAYSTHINK );

	NPCInit();

	// Limit our look distance
	SetDistLook( m_flSightDist );

	AddEffects( EF_NODRAW );
	AddSolidFlags( FSOLID_NOT_SOLID );

	// Point the cursor straight ahead so that the sniper's
	// first sweep of the laser doesn't look weird.
	Vector vecForward;
	AngleVectors( GetLocalAngles(), &vecForward );
	m_vecPaintCursor = GetBulletOrigin() + vecForward * 1024;

	// none!
	GetEnemies()->SetFreeKnowledgeDuration( 0.0f );
	GetEnemies()->SetEnemyDiscardTime( 2.0f );

	m_flTimeLastAttackedPlayer = 0.0f;
}
//
// CreateWeapon() simply takes a line from the weapons database and pulls out
// the information for the different weapons.  It then determines the type
// of weapon that should be created from the loaded string and calls the
// specific function for that type of weapon, passing to it the values from
// the database.
//
CHSDBWeapon *CHSWeaponDBArray::CreateWeapon(char *items)
{
	int  iValArray[30];	// Gets loaded with field values
	char tbuf[32];		// Temporary string storage
	char strName[256];	// Gets loaded with the weapon name.
	UINT idx;
	UINT ok;
	UINT j;
	char *ptr;
	UINT type;

	ptr = items;

	// Grab the type of weapon, which is the first char.
	type = *ptr - '0';
	ptr++;

	// Next, we should have the name surrounded by quotes.
	if (*ptr != '"')
	{
		return NULL;
	}

	ptr++;

	idx = 0;
	while (*ptr && ((ptr - items) < HS_WEAPON_NAME_LEN) && 
		(*ptr != '"'))
	{
		strName[idx++] = *ptr++;
	}
	strName[idx] = NULL;	// Got the weapon name!

	if (!*ptr)
	{
		return NULL;
	}

	// Increment past the quotes.
	if (*ptr == '"')
		ptr++;
	else
	{
		while (*ptr != '"')
			ptr++;
		ptr++;
	}
	// We're finished with the name here.


	// Skip a white space
	ptr++;

	/*
	 * Now start pulling out numbers and putting them in the array
	 */
	ok = 1;
	j = 0;
	while (ok)
	{
		// Extract the value
		extract(ptr, tbuf, j, 1, ' ');

		// Check to see if we've reached the end of the string.
		if (!*tbuf)
			break;

		// Shove the val into the array
		iValArray[j] = atoi(tbuf);
		j++;
	}
	iValArray[j] = -1;

	// Determine the type of weapon, and call the appropriate handler
	// for creating that weapon type.  Pass the name and the values extracted
	// from the database string.
	if (type == HSW_LASER)
	{
		return CreateLaser(strName, iValArray);
	}
	else if (type == HSW_MISSILE)
	{
		return CreateMissile(strName, iValArray);
	}
	else
		return NULL;
}