예제 #1
0
void CDebugView::Draw()
{
	// Get our player manager and local player
	CPlayerManager * pPlayerManager = g_pClient->GetPlayerManager();
	CLocalPlayer * pLocalPlayer = g_pClient->GetLocalPlayer();

	if(g_pClient->GetGUI() && pLocalPlayer && pPlayerManager)
	{
		if(!pLocalPlayer->IsSpawned())
			return;

		if(g_pClient->GetMainMenu()->IsVisible())
			return;

		m_fDebugTextTop = DEBUG_TEXT_TOP;

		DumpPlayer(pLocalPlayer);

		for(EntityId i = 0; i < MAX_PLAYERS; i++)
		{
			CNetworkPlayer * pPlayer = pPlayerManager->GetAt(i);

			if(pPlayer && pPlayer->IsSpawned() && !pPlayer->IsLocalPlayer())
			{
				DumpPlayer(pPlayer);
				break;
			}
		}
	}
}
예제 #2
0
void Chat(RakNet::BitStream *bitStream, Packet *packet)
{
	EntityId playerID;
	BYTE byteTextLen;
	CHAR szText[256];

	bitStream->Read(playerID);
	bitStream->Read(byteTextLen);
	bitStream->Read(szText,byteTextLen);

	szText[byteTextLen] = '\0';

	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	if(playerID == pPlayerManager->GetLocalPlayerID()) {
		pChatWindow->AddChatMessage(pNetowkManager->GetPlayerManager()->GetLocalPlayerName(),
			pPlayerManager->GetLocalPlayer()->GetTeamColorAsARGB(),szText);
	}
	else
	{
		CRemotePlayer *pRemotePlayer = pNetowkManager->GetPlayerManager()->GetAt(playerID);
		if(pRemotePlayer) {
			pRemotePlayer->Say(szText);	
		}
	}
}
예제 #3
0
void CText::InitForWorld()
{
	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	for(EntityId i = 0; i < MAX_PLAYERS; i++) {
		if(pPlayerManager->GetSlotState(i)) {
			InitForPlayer(i);
		}
	}
}
예제 #4
0
void CPlayerManager::SetGameTime(BYTE hours, BYTE minutes)
{
	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	for(BYTE i = 0; i < MAX_PLAYERS; i++) {
		if(pPlayerManager->GetSlotState(i)) {
			pPlayerManager->GetAt(i)->SetGameTime(hours, minutes);
		}
	}
}
예제 #5
0
void __stdcall CPlayerManager::PlayerEventNotify( LPVOID lpParam,
			const unsigned long &ulnID,
			const unsigned long &ulnEventType )
{
	CPlayerManager *pPM = ( CPlayerManager * )( lpParam );

	ASSERT( pPM );

	pPM->_PlayerEventNotify( ulnID, ulnEventType );
}
예제 #6
0
void AddPlayerCommand(char * szParams)
{
	// Get our player manager
	CPlayerManager * pPlayerManager = g_pClient->GetPlayerManager();

	int playerId = 0;
	sscanf(szParams, "%d", &playerId);
	pPlayerManager->Add(playerId, "jenkstax");
	pPlayerManager->Spawn(playerId, 35, CVector3(-341.36f, 1144.80f, 14.79f), 40.114815f);
}
예제 #7
0
CText::~CText()
{
	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();

	for(EntityId i = 0; i < MAX_PLAYERS; i++)
	{
		if(pPlayerManager->GetSlotState(i))
		{
			DestroyForPlayer(i);
		}
	}
}
예제 #8
0
void ServerQuit(RakNet::BitStream *bitStream, Packet *packet)
{
	CPlayerManager *pPlayerManager = pNetowkManager->GetPlayerManager();
	EntityId playerID;
	BYTE byteReason;

	bitStream->Read(playerID);
	bitStream->Read(byteReason);

	// Delete this client from the player pool.
	pPlayerManager->Delete(playerID,byteReason);
}
예제 #9
0
void CText::Show(bool show)
{
	m_bShow = show;

	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	for(EntityId i = 0; i < MAX_PLAYERS; i++) {
		if(pPlayerManager->GetSlotState(i)) {
			BitStream bsSend;
			bsSend.Write(m_iID);
			bsSend.Write(m_bShow);
			pNetowkManager->GetRPC4()->Call("Script_toggleTextForPlayer", &bsSend, HIGH_PRIORITY, RELIABLE, 0, pNetowkManager->GetRakPeer()->GetSystemAddressFromIndex(i), 0);
		}
	}
}
예제 #10
0
void CText::SetText(const char * szText)
{
	m_szText = szText;

	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	for(EntityId i = 0; i < MAX_PLAYERS; i++) {
		if(pPlayerManager->GetSlotState(i)) {
			BitStream bsSend;
			bsSend.Write(m_iID);
			bsSend.Write(strlen(szText));
			bsSend.Write(szText, strlen(szText));
			pNetowkManager->GetRPC4()->Call("Script_SetText", &bsSend, HIGH_PRIORITY, RELIABLE, 0, pNetowkManager->GetRakPeer()->GetSystemAddressFromIndex(i), 0);
		}
	}
}
예제 #11
0
void CText::SetPosition(float fPosX, float fPosY)
{
	m_fRelativePosX = fPosX;
	m_fRelativePosY = fPosY;

	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	for(EntityId i = 0; i < MAX_PLAYERS; i++) {
		if(pPlayerManager->GetSlotState(i)) {
			BitStream bsSend;
			bsSend.Write(m_iID);
			bsSend.Write(fPosX);
			bsSend.Write(fPosY);
			pNetowkManager->GetRPC4()->Call("Script_SetTextPosition", &bsSend, HIGH_PRIORITY, RELIABLE, 0, pNetowkManager->GetRakPeer()->GetSystemAddressFromIndex(i), 0);
		}
	}
}
//--------------------------------------------------------------
//		CChgCharacEffect::update()
//--------------------------------------------------------------
bool CChgCharacEffect::update(CTimerEvent * event, bool applyEffect)
{
	if (!TheDataset.isAccessible(_TargetRowId))
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}

	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		_EndTimer.setRemaining(1, new CEndEffectTimerEvent(this));
		return true;
	}
		
	//player->getScores()._PhysicalScores[_AffectedScore].RegenerateModifier += _RegenModifier;
	string var = "Modifier" + _AffectedCharac;
	
	string currentValueStr;
	player->getValue(var,currentValueStr);
	sint32 currentValue;
	NLMISC::fromString(currentValueStr, currentValue);
	string newValueStr = toString(currentValue + _Modifier1 + _Modifier2);
	player->setValue(var,newValueStr);
	
	// now only one update is needed, but the end methos must reset the modifier !
	// must update this every ticks NO !!!!
	//_UpdateTimer.setRemaining(1, event);

	return false;
} // update //
예제 #13
0
void CText::SetColor(DWORD color)
{
	m_dwColour = color;

	logprintf("color %d", color);

	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	for(EntityId i = 0; i < MAX_PLAYERS; i++) {
		if(pPlayerManager->GetSlotState(i)) {
			BitStream bsSend;
			bsSend.Write(m_iID);
			bsSend.Write(color);
			pNetowkManager->GetRPC4()->Call("Script_SetTextColor", &bsSend, HIGH_PRIORITY, RELIABLE, 0, pNetowkManager->GetRakPeer()->GetSystemAddressFromIndex(i), 0);
		}
	}
}
예제 #14
0
//---------------------------------------------------
// joinDecline :
//---------------------------------------------------
void CTeamManager::joinDecline( const NLMISC::CEntityId &charId)
{
	CCharacter * invited = PlayerManager.getOnlineChar(charId);
	if ( invited == NULL )
	{
		nlwarning("<CTeamManager joinDecline>Invalid char %s",charId.toString().c_str());
		return;
	}
	invited->setAfkState(false);
	if ( invited->getTeamInvitor() == CEntityId::Unknown )
	{
		nlwarning("<CTeamManager joinDecline>character %s has an Invalid invitor",charId.toString().c_str());
		return;
	}

	//inform both players
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);	
	params[0].setEIdAIAlias( charId, CAIAliasTranslator::getInstance()->getAIAlias( charId) );
	PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(invited->getTeamInvitor()), "TEAM_DECLINE", params);
	
	params[0].setEIdAIAlias( invited->getTeamInvitor(), CAIAliasTranslator::getInstance()->getAIAlias( invited->getTeamInvitor() ) );
	PHRASE_UTILITIES::sendDynamicSystemMessage(invited->getEntityRowId(), "TEAM_YOU_DECLINE", params);

	//cancel the proposal
	invited->setTeamInvitor( CEntityId::Unknown );
} // joinDecline //
예제 #15
0
//-----------------------------------------------
// CFaberPhrase execute
//-----------------------------------------------
void  CFaberPhrase::execute()
{
	H_AUTO(CFaberPhrase_execute);

	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (!player)
		return;

	const CStaticBrick * plan = CSheets::getSBrickForm( player->getCraftPlan() );
	if( plan == 0 )
	{
		nlwarning("<CFaberPhrase::execute> Can't found static form of craft plan %s", player->getCraftPlan().toString().c_str() );
		return;
	}

	/// set Faber time if not set (default is 2 sec)
	if ( !_FaberTime)
	{
		_FaberTime = (NLMISC::TGameCycle)(plan->CraftingDuration * 10);
	}
	nldebug("CFaberPhrase::execute> _FaberTime = %d",_FaberTime);

	const NLMISC::TGameCycle time = CTickEventHandler::getGameCycle();

	_ExecutionEndDate  = time + _FaberTime ;

	player->setCurrentAction(CLIENT_ACTION_TYPE::Faber,_ExecutionEndDate);
	player->staticActionInProgress(true);

	// set behaviour
	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::FABER );
}// CFaberPhrase execute
예제 #16
0
//-----------------------------------------------
// CTimedActionPhrase execute
//-----------------------------------------------
void  CTimedActionPhrase::execute()
{
    _ExecutionEndDate = CTickEventHandler::getGameCycle() + _ExecutionDuration;

    CCharacter* player = PlayerManager.getChar(_ActorRowId);
    if (player)
    {
        if (_IsStatic)
        {
            switch( _ActionType )
            {
            case CLIENT_ACTION_TYPE::Mount :
                player->staticActionInProgress(true, STATIC_ACT_TYPES::Mount);
                break;
            default:
                player->staticActionInProgress(true, STATIC_ACT_TYPES::Teleport);
            }
        }
        else
            player->cancelStaticActionInProgress();

        player->setCurrentAction(_ActionType, _ExecutionEndDate);
        if (_RootSheetId != CSheetId::Unknown)
        {
//			player->_PropertyDatabase.setProp( "EXECUTE_PHRASE:SHEET", _RootSheetId.asInt() );
            CBankAccessor_PLR::getEXECUTE_PHRASE().setSHEET(player->_PropertyDatabase, _RootSheetId);
//			player->_PropertyDatabase.setProp( "EXECUTE_PHRASE:PHRASE", 0 );
            CBankAccessor_PLR::getEXECUTE_PHRASE().setPHRASE(player->_PropertyDatabase, 0);
        }
    }
}// CTimedActionPhrase execute
//-----------------------------------------------
// CHarvestPhrase end
//-----------------------------------------------
void CHarvestPhrase::end()
{
	H_AUTO(CHarvestPhrase_end);
	
	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (player)
	{
		player->clearCurrentAction();
	}

	vector<uint16> qualities;

	// set behaviour no! -> set it when closing interface
//	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::LOOT_END );

	/*if (_Deposit) // obsolete (now done by the foraging actions)
	{
		//player->harvestResultDeposit( _MinQuality, false);
		//player->harvestDepositResult( max(_MinQuality,uint16(1)) );
		player->harvestDepositResult( max( (uint16)( rand() * ( _MaxQuality * 10  - _MinQuality * 10) / RAND_MAX + _MinQuality * 10 ), uint16(1)) );
	}
	else*/
		//harvestCorpseResult();
		player->harvestCorpseResult( qualities );

} // end //
//--------------------------------------------------------------
//		CModDefenseEffect::removed()
//--------------------------------------------------------------
void CModDefenseEffect::removed()
{
	// reset modifier to it's old value
	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		nlwarning("Cannot find target entity %s", _TargetRowId.toString().c_str());
		return;
	}
	
	switch( _Family )
	{
		case EFFECT_FAMILIES::PowerModDodgeSkill:
			player->incDodgeModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->dodgeSuccessModifier( 0 );
			break;
		case EFFECT_FAMILIES::PowerModParrySkill:
			player->incParryModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->parrySuccessModifier( 0 );
			break;
		case EFFECT_FAMILIES::PowerModDefenseSkill:
			player->incDodgeModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->incParryModifier( -(sint32)(_Modifier1 + _Modifier2) );
			player->dodgeSuccessModifier( 0 );
			player->parrySuccessModifier( 0 );
			break;
		default:
			break;
	}
}
예제 #19
0
//-----------------------------------------------
// CTimedActionPhrase end
//-----------------------------------------------
void CTimedActionPhrase::end()
{
    CCharacter* player = PlayerManager.getChar(_ActorRowId);
    if (player)
    {
        player->clearCurrentAction();
    }
} // end //
예제 #20
0
void ServerJoin(RakNet::BitStream *bitStream, Packet *packet)
{
	CPlayerManager *pPlayerManager = pNetowkManager->GetPlayerManager();
	CHAR szPlayerName[MAX_PLAYER_NAME];
	EntityId playerID;
	UINT uiNameLength;

	memset(szPlayerName,0,MAX_PLAYER_NAME);

	bitStream->Read(playerID);
	bitStream->Read(uiNameLength);
	bitStream->Read(szPlayerName,uiNameLength);
	szPlayerName[uiNameLength] = '\0';

	// Add this client to the player pool.
	pPlayerManager->New(playerID, szPlayerName);
}
예제 #21
0
void AddNetworkPlayer(char * szParams)
{
	// Get our player manager
	CPlayerManager * pPlayerManager = g_pClient->GetPlayerManager();

	EntityId playerId = -1;
	for(EntityId i = 0; i < MAX_PLAYERS; i++) {
		if(!pPlayerManager->DoesExist(i)) {
			playerId = i;
			break;
		}
	}

	if(playerId != -1) {
		// Add the player to the player manager
		pPlayerManager->Add(playerId, "IV:MP NetworkPlayer");
		if(pPlayerManager->DoesExist(playerId)) {
			CVector3 vecPos; g_pClient->GetLocalPlayer()->GetPosition(vecPos);
			pPlayerManager->GetAt(playerId)->SetColor((unsigned int)0xFFFFFFAA);
			pPlayerManager->GetAt(playerId)->SetPosition(vecPos);
			pPlayerManager->GetAt(playerId)->SetModel(7);
			g_pClient->GetChatWindow()->AddInfoMessage("Networkplayer Added");
		}
	}
	else
		g_pClient->GetChatWindow()->AddInfoMessage("Couldn't find free player slot..");
}
예제 #22
0
unsigned int __stdcall CPlayerManager::HelperThreadFunction( void *pV )
{
	int result = 0;

	CPlayerManager* pThis = ( CPlayerManager * )pV;
   
	if ( pThis )
	{
		try
		{
			result = pThis->Helper();
		}
		catch( ... )
		{
		}
	}

	return result;
}
예제 #23
0
//-----------------------------------------------
// CTimedActionPhrase stop
//-----------------------------------------------
void CTimedActionPhrase::stop()
{
    CCharacter* player = PlayerManager.getChar(_ActorRowId);
    if (player)
    {
        player->clearCurrentAction();
        if (_TimedAction != NULL)
            _TimedAction->stopAction(this, player);
    }
} // stop //
//--------------------------------------------------------------
//					apply()  
//--------------------------------------------------------------
void CSpecialPowerBasic::apply()
{
	if (!_Phrase)
		return;

	CCharacter *actor = PlayerManager.getChar(_ActorRowId);
	if (!actor)
	{
		nlwarning("<CSpecialPowerBasic::apply> Cannot find actor entity or not a player");
		return;
	}

	// disable power
	actor->forbidPower(_PowerType, _Phrase->getConsumableFamilyId(), CTickEventHandler::getGameCycle() + _DisablePowerTime + _Duration);

	// create effect and apply it on actor
	const TGameCycle endDate = _Duration + CTickEventHandler::getGameCycle();
	
	CSTimedEffect *effect = IEffectFactory::buildEffect(_EffectFamily);
	if (effect)
	{
		effect->setCreatorRowId(_ActorRowId);
		effect->setFamily(_EffectFamily);
		effect->setTargetRowId(_ActorRowId);
		effect->setParamValue(_ParamValue);
		effect->setEndDate(endDate);
		
		actor->addSabrinaEffect(effect);
	}
	else
		return;

	// send messages
//	TVectorParamCheck params;
	// for actor
	if (actor->getId().getType() == RYZOMID::player)
	{
		SM_STATIC_PARAMS_1(params, STRING_MANAGER::power_type);
		params[0].Enum = _PowerType;
		PHRASE_UTILITIES::sendDynamicSystemMessage(_ActorRowId, "POWER_USE", params);
	}

	// for spectators
//	{
//		vector<CEntityId> excluded;
//		excluded.push_back(actor->getId());
//
//		params.resize(2);
//		params[0].Type = STRING_MANAGER::entity;
//		params[0].EId = actor->getId();
//		params[1].Type = STRING_MANAGER::power_type;
//		params[1].Enum = _PowerType;
//		PHRASE_UTILITIES::sendDynamicGroupSystemMessage(_ActorRowId, excluded, "POWER_USE_SPECTATORS", params);
//	}
} // apply //
예제 #25
0
//--------------------------------------------------------------
void CModMagicProtectionEffect::removed()
{
	// reset modifier to it's old value
	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		nlwarning("Cannot find target entity %s", _TargetRowId.toString().c_str());
		return;
	}
	player->setUnclampedMagicProtection( _AffectedProtection, player->getUnclampedMagicProtection(_AffectedProtection) - _Modifier1 - _Modifier2 );
}
예제 #26
0
//--------------------------------------------------------------
//		removed
//--------------------------------------------------------------
void CModCraftSuccessEffect::removed()
{
	// reset modifier to it's old value
	CCharacter *player = PlayerManager.getChar(_TargetRowId);
	if (!player)
	{
		nlwarning("Cannot find target entity %s", _TargetRowId.toString().c_str());
		return;
	}

	player->craftSuccessModifier( 0 );
}
예제 #27
0
void InitGame(RakNet::BitStream *bitStream, Packet *packet)
{
	CPlayerManager *pPlayerManager = pNetowkManager->GetPlayerManager();
	EntityId myPlayerID;

	bitStream->Read((char *)&pNetowkManager->m_vecInitPlayerPos, sizeof(Vector3));
	bitStream->Read((char *)&pNetowkManager->m_vecInitCameraPos, sizeof(Vector3));
	bitStream->Read((char *)&pNetowkManager->m_vecInitCameraLook, sizeof(Vector3));
	bitStream->Read(pNetowkManager->m_WorldBounds[0]);
	bitStream->Read(pNetowkManager->m_WorldBounds[1]);
	bitStream->Read(pNetowkManager->m_WorldBounds[2]);
	bitStream->Read(pNetowkManager->m_WorldBounds[3]);
	bitStream->Read(pNetowkManager->m_byteFriendlyFire);
	bitStream->Read(pNetowkManager->m_byteShowOnRadar);
	bitStream->Read(myPlayerID);

	pPlayerManager->SetLocalPlayerID(myPlayerID);

	pGame->FadeScreen(1, 0);
	pNetowkManager->InitGameLogic();
	pNetowkManager->SetGameState(GAMESTATE_CONNECTED);
}
예제 #28
0
void InflictDamage(RakNet::BitStream * bitStream, Packet * packet)
{
	CPlayerManager * pPlayerManager = pNetowkManager->GetPlayerManager();
	CVehicleManager * pVehicleManager = pNetowkManager->GetVehicleManager();
	EntityId playerID;
	bool bPlayerVehicleDamager;
	EntityId damagerID;
	int iWeapon;
	float fUnk;
	int iPedPieces;
	BYTE byteUnk;

	bitStream->Read(playerID);

	if(!pVehicleManager->GetAt(playerID))
	{
		return;
	}

	bPlayerVehicleDamager = bitStream->ReadBit();
	bitStream->Read(damagerID);

	if((bPlayerVehicleDamager && !pPlayerManager->GetSlotState(damagerID)) || (!bPlayerVehicleDamager && !pVehicleManager->GetSlotState(damagerID)))
	{
		return;
	}

	bitStream->Read(iWeapon);
	bitStream->Read(fUnk);
	bitStream->Read(iPedPieces);
	bitStream->Read(byteUnk);

	CRemotePlayer * pPlayer = pPlayerManager->GetAt(playerID);

	if(pPlayer)
	{
		pPlayer->InflictDamage(bPlayerVehicleDamager, damagerID, iWeapon, fUnk, iPedPieces, byteUnk);
	}
}
예제 #29
0
void CPerPlayerEntity::BroadcastOnlyVisible(const CPacket& Packet)
{
    // Are we synced? (if not we're not visible to anybody)
    if (m_bIsSynced)
    {
        CPlayerManager* pPlayerManager = g_pGame->GetPlayerManager();
        for (std::set<CPlayer*>::iterator iter = m_Players.begin(); iter != m_Players.end();)
        {
            if (!pPlayerManager->Exists(*iter))
            {
                // Why does this happen?
                // CLogger::ErrorPrintf( "CPerPlayerEntity removed invalid player from list: %08x", *iter );
                m_Players.erase(iter++);
            }
            else
                ++iter;
        }

        // Send it to all players we're visible to
        CPlayerManager::Broadcast(Packet, m_Players);
    }
}
예제 #30
0
//-----------------------------------------------
// CFaberPhrase end
//-----------------------------------------------
void CFaberPhrase::end()
{
	H_AUTO(CFaberPhrase_end);

	CCharacter* player = PlayerManager.getChar(_ActorRowId);
	if (!player)
		return;

	player->unlockFaberRms();
	player->clearCurrentAction();
	player->staticActionInProgress(false);
	//player->sendCloseTempInventoryImpulsion();

	// set behaviour
	PHRASE_UTILITIES::sendUpdateBehaviour( _ActorRowId, MBEHAV::FABER_END );
} // end //