Exemple #1
0
func InitializePlayer(int iPlayer)
{
	_inherited();
	var pClonk;
	if(GetPlayerTeam(iPlayer) == 1)
	{
		pClonk = CreateObject(JAFA,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,0,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
		CreateContents(FLAG,pClonk);
		SetCursor(iPlayer,pClonk);
		pClonk = CreateObject(JAFA,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,0,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
	}
	if(GetPlayerTeam(iPlayer) == 2)
	{
		pClonk = CreateObject(WRAT,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,LandscapeHeight()/2,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
		CreateContents(FLAG,pClonk);
		SetCursor(iPlayer,pClonk);
		pClonk = CreateObject(WRAT,0,0,iPlayer);
		pClonk -> Enter(FindObject(GOEB,0,LandscapeHeight()/2,LandscapeWidth(),LandscapeHeight()/2));
		MakeCrewMember(pClonk,iPlayer);
	}
}
Exemple #2
0
func CanBeHit(object from)
{
	if(from && from->GetOwner() != GetOwner() && GetPlayerTeam(GetOwner()) && FindObject(Find_ID(Rule_NoFriendlyFire)))
	{
		if(GetPlayerTeam(GetOwner()) == GetPlayerTeam(from->GetOwner()))
			return false;
	}
	
	return true;
}
Exemple #3
0
global func FxDefManaTimer()
{
	for(var o in FindObjects(Find_ID(Clonk)))
	{
		var plr = o->GetOwner();
		if(GetPlayerTeam(plr) == 1 && o->GetX() < LandscapeWidth()/2)
			o->DoMagicEnergy(1);
			
		if(GetPlayerTeam(plr) == 2 && o->GetX() > LandscapeWidth()/2)
			o->DoMagicEnergy(1);
	}
Exemple #4
0
void FakespawnPlayer(edict_t *pEdict)
{
	int team = GetPlayerTeam(pEdict);

	if (team != TEAM_T && team != TEAM_CT)
	{
		return;
	}

	int index = ENTINDEX(pEdict);

	player_states *pPlayer = GET_PLAYER(index);

	if (pPlayer->spawning)
		return;

	pPlayer->spawning = true;

	if (g_PreSpawn > 0  && MF_ExecuteForward(g_PreSpawn, (cell)index, (cell)1) > 0)
	{
		pPlayer->spawning = false;
		return;
	}

	SpawnHandler(index, true);
	pPlayer->spawning = false;
}
Exemple #5
0
static cell AMX_NATIVE_CALL csdm_respawn(AMX *amx, cell *params)
{
	int index = params[1];

	if (index < 1 || index > gpGlobals->maxClients || !MF_IsPlayerIngame(index))
	{
		MF_LogError(amx, AMX_ERR_NATIVE, "Player %d is not valid", index);
		return 0;
	}

	edict_t *pEdict = MF_GetPlayerEdict(index);

	if (FNullEnt(pEdict))
		return 0;

	int team = GetPlayerTeam(pEdict);
	if (team == TEAM_T || team == TEAM_CT)
	{
		RespawnPlayer(pEdict);
	} else {
		return 0;
	}

	return 1;
}
Exemple #6
0
 void Battle::HandleDraw (yap::IDrawingContext& context)
 {
   background_->Draw (context);
   playerGround_->Draw (context);
   playerTrainerBack_->Draw (context);
   opponentGround_->Draw (context);
   GetPlayerTeam ().Draw (context);
   GetOpponent ().Draw (context);
 }
Exemple #7
0
// Spielerbeitritt
func InitializePlayer(iPlr)
{
  // Anwählen und in Position bringen
  SetCursor(iPlr,GetHiRank(iPlr));
  SelectCrew(iPlr, GetHiRank(iPlr), 1);
  if(GetPlayerTeam(iPlr)==1)
    SetPosition(10,1609, GetHiRank(iPlr));
  else
    SetPosition(LandscapeWidth()-10,1609, GetHiRank(iPlr));
}
Exemple #8
0
private func Execute() {
  // Alle Spieler überprüfen
  var plr_num;
  for (var plr_cnt = GetPlayerCount(); plr_cnt; plr_num++) {
    if (GetPlayerName(plr_num)) {
      plr_cnt--;
      if (GetPlayerTeam(plr_num) != -1) if (!FindBase(plr_num)) 
        EliminatePlayer(plr_num);
    }
  }
}
Exemple #9
0
private func Execute()
{
  // Alle Spieler überprüfen
  var iPlrCnt, iPlr = 0;
  for (iPlrCnt = GetPlayerCount(); iPlrCnt; iPlr++)
    if (GetPlayerName(iPlr))
      {
      iPlrCnt--;
      if (GetPlayerTeam(iPlr) != -1) if (!GetCaptain(iPlr)) 
        EliminatePlayer(iPlr);  
      }
}
Exemple #10
0
func CreateStartMaterial(int x, int y, int plr) {
    var pltf1 = PLTF->CreatePlatform(x, y, plr);
    var pltf2 = PLTF->CreatePlatform(x + 20, y, plr);
    PLTF->Connect(pltf1, pltf2);
	var team = GetPlayerTeam(plr), ox, tankX = x;
	if(team == 1) {
		tankX += 10;
		ox = 1;
	} else {
		tankX += 95;
		ox = -1;
	}
    CreateConstruction(STMT, tankX, y - 5, plr, 100);
	var artillery = CreateConstruction(CTW0, tankX + ox * 90, y - 5, plr, 100);
	artillery->ConnectCannon(CreateObject(CTW3, 0, 0, plr));
}
//
// RecordSpecialEvent()
//
void CPlayEngine::RecordSpecialEvent(int nCode, int nParam1, int nParam2, int nParam3)
{
	CPlayerStatusDialog& status = *m_pStatusDlg;
	int nPlayer = nParam1;
	int nTeam = GetPlayerTeam(nPlayer);
	int numTricks = nParam2;
	//
	switch(nCode)
	{
		case CEasyBDoc::EVENT_CLAIMED:
//			status << "3PLAYCL! " & TeamToString(nTeam) & " has claimed the remaining " &
			status << "3PLAYCL! " & PositionToString(nPlayer) & " has claimed the remaining " &
				      numTricks & " tricks.\n";
			break;

		case CEasyBDoc::EVENT_CONCEDED:
//			status << "3PLAYCN! " & TeamToString(nTeam) & " has conceded the remaining " &
			status << "3PLAYCN! " & PositionToString(nPlayer) & " has conceded the remaining " &
				      numTricks & " tricks.\n";
			break;
	}
}
Exemple #12
0
func InitializePlayer(int plr) {
    CreateMatSys(plr);
    // fill with material
    var msys = GetMatSys(plr);
    msys->DoFill(4, WOOD);
    msys->DoFill(10, METL);
    msys->DoFill(7, ROCK);
    
    //Flints
    CreateContents(FLNT, GetHiRank(plr), 2);

    var team = GetPlayerTeam(plr);
    var pos = GetStartPosition(team);
    if(GetLength(GetPlayersByTeam(team)) == 1) {
        CreateStartMaterial(pos[0], pos[1], plr);
    }

    var tank = FindObject2(Find_ID(STMT), Find_Allied(plr));
    tank->DoFill(100);
    var i = 0, clonk;
    while(clonk = GetCrew(plr, i++))
        clonk->Enter(tank);

}
void BattleGround::RemovePlayerAtLeave(ObjectGuid guid, bool Transport, bool SendPacket)
{
    Team team = GetPlayerTeam(guid);
    bool participant = false;
    // Remove from lists/maps
    BattleGroundPlayerMap::iterator itr = m_Players.find(guid);
    if (itr != m_Players.end())
    {
        UpdatePlayersCountByTeam(team, true);               // -1 player
        m_Players.erase(itr);
        // check if the player was a participant of the match, or only entered through gm command (goname)
        participant = true;
    }

    BattleGroundScoreMap::iterator itr2 = m_PlayerScores.find(guid);
    if (itr2 != m_PlayerScores.end())
    {
        delete itr2->second;                                // delete player's score
        m_PlayerScores.erase(itr2);
    }

    Player* plr = sObjectMgr.GetPlayer(guid);

    if (plr)
    {
        // should remove spirit of redemption
        if (plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
            plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);

        if (!plr->isAlive())                                // resurrect on exit
        {
            plr->ResurrectPlayer(1.0f);
            plr->SpawnCorpseBones();
        }
    }

    RemovePlayer(plr, guid);                                // BG subclass specific code

    if (participant) // if the player was a match participant, remove auras, calc rating, update queue
    {
        BattleGroundTypeId bgTypeId = GetTypeID();
        BattleGroundQueueTypeId bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID());
        if (plr)
        {
            if (!team) team = plr->GetTeam();

            if (SendPacket)
            {
                WorldPacket data;
                sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0);
                plr->GetSession()->SendPacket(&data);
            }

            // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
            plr->RemoveBattleGroundQueueId(bgQueueTypeId);
        }

        // remove from raid group if player is member
        if (Group* group = GetBgRaid(team))
        {
            if (!group->RemoveMember(guid, 0))              // group was disbanded
            {
                SetBgRaid(team, NULL);
                delete group;
            }
        }
        DecreaseInvitedCount(team);
        // we should update battleground queue, but only if bg isn't ending
        if (GetStatus() < STATUS_WAIT_LEAVE)
        {
            // a player has left the battleground, so there are free slots -> add to queue
            AddToBGFreeSlotQueue();
            sBattleGroundMgr.ScheduleQueueUpdate(bgQueueTypeId, bgTypeId, GetBracketId());
        }

        // Let others know
        WorldPacket data;
        sBattleGroundMgr.BuildPlayerLeftBattleGroundPacket(&data, guid);
        SendPacketToTeam(team, &data, plr, false);
    }

    if (plr)
    {
        // Do next only if found in battleground
        plr->SetBattleGroundId(0, BATTLEGROUND_TYPE_NONE);  // We're not in BG.
        // reset destination bg team
        plr->SetBGTeam(TEAM_NONE);

        if (Transport)
            plr->TeleportToBGEntryPoint();

        DETAIL_LOG("BATTLEGROUND: Removed player %s from BattleGround.", plr->GetName());
    }

    // battleground object will be deleted next BattleGround::Update() call
}
Exemple #14
0
//
//---------------------------------------------------------
//
BOOL CEasyBDoc::ReadFile(CArchive& ar) 
{
	int i,nRtnCode,nLineCode,nSectionCode;
	int	nIndex,nValue,nOffset,nLen;
	int nPlayOffset, nPos;
	int nBidIndex = 0;
	CString strMessage,string,partString;
	CCard* pCard;
	double fValue;
	BOOL bValue;
	BOOL bFileInfoFound = FALSE;

	
	// read
	m_nLineNumber = 0;
	try
	{
		for(;;) 
		{

			nRtnCode = ReadLine(ar, strBuf);
next:		if (nRtnCode == EOF)
				break;
			if (nRtnCode == 0)
				continue;
			if ((strBuf[0] == '#') || (strBuf[0] == '*'))
				continue;
			nLineLen = nRtnCode;
			nLineCode = ParseLine(strBuf,nLineLen);
			
			if (nLineCode < 0) 
			{

				// section signifier
				nSectionCode = -nLineCode;
				if (nSectionCode == BLOCK_FILEINFO)
				{
					//
					bFileInfoFound = TRUE;
					// file info; skip this section
					do {
						nRtnCode = ReadLine(ar, strBuf);
					} while ((nRtnCode != EOF) && (strBuf.Left(2) != "[["));
					//
					goto next;
				} 
				//
				if (nSectionCode == BLOCK_FILEDESC) 
				{
					// file description; read until next block
					m_strFileDescription.Empty();
					do {
						nRtnCode = ReadLine(ar, strBuf);
						if (strBuf.Left(2) != "[[")
						{
							strBuf += "\r\n";
							m_strFileDescription += strBuf;
						}
					} while ((nRtnCode != EOF) && (strBuf.Left(2) != "[["));

					// trim ending CR/LF
					int nLen = m_strFileDescription.GetLength();
					if ((nLen >= 2) && (m_strFileDescription[nLen-1] == _T('\n')))
						m_strFileDescription = m_strFileDescription.Left(nLen-2);
					//
					goto next;
				} 
				else if (nSectionCode == BLOCK_COMMENTS) 
				{
					// file comments
					for (;;) 
					{
						nRtnCode = ReadLine(ar, strBuf);
						if ((nRtnCode == EOF) || (strBuf.Left(2) == "[[")) 
						{
							// update file comments dialog if it's open
							CWnd* pWnd = pMAINFRAME->GetDialog(twFileCommentsDialog);
							if (pWnd)
								pWnd->SendMessage(WM_COMMAND, WMS_UPDATE_TEXT, FALSE);
							goto next;
						}
						strBuf += "\r\n";
						m_strFileComments += strBuf;
					}
				}
				else if ((nSectionCode == BLOCK_SOUTH_ANALYSIS) ||
						 (nSectionCode == BLOCK_WEST_ANALYSIS) ||
						 (nSectionCode == BLOCK_NORTH_ANALYSIS) ||
						 (nSectionCode == BLOCK_EAST_ANALYSIS))
				{
					// don't bother to save the analysis
					int nPlayer = nSectionCode - BLOCK_SOUTH_ANALYSIS;
					CString strAnalysisBiffer;
					do {
						nRtnCode = ReadLine(ar, strBuf);
	//					strBuf += "\r\n";
	//					strAnalysisBiffer += strBuf;
					} while ((nRtnCode != EOF) && (strBuf.Left(2) != "[["));
	//				m_player[nPlayer].SetValueString(tszAnalysis,  strAnalysisBiffer);
					goto next;
				}

			} 
			else if (nLineCode > 0) 
			{

				// first skip spaces
				nLen = strBuf.GetLength();
				while ((nDataPosition < nLen) && 
						(strBuf[nDataPosition] == ' '))
					nDataPosition++;
				if (nDataPosition >= nLen)
					continue;
				// then get data item
				string = strBuf.Mid(nDataPosition);
				nValue = atoi(string);
				fValue = atof(string);
				if ((string == "Yes") || (string == "1"))
					bValue = TRUE;
				else
					bValue = FALSE;

				switch(nLineCode) 
				{

					case ITEM_PROGRAM_ID:
						m_strFileProgTitle = string;
						break;

					case ITEM_MAJOR_VERSIONNO:
						m_nFileProgMajorVersion = nValue;
						break;

					case ITEM_MINOR_VERSIONNO:
						m_nFileProgMinorVersion = nValue;
						break;

					case ITEM_INCREMENT_VERSIONNO:
						m_nFileProgIncrementVersion = nValue;
						break;

					case ITEM_BUILD_NUMBER:
						m_nFileProgBuildNumber = nValue;
						break;

					case ITEM_BUILD_DATE:
						m_strFileProgBuildDate = string;
						break;

					case ITEM_FILE_DATE:
						m_strFileDate = string;
						break;

					// hand info, 10..19
					case ITEM_CURRHAND_NORTH:
						AssignCards(string,NORTH);
						break;

					case ITEM_CURRHAND_EAST:
						AssignCards(string,EAST);
						break;

					case ITEM_CURRHAND_SOUTH:
						AssignCards(string,SOUTH);
						break;

					case ITEM_CURRHAND_WEST:
						AssignCards(string,WEST);
						break;

					case ITEM_ORIGHAND_NORTH:
						AssignCards(string,NORTH,TRUE);
						break;

					case ITEM_ORIGHAND_EAST:
						AssignCards(string,EAST,TRUE);
						break;

					case ITEM_ORIGHAND_SOUTH:
						AssignCards(string,SOUTH,TRUE);
						break;

					case ITEM_ORIGHAND_WEST:
						AssignCards(string,WEST,TRUE);
						break;

					// current round info
					case ITEM_CURR_ROUND_LEAD:
						m_nRoundLead = StringToPosition(string);
						break;

					case ITEM_NUM_CARDS_PLAYED_IN_ROUND:
						m_numCardsPlayedInRound = nValue;
						break;

					case ITEM_TRICK_CARD_1:
						m_pCurrTrick[0] = deck.GetCard(string);
						break;

					case ITEM_TRICK_CARD_2:
						m_pCurrTrick[1] = deck.GetCard(string);
						break;

					case ITEM_TRICK_CARD_3:
						m_pCurrTrick[2] = deck.GetCard(string);
						break;

					case ITEM_TRICK_CARD_4:
						m_pCurrTrick[3] = deck.GetCard(string);
						break;

					// game status info
					case ITEM_VIEW_STATUS_CODE:
						pVIEW->SetCurrentMode((CEasyBView::ScreenMode)nValue);
						break;

					case ITEM_RUBBER_IN_PROGRESS:
						theApp.SetValue(tbRubberInProgress, bValue);
						break;

					case ITEM_GAME_IN_PROGRESS:
						// TEMP
//						theApp.SetValue(tbGameInProgress, FALSE);
						theApp.SetValue(tbGameInProgress, bValue);
						break;

					case ITEM_BIDDING_IN_PROGRESS:
						theApp.SetValue(tbBiddingInProgress, bValue);
						break;

					case ITEM_HANDS_DEALT:
						m_bHandsDealt = bValue;
						break;
					
					case ITEM_CONTRACT_SUIT:
						nLen = string.GetLength();
						m_nContractSuit = CharToSuit(string.GetAt(0));
						break;

					case ITEM_CONTRACT_LEVEL:
						m_nContractLevel = nValue;
						break;

					case ITEM_CONTRACT_MODIFIER:
						switch(nValue) 
						{
							case 0:
								m_bDoubled = FALSE;
								m_bRedoubled = FALSE;
								m_nContractModifier = 0;
								break;
							case 1:
								m_bDoubled = TRUE;
								m_bRedoubled = FALSE;
								m_nContractModifier = 1;
								break;
							case 2:
								m_bDoubled = FALSE;
								m_bRedoubled = TRUE;
								m_nContractModifier = 2;
								break;
						}
						break;

					case ITEM_DEALER:
						m_nDealer = StringToPosition(string);
						break;

					case ITEM_NUM_BIDS:
//						m_numBidsMade = nValue;
						break;

					case ITEM_BIDDING_HISTORY:
						strBiddingHistory = string;
						break;

					case ITEM_DECLARER:
						m_nDeclarer = StringToPosition(string);
						m_nContractTeam = GetPlayerTeam(m_nDeclarer);
						m_nDefendingTeam = (m_nContractTeam == NORTH_SOUTH)? EAST_WEST : NORTH_SOUTH;
						break;

					// game record
					case ITEM_NUM_TRICKS_PLAYED:
						m_numTricksPlayed = nValue;
						break;

					case ITEM_NUM_TRICKS_WON_NS:
						m_numTricksWon[0] = nValue;
						break;

					case ITEM_NUM_TRICKS_WON_EW:
						m_numTricksWon[1] = nValue;
						break;

					case ITEM_GAME_LEAD:
						m_nGameLead = StringToPosition(string);
						break;

					case ITEM_GAME_TRICK_1: case ITEM_GAME_TRICK_2: 
					case ITEM_GAME_TRICK_3: case ITEM_GAME_TRICK_4: 
					case ITEM_GAME_TRICK_5: case ITEM_GAME_TRICK_6: 
					case ITEM_GAME_TRICK_7: case ITEM_GAME_TRICK_8: 
					case ITEM_GAME_TRICK_9: case ITEM_GAME_TRICK_10: 
					case ITEM_GAME_TRICK_11: case ITEM_GAME_TRICK_12: 
					case ITEM_GAME_TRICK_13:
						try
						{
							nIndex = nLineCode - ITEM_GAME_TRICK_1;
							nOffset = 0;
							nLen = string.GetLength();
							// first read the lead player for the trick
							partString = string.Mid(nOffset);
							m_nTrickLead[nIndex] = StringToPosition(partString);
							nOffset = string.Find(' ');
							//
							for(i=0;i<4;i++) 
							{
								while((nOffset < nLen) && (string[nOffset] == ' '))
									nOffset++;
								partString = string.Mid(nOffset);
								nOffset += 2;
								if (partString.IsEmpty()) 
								{
									strMessage.Format("Incomplete Trick record at line %d;\n%s",
													  m_nLineNumber, string);
									AfxMessageBox(strMessage);
									break;
								}
								//
								if (partString.Left(2) == "--")
								{
									m_pGameTrick[nIndex][i] = NULL;
								}
								else
								{
									pCard = deck.GetCard(partString);
									m_pGameTrick[nIndex][i] = pCard;
								}
							}
							// insert the trick record into the game record
							// in the proper order
							nPlayOffset = nIndex * 4;
							nPos = m_nTrickLead[nIndex];
							for(i=0;i<4;i++)
							{
								CCard* pCard = m_pGameTrick[nIndex][nPos];
								if (pCard)
									m_nPlayRecord[nPlayOffset+i] = pCard->GetDeckValue();
								nPos = GetNextPlayer(nPos);
							}
							// and finally read the trick's winner 
							while((nOffset < nLen) && (string[nOffset] == ' '))
								nOffset++;
							partString = string.Mid(nOffset);
							m_nTrickWinner[nIndex] = StringToPosition(partString);
						}
						catch(...)
						{
							// error
						}
						break;

					// match info
					case ITEM_SCORE_NS_BONUS:
						m_nBonusScore[NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAME0:
						m_nGameScore[0][NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAME1:
						m_nGameScore[1][NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAME2:
						m_nGameScore[2][NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_NS_GAMES_WON:
						m_numGamesWon[NORTH_SOUTH] = nValue;
						break;

					case ITEM_SCORE_EW_BONUS:
						m_nBonusScore[EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAME0:
						m_nGameScore[0][EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAME1:
						m_nGameScore[1][EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAME2:
						m_nGameScore[2][EAST_WEST] = nValue;
						break;

					case ITEM_SCORE_EW_GAMES_WON:
						m_numGamesWon[EAST_WEST] = nValue;
						break;

					case ITEM_CURRENT_GAME_INDEX:
						m_nCurrGame = nValue-1;
						break;

					case ITEM_BONUS_SCORE_RECORD:
						m_strArrayBonusPointsRecord.Add(StripQuotes(string));
						break;

					case ITEM_GAME_SCORE_RECORD:
						m_strArrayTrickPointsRecord.Add(StripQuotes(string));
						break;

					// misc info
					case ITEM_AUTOSHOW_COMMENTS:
						m_bShowCommentsUponOpen = bValue;
						break;
					case ITEM_AUTOSHOW_BID_HISTORY:
						m_bShowBidHistoryUponOpen = bValue;
						break;
					case ITEM_AUTOSHOW_PLAY_HISTORY:
						m_bShowPlayHistoryUponOpen = bValue;
						break;
					case ITEM_AUTOSHOW_ANALYSES:
						m_bShowAnalysesUponOpen = bValue;
						break;

				}

			} 
			else 
			{

	/*
				// unknown line
				strMessage.Format("Found Unknown line\n%s.\nContinue?",strBuf);
				if (AfxMessageBox(strMessage, MB_ICONEXCLAMATION | MB_OKCANCEL) == IDCANCEL)
					break;
	*/
			}

		}
	}
	catch(...)
	{
		// handle any improper file error here
		ClearAllInfo();
//		AfxMessageBox("An error ocurred while reading the game file.");
		return FALSE;
	}

	// see if this was a valid file
	if (!bFileInfoFound)
	{
		AfxMessageBox("This is not a proper Easy Bridge game file.");
		AfxThrowFileException(CFileException::generic);
	}

	//
	// do some sanity checks
	//
	m_nContract = MAKEBID(m_nContractSuit, m_nContractLevel);
	if (!ISPLAYER(m_nDeclarer) || !ISBID(m_nContract))
		theApp.SetValue(tbGameInProgress, FALSE);

	//
	// parse the bidding history
	//
	if (!ISPLAYER(m_nDeclarer))
		m_nDeclarer = SOUTH;
	nPos = m_nDeclarer;
	m_nCurrPlayer = nPos;
	int nTeam = GetPlayerTeam(nPos);
	nOffset = 0;
	// 
	nLen = strBiddingHistory.GetLength();
	for(i=0;;i++) 
	{
		// skip leading spaces
		while((nOffset < nLen) && (strBiddingHistory[nOffset] == ' '))
			nOffset++;
		if (nOffset >= nLen)
			break;
		// grab the next bid
		partString = strBiddingHistory.Mid(nOffset);
		int nBid = ContractStringToBid(partString);
		// and record it
		m_nBiddingHistory[m_numBidsMade] = nBid;
		m_numBidsMade++;
		m_nCurrPlayer = GetNextPlayer(m_nCurrPlayer);
		int nBiddingRound = i % 4;
		m_nBidsByPlayer[nPos][nBiddingRound] = nBid;
		// see if this is an actual numeric bid
		if (ISBID(nBid))
		{
			m_nValidBidHistory[m_numValidBidsMade] = nBid;
			m_numValidBidsMade++;
			m_nLastValidBid = nBid;
			m_nLastValidBidTeam = nTeam;
		}
		// skip over remainder of current bid string
		while((nOffset < nLen) && (strBiddingHistory[nOffset] != ' '))
			nOffset++;
		// and move to the next player
		nPos = GetNextPlayer(nPos);
		nTeam = GetOpposingTeam(nTeam);
	}
	if (ISBID(m_nContract))
		UpdateBiddingHistory();


	// tally some figures
	m_nTotalScore[0] = m_nGameScore[0][0] + m_nGameScore[1][0] +
					   m_nGameScore[2][0] + m_nBonusScore[0];
	m_nTotalScore[1] = m_nGameScore[0][1] + m_nGameScore[1][1] +
					   m_nGameScore[2][1] + m_nBonusScore[1];

	// vulnerability
	if ((m_numGamesWon[0] > 0) && (m_numGamesWon[1] > 0)) 
	{
		m_nVulnerableTeam = BOTH;
		m_bVulnerable[0] = m_bVulnerable[1] = TRUE;
	} 
	else if (m_numGamesWon[0] > 0) 
	{
		m_nVulnerableTeam = NORTH_SOUTH;
		m_bVulnerable[0] = TRUE;
	} 
	else if (m_numGamesWon[1] > 0)
	{
		m_nVulnerableTeam = EAST_WEST;
		m_bVulnerable[1] = TRUE;
	} 
	else 
	{
		m_nVulnerableTeam = NEITHER;
	}

	//
	// set contract info
	//
	m_nContract = ContractParamsToBid(m_nContractSuit,m_nContractLevel);
	m_nTrumpSuit = m_nContractSuit;
	m_nBiddingRound = nBidIndex;
	// set play info 
	if (ISBID(m_nContract) && ISPLAYER(m_nDeclarer))
	{
		// contract has been reached
		m_nDummy = GetPartner((int) m_nDeclarer);
		m_nGameLead = GetNextPlayer(m_nDeclarer);
		m_nRoundLead = m_nGameLead;
		m_nCurrPlayer = m_nRoundLead;
		m_nTrickLead[0] = m_nRoundLead;
//		m_pPlayer[m_nDummy]->SetDummyFlag(TRUE);
//		m_pPlayer[m_nDeclarer]->SetDeclarerFlag(TRUE);
	}
	else
	{
		// contract has NOT been reached, so restart
		m_nCurrPlayer = m_nDealer;
		m_numBidsMade = 0;
	}

	// restore initial hands (temp?)
	for(i=0;i<4;i++)
		m_pPlayer[i]->RestoreInitialHand();

	// not reviewing game
	m_bReviewingGame = FALSE;

	// all done
	return TRUE;
}
//
//-----------------------------------------------------
//
// respond to partner's Michaels Cue Bid
//
BOOL CMichaelsCueBidConvention::RespondToConvention(const CPlayer& player, 
													const CConventionSet& conventions, 
													CHandHoldings& hand, 
													CCardLocation& cardLocation, 
												    CGuessedHandHoldings** ppGuessedHands,
													CBidEngine& bidState,  
													CPlayerStatusDialog& status)
{
	// first see if another convention is active
	if ((bidState.GetActiveConvention() != NULL) &&
					(bidState.GetActiveConvention() != this))
		return FALSE;

	//
	// make a responding bid
	//
	int nPartnersBid = bidState.nPartnersBid;
	int nPartnersBidLevel = bidState.nPartnersBidLevel;
	int nPartnersSuit = bidState.nPartnersSuit;
	int nPartnersPrevSuit = bidState.nPartnersPrevSuit;
	//
	int nBid, nSuit;
	double fPts = bidState.fPts;
	double fCardPts = bidState.fCardPts;

	// 
	// see what round this is
	//
	int nStatus = bidState.GetConventionStatus(this);
	if (nStatus == CONV_INACTIVE)
	{
		//
		// Bidding in response to partner's Michael's bid? check requirements
		//
		// the identifying marks of a Michaels bid are:
		// 1: we must not have bid yet
		// 2: LHO must have bid a suit at the 1 level, and 
		// 3: partner overcalled LHO's suit at the 2 level
		int nLastValidBid = pDOC->GetLastValidBid();

		// apply tests #1, 2, and 3
		int nOpeningBid = pDOC->GetOpeningBid();
		int nOpeningBidder = pDOC->GetOpeningBidder();
		BOOL bLHOMajor = ISMAJOR(nOpeningBid);
		if (ISBID(nOpeningBid) && (GetPlayerTeam(nOpeningBidder) != player.GetTeam()) &&
			 ((nOpeningBid >= BID_1C) && (nOpeningBid <= BID_1S)) &&
			  (nPartnersSuit == bidState.nLHOSuit) && (nPartnersBidLevel == 2) &&
			  (bidState.m_numBidsMade == 0) )
		{
			//
			status << "MCLR10! Partner has made a Michaels Cue bid of " & BTS(nPartnersBid) &
					  ", indicating 5/5 length in " &
					  (bLHOMajor? ((bidState.nLHOSuit == HEARTS)? "Spades and a minor" : "Hearts and a minor") : "the majors") & ".\n";
		}
		else
		{
			return FALSE;
		}

		// did partner bid a minor, indicating both majors?
		if (ISMINOR(nPartnersSuit))
		{
			// Pard has both majors -- pick the preferred one
			nSuit = bidState.PickSuperiorSuit(HEARTS, SPADES);
			if (hand.GetNumCardsInSuit(nSuit) < 3)
			{
				// should have at least 3 trumps
				int nOtherSuit = (nSuit == HEARTS)? SPADES : HEARTS;
				if (hand.GetNumCardsInSuit(nOtherSuit) >= 3)
					nSuit = nOtherSuit;
			}
		}
		else if (nPartnersSuit == HEARTS)
		{
			// pard has Spades + a minor
			// see if Spades are decent (3-card support)
//			if ((hand.GetNumCardsInSuit(SPADES) >= 3) && (hand.GetSuitStrength(SPADES) >= SS_MODERATE_SUPPORT))
			if (hand.GetNumCardsInSuit(SPADES) >= 3)
			{
				// fine, go with Spades
				nSuit = SPADES;
			}
			else 
			{
				// Spades are too weak; look for a minor
				if ((hand.GetSuitStrength(CLUBS) >= SS_MODERATE_SUPPORT) || (hand.GetSuitStrength(DIAMONDS) >= SS_MODERATE_SUPPORT))
					nSuit = NOTRUMP;
				else
					nSuit = SPADES;	// minors are no good either, so go with Spades
			}
		}
		else 
		{
			// pard has Hearts + a minor
			// see if Hearts are decent (3-card support)
//			if ((hand.GetNumCardsInSuit(HEARTS) >= 3) && (hand.GetSuitStrength(HEARTS) >= SS_MODERATE_SUPPORT))
			if (hand.GetNumCardsInSuit(HEARTS) >= 3)
			{
				// fine, go with Hearts
				nSuit = HEARTS;
			}
			else 
			{
				// Spades are too weak; look for a minor
				if ((hand.GetSuitStrength(CLUBS) >= SS_MODERATE_SUPPORT) || (hand.GetSuitStrength(DIAMONDS) >= SS_MODERATE_SUPPORT))
					nSuit = NOTRUMP;
				else
					nSuit = HEARTS;	// minors are no good either, so go with Hearts
			}
		}

		// now adjust point count
		if (ISSUIT(nSuit))
		{
			bidState.SetAgreedSuit(nSuit);
			fPts = bidState.fAdjPts = hand.RevalueHand(REVALUE_DECLARER, nSuit, TRUE);
		}
		// partner may have 6-11 OR 17+ pts; assume it's a weak hand
		bidState.AdjustPartnershipPoints(6, 11);

		// and make a responding bid
		CString strChoices = ISMINOR(nPartnersSuit)? "the two majors" : 
					(nPartnersSuit == HEARTS)? "Spades and a minor" : "Hearts and an unknown minor";
		int numTrumps = ISSUIT(nSuit)? hand.GetNumCardsInSuit(nSuit) : 0;

		// set initial convention status to finished
		bidState.SetConventionStatus(this, CONV_FINISHED);

		// see if we need to look at the minor
		if (nSuit == NOTRUMP)
		{
			// bid 2NT to ask for the minor
			nBid = BID_2NT;
			if (nBid > nLastValidBid)
			{
				if (nPartnersSuit == HEARTS)
					status << "MCLR12! Given a choice between a " & hand.GetNumCardsInSuit(SPADES) &
							  "-card Spade suit and an unknown minor, we're forced to ask for the minor by bidding " & BTS(nBid) & ".\n";
				else
					status << "MCLR12! Given a choice between a " & hand.GetNumCardsInSuit(HEARTS) &
							  "-card Heart suit and an unknown minor, we're forced to ask for the minor by bidding " & BTS(nBid) & ".\n";
				// this convention will go another round
				bidState.SetConventionStatus(this, CONV_RESPONDED_ROUND1);
			}
			else
			{
				nBid = BID_PASS;
				status << "MCLR13! We'd like to bid 2NT to ask for partner's minor, but we can't do so after RHO's interference, so we have to pass.\n";
			}
		}
		else if ((numTrumps >= 5) && (bidState.m_fMinTPPoints <= PT_COUNT(20)) &&
			ISMAJOR(nSuit) && (MAKEBID(nSuit, 4) > nLastValidBid))
		{
			// make a preemptive bid if possible
			nBid = MAKEBID(nSuit, 4);
			status << "MCLR15! With " & numTrumps & " " & STS(nSuit) & " and a total of " & 
					  bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
					  " pts in the partnership, make a shutout bid in " & STS(nSuit) & 
					  " by jumping to " & BTS(nBid) & ".\n";
		}
		else if (bidState.m_fMinTPPoints <= PT_COUNT(21))
		{
			// respond at the 2-level
			nBid = bidState.GetCheapestShiftBid(nSuit, nLastValidBid);
			if (BID_LEVEL(nBid) == 2)
			{
				status << "MCLR20! Given a choice between " & strChoices & 
						   ", respond to partner's Michaels with the preferred " & 
						   STSS(nSuit) & " suit with a bid of " & BTS(nBid) & ".\n";
			}
			else
			{
				nBid = BID_PASS;
				status << "MCLR21! After RHO interference, we don't have the points to go to the 3-level in response to partner's Michaels, so pass.\n";
			}
		}
		else if (bidState.m_fMinTPPoints <= PT_COUNT(24))
		{
			// bid at the 3-level
			nBid = MAKEBID(nSuit, 3);
			if (nBid > nLastValidBid)
			{
				status << "MCLR24! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						   " pts in the partnership and a choice between " & strChoices &
						   ", invite game in " & STS(nSuit) & " by jumping to " & BTS(nBid) & ".\n";
			}
			else
			{
				nBid = BID_PASS;
				status << "MCLR25! After RHO interference, we don't have the points to go to the 4-level in response to partner's Michaels, so pass.\n";
			}
		}
		else if (ISMINOR(nSuit) && (bidState.m_fMinTPPoints <= PT_COUNT(27)))
		{
			// with 25+ pts, bid game
			nBid = bidState.GetGameBid(nSuit);
			if (nBid > nLastValidBid)
			{
				status << "MCLR27! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						   " pts in the partnership and a choice between " & strChoices & 
						   ", jump to the 4-level in " & STS(nSuit) & " with a bid of " & BTS(nBid) & ".\n";
			}
			else
			{
				nBid = BID_PASS;
				status << "MCLR28! After RHO interference, we don't have the points to go to the 5-level in response to partner's Michaels, so pass.\n";
			}
		}
		else
		{
			// with 25+ pts in a major, or 28+ pts in a minor, bid game
			nBid = bidState.GetGameBid(nSuit);
			if (nBid > nLastValidBid)
			{
				status << "MCLR30! With a total of " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						   " pts in the partnership and a choice between " & strChoices & 
						   ", jump to game in " & STS(nSuit) & " at " & BTS(nBid) & ".\n";
			}
			else
			{
				nBid = BID_PASS;
				status << "MCLR31! After RHO interference, we don't want to bid past game, so pass.\n";
			}
		}

		// done!
		bidState.SetBid(nBid);
		return TRUE;

	}
	else if (nStatus == CONV_RESPONDED_ROUND1)
	{
		//
		// round 2 -- we must've bid 2NT last time to ask for partner's minor
		//

		// see if partner cue bid the enemy suit again
		if (nPartnersSuit == nPartnersPrevSuit)
		{
			// partner has 17+ pts
			bidState.AdjustPartnershipPoints(OPEN_PTS(17), MIN(17,40 - bidState.fCardPts));

			// bid 4NT to ask for the minor again
			if (fPts >= PT_COUNT(15))
			{
				// else make a natural game bid
				nBid = BID_4NT;
				status << "MCLR35! Partner cue bid the enemy suit again, indicating a strong Michaels opening hand with " &
						   OPEN_PTS(17) & "+ pts; so with " & 
						   bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						   " pts in the partnership, ask for the other minor by bidding " & BTS(nBid) & ".\n";
				bidState.SetConventionStatus(this, CONV_RESPONDED_ROUND2);
			}
			else
			{
				// else make a natural 3NT game bid
				nBid = BID_3NT;
				status << "MCLR36! Partner cue bid the enemy suit again, indicating a strong Michaels opening hand with " &
						   OPEN_PTS(17) & "+ pts; but with " & 
						   bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						   " pts in the partnership, stop at game with a natural bid of " & BTS(nBid) & ".\n";
				bidState.SetConventionStatus(this, CONV_FINISHED);
			}
			// done
			bidState.SetBid(nBid);
			return TRUE;
		}

		// see if partner's bid is valid
		if (!ISMINOR(nPartnersSuit))
		{
			status << "MCLR40! After his opening Michaels Cue Bid, partner did not respond properly to our 2NT minor suit inquiry, so michaels is off.\n";
			bidState.SetConventionStatus(this, CONV_ERROR);
			return FALSE;
		}

		// see if we can live with partner's minor
		int nAgreedSuit;
		if (hand.GetNumCardsInSuit(nPartnersSuit) >= 3)
		{
			// stick with the minor
			status << "4MCLR41! Since we have " & hand.GetNumCardsInSuit(nPartnersSuit) & 
					  " cards in the " & STSS(nPartnersSuit) & " suit, choose that suit for our response.\n";
			nAgreedSuit = nPartnersSuit;
		}
		else
		{
			// minor's not so great; select the better of the minor or the major
			nAgreedSuit = bidState.PickSuperiorSuit(nPartnersSuit, bidState.nPartnersPrevSuit);
			if (nAgreedSuit == nPartnersSuit)
				status << "4MCLR42! The " & STSS(nPartnersSuit) & " suit isn't great, but it's better than " &
						   STS(bidState.nPartnersPrevSuit) & ", so choose that suit for our response.\n";
			else
				status << "4MCLR43! The " & STSS(nPartnersSuit) & " suit is poor, so pick the major suit ("& 
						   STS(bidState.nPartnersPrevSuit) & ") for our response.\n";
			bidState.SetAgreedSuit(bidState.PickSuperiorSuit(nPartnersSuit, bidState.nPartnersPrevSuit));
		}

		// recalc points as dummy
		bidState.SetAgreedSuit(nAgreedSuit);
		fPts = bidState.fAdjPts = hand.RevalueHand(REVALUE_DECLARER, nAgreedSuit, TRUE);
		bidState.AdjustPartnershipPoints();

		// select the bid level
		if (ISMINOR(nAgreedSuit))
		{
			// Clubs or Diamonds
			if (bidState.m_fMinTPPoints <= PTS_MINOR_GAME-6)	// <= 22
				nBid = BID_PASS;
			else if (bidState.m_fMinTPPoints <= PTS_MINOR_GAME-4)	// <= 24
				nBid = MAKEBID(nPartnersBid, 4);
			else 
				nBid = MAKEBID(nPartnersBid, 5);	// go for game
			//
			if (nBid == BID_PASS)
				status << "MCLR45! Partner showed his minor to be " & STS(nPartnersSuit) & 
						  ", which we can support with " & hand.GetNumCardsInSuit(nPartnersSuit) &
						  " trumps, but with only " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						  " pts in the partnership, we have to pass.\n";
			else
				status << "MCLR46! Partner showed his minor to be " & STS(nPartnersSuit) & 
						  ", which we can support with " & hand.GetNumCardsInSuit(nPartnersSuit) &
						  " trumps, so with " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						  " pts in the partnership, we bid " & BTS(nBid) & ".\n";
		}
		else
		{
			// sticking with the major (though not a very good one!)
			// sign off at the 3-level or go to game
			if (bidState.m_fMinTPPoints < PTS_MAJOR_GAME)	// < 25
				nBid = MAKEBID(nPartnersBid, 3);
			else	
				nBid = MAKEBID(nPartnersBid, 4);
			//
			if (BID_LEVEL(nBid) == 3)
				status << "MCLR47! With " & hand.GetNumCardsInSuit(nAgreedSuit) & 
						  "-card support for partner's " & STS(nAgreedSuit) & 
						  ", and with only " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						  " pts in the partnership, we have to pass.\n";
			else
				status << "MCLR47! With " & hand.GetNumCardsInSuit(nAgreedSuit) & 
						  "-card support for partner's " & STS(nAgreedSuit) & 
						  ", and with " & bidState.m_fMinTPPoints & "-" & bidState.m_fMaxTPPoints &
						  " pts in the partnership, we can go to game at " & BTS(nBid) & ".\n";
		}

		// done!
		bidState.SetBid(nBid);
		bidState.SetConventionStatus(this, CONV_FINISHED);
		return TRUE;
	}
	else if (nStatus == CONV_RESPONDED_ROUND2)
	{
		//
		// round 3 -- we must've bid 4NT last time to ask for partner's minor
		//            after partner's second Michaels cue bid
		//

	}


	//
	return FALSE;
} 
void BattleGroundNA::Update(uint32 diff)
{
    BattleGround::Update(diff);

    // after bg start we get there
    if (GetStatus() == STATUS_WAIT_JOIN && GetPlayersSize())
    {
        ModifyStartDelayTime(diff);

        if (!(m_Events & 0x01))
        {
            m_Events |= 0x01;
            // setup here, only when at least one player has ported to the map
            if (!SetupBattleGround())
            {
                EndNow();
                return;
            }
            for (uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_4; i++)
                SpawnBGObject(i, RESPAWN_IMMEDIATELY);

            AddSpectatorNPC(4055.74f, 2921.20f, 39.54f, 0.0f);

            SetStartDelayTime(START_DELAY1);
            SendMessageToAll(LANG_ARENA_ONE_MINUTE);
        }
        // After 30 seconds, warning is signalled
        else if (GetStartDelayTime() <= START_DELAY2 && !(m_Events & 0x04))
        {
            m_Events |= 0x04;
            SendMessageToAll(LANG_ARENA_THIRTY_SECONDS);
        }
        // After 15 seconds, warning is signalled
        else if (GetStartDelayTime() <= START_DELAY3 && !(m_Events & 0x08))
        {
            m_Events |= 0x08;
            SendMessageToAll(LANG_ARENA_FIFTEEN_SECONDS);
        }
        // delay expired (1 minute)
        else if (GetStartDelayTime() <= 0 && !(m_Events & 0x10))
        {
            m_Events |= 0x10;

            for (uint32 i = BG_NA_OBJECT_DOOR_1; i <= BG_NA_OBJECT_DOOR_2; i++)
                DoorOpen(i);

            for (uint32 i = BG_NA_OBJECT_BUFF_1; i <= BG_NA_OBJECT_BUFF_2; i++)
                SpawnBGObject(i, 60);

            SendMessageToAll(LANG_ARENA_BEGUN);
            SetStatus(STATUS_IN_PROGRESS);
            SetStartDelayTime(0);

            for (BattleGroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
                if (Player *plr = sObjectMgr.GetPlayer(itr->first))
                {
                    SendPacketToEnemyTeam(GetPlayerTeam(plr->GetGUID()), plr->BuildGladdyUpdate());
                    plr->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
                }

            if (!GetPlayersCountByTeam(ALLIANCE) && GetPlayersCountByTeam(HORDE))
                EndBattleGround(HORDE);
            else if (GetPlayersCountByTeam(ALLIANCE) && !GetPlayersCountByTeam(HORDE))
                EndBattleGround(ALLIANCE);
        }
    }

    /*if(GetStatus() == STATUS_IN_PROGRESS)
    {
        // update something
    }*/
}
Exemple #17
0
void BattleGround::RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket)
{
    uint32 team = GetPlayerTeam(guid);
    bool participant = false;
    // Remove from lists/maps
    std::map<uint64, BattleGroundPlayer>::iterator itr = m_Players.find(guid);
    if(itr != m_Players.end())
    {
        UpdatePlayersCountByTeam(team, true);   // -1 player
        m_Players.erase(itr);
        // check if the player was a participant of the match, or only entered through gm command (goname)
        participant = true;
    }

    BattleGroundScoreMap::iterator itr2 = m_PlayerScores.find(guid);
    if(itr2 != m_PlayerScores.end())
    {
        delete itr2->second;                                // delete player's score
        m_PlayerScores.erase(itr2);
    }

    Player *plr = sObjectMgr.GetPlayer(guid);

    // should remove spirit of redemption
    if(plr && plr->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION))
        plr->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);

    if(plr && !plr->isAlive())                              // resurrect on exit
    {
        plr->ResurrectPlayer(1.0f);
        plr->SpawnCorpseBones();
    }

    RemovePlayer(plr, guid);                                // BG subclass specific code

    if(plr)
    {
        if(participant) // if the player was a match participant, remove auras, calc rating, update queue
        {
            if(!team) team = plr->GetTeam();

            BattleGroundTypeId bgTypeId = GetTypeID();
            uint32 bgQueueTypeId = BattleGroundMgr::BGQueueTypeId(GetTypeID());

            WorldPacket data;
            if(SendPacket)
            {
                sBattleGroundMgr.BuildBattleGroundStatusPacket(&data, this, team, plr->GetBattleGroundQueueIndex(bgQueueTypeId), STATUS_NONE, 0, 0);
                plr->GetSession()->SendPacket(&data);
            }

            // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
            plr->RemoveBattleGroundQueueId(bgQueueTypeId);

            DecreaseInvitedCount(team);
            //we should update battleground queue, but only if bg isn't ending
            if (GetBracketId() < MAX_BATTLEGROUND_BRACKETS)
                sBattleGroundMgr.m_BattleGroundQueues[bgQueueTypeId].Update(bgTypeId, GetBracketId());

            Group * group = plr->GetGroup();
            // remove from raid group if exist
            if(group && group == GetBgRaid(team))
            {
                if(!group->RemoveMember(guid, 0))               // group was disbanded
                {
                    SetBgRaid(team, NULL);
                    delete group;
                }
            }

            // Let others know
            sBattleGroundMgr.BuildPlayerLeftBattleGroundPacket(&data, plr);
            SendPacketToTeam(team, &data, plr, false);
        }

        // Do next only if found in battleground
        plr->SetBattleGroundId(0);                          // We're not in BG.
        // reset destination bg team
        plr->SetBGTeam(0);

        if(Transport)
            plr->TeleportTo(plr->GetBattleGroundEntryPoint());

        DETAIL_LOG("BATTLEGROUND: Removed player %s from BattleGround.", plr->GetName());
    }

    if(!GetPlayersSize() && !GetInvitedCount(HORDE) && !GetInvitedCount(ALLIANCE))
    {
        // if no players left AND no invitees left, set this bg to delete in next update
        // direct deletion could cause crashes
        m_SetDeleteThis = true;
        // return to prevent addition to freeslotqueue
        return;
    }

    // a player exited the battleground, so there are free slots. add to queue
    this->AddToBGFreeSlotQueue();
}
Exemple #18
0
func OnClonkDeath(object pClonk)
{
	if(GetPlayerTeam(GetOwner(pClonk)) == 1) Deaths1++;
	if(GetPlayerTeam(GetOwner(pClonk)) == 2) Deaths2++;
	UpdateScoreboard();
}