//----------------------------------------------------------------------------
void cbClientGroupAbandonMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    CEntityId userId;
    uint8 index;
    msgin.serial(userId,index);

    if (!checkPlayer(userId, "cbClientGroupAbandonMission")) return;
    CCharacter * user = PlayerManager.getChar( userId );

    user->setAfkState(false);
    CTeam * team = TeamManager.getRealTeam( user->getTeamId() );
    if ( !team )
    {
        MISLOG("user:%s cbClientGroupAbandonMission : Invalid team", userId.toString().c_str());
        return;
    }
    if ( team->getLeader() != userId )
    {
        CCharacter::sendDynamicSystemMessage( user->getEntityRowId(), "REQ_LEADER_TO_ABANDON_MISSION" );
        return;
    }

    if ( index >=  team->getMissions().size() )
    {
        MISLOG("user:%s cbClientGroupAbandonMission : Invalid group mission %u ( count %u )",
               userId.toString().c_str(), index, team->getMissions().size());
        return;
    }


    CMissionTeam* mission = team->getMissions()[index];
    nlassert(mission);

    if ( mission->getFinished() == false )
    {
        CMissionTemplate * templ = CMissionManager::getInstance()->getTemplate( mission->getTemplateId() );
        if ( !templ )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : invalid group mission alias %u",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }
        if ( templ->Tags.NonAbandonnable )
        {
            MISLOG("user:%s cbClientGroupAbandonMission : group mission alias %u is not abandonnable but user tries to abandon it",
                   userId.toString().c_str(), mission->getTemplateId());
            return;
        }
        set<CEntityId> excluded;
        excluded.insert( userId );

        team->sendDynamicMessageToMembers( "ABANDON_GROUP_MISSION",TVectorParamCheck(), excluded );
    }
    team->removeMission( index, mr_abandon );
}
Exemple #2
0
//---------------------------------------------------
// PvP help occurs in a team
//---------------------------------------------------
void CTeamManager::pvpHelpOccursInTeam( CCharacter * actor, CCharacter * target )
{
	return;
	nlassert( actor );
	nlassert( target);
	CTeam * team = getRealTeam( actor->getTeamId() );
	if ( team != NULL )
	{
		//check if actor and target is not in same team
		if( actor->getTeamId() != target->getTeamId() )
		{
			// check if attack is in PvP faction context
			if( actor->getPVPFlag() && target->getPVPFlag() )
			{
				if( CPVPManager2::getInstance()->isFactionInWar( actor->getAllegiance().first ) || CPVPManager2::getInstance()->isFactionInWar( actor->getAllegiance().second ) )
				{
					// help is made in PvP faction context, on an external character of team
			
					// inform the kicked player
					SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);	
					params[0].setEIdAIAlias( actor->getId(), CAIAliasTranslator::getInstance()->getAIAlias( actor->getId() ) );
					PHRASE_UTILITIES::sendDynamicSystemMessage(actor->getEntityRowId(), "TEAM_PVP_HELPER_KICKED_YOU", params);
					
					// inform other team members
					SM_STATIC_PARAMS_2(params2, STRING_MANAGER::player, STRING_MANAGER::player);	
					params2[0].setEIdAIAlias( actor->getId(), CAIAliasTranslator::getInstance()->getAIAlias( actor->getId() ) );
					params2[1].setEIdAIAlias( target->getId(), CAIAliasTranslator::getInstance()->getAIAlias( target->getId() ) );
					set<CEntityId> exclude;
					exclude.insert( actor->getId() );
					team->sendDynamicMessageToMembers("TEAM_PVP_HELPER_KICKED", params2, exclude);

					//  remove the kicked player from team	
					removeCharacter( actor->getId() );
				}
			}
		}
	}
}
Exemple #3
0
//---------------------------------------------------
// removeCharacter :
//---------------------------------------------------
void CTeamManager::removeCharacter( const CEntityId &charId )
{
	CCharacter * player = PlayerManager.getOnlineChar( charId );
	if ( player == NULL )
	{
		nlwarning("<CTeamManager removeCharacter> Player %s is invalid", charId.toString().c_str() );
		return;
	}
	player->setAfkState(false);
	CTeam * team = getRealTeam( player->getTeamId() );	
	if ( team == NULL )
	{
		nlwarning("<CTeamManager removeCharacter> Player %s has an invalid team id %d", charId.toString().c_str(), player->getTeamId() );
		return;
	}

	uint16 nbMembers = team->getTeamSize();
	// send message to former member
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);
	if (nbMembers > 2)
	{
		if (charId != team->getLeader())
		{
			params[0].setEIdAIAlias( team->getLeader(), CAIAliasTranslator::getInstance()->getAIAlias(team->getLeader()) );
			PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE", params);
		}
		else
		{
			const list<CEntityId> &members = team->getTeamMembers();
			
			CEntityId eId(team->getSuccessor());
			params[0].setEIdAIAlias( eId, CAIAliasTranslator::getInstance()->getAIAlias(eId) );
			PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE_LEADER", params);
		}
	}
	else if(nbMembers==2)
	{
		params[0].setEIdAIAlias( team->getLeader(), CAIAliasTranslator::getInstance()->getAIAlias(team->getLeader()) );
		PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(charId), "TEAM_YOU_LEAVE_DISOLVE", params);
	}

	// send message to all other team members
	params[0].setEIdAIAlias( charId, CAIAliasTranslator::getInstance()->getAIAlias(charId) );
	set<CEntityId> exclude;
	exclude.insert( charId );
	team->sendDynamicMessageToMembers("TEAM_LEAVE", params, exclude);

	// remove the player from his team
	team->removeCharacter( player );

	/*
	TGroupId groupId =CHAT_GROUPS_IDS::getTeamChatGroupId(player->getTeamId());
	string msgName = "OPS_LEAVE_TEAM_E";
	CMessage msggroup("STATIC_STRING");
	msggroup.serial( groupId );
	std::set<CEntityId> exclude;
	exclude.insert( charId );
	msggroup.serialCont( exclude);
	msggroup.serial( msgName );
	msggroup.serial( (CEntityId&) charId );
	sendMessageViaMirror( "IOS", msggroup );
	*/
} // removeCharacter //
Exemple #4
0
//---------------------------------------------------
// kickCharacter :
//---------------------------------------------------
void CTeamManager::kickCharacter( CCharacter * leader, uint8 memberIndex )
{
	// check must be done before
	nlassert(leader);
	const NLMISC::CEntityId & leaderId = leader->getId();
	
	// get the leader's team
	CTeam * team = getRealTeam( leader->getTeamId() );	
	if ( team == NULL )
	{
		nlwarning("<CTeamManager kickCharacter> Player %s has an invalid team id %d", leaderId.toString().c_str(), leader->getTeamId() );
		return;
	}
	// only leaders can kick
	if ( leaderId != team->getLeader() )
	{
		nlwarning("<CTeamManager kickCharacter> Player %s tries kicking but is not the leader", leaderId.toString().c_str() );
		return;
	}

	// increment the target index as the leader is not in its team list
	memberIndex++;
	const std::list< NLMISC::CEntityId >  & members = team->getTeamMembers();
	std::list< NLMISC::CEntityId >::const_iterator it = members.begin();
	uint i = 0;
	for (; i < memberIndex; i++ )
	{
		if ( it == members.end() )
		{
			nlwarning("<CTeamManager kickCharacter> Player %s kicks teammate %d but there are %d members", leaderId.toString().c_str(), memberIndex,i+1 );
			return;
		}
		++it;
	}
	if ( it == members.end() )
	{
		nlwarning("<CTeamManager kickCharacter> Player %s kicks teammate %d but there are %d members", leaderId.toString().c_str(), memberIndex,i+1 );
		return;
	}

	CCharacter * kickedChar = PlayerManager.getOnlineChar( (*it) );
	if ( kickedChar == NULL )
	{
		nlwarning("<CTeamManager kickCharacter> kicked Player %d is invalid", memberIndex );
		return;
	}


	// inform the kicked player
	SM_STATIC_PARAMS_1(params, STRING_MANAGER::player);	
	params[0].setEIdAIAlias( leaderId, CAIAliasTranslator::getInstance()->getAIAlias( leaderId ) );
	PHRASE_UTILITIES::sendDynamicSystemMessage(TheDataset.getDataSetRow(*it), "TEAM_KICKED_YOU", params);
	
	// inform other team members
	params[0].setEIdAIAlias( *it, CAIAliasTranslator::getInstance()->getAIAlias( *it ) );
	set<CEntityId> exclude;
	exclude.insert(*it);
	team->sendDynamicMessageToMembers("TEAM_KICKED", params, exclude);

	//  remove the kicked player from team	
	team->removeCharacter( kickedChar );

	leader->updateTarget();
	/*
	TGroupId groupId = CEntityId(RYZOMID::chatGroup, leader->getTeamId() + 1);
	string msgName = "OPS_KICKED_TEAM_E";
	CMessage msggroup("STATIC_STRING");
	msggroup.serial( groupId );
	std::set<CEntityId> exclude;
	exclude.insert(*it);
	msggroup.serialCont( exclude);
	msggroup.serial( msgName );
	msggroup.serial( (CEntityId&)(*it) );
	sendMessageViaMirror( "IOS", msggroup );
	*/

	CMissionManager::getInstance()->updateEscortTeam( kickedChar->getId() );
	
}// kickCharacter