예제 #1
0
bool AWeapon::CheckAmmo (int fireMode, bool autoSwitch, bool requireAmmo)
{
	int altFire;
	int count1, count2;
	int enough, enoughmask;

	if ((dmflags & DF_INFINITE_AMMO) || (Owner->player->cheats & CF_INFINITEAMMO))
	{
		return true;
	}
	if (fireMode == EitherFire)
	{
		bool gotSome = CheckAmmo (PrimaryFire, false) || CheckAmmo (AltFire, false);
		if (!gotSome && autoSwitch)
		{
			barrier_cast<APlayerPawn *>(Owner)->PickNewWeapon (NULL);
		}
		return gotSome;
	}
	altFire = (fireMode == AltFire);
	if (!requireAmmo && (WeaponFlags & (WIF_AMMO_OPTIONAL << altFire)))
	{
		return true;
	}
	count1 = (Ammo1 != NULL) ? Ammo1->Amount : 0;
	count2 = (Ammo2 != NULL) ? Ammo2->Amount : 0;

	enough = (count1 >= AmmoUse1) | ((count2 >= AmmoUse2) << 1);
	if (WeaponFlags & (WIF_PRIMARY_USES_BOTH << altFire))
	{
		enoughmask = 3;
	}
	else
	{
		enoughmask = 1 << altFire;
	}
	if (altFire && FindState(NAME_AltFire) == NULL)
	{ // If this weapon has no alternate fire, then there is never enough ammo for it
		enough &= 1;
	}
	if (((enough & enoughmask) == enoughmask) || (enough && (WeaponFlags & WIF_AMMO_CHECKBOTH)))
	{
		return true;
	}
	// out of ammo, pick a weapon to change to
	if (autoSwitch)
	{
		barrier_cast<APlayerPawn *>(Owner)->PickNewWeapon (NULL);
	}
	return false;
}
예제 #2
0
파일: Plant.cpp 프로젝트: Xydrel/Infected
//------------------------------------------------------------------------
void CPlant::Activate(bool activate)
{
	BaseClass::Activate(activate);

	m_planting = false;
	m_pressing = false;

	if(activate && m_pWeapon->GetOwnerActor())
	{
		CheckAmmo();
	}
}
예제 #3
0
//=========================================================
// RunAI
//=========================================================
void CBaseMonster :: RunAI ( void )
{
	// to test model's eye height
	//UTIL_ParticleEffect ( pev->origin + pev->view_ofs, g_vecZero, 255, 10 );

	// IDLE sound permitted in ALERT state is because monsters were silent in ALERT state. Only play IDLE sound in IDLE state
	// once we have sounds for that state.
	if ( ( m_MonsterState == MONSTERSTATE_IDLE || m_MonsterState == MONSTERSTATE_ALERT ) && RANDOM_LONG(0,99) == 0 && !(pev->flags & SF_MONSTER_GAG) )
	{
		IdleSound();
	}

	if ( m_MonsterState != MONSTERSTATE_NONE	&& 
		 m_MonsterState != MONSTERSTATE_PRONE   && 
		 m_MonsterState != MONSTERSTATE_DEAD )// don't bother with this crap if monster is prone. 
	{
		// collect some sensory Condition information.
		// don't let monsters outside of the player's PVS act up, or most of the interesting
		// things will happen before the player gets there!
		// UPDATE: We now let COMBAT state monsters think and act fully outside of player PVS. This allows the player to leave 
		// an area where monsters are fighting, and the fight will continue.
		if ( !FNullEnt( FIND_CLIENT_IN_PVS( edict() ) ) || ( m_MonsterState == MONSTERSTATE_COMBAT ) )
		{
			Look( m_flDistLook );
			Listen();// check for audible sounds. 

			// now filter conditions.
			ClearConditions( IgnoreConditions() );

			GetEnemy();
		}

		// do these calculations if monster has an enemy.
		if ( m_hEnemy != NULL )
		{
			CheckEnemy( m_hEnemy );
		}

		CheckAmmo();
	}

	FCheckAITrigger();

	PrescheduleThink();

	MaintainSchedule();

	// if the monster didn't use these conditions during the above call to MaintainSchedule() or CheckAITrigger()
	// we throw them out cause we don't want them sitting around through the lifespan of a schedule
	// that doesn't use them. 
	m_afConditions &= ~( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE );
}
//------------------------------------------------------------------------
void CThrow::Activate(bool activate)
{
	CSingle::Activate(activate);
	m_hold_timer = 0.0f;
	m_thrown = false;
	m_pulling = false;
	m_throwing = false;
	m_firing = false;
	m_netfiring = false;
	m_throwableId = 0;
	m_throwableAction = 0;
	CheckAmmo();
}
예제 #5
0
파일: Plant.cpp 프로젝트: kitnet/project-o
//------------------------------------------------------------------------
void CPlant::Activate(bool activate)
{
	m_plantTimer = 0.0f;
	m_planting = false;
	m_pressing = false;
	m_holding = false;
	m_timing = false;

	m_time = 0.0f;
	m_tickTimer = 0.0f;

	CheckAmmo();
}
예제 #6
0
bool AWeapon::DepleteAmmo (bool altFire, bool checkEnough, int ammouse)
{
	if (!((dmflags & DF_INFINITE_AMMO) || (Owner->player->cheats & CF_INFINITEAMMO)))
	{
		if (checkEnough && !CheckAmmo (altFire ? AltFire : PrimaryFire, false, false, ammouse))
		{
			return false;
		}
		if (!altFire)
		{
			if (Ammo1 != NULL)
			{
				if (ammouse >= 0 && (WeaponFlags & WIF_DEHAMMO))
				{
					Ammo1->Amount -= ammouse;
				}
				else
				{
					Ammo1->Amount -= AmmoUse1;
				}
			}
			if ((WeaponFlags & WIF_PRIMARY_USES_BOTH) && Ammo2 != NULL)
			{
				Ammo2->Amount -= AmmoUse2;
			}
		}
		else
		{
			if (Ammo2 != NULL)
			{
				Ammo2->Amount -= AmmoUse2;
			}
			if ((WeaponFlags & WIF_ALT_USES_BOTH) && Ammo1 != NULL)
			{
				Ammo1->Amount -= AmmoUse1;
			}
		}
		if (Ammo1 != NULL && Ammo1->Amount < 0)
			Ammo1->Amount = 0;
		if (Ammo2 != NULL && Ammo2->Amount < 0)
			Ammo2->Amount = 0;
	}
	return true;
}
예제 #7
0
파일: Test.cpp 프로젝트: Tumba/Keeper
PLUGIN_EXPORT void PLUGIN_CALL ProcessTick()
{
     
	static int timer = 0;
	static int time = 0;
	timer ++;
	time ++;
/*	for(int i = 0;i < MAX_PLAYERS;i++)
	{ 
		if(!IsConnected[i]) continue;
		if(ToKick[i] == 0) continue;
		g_Invoke->callNative(&PAWN::ResetPlayerWeapons,i);
	}*/
	if(time == 200)
	{
		  for(int i = 0;i < MAX_VEHICLES;i++)
		  {
			  if(SaveCord[i] > 0)
			  {
				  SaveCord[i] --;
				  if(SaveCord[i] == 0)
				  {
					  float x[3];float z;
					  g_Invoke->callNative(&PAWN::GetVehiclePos,i,&x[0],&x[1],&x[2]);
					  g_Invoke->callNative(&PAWN::GetVehicleZAngle,i,&z);
					  Vehicle[i].posx = x[0];
					  Vehicle[i].posy = x[1];
					  Vehicle[i].posz = x[2];
					  Vehicle[i].posa = z;
					  
				  }

			  }
		  }
		  for(int i = 0;i < MAX_PLAYERS;i++)
		  {
			  if(!IsConnected[i]) continue;
			  
			  if(ToKick[i] > 0)
			  {
			      ToKick[i] -= 1;
				  if(ToKick[i] == 0) g_Invoke->callNative(&PAWN::Kick,i);
				  continue;
			  }
			  if(ToBan[i] > 0)
			  {
			      ToBan[i] -= 1;
				  if(ToBan[i] == 0) g_Invoke->callNative(&PAWN::Ban,i);
				  continue;
			  }
			  CheckLag(i);
			  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_ONFOOT) AirCheck(i);
			  if(GunNoCheck[i] <= 0 && g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_ONFOOT)
			  {
				   CheckGun(i); 
			       CheckAmmo(i);
			  }
			  else  GunNoCheck[i] --;
			//  CheckHealth(i);
			//  CheckArmour(i);
			  if(g_Invoke->callNative(&PAWN::GetPlayerSpecialAction,i) == 2)
			  {
				  SafeKick(i,"JetPack",AC_JETPACK);
				  continue;
			  }
			  if(RemoveCheck[i] != 0)
			  {
				  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_ONFOOT)
				  {
					  RemoveCheck[i] = 0;
					  continue;
				  }
				  RemoveCheck[i] --;
				  if(RemoveCheck[i] == 0)
				  {
					   if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_DRIVER)
					   {
						   SafeKick(i,"Анти RemovePlayerFromVehicle",AC_REMOVE);
					       continue;
					   }
				  }
				 
			  }
		  }
		  time = 0;
	}
	if(timer == 20)
	{
		  for(int i = 0;i < MAX_PLAYERS;i++)
		  {
			  if(!IsConnected[i]) continue;
			  DeathTimes[i] = false;
			  if(ToKick[i] > 0) continue;
			  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_DRIVER && !IsAdmin(i)) CheckSpeed(i);
			  if(!IsAdmin(i)) FlyCheck(i);
			  if(g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_DRIVER || g_Invoke->callNative(&PAWN::GetPlayerState,i) == PLAYER_STATE_PASSENGER) CarAir(i);

		  }
		  timer = 0;
	}
  
}