//----------------------------------------------------------------------------
void cbClientBotChatPickStaticMission( NLNET::CMessage& msgin, const std::string &serviceName, NLNET::TServiceId serviceId )
{
    if ( !MissionSystemEnabled )
        return;
    CEntityId userId;
    uint8 index;
    msgin.serial(userId);
    msgin.serial(index);
    //get the user and the asked mission
    if (!checkPlayer(userId, "cbClientBotChatPickStaticMission")) return;
    CCharacter	* user = PlayerManager.getChar( userId );

    // Create the debug string
    string sDebugPrefix = string("user:"******" cbClientBotChatPickStaticMission :";

    // Check for user
    if ( user == NULL )
    {
        MISLOG("%s cant find user.", sDebugPrefix.c_str());
        return;
    }

    // Check that index falls in good range
    if ( index >= user->getCurrentMissionList().size() )
    {
        MISLOG("%s invalid index %u, there are %u", sDebugPrefix.c_str(), index, user->getCurrentMissionList().size() );
        return;
    }

    // Check if the user is not cheating (trying to get a mission grayed)
    if ( user->getCurrentMissionList()[index].PreReqState != MISSION_DESC::PreReqSuccess)
    {
        MISLOG("%s user choose a mission with failed prerequesit (index %u)", sDebugPrefix.c_str(), index);
        return;
    }

    CCreature * bot = CreatureManager.getCreature( user->getCurrentInterlocutor() );
    if (!bot || bot->getAlias() == CAIAliasTranslator::Invalid )
    {
        MISLOG("%s invalid interlocutor", sDebugPrefix.c_str());
        return;
    }

    // End the user bot chat (must be done before instanciateMission() because it would clear any dynchat's interlocutor open by the mission
    user->endBotChat();
    user->setAfkState(false);

    std::list< CMissionEvent* > eventList;
    CMissionManager::getInstance()->instanciateMission(user, user->getCurrentMissionList()[index].Mission,
            bot->getAlias(), eventList);
    user->processMissionEventList( eventList,true, CAIAliasTranslator::Invalid );
}
示例#2
0
	uint processEvent( const TDataSetRow & userRow, const CMissionEvent & event,uint subStepIndex,const TDataSetRow & giverRow )
	{
		if ( event.Type == CMissionEvent::Kill )
		{
			CMissionEventKill & eventSpe = (CMissionEventKill&)event;
			CCreature * c = CreatureManager.getCreature( event.TargetEntity );
			if ( !c )
			{
				LOGMISSIONSTEPERROR("kill_npc : invalid creature " + toString(event.TargetEntity.getIndex()));
			}
			else
			{
				if ( _SubSteps[subStepIndex].Alias != CAIAliasTranslator::Invalid )
				{
					if ( _SubSteps[subStepIndex].Alias == c->getAlias() )
					{
						LOGMISSIONSTEPSUCCESS("kill_npc");
						return 1;
					}
				}
				else if (  event.TargetEntity == giverRow )
				{
					LOGMISSIONSTEPSUCCESS("kill_npc");
					return 1;
				}
			}
		}
		return 0;
	}
示例#3
0
	uint processEvent( const TDataSetRow & userRow, const CMissionEvent & event,uint subStepIndex,const TDataSetRow & giverRow )
	{
		if ( event.Type == CMissionEvent::Kill )
		{
			CMissionStepKillByName & eventSpe = (CMissionStepKillByName&)event;
			CCreature * c = CreatureManager.getCreature( event.TargetEntity );
			if ( !c )
			{
				LOGMISSIONSTEPERROR("kill_npc_by_name : invalid creature " + toString(event.TargetEntity.getIndex()));
			}
			else
			{
				if ( (GroupKill && Aliases.find(c->getAIGroupAlias()) != Aliases.end())
					|| Aliases.find( c->getAlias() ) != Aliases.end() )
				{
					if ( Place != 0xFFFF )
					{
						float gooDistance;
						const CPlace * stable = NULL;
						std::vector<const CPlace *> places;
						const CRegion * region = NULL;
						const CContinent * continent = NULL;
						if ( !CZoneManager::getInstance().getPlace( c->getState().X, c->getState().Y, gooDistance, &stable, places, &region , &continent ) )
							return 0;
						if ( continent && continent->getId() == Place )
						{
							LOGMISSIONSTEPSUCCESS("kill_npc_by_name");
							return 1;
						}
						if ( region && region->getId() == Place )
						{
							LOGMISSIONSTEPSUCCESS("kill_npc_by_name");
							return 1;
						}
						for ( uint i = 0; i < places.size(); i++ )
						{
							if ( places[i] && places[i]->getId() == Place )
							{
								LOGMISSIONSTEPSUCCESS("kill_npc_by_name");
								return 1;
							}
						}
						return 0;
					}
					else
					{
						LOGMISSIONSTEPSUCCESS("kill_npc_by_name");
						return 1;
					}
				}
			}
		}
		return 0;
	}