コード例 #1
0
// ----------------------------------------------------------------------------------------------------------------
//## функция сепаратора для протокола
void DuelSystem::RecvWatchRequest(LPOBJ lpObj, PMSG_DUEL_REQUEST_WATCH* lpMsg)
{
	if(lpObj->m_IfState.use == 0 || lpObj->m_IfState.type != 20) 
	{
		return;
	}
	// ----
	lpObj->m_IfState.use  = 0;
	lpObj->m_IfState.type = 0;
	// ----
	if(lpMsg->btRoomIndex >= 0 && lpMsg->btRoomIndex < MAX_DUEL_ROOMS)
	{
		if(this->g_DuelRooms[lpMsg->btRoomIndex].RoomFree == TRUE) 
		{
			GCServerMsgStringSend("Sorry, but this room is free!", lpObj->m_Index, 1);
			return;
		}
		// ----
		for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
		{
			if(this->g_DuelRooms[lpMsg->btRoomIndex].szSeparators[i] == NULL)
			{
				if(gObjMoveGate(lpObj->m_Index, g_DuelGates[lpMsg->btRoomIndex].SeparatorGate))
				{
					this->g_DuelRooms[lpMsg->btRoomIndex].szSeparators[i] = lpObj;
					// ----
					this->SendSpectatorList(lpObj, lpMsg->btRoomIndex);
					// ----
					this->SendSpectatorList(lpMsg->btRoomIndex);
					// ----
					this->SendSpectatorAdd(i, lpMsg->btRoomIndex);
					// ----
					GCServerMsgStringSend("Please sit down and watch this duel. Have fun.", lpObj->m_Index, 1);
					// ----
							if(Config.Duel.Logging)
		{
					Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System][%s][%s] Spectator join to room: [%d]", 
									lpObj->AccountID, lpObj->Name, lpMsg->btRoomIndex + 1);
							}
					// ----
					GCStateInfoSendg(lpObj, 1, 98);
					// ----
					this->SendLifebarInit(lpObj, lpMsg->btRoomIndex);
					// ----
					this->SendLifebarStatus(lpObj, lpMsg->btRoomIndex);
					// ----
					this->UpdateDuelScore(lpMsg->btRoomIndex);
					// ----
					AddTab[lpObj->m_Index].DUEL_SpecVisible = 1;
					// ----
					return;
				}
				GCServerMsgStringSend("Failed to move to Duel Room!", lpObj->m_Index, 1);
				return;
			}
		}
		GCServerMsgStringSend("Sorry, but this room is full!", lpObj->m_Index, 1);
		return;
	}
}
コード例 #2
0
void cDuelSystem::Run()
{
    for(short i = 0; i < MAX_DUEL_ROOMS; ++i)
    {
        if(this->g_DuelRooms[i].RoomFree == FALSE)
        {
            if(GetTickCount() - this->g_DuelRooms[i].dwStartTime < 5000)
            {
                continue;
            }

            for(short u = 0; u < MAX_DUEL_SEPARATORS; u++)
            {
                if(this->g_DuelRooms[i].szSeparators[u] == NULL)
                {
                    continue;
                }

                if(Utilits.gObjIsConnected(this->g_DuelRooms[i].szSeparators[u]->m_Index))
                {

                    if(this->g_DuelRooms[i].szSeparators[u]->MapNumber != 0x40)
                    {
                        this->SendEndDuel(this->g_DuelRooms[i].szSeparators[u]);

                        AddBuff(this->g_DuelRooms[i].szSeparators[u], 18, 0, 0, 0, 0, 1);

                        gObjViewportListProtocolCreate(this->g_DuelRooms[i].szSeparators[u]);

                        GCStateInfoSendg(this->g_DuelRooms[i].szSeparators[u], 0, 98);


                        if(Config.Logging)
                        {
                            Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Spectator [%s] Leave [%d] Room",this->g_DuelRooms[i].szSeparators[u]->Name, i + 1);
                        }

                        this->SendSpectatorRemove(u, i);
                        this->g_DuelRooms[i].szSeparators[u] = NULL;
                    }
                }
                else
                {
                    if(Config.Logging)
                    {
                        Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Spectator Leave Room [%d]", i + 1);
                    }

                    this->g_DuelRooms[i].szSeparators[u] = NULL;
                    this->SendSpectatorList(i);
                }

                SendSpectatorList(i);
            }

            if(this->g_DuelRooms[i].szlpObjOne != NULL || this->g_DuelRooms[i].szlpObjTy != NULL)
            {
                if
                (
                    Utilits.gObjIsConnected(this->g_DuelRooms[i].szlpObjOne->m_Index) == FALSE ||
                    Utilits.gObjIsConnected(this->g_DuelRooms[i].szlpObjTy->m_Index)  == FALSE
                )
                {
                    this->RoomReset(i);

                    continue;
                }
                else if
                (
                    (this->g_DuelRooms[i].szlpObjOne->MapNumber != 0x40 || this->g_DuelRooms[i].szlpObjTy->MapNumber  != 0x40) && this->g_DuelRooms[i].szWinner == FALSE
                )
                {
                    this->RoomReset(i);

                    continue;
                }

                else if(this->g_DuelRooms[i].szlpObjOne->Connected < PLAYER_PLAYING || this->g_DuelRooms[i].szlpObjTy->Connected  < PLAYER_PLAYING)
                {
                    this->RoomReset(i);

                    continue;
                }
            }
            else
            {
                this->RoomReset(i);

                continue;
            }

            if(this->UpdateLifebarTime < GetTickCount())
            {
                this->SendLifebarStatus(i);
                this->UpdateLifebarTime = GetTickCount() + 2000;
            }

            if(this->g_DuelRooms[i].dwTicketCount != 0)
            {
                if(this->g_DuelRooms[i].dwTicketCount < GetTickCount())
                {
                    this->RoomReset(i);

                    if(Config.Logging)
                    {
                        Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Room [%d] Cleaned", i + 1);
                    }
                }
            }

            if(this->g_DuelRooms[i].RoomFree == FALSE && this->g_DuelRooms[i].DuelWaiting == FALSE && this->g_DuelRooms[i].szWinner == FALSE)
            {
                for(short s = 0; s < MAX_DUEL_SEPARATORS; s++)
                {
                    if(this->g_DuelRooms[i].szSeparators[s] != NULL)
                    {
                        if(AddTab[this->g_DuelRooms[i].szSeparators[s]->m_Index].DUEL_SpecVisible == 1)
                        {
                            AddBuff(this->g_DuelRooms[i].szSeparators[s], 18, 0, 0, 0, 0, -10);

                            gObjViewportListProtocolDestroy(this->g_DuelRooms[i].szSeparators[s]);

                            if(Config.Logging)
                            {
                                Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Character [%s] Added Invisible", this->g_DuelRooms[i].szSeparators[s]->Name);
                            }

                            AddTab[this->g_DuelRooms[i].szSeparators[s]->m_Index].DUEL_SpecVisible = 0;
                        }
                    }
                }
            }
        }
    }

    for(short n = 0; n < MAX_DUEL_ROOMS; n++)
    {
        if(this->g_DuelRooms[n].DuelWaiting == TRUE)
        {
            if(Utilits.gObjIsConnected(this->g_DuelRooms[n].szlpObjOne->m_Index) == FALSE || Utilits.gObjIsConnected(this->g_DuelRooms[n].szlpObjTy->m_Index)  == FALSE )
            {
                this->RoomReset(n);

                continue;
            }
            else if(this->g_DuelRooms[n].szlpObjOne->Connected < PLAYER_PLAYING || this->g_DuelRooms[n].szlpObjTy->Connected  < PLAYER_PLAYING)
            {
                this->RoomReset(n);

                continue;
            }
        }
    }

    if(this->UpdateTickCount < GetTickCount())
    {
        for(short i = 8000; i < OBJECT_MAX; ++i)
        {
            LPOBJ lpObj    = (LPOBJ)OBJECT_POINTER(i);

            if((lpObj->m_IfState.use) && lpObj->m_IfState.type == 20)
            {
                this->SendDuelStatus(lpObj);
            }
        }

        this->UpdateTickCount = GetTickCount() + 6000;
    }

    return;
}
コード例 #3
0
void cDuelSystem::RoomReset(short iRoom, bool dontMove, bool dontSendEnd)
{
    if(this->g_DuelRooms[iRoom].szlpObjOne != NULL) // Player 1
    {
        if(Utilits.gObjIsConnected(this->g_DuelRooms[iRoom].szlpObjOne->m_Index))
        {
            if(dontSendEnd == false)
            {
                this->SendEndDuel(this->g_DuelRooms[iRoom].szlpObjOne);
            }

            if(this->g_DuelRooms[iRoom].szlpObjOne->MapNumber == 0x40)
            {
                if(dontMove == false)
                {
                    gObjMoveGate(this->g_DuelRooms[iRoom].szlpObjOne->m_Index, DuelSystem.Config.DuelGate);
                }
            }
        }

        this->UserDuelInfoReset(this->g_DuelRooms[iRoom].szlpObjOne);
    }

    if(this->g_DuelRooms[iRoom].szlpObjTy != NULL)  // Player 2
    {
        if(Utilits.gObjIsConnected(this->g_DuelRooms[iRoom].szlpObjTy->m_Index))
        {
            if(dontSendEnd == false)
            {
                this->SendEndDuel(this->g_DuelRooms[iRoom].szlpObjTy);
            }

            if(this->g_DuelRooms[iRoom].szlpObjTy->MapNumber == 0x40)
            {
                if(dontMove == false)
                {
                    gObjMoveGate(this->g_DuelRooms[iRoom].szlpObjTy->m_Index, DuelSystem.Config.DuelGate);
                }
            }
        }

        this->UserDuelInfoReset(this->g_DuelRooms[iRoom].szlpObjTy);
    }

    for(short i = 0; i < MAX_DUEL_SEPARATORS; ++i)
    {
        if(this->g_DuelRooms[iRoom].szSeparators[i] != NULL)
        {
            this->SendEndDuel(this->g_DuelRooms[iRoom].szSeparators[i]);

            AddBuff(this->g_DuelRooms[iRoom].szSeparators[i], 18, 0, 0, 0, 0, 1);

            gObjViewportListProtocolCreate(this->g_DuelRooms[iRoom].szSeparators[i]);

            GCStateInfoSendg(this->g_DuelRooms[iRoom].szSeparators[i], 0, 98);

            gObjMoveGate(this->g_DuelRooms[iRoom].szSeparators[i]->m_Index, DuelSystem.Config.DuelGate);
        }

        this->g_DuelRooms[iRoom].szSeparators[i] = NULL;
    }

    this->g_DuelRooms[iRoom].szlpObjOne   = NULL;
    this->g_DuelRooms[iRoom].szPointsOne  = 0;

    this->g_DuelRooms[iRoom].szlpObjTy    = NULL;
    this->g_DuelRooms[iRoom].szPointsTy   = 0;

    this->g_DuelRooms[iRoom].RoomFree	  = TRUE;
    this->g_DuelRooms[iRoom].DuelWaiting  = FALSE;
    this->g_DuelRooms[iRoom].szWinner	  = FALSE;

    this->g_DuelRooms[iRoom].dwTicketCount= 0;
    this->g_DuelRooms[iRoom].dwStartTime  = 0;

    if(Config.Logging)
    {
        Log.ConsoleOutPut(1, c_Blue, t_Duel,"[Duel System] Room [%d] Has Restarted", iRoom +1);
    }
}