Пример #1
0
//--------------------------------------------------------------------------------------
// Checks whether the necessary conditions for the execution of a certain manoeuvre are 
// still given
// Param1: Identifies the manoeuvre, for which to check the conditions.
// Returns true if the conditions for the manoeuvre are still fulfilled, false otherwise.
//--------------------------------------------------------------------------------------
bool MultiflagCTFTeamAI::ManoeuvreStillValid(TeamManoeuvreType manoeuvre)
{
	EntityTeam enemyTeam = None;
	if(GetTeam() == TeamRed)
	{
		enemyTeam = TeamBlue;
	}else
	{
		enemyTeam = TeamRed;
	}

	switch(manoeuvre)
	{
	case DefendBaseEntrancesManoeuvre:
		return (m_flagData[GetTeam()].m_state == InBase);
		break;
	case RushBaseAttackManoeuvre:
		return (m_flagData[enemyTeam].m_state == InBase);
		break;
	case CoordinatedBaseAttackManoeuvre:
		return (m_flagData[enemyTeam].m_state == InBase);
		break;
	case DistractionBaseAttackManoeuvre:
		return (m_flagData[enemyTeam].m_state == InBase);
		break;
	case SimpleBaseAttackManoeuvre:
		return (m_flagData[enemyTeam].m_state == InBase);
		break;
	case PickUpDroppedFlagManoeuvre:
		return (m_flagData[enemyTeam].m_state == Dropped);
		break;
	case RunTheFlagHomeManoeuvre:
		return (m_flagData[enemyTeam].m_state == Stolen);
		break;
	case ReturnDroppedFlagManoeuvre:
		return (m_flagData[GetTeam()].m_state == Dropped);
		break;
	case SimpleBaseDefenceManoeuvre:
		return (m_flagData[GetTeam()].m_state == InBase);
		break;
	case ActiveBaseDefenceManoeuvre:
		return (m_flagData[GetTeam()].m_state == InBase);
		break;
	case GuardedFlagCaptureManoeuvre:
		return (m_flagData[enemyTeam].m_state == Stolen);
		break;
	case InterceptFlagCarrierManoeuvre:
		return (m_flagData[GetTeam()].m_state == Stolen);
		break;
	default:
		return TeamAI::ManoeuvreStillValid(manoeuvre);
	}
}
Пример #2
0
void CObject::HandleSpecialSegment (void)
{
if ((info.nType == OBJ_PLAYER) && (gameData.multiplayer.nLocalPlayer == info.nId)) {
	CSegment*		segP = SEGMENTS + info.nSegment;
	CPlayerData*	playerP = gameData.multiplayer.players + gameData.multiplayer.nLocalPlayer;
	fix				shields, fuel;

   if (gameData.app.nGameMode & GM_CAPTURE)
		 segP->CheckForGoal ();
   else if (gameData.app.nGameMode & GM_HOARD)
		 segP->CheckForHoardGoal ();
	else if (Controls [0].forwardThrustTime || Controls [0].verticalThrustTime || Controls [0].sidewaysThrustTime) {
		gameStates.entropy.nTimeLastMoved = -1;
		if ((gameData.app.nGameMode & GM_ENTROPY) &&
			 ((segP->m_owner < 0) || (segP->m_owner == GetTeam (gameData.multiplayer.nLocalPlayer) + 1))) {
			StopConquerWarning ();
			}
		}
	else if (gameStates.entropy.nTimeLastMoved < 0)
		gameStates.entropy.nTimeLastMoved = 0;

	shields = segP->Damage (playerP->shields + 1);
	if (shields > 0) {
		playerP->shields -= shields;
		MultiSendShields ();
		if (playerP->shields < 0)
			StartPlayerDeathSequence (this);
		else
			segP->ConquerCheck ();
		}
	else {
		StopConquerWarning ();
		fuel = segP->Refuel (INITIAL_ENERGY - playerP->energy);
		if (fuel > 0)
			playerP->energy += fuel;
		shields = segP->Repair (INITIAL_SHIELDS - playerP->shields);
		if (shields > 0) {
			playerP->shields += shields;
			MultiSendShields ();
			}
		if (!segP->m_owner)
			segP->ConquerCheck ();
		}
	}
}
Пример #3
0
//------------------------------------------------------------------------
IMPLEMENT_RMI(CGameRules, ClSetTeam)
{
	if (!params.entityId) // ignore these for now
		return true;

	int oldTeam = GetTeam(params.entityId);
	if (oldTeam==params.teamId)
		return true;

	TEntityTeamIdMap::iterator it=m_entityteams.find(params.entityId);
	if (it!=m_entityteams.end())
		m_entityteams.erase(it);

	IActor *pActor=m_pActorSystem->GetActor(params.entityId);
	bool isplayer=pActor!=0;
	if (isplayer && oldTeam)
	{
		TPlayerTeamIdMap::iterator pit=m_playerteams.find(oldTeam);
		assert(pit!=m_playerteams.end());
		stl::find_and_erase(pit->second, params.entityId);
	}

	if (params.teamId)
	{
		m_entityteams.insert(TEntityTeamIdMap::value_type(params.entityId, params.teamId));
		if (isplayer)
		{
			TPlayerTeamIdMap::iterator pit=m_playerteams.find(params.teamId);
			assert(pit!=m_playerteams.end());
			pit->second.push_back(params.entityId);
		}
	}

	if(isplayer)
	{
		ReconfigureVoiceGroups(params.entityId,oldTeam,params.teamId);

		if (pActor->IsClient())
			m_pRadio->SetTeam(GetTeamName(params.teamId));
	}

	m_pScript->CallMethod( "OnSetTeam", params.entityId, params.teamId);

	return true;
}
Пример #4
0
void PulseLaser::PrepareMove()
{
  m_front += m_speed;

  if (m_frame.CheckCollision(m_front, m_back, GetTeam(), GetOwner()))
  {
    m_frame.RemoveProjectile(this);
  }

  m_back += m_speed;

  Size screenSize = DrawWrapper::GetSize();

  if (m_back.x > screenSize.x || m_back.x < 0 || m_back.y > screenSize.y || m_back.y < 0)
  {
    m_frame.RemoveProjectile(this);
  }
}
//------------------------------------------------------------------------
void CGameRules::StoreMigratingPlayer(IActor *pActor)
{
	if (pActor == NULL)
	{
		GameWarning("Invalid data for migrating player");
		return;
	}

	IEntity *pEntity = pActor->GetEntity();
	EntityId id = pEntity->GetId();
	bool registered = false;
	uint16 channelId = pActor->GetChannelId();
	CRY_ASSERT(channelId);
	bool bShouldAdd = true;

	if (bShouldAdd && (!m_hostMigrationCachedEntities.empty()))
	{
		if (!stl::find(m_hostMigrationCachedEntities, pActor->GetEntityId()))
		{
			bShouldAdd = false;
		}
	}

	if (bShouldAdd)
	{
		for (uint32 index = 0; index < m_migratingPlayerMaxCount; ++index)
		{
			if (!m_pMigratingPlayerInfo[index].InUse())
			{
				m_pMigratingPlayerInfo[index].SetData(pEntity->GetName(), id, GetTeam(id), pEntity->GetWorldPos(), pEntity->GetWorldAngles(), pActor->GetHealth());
				m_pMigratingPlayerInfo[index].SetChannelID(channelId);
				registered = true;
				break;
			}
		}
	}

	pEntity->Hide(true);		// Hide the player, they will be unhidden when they rejoin

	if (!registered && bShouldAdd)
	{
		GameWarning("Too many migrating players!");
	}
}
Пример #6
0
bool CHL2MP_Player::HandleCommand_JoinTeam( int team )
{
	if ( !GetGlobalTeam( team ) || team == 0 )
	{
		Warning( "HandleCommand_JoinTeam( %d ) - invalid team index.\n", team );
		return false;
	}

	if ( team == TEAM_SPECTATOR )
	{
		// Prevent this is the cvar is set
		if ( !mp_allowspectators.GetInt() )
		{
			ClientPrint( this, HUD_PRINTCENTER, "#Cannot_Be_Spectator" );
			return false;
		}

		if ( /*GetTeamNumber() != TEAM_UNASSIGNED &&*/ !IsDead() ) //DHL - Skillet - Players in deathmatch are unassigned
		{
			m_fNextSuicideTime = gpGlobals->curtime;	// allow the suicide to work

			CommitSuicide();

			// add 1 to frags to balance out the 1 subtracted for killing yourself
			IncrementFragCount( 1 );
			GetTeam()->AddScore( 1 ); //DHL - Skillet - Required to keep the scoreboard headers from getting out of sync
		}

		ChangeTeam( TEAM_SPECTATOR );

		return true;
	}
	else
	{
		StopObserverMode();
		State_Transition(STATE_ACTIVE);
	}

	// Switch their actual team...
	ChangeTeam( team );

	return true;
}
Пример #7
0
bool Monster::Shot(Game_Manager* gm_, coord_def c, float focus_, int item_num)
{
	if(GetShotStop())
		return false;
	if(GetStop())
		return false;
	if(!GetDelay() && weapon)
	{
		focus_ += weapon->GetFocusBase()+GetFocusSum();
		while(SetDelay(weapon->Shot(gm_, this, GetTeam(), GetPos(), c, focus_)*panalty) < 0)
		{
			SetDelay(0.0f);
			weapon->Reload(); //몬스터는 무한 리로드한다.
		}
		if(GetFocus() < weapon->GetFocusMaxReact())
			UpDownFocus(weapon->GetFocusReact());
		return true;
	}
	return false;
}
IMPLEMENT_RMI(CGameRules, ClEnteredGame)
{
	CPlayer *pClientActor = static_cast<CPlayer *>(m_pGameFramework->GetClientActor());

	if (pClientActor)
	{
		IEntity *pClientEntity = pClientActor->GetEntity();
		const EntityId clientEntityId = pClientEntity->GetId();

		if(!gEnv->bServer)
		{
			int status[2];
			status[0] = GetTeam(clientEntityId);
			status[1] = pClientActor->GetSpectatorMode();
			m_pGameplayRecorder->Event(pClientEntity, GameplayEvent(eGE_Connected, 0, 0, (void *)status));
		}
	}

	return true;
}
Пример #9
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int C_TF_PlayerResource::GetCountForPlayerClass( int iTeam, int iClass, bool bExcludeLocalPlayer /*=false*/ )
{
	int count = 0;
	int iLocalPlayerIndex = GetLocalPlayerIndex();

	for ( int i = 1 ; i <= MAX_PLAYERS ; i++ )
	{
		if ( bExcludeLocalPlayer && ( i == iLocalPlayerIndex ) )
		{
			continue;
		}

		if ( ( GetTeam( i ) == iTeam ) && ( GetPlayerClass( i ) == iClass ) )
		{
			count++;
		}
	}

	return count;
}
Пример #10
0
bool Shot_net::Action(Game_Manager* gm_)
{
	if(valid)
	{
		if(gm_)
		{
			for(list<Unit*>::iterator it = gm_->unit_list.begin();it != gm_->unit_list.end();it++)
			{
				if((*it)->isLive() && !(*it)->isNonTarget()  && (*it)->GetTeam() != GetTeam() && (*it)->isCollution())
				{
					if((*it)->collution(GetPos(), 5.0f))
					{
						(*it)->SetNet(net_time);
						(*it)->StateApply("그물",net_time);
						valid = false;
					}
				}
			}
		}


		if(collution(3))
		{
			valid = false;
		}
		else
			Move();


		distance -= const_speed;
		if(distance<0)
			valid = false;
	}


	if(!valid)
	{
		return true;
	}
	return false;
}
Пример #11
0
void BotControl::CheckTeamEconomics (int team)
{
   // this function decides is players on specified team is able to buy primary weapons by calculating players
   // that have not enough money to buy primary (with economics), and if this result higher 80%, player is can't
   // buy primary weapons.

   extern ConVar yb_ecorounds;

   if (!yb_ecorounds.GetBool ())
   {
      m_economicsGood[team] = true;
      return; // don't check economics while economics disable
   }

   int numPoorPlayers = 0;
   int numTeamPlayers = 0;

   // start calculating
   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (m_bots[i] != null && GetTeam (m_bots[i]->GetEntity ()) == team)
      {
         if (m_bots[i]->m_moneyAmount <= g_botBuyEconomyTable[0])
            numPoorPlayers++;

         numTeamPlayers++; // update count of team
      }
   }
   m_economicsGood[team] = true;

   if (numTeamPlayers <= 1)
      return;

   // if 80 percent of team have no enough money to purchase primary weapon
   if ((numTeamPlayers * 80) / 100 <= numPoorPlayers)
      m_economicsGood[team] = false;

   // winner must buy something!
   if (m_lastWinner == team)
      m_economicsGood[team] = true;
}
Пример #12
0
PlayerBase::PlayerBase(BallTeam* home_team,
                       int       home_region,
                       double    maxSpeed,
                       Vector2D    pos,
                       player_role role):MovingEntity(pos,
                                                      Vector2D(0,0),
                                                      Vector2D(1,0),
                                                      Vector2D(1,1),
                                                      0.3,
                                                      maxSpeed,
                                                      0.5,
                                                      0.5,
                                                      0.2),
                                         m_pTeam(home_team),
                                         m_iHomeRegion(home_region),
                                         m_PlayerRole(role),
                                         m_regulator(NULL)
{
    m_pSteering = new SteeringBehaviors(this, GetTeam()->GetGame()->GetBall());
    m_pSteering->SeparationOn();
}
Пример #13
0
std::vector<TechType> DiscoverCmd::GetAncientTechs(const LiveGame& game) const
{
	// "the cheapest Technology Tile you don't already have". Ignoring discounts. 

	// Get all available unresearched techs.
	std::multimap<int, TechType> map;
	auto& team = GetTeam(game);
	for (auto&& pair : game.GetTechnologies())
		if (!team.GetTechTrack().Has(pair.first))
			map.insert(std::make_pair(Technology::GetMaxCost(pair.first), pair.first));

	std::vector<TechType> techs;
	if (!map.empty())
	{
		auto it = map.begin();
		int cheapest = it->first;
		for (; it->first == cheapest; ++it)
			techs.push_back(it->second);
	}
	return techs;
}
Пример #14
0
void ScoreTableRedraw ()
{
	int i, color;
	int sorted [MAX_NUM_NET_PLAYERS];

xOffs = (grdCurCanv->cvBitmap.bmProps.w - 640) / 2;
yOffs = (grdCurCanv->cvBitmap.bmProps.h - 480) / 2;
if (xOffs < 0)
	xOffs = 0;
if (yOffs < 0)
	yOffs = 0;
if (gameData.app.nGameMode & GM_MULTI_COOP) {
	ScoreTableDrawCoop ();
	return;
	}
MultiSortKillList ();
WIN (DDGRLOCK (dd_grd_curcanv));
grdCurCanv->cvFont = MEDIUM3_FONT;
GrString (0x8000, LHY (10), TXT_KILL_MATRIX_TITLE, NULL);
grdCurCanv->cvFont = SMALL_FONT;
MultiGetKillList (sorted);
ScoreTableDrawNames (sorted);
for (i=0; i<gameData.multiplayer.nPlayers; i++) {
	if (gameData.app.nGameMode & GM_TEAM)
		color = GetTeam (sorted [i]);
	else
		color = sorted [i];
	if (!gameData.multiplayer.players [sorted [i]].connected)
		GrSetFontColorRGBi (GRAY_RGBA, 1, 0, 0);
	else
		GrSetFontColorRGBi (RGBA_PAL2 (playerColors  [color].r, playerColors  [color].g, playerColors [color].b), 1, 0, 0);
	ScoreTableDrawItem (i, sorted);
	}
ScoreTableDrawDeaths (sorted);
PA_DFX (pa_set_frontbuffer_current ());
GrUpdate (0);
PA_DFX (pa_set_backbuffer_current ());
WIN (DDGRUNLOCK (dd_grd_curcanv));
GrPaletteStepLoad (NULL);
}
Пример #15
0
bool Monster::Melee(Game_Manager* gm_)
{
	if(!GetDamage())
		return false;
	bool ok_ = false;
	if(GetStop())
		return false;
	for(list<Unit*>::iterator it = gm_->unit_list.begin();it != gm_->unit_list.end();it++)
	{
		if((*it)->isLive() && !(*it)->isNonTarget()  && GetTeam() != (*it)->GetTeam())
		{
			if(GetSize()+(*it)->GetSize()+5.0f > distan_coord(GetPos(), (*it)->GetPos()))
			{
				//if(각도가 맞으면)
				MeleeDamage(gm_,(*it));
				SetDelay(30.0f);
				ok_ = true;
			}
		}
	}
	return ok_;
}
Пример #16
0
bool Named_fly_boss::Shot(Game_Manager* gm_, coord_def c, float focus_, int item_num)
{
	if(GetShotStop())
		return false;
	if(GetStop())
		return false;
	if(!GetDelay())
	{
		float length_ = distan_coord(GetPos(), c);

		if(length_ >120)
			return false;
		float angle_ = GetAngleToTarget(GetPos(), c);

		Unit* target_ = NULL;
		if(gm_)
		{
			for(list<Unit*>::iterator it = gm_->unit_list.begin();it != gm_->unit_list.end();it++)
			{
				if((*it)->isLive() && !(*it)->isNonTarget()  && (*it)->GetTeam() != GetTeam())
				{
					if((*it)->collution(c, 30.0f))
					{
						target_ = (*it);
						break;
					}
				}
			}
		}
		Unit* temp = new Mon_bug_child_fly(monster__bug_child_fly,this, target_, GetX(), GetY(), GetTeam(),200);
		temp->SetAi(MS_NORMAL, NULL, 2);
		temp->SetFlyAngle(GetAngle()+rand_float(-1.0f,1.0f,"Named_fly_boss::Shot delta angle"));
		gm_->unit_list.push_back(temp);			
		SetDelay(50.0f);
		return true;
	}
	return false;

}
Пример #17
0
//-----------------------------------------------------------------------------
// Purpose: Slowly destroy the object I'm attached to
//-----------------------------------------------------------------------------
void CObjectSapper::SapperThink( void )
{
	if ( !GetTeam() )
		return;

	CBaseObject *pObject = GetParentObject();
	if ( !pObject )
	{
		DestroyObject();
		return;
	}

	SetNextThink( gpGlobals->curtime + 0.1, SAPPER_THINK_CONTEXT );

	// Don't bring objects back from the dead
	if ( !pObject->IsAlive() || pObject->IsDying() )
		return;

	// how much damage to give this think?
	float flTimeSinceLastThink = gpGlobals->curtime - m_flLastThinkTime;
	float flDamageToGive = ( flTimeSinceLastThink ) * obj_sapper_amount.GetFloat();

	// add to accumulator
	m_flSapperDamageAccumulator += flDamageToGive;

	int iDamage = (int)m_flSapperDamageAccumulator;

	m_flSapperDamageAccumulator -= iDamage;

	CTakeDamageInfo info;
	info.SetDamage( iDamage );
	info.SetAttacker( this );
	info.SetInflictor( this );
	info.SetDamageType( DMG_CRUSH );

	pObject->TakeDamage( info );

	m_flLastThinkTime = gpGlobals->curtime;
}
Пример #18
0
bool Player::Special(Game_Manager* gm_, coord_def c, float focus_)
{
	if(GetStop())
		return false;
	if(current_weapon)
	{
		//focus_ += GetFocusSum();
		//InitNoneMoveCount();
		if(SetDelay(current_weapon->special(gm_, this, GetTeam(), GetPos(), c, focus_)) == -1)
		{
			//ÀÌ ºÎºÐÀº ¹Ì±¸Çö
			//SetDelay(0);
			return false;
		}
		else
		{
			//ÀÌ ºÎºÐµµ ¹Ì±¸Çö
			return true;
		}
	}
	return false;
}
Пример #19
0
bool Bot::IsGroupOfEnemies (Vector location, int numEnemies, int radius)
{
   int numPlayers = 0;

   // search the world for enemy players...
   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      if (!(g_clients[i].flags & CFLAG_USED) || !(g_clients[i].flags & CFLAG_ALIVE) || g_clients[i].ent == GetEntity ())
         continue;

      if ((g_clients[i].ent->v.origin - location).GetLength () < radius)
      {
         // don't target our teammates...
         if (g_clients[i].team == GetTeam (GetEntity ()))
            return false;

         if (numPlayers++ > numEnemies)
            return true;
      }
   }
   return false;
}
Пример #20
0
bool Player::SendBattleGroundChat(uint32 msgtype, std::string message)
{
	// Select distance to broadcast to.
	float distance = msgtype == CHAT_MSG_SAY ? sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_SAY) : sWorld->getFloatConfig(CONFIG_LISTEN_RANGE_YELL);

	if (Battleground* pBattleGround = GetBattleground())
	{
		if (pBattleGround->isArena()) // Only fake chat in BG's. CFBG should not interfere with arenas.
			return false;

		for (Battleground::BattlegroundPlayerMap::const_iterator itr = pBattleGround->GetPlayers().begin(); itr != pBattleGround->GetPlayers().end(); ++itr)
		{
			if (Player* pPlayer = ObjectAccessor::FindPlayer(itr->first))
			{
				if (GetDistance2d(pPlayer->GetPositionX(), pPlayer->GetPositionY()) <= distance)
				{
					WorldPacket data(SMSG_MESSAGECHAT, 200);

					if (GetTeam() == pPlayer->GetTeam())
					{
						WorldPacket data;
						ChatHandler::BuildChatPacket(data, ChatMsg(msgtype), LANG_UNIVERSAL, pPlayer, NULL, message);
						pPlayer->GetSession()->SendPacket(&data);
					}
					else if (msgtype != CHAT_MSG_EMOTE)
					{
						WorldPacket data;
						ChatHandler::BuildChatPacket(data, ChatMsg(msgtype), pPlayer->GetTeam() == ALLIANCE ? LANG_ORCISH : LANG_COMMON, pPlayer, NULL, message);
						pPlayer->GetSession()->SendPacket(&data);
					}
					pPlayer->GetSession()->SendPacket(&data);
				}
			}
		}
		return true;
	}
	else
		return false;
}
Пример #21
0
void DiskShip::PrepareMove()
{
  m_shot = false;
  m_shoot = false;
  ++m_ticker;
  if (0 < m_cooldown)
  {
    --m_cooldown;
  }

  if (m_dead)
  {
    if (0 == --m_dead)
    {
      m_center = m_frame.PlaceMe(GetTeam());
    }
  }
  else
  {
    m_ai->Do();
  }
}
Пример #22
0
int TaskForceClass::DetectVs (AircraftClass *ac, float *d, int *combat, int *spot)
{
    int			react,det = Detected(this,ac,d);
    CampEntity	e;

    e = ac->GetCampaignObject();

    // 2001-03-22 ADDED BY S.G. DETECTION DOESN'T INCLUDED SPOTTED, ONLY THAT THIS ENTITY DETECTED THE OTHER BY ITSELF.
    int detTmp = det;

    // Check type of entity before GCI is used
    if (CheckValidType(this, e))
        detTmp |= e->GetSpotted(GetTeam()) ? ENEMY_DETECTED : 0;

    // Check type of entity before GCI is used
    if (CheckValidType(e, this))
        detTmp |= GetSpotted(e->GetTeam()) ? FRIENDLY_DETECTED : 0;

    if (!(detTmp & REACTION_MASK))
        return 0;

    react = Reaction(e,detTmp,*d);

    if (det & ENEMY_IN_RANGE && react)
        *combat = 1;

    // Spotting will be set only if our enemy is aggregated or if he's an AWAC. SensorFusion or GroundClass::Exec will hanlde deaggregated vehicles.
    // I can't let SensorFusion handle the spotting for AWAC because this will put a too big toll on the CPU
    // e has to be a flight since it is derived from an aircraft class so less checks needs to be done here then against flights below
    if (det & FRIENDLY_DETECTED) {
        // Spotting will be set only if our enemy is aggregated or if he's an AWAC. SensorFusion or GroundClass::Exec will hanlde deaggregated vehicles.
        if ((e->IsAggregate() && CheckValidType(e, this)) || (e->IsFlight() && e->GetSType() == STYPE_UNIT_AWACS)) {
            SetSpotted(e->GetTeam(),TheCampaign.CurrentTime, CanItIdentify(this, e, *d, e->GetMovementType())); // 2002-02-11 MODIFIED BY S.G. Added 'CanItIdentify' which query if the target can be identified
            *spot = 1;
        }
    }
    return react;
}
Пример #23
0
Bot *BotControl::GetHighestFragsBot (int team)
{
   Bot *highFragBot = null;

   int bestIndex = 0;
   float bestScore = -1;

   // search bots in this team
   for (int i = 0; i < engine->GetMaxClients (); i++)
   {
      highFragBot = g_botManager->GetBot (i);

      if (highFragBot != null && IsAlive (highFragBot->GetEntity ()) && GetTeam (highFragBot->GetEntity ()) == team)
      {
         if (highFragBot->pev->frags > bestScore)
         {
            bestIndex = i;
            bestScore = highFragBot->pev->frags;
         }
      }
   }
   return GetBot (bestIndex);
}
Пример #24
0
int CheckMonsterballScore (void)
{
	ubyte	special;

if (!(gameData.app.nGameMode & GM_MONSTERBALL))
	return 0;
if (!gameData.hoard.monsterballP)
	return 0;
if (gameData.hoard.nLastHitter != LOCALPLAYER.nObject)
	return 0;
special = gameData.segs.segment2s [gameData.hoard.monsterballP->nSegment].special;
if ((special != SEGMENT_IS_GOAL_BLUE) && (special != SEGMENT_IS_GOAL_RED))
	return 0;
if ((GetTeam (gameData.multiplayer.nLocalPlayer) == TEAM_RED) == (special == SEGMENT_IS_GOAL_RED))
	MultiSendCaptureBonus (gameData.multiplayer.nLocalPlayer);
else
	MultiSendCaptureBonus (-gameData.multiplayer.nLocalPlayer - 1);
CreatePlayerAppearanceEffect (gameData.hoard.monsterballP);
RemoveMonsterball ();
CreateMonsterball ();
MultiSendMonsterball (1, 1);
return 1;
}
Пример #25
0
void Player::FitPlayerInTeam(bool action, Battleground* pBattleGround)
{
	if (!pBattleGround)
		pBattleGround = GetBattleground();

	if ((!pBattleGround || pBattleGround->isArena()) && action)
		return;

	if (!IsPlayingNative() && action)
		setFactionForRace(getRace());
	else
		setFactionForRace(getCFSRace());

	if (action)
		SetForgetBGPlayers(true);
	else
		SetForgetInListPlayers(true);

	MorphFit(action);

	if (pBattleGround && action)
		SendChatMessage("%sYou are playing for the %s%s in this %s", MSG_COLOR_WHITE, GetTeam() == ALLIANCE ? MSG_COLOR_DARKBLUE"alliance" : MSG_COLOR_RED"horde", MSG_COLOR_WHITE, pBattleGround->GetName().c_str());
}
Пример #26
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseTFVehicle::VehiclePassengerThink( void )
{
	SetNextThink( gpGlobals->curtime + 10.0, PASSENGER_THINK_CONTEXT );

	if ( IsPlacing() )
	{
		ResetDeteriorationTime();
		return;
	}

	// If there are any passengers in the vehicle, push off deterioration time
	if ( GetPassengerCount() )
	{
		ResetDeteriorationTime();
		return;
	}

	// See if there are any team members nearby
	if ( GetTeam() )
	{
		int iNumPlayers = GetTFTeam()->GetNumPlayers();
		for ( int i = 0; i < iNumPlayers; i++ )
		{
			if ( GetTFTeam()->GetPlayer(i) )
			{
				Vector vecOrigin = GetTFTeam()->GetPlayer(i)->GetAbsOrigin();
				if ( (vecOrigin - GetAbsOrigin()).LengthSqr() < DETERIORATION_DISTANCE )
				{
					// Found one nearby, reset our deterioration time
					ResetDeteriorationTime();
					return;
				}
			}
		}
	}
}
Пример #27
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *pTeam - 
//-----------------------------------------------------------------------------
void CObjectResupply::ChangeTeam( int iTeamNum )
{
	CTFTeam *pExisting = (CTFTeam*)GetTeam();
	CTFTeam *pTeam = (CTFTeam*)GetGlobalTeam( iTeamNum );

	// Already on this team
	if ( GetTeamNumber() == iTeamNum )
		return;

	if ( pExisting )
	{
		// Remove it from current team ( if it's in one ) and give it to new team
		pExisting->RemoveResupply( this );
	}
		
	// Change to new team
	BaseClass::ChangeTeam( iTeamNum );
	
	// Add this object to the team's list
	if (pTeam)
	{
		pTeam->AddResupply( this );
	}
}
Пример #28
0
void ScoreTableRedraw (void)
{
	int i, color;
	int sorted [MAX_PLAYERS];

xOffs = (CCanvas::Current ()->Width () - 640) / 2;
yOffs = (CCanvas::Current ()->Height () - 480) / 2;
if (xOffs < 0)
	xOffs = 0;
if (yOffs < 0)
	yOffs = 0;
if (gameData.app.nGameMode & GM_MULTI_COOP) {
	ScoreTableDrawCoop ();
	return;
	}
MultiSortKillList ();
fontManager.SetCurrent (MEDIUM3_FONT);
GrString (0x8000, LHY (10), TXT_KILL_MATRIX_TITLE, NULL);
fontManager.SetCurrent (SMALL_FONT);
MultiGetKillList (sorted);
ScoreTableDrawNames (sorted);
for ( i =0; i<gameData.multiplayer.nPlayers; i++) {
	if (gameData.app.nGameMode & GM_TEAM)
		color = GetTeam (sorted [i]);
	else
		color = sorted [i];
	if (!gameData.multiplayer.players [sorted [i]].connected)
		fontManager.SetColorRGBi (GRAY_RGBA, 1, 0, 0);
	else
		fontManager.SetColorRGBi (RGBA_PAL2 (playerColors  [color].red, playerColors  [color].green, playerColors  [color].blue), 1, 0, 0);
	ScoreTableDrawItem (i, sorted);
	}
ScoreTableDrawDeaths (sorted);
GrUpdate (1);
//paletteManager.ResumeEffect ();
}
Пример #29
0
void C_HL2MP_Player::AvoidPlayers( CUserCmd *pCmd )
{
	// This is only used in team play.
	if ( !HL2MPRules()->IsTeamplay() )
		return;

	// Don't test if the player doesn't exist or is dead.
	if ( IsAlive() == false )
		return;

	C_Team *pTeam = ( C_Team * )GetTeam();
	if ( !pTeam )
		return;

	// Up vector.
	static Vector vecUp( 0.0f, 0.0f, 1.0f );

	Vector vecHL2MPPlayerCenter = GetAbsOrigin();
	Vector vecHL2MPPlayerMin = GetPlayerMins();
	Vector vecHL2MPPlayerMax = GetPlayerMaxs();
	float flZHeight = vecHL2MPPlayerMax.z - vecHL2MPPlayerMin.z;
	vecHL2MPPlayerCenter.z += 0.5f * flZHeight;
	VectorAdd( vecHL2MPPlayerMin, vecHL2MPPlayerCenter, vecHL2MPPlayerMin );
	VectorAdd( vecHL2MPPlayerMax, vecHL2MPPlayerCenter, vecHL2MPPlayerMax );

	// Find an intersecting player or object.
	int nAvoidPlayerCount = 0;
	C_HL2MP_Player *pAvoidPlayerList[MAX_PLAYERS];

	C_HL2MP_Player *pIntersectPlayer = NULL;
	float flAvoidRadius = 0.0f;

	Vector vecAvoidCenter, vecAvoidMin, vecAvoidMax;
	for ( int i = 0; i < pTeam->GetNumPlayers(); ++i )
	{
		C_HL2MP_Player *pAvoidPlayer = static_cast< C_HL2MP_Player * >( pTeam->GetPlayer( i ) );
		if ( pAvoidPlayer == NULL )
			continue;
		// Is the avoid player me?
		if ( pAvoidPlayer == this )
			continue;

		// Save as list to check against for objects.
		pAvoidPlayerList[nAvoidPlayerCount] = pAvoidPlayer;
		++nAvoidPlayerCount;

		// Check to see if the avoid player is dormant.
		if ( pAvoidPlayer->IsDormant() )
			continue;

		// Is the avoid player solid?
		if ( pAvoidPlayer->IsSolidFlagSet( FSOLID_NOT_SOLID ) )
			continue;

		Vector t1, t2;

		vecAvoidCenter = pAvoidPlayer->GetAbsOrigin();
		vecAvoidMin = pAvoidPlayer->GetPlayerMins();
		vecAvoidMax = pAvoidPlayer->GetPlayerMaxs();
		flZHeight = vecAvoidMax.z - vecAvoidMin.z;
		vecAvoidCenter.z += 0.5f * flZHeight;
		VectorAdd( vecAvoidMin, vecAvoidCenter, vecAvoidMin );
		VectorAdd( vecAvoidMax, vecAvoidCenter, vecAvoidMax );

		if ( IsBoxIntersectingBox( vecHL2MPPlayerMin, vecHL2MPPlayerMax, vecAvoidMin, vecAvoidMax ) )
		{
			// Need to avoid this player.
			if ( !pIntersectPlayer )
			{
				pIntersectPlayer = pAvoidPlayer;
				break;
			}
		}
	}

	// Anything to avoid?
	if ( !pIntersectPlayer )
		return;

	// Calculate the push strength and direction.
	Vector vecDelta;

	// Avoid a player - they have precedence.
	if ( pIntersectPlayer )
	{
		VectorSubtract( pIntersectPlayer->WorldSpaceCenter(), vecHL2MPPlayerCenter, vecDelta );

		Vector vRad = pIntersectPlayer->WorldAlignMaxs() - pIntersectPlayer->WorldAlignMins();
		vRad.z = 0;

		flAvoidRadius = vRad.Length();
	}

	float flPushStrength = RemapValClamped( vecDelta.Length(), flAvoidRadius, 0, 0, hl2mp_max_separation_force.GetInt() ); //flPushScale;

	//Msg( "PushScale = %f\n", flPushStrength );

	// Check to see if we have enough push strength to make a difference.
	if ( flPushStrength < 0.01f )
		return;

	Vector vecPush;
	if ( GetAbsVelocity().Length2DSqr() > 0.1f )
	{
		Vector vecVelocity = GetAbsVelocity();
		vecVelocity.z = 0.0f;
		CrossProduct( vecUp, vecVelocity, vecPush );
		VectorNormalize( vecPush );
	}
	else
	{
		// We are not moving, but we're still intersecting.
		QAngle angView = pCmd->viewangles;
		angView.x = 0.0f;
		AngleVectors( angView, NULL, &vecPush, NULL );
	}

	// Move away from the other player/object.
	Vector vecSeparationVelocity;
	if ( vecDelta.Dot( vecPush ) < 0 )
	{
		vecSeparationVelocity = vecPush * flPushStrength;
	}
	else
	{
		vecSeparationVelocity = vecPush * -flPushStrength;
	}

	// Don't allow the max push speed to be greater than the max player speed.
	float flMaxPlayerSpeed = MaxSpeed();
	float flCropFraction = 1.33333333f;

	if ( ( GetFlags() & FL_DUCKING ) && ( GetGroundEntity() != NULL ) )
	{	
		flMaxPlayerSpeed *= flCropFraction;
	}	

	float flMaxPlayerSpeedSqr = flMaxPlayerSpeed * flMaxPlayerSpeed;

	if ( vecSeparationVelocity.LengthSqr() > flMaxPlayerSpeedSqr )
	{
		vecSeparationVelocity.NormalizeInPlace();
		VectorScale( vecSeparationVelocity, flMaxPlayerSpeed, vecSeparationVelocity );
	}

	QAngle vAngles = pCmd->viewangles;
	vAngles.x = 0;
	Vector currentdir;
	Vector rightdir;

	AngleVectors( vAngles, &currentdir, &rightdir, NULL );

	Vector vDirection = vecSeparationVelocity;

	VectorNormalize( vDirection );

	float fwd = currentdir.Dot( vDirection );
	float rt = rightdir.Dot( vDirection );

	float forward = fwd * flPushStrength;
	float side = rt * flPushStrength;

	//Msg( "fwd: %f - rt: %f - forward: %f - side: %f\n", fwd, rt, forward, side );

	pCmd->forwardmove	+= forward;
	pCmd->sidemove		+= side;

	// Clamp the move to within legal limits, preserving direction. This is a little
	// complicated because we have different limits for forward, back, and side

	//Msg( "PRECLAMP: forwardmove=%f, sidemove=%f\n", pCmd->forwardmove, pCmd->sidemove );

	float flForwardScale = 1.0f;
	if ( pCmd->forwardmove > fabs( cl_forwardspeed.GetFloat() ) )
	{
		flForwardScale = fabs( cl_forwardspeed.GetFloat() ) / pCmd->forwardmove;
	}
	else if ( pCmd->forwardmove < -fabs( cl_backspeed.GetFloat() ) )
	{
		flForwardScale = fabs( cl_backspeed.GetFloat() ) / fabs( pCmd->forwardmove );
	}

	float flSideScale = 1.0f;
	if ( fabs( pCmd->sidemove ) > fabs( cl_sidespeed.GetFloat() ) )
	{
		flSideScale = fabs( cl_sidespeed.GetFloat() ) / fabs( pCmd->sidemove );
	}

	float flScale = min( flForwardScale, flSideScale );
	pCmd->forwardmove *= flScale;
	pCmd->sidemove *= flScale;

	//Msg( "Pforwardmove=%f, sidemove=%f\n", pCmd->forwardmove, pCmd->sidemove );
}
Пример #30
0
//------------------------------------------------------------------------
IMPLEMENT_RMI(CGameRules, ClSetTeam)
{
	if (!params.entityId) // ignore these for now
		return true;

	// [D6] Code is handled in team manager now
	assert(g_D6Core->pTeamManager);
	bool bResult = g_D6Core->pTeamManager->SetTeam(params.teamId, params.entityId);
	int oldTeam = GetTeam(params.entityId);
	if (oldTeam==params.teamId)
		return true;
	IActor *pActor=m_pActorSystem->GetActor(params.entityId);
	bool isplayer=pActor!=0;

	/*TEntityTeamIdMap::iterator it=m_entityteams.find(params.entityId);
	if (it!=m_entityteams.end())
		m_entityteams.erase(it);

	if (isplayer && oldTeam)
	{
		TPlayerTeamIdMap::iterator pit=m_playerteams.find(oldTeam);
		assert(pit!=m_playerteams.end());
		stl::find_and_erase(pit->second, params.entityId);
	}

	if (params.teamId)
	{
		m_entityteams.insert(TEntityTeamIdMap::value_type(params.entityId, params.teamId));
		if (isplayer)
		{
			TPlayerTeamIdMap::iterator pit=m_playerteams.find(params.teamId);
			assert(pit!=m_playerteams.end());
			pit->second.push_back(params.entityId);
		}
	}*/
	// [/D6]

	if(IActor *pClient = g_pGame->GetIGameFramework()->GetClientActor())
	{
		if(GetTeam(pClient->GetEntityId()) == params.teamId)
		{
			if(params.entityId == pClient->GetGameObject()->GetWorldQuery()->GetLookAtEntityId())
			{
				if(g_pGame->GetHUD())
				{
					g_pGame->GetHUD()->GetCrosshair()->SetUsability(0);
					g_pGame->GetHUD()->GetCrosshair()->SetUsability(1);
				}
			}
		}
	}

	if(isplayer)
	{
		ReconfigureVoiceGroups(params.entityId,oldTeam,params.teamId);

		if (pActor->IsClient())
			m_pRadio->SetTeam(GetTeamName(params.teamId));
	}

	ScriptHandle handle(params.entityId);
	CallScript(m_clientStateScript, "OnSetTeam", handle, params.teamId);

	return true;
}