示例#1
0
	virtual void getTextParams( uint & nbSubSteps, const std::string* & textPtr,TVectorParamCheck& retParams, const std::vector<uint32>& subStepStates)
	{
		static const std::string stepTextNoLoc = "MIS_KILL_NPC_BY_NAME";
		static const std::string stepTextLoc = "MIS_KILL_NPC_BY_NAME_LOC";
		if ( Place != 0xFFFF )
			retParams.resize(3);
		else
			retParams.resize(2);
		retParams[0].Type = STRING_MANAGER::bot_name;
		retParams[0].Identifier = TargetName;
		retParams[1].Type = STRING_MANAGER::integer;
		nlassert( subStepStates.size() == 1 );
		retParams[1].Int = subStepStates[0];
		if ( Place != 0xFFFF )
		{
			CPlace * place = CZoneManager::getInstance().getPlaceFromId( Place );
			if ( !place )
			{
				MISLOG("sline:%u ERROR : kill_npc_by_name : invalid place %u", _SourceLine, Place);
			}
			else
			{
				retParams[2].Type = STRING_MANAGER::place;
				retParams[2].Identifier = place->getName();
				textPtr = &stepTextLoc;
			}
		}
		else
			textPtr = &stepTextNoLoc;

	}
示例#2
0
//----------------------------------------------------------------------------
void CMissionStepQueueStart::getTextParams( uint & nbSubSteps,const std::string* & textPtr,TVectorParamCheck& retParams, const std::vector<uint32>& subStepStates)
{
	// get estimated remaining time
	uint32 days, hours, minutes, seconds;
	getDHMS(uint32(Timer*(_HasPlayerInCriticalZone?1+_NbOnlineWaiters:_NbOnlineWaiters)*CTickEventHandler::getGameTimeStep()),
		days, hours, minutes, seconds);
	
	static const std::string stepText = "MISSION_QUEUE_WAIT";
	textPtr = &stepText;
	nlassert( subStepStates.size() == 1);
	retParams.push_back(STRING_MANAGER::TParam());
	retParams.back().Type = STRING_MANAGER::integer;
	retParams.back().Int = _NbWaiters;
	
	retParams.push_back(STRING_MANAGER::TParam());
	retParams.back().Type = STRING_MANAGER::integer;
	retParams.back().Int = _NbOnlineWaiters;

	retParams.push_back(STRING_MANAGER::TParam());
	retParams.back().Type = STRING_MANAGER::integer;
	retParams.back().Int = days;

	retParams.push_back(STRING_MANAGER::TParam());
	retParams.back().Type = STRING_MANAGER::integer;
	retParams.back().Int = hours;

	retParams.push_back(STRING_MANAGER::TParam());
	retParams.back().Type = STRING_MANAGER::integer;
	retParams.back().Int = minutes;
}
示例#3
0
	virtual void getTextParams( uint & nbSubSteps,const std::string* & textPtr,TVectorParamCheck& retParams, const std::vector<uint32>& subStepStates)
	{
		static const std::string stepText = "MIS_KILL_FACTION";
		static const std::string stepTextLoc = "MIS_KILL_FACTION_LOC";
		nlassert( subStepStates.size() == 1);

		nbSubSteps = 1;
		retParams.push_back(STRING_MANAGER::TParam(STRING_MANAGER::faction));
		retParams.back().Enum = _Faction;
		retParams.push_back(STRING_MANAGER::TParam(STRING_MANAGER::integer, sint32(_Quantity)));
				
		if ( _Place != 0xFFFF )
		{
			STRING_MANAGER::TParam param;
			param.Type = STRING_MANAGER::place;
			CPlace * place = CZoneManager::getInstance().getPlaceFromId(_Place);
			if ( !place )
			{
				MISLOG("sline:%u ERROR : kill_faction : invalid place %u", _SourceLine, _Place);
			}
			else
			{
				param.Identifier = place->getName();
				retParams.push_back(param);
			}
			textPtr = &stepTextLoc;
		}
		else
			textPtr = &stepText;
		
	}
bool CMissionParser::solveTextsParams(uint32 lineNum, TVectorParamCheck & txtParams, CMissionSpecificParsingData & missionData  )
{
	if (  txtParams.empty() )
		return true;
	std::vector< std::pair< std::string, STRING_MANAGER::TParamType> > & paramTypes = missionData.ChatParams;
	bool ret = true;
	for ( uint i = 0; i < txtParams.size(); i++ )
	{
		std::map< std::string, uint >::iterator itInt = missionData.Integers.find( txtParams[i].Identifier );
		if ( itInt != missionData.Integers.end() )
		{
			txtParams[i].Identifier.clear();
			txtParams[i].Type = STRING_MANAGER::integer;
			txtParams[i].Int = (*itInt).second;
		}
		// if it is a bot name param
		else if ( txtParams[i].Identifier.size() > 2 && txtParams[i].Identifier[0] =='\"' &&  txtParams[i].Identifier[ txtParams[i].Identifier.size() - 1] =='\"' )
		{
			// remove quotes
			txtParams[i].Identifier.erase(txtParams[i].Identifier.begin());
			//txtParams[i].Identifier.pop_back();
			txtParams[i].Identifier.resize(txtParams[i].Identifier.size()-1);
			txtParams[i].Type = STRING_MANAGER::bot_name;
		}
		else
		{
			uint j = 0;
			for (; j < paramTypes.size(); j++ )
			{
				if ( txtParams[i].Identifier == paramTypes[j].first )
				{
					txtParams[i].Identifier.clear();
					if ( !fillTextParam( txtParams[i],paramTypes[j].first,paramTypes[j].second ) )
					{
						MISLOG("<MISSIONS> at line %u: param '%s' could not be parsed", lineNum, paramTypes[j].first.c_str());
						ret = false;
					}
					break;
				}
			}
			if ( j == paramTypes.size() )
			{
				txtParams[i].Type = STRING_MANAGER::integer;
				NLMISC::fromString( txtParams[i].Identifier, txtParams[i].Int);
				if ( txtParams[i].Int == 0 && txtParams[i].Identifier != "0" )
				{
					MISLOG("<MISSIONS> at line %u: param '%s' has an unknown type", lineNum, txtParams[i].Identifier.c_str());
					ret = false;
				}
				txtParams[i].Identifier.clear();
			}
		}
	}
	return ret;
}// CMissionTemplate::solveTextsParams
示例#5
0
	virtual void getTextParams( uint & nbSubSteps, const std::string* & textPtr,TVectorParamCheck& retParams, const std::vector<uint32>& subStepStates)
	{
		/// overloaded text in script

		static const std::string stepText = "MIS_KILL_GROUP";
		textPtr = &stepText;
		retParams.push_back(STRING_MANAGER::TParam(STRING_MANAGER::bot_name));
		retParams.back().Type = STRING_MANAGER::bot_name;
		retParams.back().Identifier = Target;

	}
//--------------------------------------------------------------
//		CCombatStunEffect::removed()
//--------------------------------------------------------------
void CCombatStunEffect::removed()
{
	if (!_StunnedEntity) return;

	// returns if entity already dead
	if (_StunnedEntity->isDead())
		return;

	DEBUGLOG("COMBAT EFFECT: stun effect ends on entity %s", _StunnedEntity->getId().toString().c_str());

	// if this is the last STUN effect on target, then wake it
	const std::vector<CSEffect*>& effects = _StunnedEntity->getSEffects();
	for (uint i = 0 ; i < effects.size() ; ++i)
	{
		if (effects[i] && effects[i] != this && (effects[i]->getFamily() == EFFECT_FAMILIES::Stun || effects[i]->getFamily() == EFFECT_FAMILIES::CombatStun) )
		{
			DEBUGLOG("COMBAT EFFECT : entity is still stunned (has another stun effect)");
			return;
		}
	}

	// wake entity
	_StunnedEntity->wake();
	DEBUGLOG("COMBAT EFFECT : was last stun effects on this entity, wake it");

	CEntityId actorId;
	if (TheDataset.isDataSetRowStillValid(_CreatorRowId))
		actorId = TheDataset.getEntityId(_CreatorRowId);

	// send message
//	PHRASE_UTILITIES::sendSimpleMessage( _TargetRowId, "OPS_EFFECT_STUN_END" );
//	PHRASE_UTILITIES::sendMessage( _CreatorRowId, "OPS_EFFECT_STUN_END_E", _TargetRowId );

	TVectorParamCheck params;

	if (_StunnedEntity->getId().getType() == RYZOMID::player)
	{
		PHRASE_UTILITIES::sendDynamicSystemMessage(_StunnedEntity->getEntityRowId(), "EFFECT_STUN_END_TARGET");
	}

	if ( actorId.getType() == RYZOMID::player)
	{
		params.resize(1);
		params[0].Type = STRING_MANAGER::entity;
		params[0].EId = _StunnedEntity->getId();

		PHRASE_UTILITIES::sendDynamicSystemMessage(_CreatorRowId, "EFFECT_STUN_END_ACTOR", params);
	}
	// todo spectators and self stun
} // removed //
示例#7
0
	virtual void getTextParams( uint & nbSubSteps, const std::string* & textPtr,TVectorParamCheck& retParams, const std::vector<uint32>& subStepStates)
	{
		static const std::string stepText = "MIS_KILL_NPC_";
		textPtr = &stepText;
		nlassert( _SubSteps.size() == subStepStates.size() );
		for ( uint i  = 0; i < subStepStates.size(); i++ )
		{
			if( subStepStates[i] != 0 )
			{
				nbSubSteps++;
				retParams.push_back(STRING_MANAGER::TParam());
				retParams.back().Type = STRING_MANAGER::bot;
				if ( _SubSteps[i].Alias != CAIAliasTranslator::Invalid )
					retParams.back().Int = _SubSteps[i].Alias;
				else
					retParams.back().Identifier = "giver";
			}
		}
	}
uint32 IMissionStepTemplate::sendRpStepText(CCharacter * user,const std::vector<uint32>& stepStates,const NLMISC::CEntityId & giver)
{
	TVectorParamCheck params;
	string buffer;
	uint nbSteps = 0;
	const std::string* textPtr = NULL;

	_User = user;

	if ( !_RoleplayText.empty() )
	{
		// build the param list
		getTextParams(nbSteps,(const std::string *&)textPtr,params,stepStates);

		params.reserve(params.size() + _AdditionalParams.size());
		params.insert(params.end(), _AdditionalParams.begin(), _AdditionalParams.end());
		if ( textPtr && !textPtr->empty() && (*textPtr)[textPtr->size()-1] == '_' )
		{
			buffer = _RoleplayText + "_";
			textPtr = &buffer;
		}
		else
			textPtr = &_RoleplayText;
	}
	
	if( !textPtr )
		return 0;

	// solve dynamic names
	CMissionParser::solveEntitiesNames(params,user->getEntityRowId(),giver);

	// if the text was generated, compute its suffix
	if ( !textPtr->empty() && (*textPtr)[textPtr->size()-1] == '_' )
	{
		std::string text = NLMISC::toString( "%s%u", textPtr->c_str(),nbSteps );
		return STRING_MANAGER::sendStringToClient( user->getEntityRowId(),text,params);
	}
	else
		return STRING_MANAGER::sendStringToClient( user->getEntityRowId(),*textPtr,params);

}// IMissionStepTemplate::sendRpStepText
示例#9
0
	virtual void getTextParams( uint & nbSubSteps, const std::string* & textPtr,TVectorParamCheck& retParams, const std::vector<uint32>& subStepStates)
	{
		static const std::string stepText = "MIS_KILL_RACE_";
		static const std::string stepTextLoc = "MIS_KILL_RACE_LOC_";

		nlassert( _SubSteps.size() == subStepStates.size() );
		for ( uint i  = 0; i < subStepStates.size(); i++ )
		{
			if( subStepStates[i] != 0 )
			{
				nbSubSteps++;
				retParams.push_back(STRING_MANAGER::TParam());
				retParams.back().Type = STRING_MANAGER::race;
				retParams.back().Enum = (uint)_SubSteps[i].Race;
			
				retParams.push_back(STRING_MANAGER::TParam());
				retParams.back().Type = STRING_MANAGER::integer;
				retParams.back().Int = subStepStates[i];
			}
		}
		if ( _Place != 0xFFFF )
		{
			STRING_MANAGER::TParam param;
			param.Type = STRING_MANAGER::place;
			CPlace * place = CZoneManager::getInstance().getPlaceFromId(_Place);
			if ( !place )
			{
				MISLOG("sline:%u ERROR : kill_race : Invalid place %u", _SourceLine, _Place);
			}
			else
			{
				param.Identifier = place->getName();
				retParams.push_back(param);
			}
			textPtr = &stepTextLoc;
		}
		else
			textPtr = &stepText;
	}
void CMissionParser::solvePlayerName( TVectorParamCheck & params , const TDataSetRow & playerRow )
{
	CCharacter * user = PlayerManager.getChar(playerRow);
	if( !user )
	{
		nlwarning("<CMissionParser solvePlayerName>Invalid user %u",playerRow.getIndex());
		return;
	}
	for ( uint i = 0; i< params.size(); i++)
	{
		if ( params[i].Type == STRING_MANAGER::player  )
		{
			params[i].setEIdAIAlias( user->getId(), CAIAliasTranslator::getInstance()->getAIAlias(user->getId()) );
		}
	}
}
bool CMissionParser::parseParamText(uint32 line, const std::string & script,std::string & textId, TVectorParamCheck & textParams )
{
	vector< string > args;
	splitString(script,";",args);
	textId = CMissionParser::getNoBlankString(args[0]);
	if( textId.find_first_of(";:\t ,") != string::npos )
	{
		MISLOG("<MISSIONS> line %u: invalid text %s", line, textId.c_str() );
		return false;
	}
	textParams.resize( args.size() - 1 );
	for ( uint i = 1; i < args.size(); i++ )
	{
		CMissionParser::removeBlanks(args[i]);
		textParams[i-1].Identifier = args[i];
	}
	return true;
}
void CMissionParser::solveEntitiesNames( TVectorParamCheck & params , const TDataSetRow & playerRow,const NLMISC::CEntityId& giver )
{
	CCharacter * user = PlayerManager.getChar(playerRow);
	if( !user )
	{
		nlwarning("<CMissionParser solveEntitiesNames>Invalid user %u",playerRow.getIndex());
		return;
	}
	for ( uint i = 0; i< params.size(); i++)
	{
		if ( params[i].Type == STRING_MANAGER::player  )
		{
			params[i].setEIdAIAlias( user->getId(), CAIAliasTranslator::getInstance()->getAIAlias(user->getId()) );
		}
		else if ( params[i].Type == STRING_MANAGER::bot  )
		{
			if ( params[i].getEId() == NLMISC::CEntityId::Unknown )
			{
				if ( params[i].Identifier == "giver" )
				{
					params[i].setEIdAIAlias( giver, CAIAliasTranslator::getInstance()->getAIAlias(giver) );
				}
				else
				{
					params[i].setEIdAIAlias( CAIAliasTranslator::getInstance()->getEntityId( params[i].Int ), params[i].Int );
				}
			}
		}
		else if ( params[i].Type == STRING_MANAGER::string_id && params[i].Identifier == "$guild_name$" )
		{
			// resolve the player guild name
			/// todo guild mission
			/*
			CGuild *g = user->getGuild();
			if (g == NULL)
			{
				nlwarning("<CMissionParser solveEntitiesNames>No guild for user %u",playerRow.getIndex());
				return;
			}
			params[i].StringId = g->getNameId();
			*/
		}
	}
}
示例#13
0
uint32 IMissionStepTemplate::sendStepText(CCharacter * user,const std::vector<uint32>& stepStates,const NLMISC::CEntityId & giver)
{
	TVectorParamCheck params;
	string buffer;
	uint nbSteps = 0;
	const std::string* textPtr = NULL;

	_User = user;

	// build the param list
	getTextParams(nbSteps,(const std::string *&)textPtr,params,stepStates);
	
	// If the text is overriden, add the overide parameters
	if ( !_OverridenText.empty() )
	{
		if ( _AddDefaultParams )
		{
			params.reserve(params.size() + _AdditionalParams.size());
			params.insert(params.end(), _AdditionalParams.begin(), _AdditionalParams.end());
			if ( textPtr && !textPtr->empty() && (*textPtr)[textPtr->size()-1] == '_' )
			{
				buffer = _OverridenText + "_";
				textPtr = &buffer;
			}
			else
				textPtr = &_OverridenText;
		}
		else
		{
			params = _AdditionalParams;
			textPtr = &_OverridenText;
		}

	}

	if( !textPtr )
		return 0;

	// solve dynamic names
	CMissionParser::solveEntitiesNames(params,user->getEntityRowId(),giver);

	// if the text was generated, compute its suffix
	if ( !textPtr->empty() && (*textPtr)[textPtr->size()-1] == '_' )
	{
//		if( !isAny() )
		{
			std::string text = NLMISC::toString( "%s%u", textPtr->c_str(),nbSteps );
			return STRING_MANAGER::sendStringToClient( user->getEntityRowId(),text,params);
		}
//		else
//		{
//			std::string text = NLMISC::toString( "%s%u", textPtr->c_str(),nbSteps );
//			SM_STATIC_PARAMS_1(paramsAnyOr, STRING_MANAGER::dyn_string_id);
//			paramsAnyOr[0].StringId = STRING_MANAGER::sendStringToClient( user->getEntityRowId(),text,params);
//			return STRING_MANAGER::sendStringToClient( user->getEntityRowId(),"MISSION_GOAL_STEP_ANY_OR",paramsAnyOr);
//		}
	}
	else
	{
//		if( !isAny() )
		{
			return STRING_MANAGER::sendStringToClient( user->getEntityRowId(),*textPtr,params);
		}
//		else
//		{
//			SM_STATIC_PARAMS_1(paramsAnyOr, STRING_MANAGER::dyn_string_id);
//			paramsAnyOr[0].StringId = STRING_MANAGER::sendStringToClient( user->getEntityRowId(),*textPtr,params);
//			return STRING_MANAGER::sendStringToClient( user->getEntityRowId(),"MISSION_GOAL_STEP_ANY_OR",paramsAnyOr);
//		}
	}
}// IMissionStepTemplate::sendStepText