当前位置: 首页>>代码示例>>C++>>正文


C++ idDict::GetBool方法代码示例

本文整理汇总了C++中idDict::GetBool方法的典型用法代码示例。如果您正苦于以下问题:C++ idDict::GetBool方法的具体用法?C++ idDict::GetBool怎么用?C++ idDict::GetBool使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在idDict的用法示例。


在下文中一共展示了idDict::GetBool方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadFromDict

void CShop::LoadFromDict(const idDict& dict)
{
	// greebo: Assemble the difficulty prefix (e.g. "diff_0_")
	idStr diffPrefix = "diff_" + idStr(gameLocal.m_DifficultyManager.GetDifficultyLevel()) + "_";

	if (dict.GetBool("shop_skip","0") || dict.GetBool(diffPrefix + "shop_skip","0"))
	{
		// if skip flag is set, skip the shop
		_skipShop = true;

		// No need to parse any further, the shop will be skipped anyway
		return;
	}

	// Check for loot carry-over rules
	LoadLootRules(dict);

	// Check for an "all-difficulty" gold value
	if (dict.FindKey("shop_gold_start") != NULL)
	{
		SetGold(dict.GetInt("shop_gold_start"));
	}

	// Try to retrieve the starting gold for the given difficulty level
	if (dict.FindKey(diffPrefix + "shop_gold_start") != NULL)
	{
		SetGold(dict.GetInt(diffPrefix + "shop_gold_start"));
	}

	// items for sale
	AddItems(dict, "shopItem", _itemsForSale);

	// starting items (items that player already has
	AddItems(dict, "startingItem", _startingItems);
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:35,代码来源:Shop.cpp

示例2: InhibitEntitySpawn

/*
============
sdGameRulesStopWatch::InhibitEntitySpawn
============
*/
bool sdGameRulesStopWatch::InhibitEntitySpawn( idDict &spawnArgs ) const {
	if ( spawnArgs.GetBool( "noStopwatch" ) ) {
		return true;
	}

	return false;
}
开发者ID:,项目名称:,代码行数:12,代码来源:

示例3: CreateTimer

void CStimResponseCollection::CreateTimer(const idDict& args, const CStimPtr& stim, int index)
{
	CStimResponseTimer* timer = stim->GetTimer();

	timer->m_Reload = args.GetInt(va("sr_timer_reload_%u", index) , "-1");

	idStr str = args.GetString(va("sr_timer_type_%u", index), "");

	timer->m_Type = (str == "RELOAD") ? CStimResponseTimer::SRTT_RELOAD : CStimResponseTimer::SRTT_SINGLESHOT;
	
	args.GetString(va("sr_timer_time_%u", index), "0:0:0:0", str);

    TimerValue val = CStimResponseTimer::ParseTimeString(str);
	
	// if timer is actually set
	if (val.Time.Hour || val.Time.Minute || val.Time.Second || val.Time.Millisecond)
	{
		// TODO: Return a bool here so that the outer function knows not to add this to m_Stim in the collection?

		stim->AddTimerToGame();
		timer->SetTimer(val.Time.Hour, val.Time.Minute, val.Time.Second, val.Time.Millisecond);
		
		// timer starts on map startup by default, otherwise wait for start
		if (!args.GetBool(va("sr_timer_waitforstart_%u", index), "0"))
		{
			timer->Start(static_cast<unsigned long>(sys->GetClockTicks()));
		}
	}
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:29,代码来源:StimResponseCollection.cpp

示例4: ParseSpawnargs

void CInventoryItem::ParseSpawnargs(const idDict& spawnArgs)
{
	m_Persistent = spawnArgs.GetBool("inv_persistent", "0");
	m_LightgemModifier = spawnArgs.GetInt("inv_lgmodifier", "0");
	m_MovementModifier = spawnArgs.GetFloat("inv_movement_modifier", "1");
	m_FrobDistanceCap = spawnArgs.GetFloat("inv_frob_distance_cap", "-1");
	m_Icon = spawnArgs.GetString("inv_icon", "");
}
开发者ID:ProfessorKaos64,项目名称:tdm,代码行数:8,代码来源:InventoryItem.cpp

示例5: LoadData

/*
================
sdVehiclePosition::LoadData
================
*/
void sdVehiclePosition::LoadData( const idDict& dict ) {
	requirements.Load( dict, "require" );

	const char* tipName = dict.GetString( "tt_blocked" );
	if ( *tipName ) {
		blockedTip = gameLocal.declToolTipType[ tipName ];
	}

	maxViewOffset	= dict.GetFloat( "max_view_offset", "0.f" );
	viewOffsetRate	= dict.GetFloat( "view_offset_rate", "0.f" );
	if ( maxViewOffset ) {
		viewOffsetRate /= maxViewOffset;
	}

	const char* attachJointName = dict.GetString( "joint_attach" );
	if ( !*attachJointName ) {
		attachJointName = "origin";
	}

	attachAnim				= dict.GetString( "player_anim", "VehicleDefault" );
	showPlayer				= dict.GetBool( "show_player" );
	minZfrac				= dict.GetFloat( "min_z_frac", "-2.f" );
	ejectOnKilled			= dict.GetBool( "use_fallback" );
	takesDamage				= dict.GetBool( "take_damage" );
	playerHeight			= dict.GetFloat( "player_height" );
	allowWeapon				= dict.GetBool( "allow_weapon" );
	allowAdjustBodyAngles	= dict.GetBool( "adjust_body_angles" );
	resetViewOnEnter		= dict.GetBool( "reset_view_on_enter", "1" );
	damageScale				= dict.GetFloat( "damage_scale", "1" );
	playerStance			= dict.GetBool( "player_stance_crouch" ) ? PS_CROUCH : PS_NORMAL;

	const char* iconJointName = dict.GetString( "joint_icon" );
	if ( *iconJointName != '\0' ) {
		iconJoint = transport->GetAnimator()->GetJointHandle( iconJointName );
	} else {
		iconJoint = INVALID_JOINT;
	}

	const idKeyValue* kv = NULL;
	while ( kv = dict.MatchPrefix( "ability", kv ) ) {
		abilities.Add( kv->GetValue() );
	}

	attachJoint				= transport->GetAnimator()->GetJointHandle( attachJointName );
	if ( attachJoint == INVALID_JOINT ) {
		gameLocal.Warning( "sdVehiclePosition::LoadData  Joint \"%s\" does not exist in vscript %s", attachJointName, transport->GetVehicleScript()->GetName() );
	}

	cockpitName = dict.GetString( "cockpit", "" );

	const char* statName = dict.GetString( "stat_name" );
	if ( *statName ) {
		sdStatsTracker& tracker = sdGlobalStatsTracker::GetInstance();

		statTimeSpent = tracker.GetStat( tracker.AllocStat( va( "%s_time_spent", statName ), sdNetStatKeyValue::SVT_INT ) );
	} else {
		gameLocal.Warning( "Missing Stat Name on '%s'", name.c_str() );
	}
}
开发者ID:,项目名称:,代码行数:64,代码来源:

示例6: Setup

/*
================
sdVehicleWeaponAimer::Setup
================
*/
bool sdVehicleWeaponAimer::Setup( sdTransport* _vehicle, const angleClamp_t& yaw, const angleClamp_t& pitch, const idDict& ikParms ) {
	if ( !sdVehicleIKSystem::Setup( _vehicle, yaw, pitch, ikParms ) ) {
		return false;
	}

	idAnimator* animator = vehicle->GetAnimator();

	jointHandle_t pitchJoint	= animator->GetJointHandle( ikParms.GetString( "jointWrist" ) );
	jointHandle_t yawJoint		= animator->GetJointHandle( ikParms.GetString( "jointElbow" ) );
	jointHandle_t muzzleJoint	= animator->GetJointHandle( ikParms.GetString( "jointMuzzle" ) );
	jointHandle_t shoulderJoint = animator->GetJointHandle( ikParms.GetString( "jointShoulder" ) );
	if ( shoulderJoint == INVALID_JOINT ) {
		shoulderJoint = animator->GetJointParent( yawJoint );
	}

	int anim = animator->GetAnim( ikParms.GetString( "deployed_anim" ) );

	aimer.Init( ikParms.GetBool( "fix_barrel" ), ikParms.GetBool( "invert_pitch" ), _vehicle, anim, yawJoint, pitchJoint, muzzleJoint, shoulderJoint, clampYaw, clampPitch );

	return true;
}
开发者ID:,项目名称:,代码行数:26,代码来源:

示例7: InhibitEntitySpawn

bool DifficultyManager::InhibitEntitySpawn( const idDict &target ) {
	bool isAllowed( true );
	// Construct the key ("diff_0_spawn")
	idStr key = va( "diff_%d_nospawn", _difficulty );
	// The entity is allowed to spawn by default, must be set to 1 by the mapper
	isAllowed = !target.GetBool( key, "0" );
	DM_LOG( LC_DIFFICULTY, LT_INFO )LOGSTRING( "Entity %s is allowed to spawn on difficulty %i: %s.\r", target.GetString( "name" ), _difficulty, isAllowed ? "YES" : "NO" );
	// Tels: #3223: See if this entity should spawn this time
	float random_remove = target.GetFloat( "random_remove", "1.1" );
	float random_value = gameLocal.random.RandomFloat();
	if( random_remove < random_value ) {
		isAllowed = false;
		DM_LOG( LC_ENTITY, LT_INFO )LOGSTRING( "Removing entity %s due to random_remove %f < %f.\r", target.GetString( "name" ), random_remove, random_value );
	}
	// Return false if the entity is allowed to spawn
	return !isAllowed;
}
开发者ID:revelator,项目名称:The-Darkmod-Experimental,代码行数:17,代码来源:DifficultyManager.cpp

示例8: Set

//
// Set()
//
void hhReactionDesc::Set(const idDict &keys) {
	
	cause				= StrToCause(keys.GetString("cause"));
	effect				= StrToEffect(keys.GetString("effect"));

	flags				= 0;
	effectRadius		= keys.GetFloat("effect_radius","-1.0f");
	effectMinRadius		= keys.GetFloat("effect_min_radius","0.0f");

	if(keys.GetBool("snap_to_point")) {
		flags |= flag_SnapToPoint;
	}
	if(keys.GetBool("effect_all_players")) {
		flags |= flag_EffectAllPlayers;
	}
	if(keys.GetBool("effect_all_monsters")) {
		flags |= flag_EffectAllMonsters;
	}
	if(keys.GetBool("req_novehicle")) {
		flags |= flagReq_NoVehicle;
	}
	if(keys.GetBool("exclusive")) {
		flags |= flag_Exclusive;
	}
	if(keys.GetBool("effect_listener")) {
		flags |= flag_EffectListener;
	}
	
	if(keys.GetBool("anim_face_cause_dir")) {
		flags |= flag_AnimFaceCauseDir;
	}
	if(keys.GetBool("anim_trigger_cause")) {
		flags |= flag_AnimTriggerCause;
	}
		

	idStr keyString("");
	if(keys.GetString("req_key", "", keyString)) {
		if(keyString.Length() > 1) {
			flags |= flagReq_KeyValue;
			int firstSpace = keyString.Find(' ');
			if( firstSpace >= 0 ) {				
				key		= keyString.Left( firstSpace);		
				keyVal	= keyString.Right( keyString.Length() - firstSpace -1);
			}		
		}
		else
			gameLocal.Error("Invalide key for 'reaction_req_ley' value: %s", (const char*)keyString);
	}
//MDC begin
	keyString.Empty();
	if( keys.GetString( "finish_key", "", keyString)) {
		if( keyString.Length() > 1 ) {
			int firstSpace = keyString.Find(' ');
			if( firstSpace >= 0 ) {
				finish_key = keyString.Left( firstSpace );
				finish_val = keyString.Right( keyString.Length() - firstSpace - 1 );
			}
		}
	}
//MDC end

	idStr animString("");
	if(keys.GetString("req_anim", "", animString)) {
		flags |= flagReq_Anim;
		anim = animString;
	}

	if(keys.GetBool("req_rangeattack")) {
		flags |= flagReq_RangeAttack;
	}
	if(keys.GetBool("req_meleeattack")) {
		flags |= flagReq_MeleeAttack;
	}
	if(keys.GetBool("req_can_see")) {
		flags |= flagReq_CanSee;
	}

	if(keys.GetBool("req_telepathic") || cause == hhReactionDesc::Cause_Telepathic_Throw || cause == hhReactionDesc::Cause_Telepathic_Trigger) {
		flags |= flagReq_Telepathic;
	}

	
	// Effect volumes
	effectVolumes.Clear();
	const idKeyValue *kv = keys.MatchPrefix("effect_volume", NULL);
	while(kv) {
		idStr effectVolName = kv->GetValue();
		if(effectVolName.Length() > 0) {
			idEntity *e = gameLocal.FindEntity(effectVolName.c_str());
			if(!e) {
				gameLocal.Error("Failed to find effect_volume named %s", effectVolName.c_str());
			}
			if(!e->IsType(hhReactionVolume::Type)) {
				gameLocal.Error("effect_volume named %s was of incorrect spawn type. Must be hhReactionVolume", effectVolName.c_str());
			}

//.........这里部分代码省略.........
开发者ID:mrwonko,项目名称:preymotionmod,代码行数:101,代码来源:ai_reaction.cpp

示例9: Init

/*
================
sdRequirementCheck_Property::Init
================
*/
void sdRequirementCheck_Property::Init( const idDict& parms ) {
	useOther					= parms.GetBool( "use_other" );
	const char* propertyName	= parms.GetString( "property" );
	const char* subPropertyName = parms.GetString( "property_type" );

	if ( !idStr::Icmp( propertyName, "health" ) ) {
		property = PT_HEALTH;
	} else if ( !idStr::Icmp( propertyName, "range" ) ) {
		property = PT_RANGE;
	} else if ( !idStr::Icmp( propertyName, "total_xp" ) ) {
		property = PT_TOTAL_XP;
	} else if ( !idStr::Icmp( propertyName, "xp" ) ) {
		property = PT_XP;
		const sdDeclProficiencyType* prof = gameLocal.declProficiencyTypeType[ subPropertyName ];
		if ( !prof ) {
			gameLocal.Error( "sdRequirementCheck_Property::Init Invalid Proficiency Type '%s'", subPropertyName );
		}
		subProperty = prof->Index();
	} else if ( !idStr::Icmp( propertyName, "need_revive" ) ) {
		property = PT_NEEDSREVIVE;
	} else if ( !idStr::Icmp( propertyName, "want_revive" ) ) {
		property = PT_WANT_REVIVE;
	} else if ( !idStr::Icmp( propertyName, "same_entity" ) ) {
		property = PT_SAME_ENTITY;
	} else if ( !idStr::Icmp( propertyName, "spectator" ) ) {
		property = PT_SPECTATOR;
	} else if ( !idStr::Icmp( propertyName, "prone" ) ) {
		property = PT_PRONE;
	} else if ( !idStr::Icmp( propertyName, "crouch" ) ) {
		property = PT_CROUCH;
	} else if ( !idStr::Icmp( propertyName, "need_repair" ) ) {
		property = PT_NEEDSREPAIR;
	} else if ( !idStr::Icmp( propertyName, "proficiency" ) ) {
		property = PT_PROFICIENCY;
		const sdDeclProficiencyType* prof = gameLocal.declProficiencyTypeType[ subPropertyName ];
		if ( !prof ) {
			gameLocal.Error( "sdRequirementCheck_Property::Init Invalid Proficiency Type '%s'", subPropertyName );
		}
		subProperty = prof->Index();
	} else if ( !idStr::Icmp( propertyName, "spawn_proficiency" ) ) {
		property = PT_SPAWN_PROFICIENCY;
		const sdDeclProficiencyType* prof = gameLocal.declProficiencyTypeType[ subPropertyName ];
		if ( !prof ) {
			gameLocal.Error( "sdRequirementCheck_Property::Init Invalid Proficiency Type '%s'", subPropertyName );
		}
		subProperty = prof->Index();
	} else if ( !idStr::Icmp( propertyName, "driver" ) ) {
		property = PT_DRIVER;
	} else if ( !idStr::Icmp( propertyName, "disguised" ) ) {
		property = PT_DISGUISED;
	} else if ( !idStr::Icmp( propertyName, "vehicle_full" ) ) {
		property = PT_VEHICLEFULL;
	} else if ( !idStr::Icmp( propertyName, "in_vehicle" ) ) {
		property = PT_INVEHICLE;
		subProperty = 0;
		if ( !idStr::Icmp( subPropertyName, "local_player" ) ) {
			subProperty = 1;
		}
	} else if ( !idStr::Icmp( propertyName, "same_fireteam" ) ) {
		property = PT_SAME_FIRETEAM;
	} else {
		gameLocal.Error( "sdRequirementCheck_Property::Init Invalid Property Type '%s'", propertyName );
	}

	value = parms.GetFloat( "value" );

	const char* conditionName = parms.GetString( "condition" );

	if ( !idStr::Icmp( conditionName, "==" ) ) {
		condition = CND_EQ;
	} else if ( !idStr::Icmp( conditionName, "!=" ) ) {
		condition = CND_NE;
	} else if ( !idStr::Icmp( conditionName, ">" ) ) {
		condition = CND_GT;
	} else if ( !idStr::Icmp( conditionName, "<" ) ) {
		condition = CND_LT;
	} else if ( !idStr::Icmp( conditionName, ">=" ) ) {
		condition = CND_GE;
	} else if ( !idStr::Icmp( conditionName, "<=" ) ) {
		condition = CND_LE;
	} else {
		gameLocal.Error( "sdRequirementCheck_Property::Init Invalid Condition Type '%s'", conditionName );
	}

	if ( property == PT_RANGE ) {
		value *= value;
	}
}
开发者ID:,项目名称:,代码行数:93,代码来源:

示例10: ParseSpawnArg

bool CStimResponseCollection::ParseSpawnArg( const idDict &args, idEntity *owner, const char sr_class, int index ) {
	bool rc = false;
	idStr str;
	CStimPtr stim;
	CResponsePtr resp;
	CStimResponsePtr sr;
	StimState state( SS_DISABLED );
	StimType typeOfStim;
	// Check if the entity contains either a stim or a response.
	if( sr_class != 'S' && sr_class != 'R' ) {
		DM_LOG( LC_STIM_RESPONSE, LT_ERROR )LOGSTRING( "Invalid sr_class value [%s]\r", str.c_str() );
		goto Quit;
	}
	// Get the id of the stim/response type so we know what sub-class to create
	args.GetString( va( "sr_type_%u", index ), "-1", str );
	// This is invalid as an entity definition
	if( str == "-1" ) {
		sr.reset();
		goto Quit;
	}
	// If the first character is alphanumeric, we check if it
	// is a known id and convert it.
	/* StimType */ typeOfStim = ST_DEFAULT;
	if( ( str[0] >= 'a' && str[0] <= 'z' )
			|| ( str[0] >= 'A' && str[0] <= 'Z' ) ) {
		// Try to recognise the string as known Stim type
		typeOfStim = CStimResponse::GetStimType( str );
		// If the string hasn't been found, we have id == ST_DEFAULT.
		if( typeOfStim == ST_DEFAULT ) {
			DM_LOG( LC_STIM_RESPONSE, LT_ERROR )LOGSTRING( "Invalid sr_type id [%s]\r", str.c_str() );
			sr.reset();
			goto Quit;
		}
	} else if( str[0] >= '0' && str[0] <= '9' ) { // Is it numeric?
		typeOfStim = ( StimType ) atol( str.c_str() );
	} else {	// neither a character nor a number, thus it is invalid.
		DM_LOG( LC_STIM_RESPONSE, LT_ERROR )LOGSTRING( "Invalid sr_type id [%s]\r", str.c_str() );
		sr.reset();
		goto Quit;
	}
	if( sr_class == 'S' ) {
		stim = CreateStim( owner, typeOfStim );
		if( stim == NULL ) { // grayman #2862
			goto Quit; // nasty goto!!
		}
		sr = stim;
	} else if( sr_class == 'R' ) {
		resp = CreateResponse( owner, typeOfStim );
		sr = resp;
	}
	// Set stim response type
	sr->m_StimTypeId = typeOfStim;
	// Set stim response name string
	sr->m_StimTypeName = str;
	// Read stim response state from the def file
	state = static_cast<StimState>( args.GetInt( va( "sr_state_%u", index ), "1" ) );
	sr->SetEnabled( state == SS_ENABLED );
	sr->m_Chance = args.GetFloat( va( "sr_chance_%u", index ), "1.0" );
	// A stim also may have a radius
	if( sr_class == 'S' ) {
		stim->m_Radius = args.GetFloat( va( "sr_radius_%u", index ), "0" );
		stim->m_RadiusFinal = args.GetFloat( va( "sr_radius_final_%u", index ), "-1" );
		stim->m_FallOffExponent = args.GetInt( va( "sr_falloffexponent_%u", index ), "0" );
		stim->m_bUseEntBounds = args.GetBool( va( "sr_use_bounds_%u", index ), "0" );
		stim->m_bCollisionBased = args.GetBool( va( "sr_collision_%u", index ), "0" );
		stim->m_Velocity = args.GetVector( va( "sr_velocity_%u", index ), "0 0 0" );
		stim->m_Bounds[0] = args.GetVector( va( "sr_bounds_mins_%u", index ), "0 0 0" );
		stim->m_Bounds[1] = args.GetVector( va( "sr_bounds_maxs_%u", index ), "0 0 0" );
		// set up time interleaving so the stim isn't fired every frame
		stim->m_TimeInterleave = args.GetInt( va( "sr_time_interval_%u", index ), "0" );
		// greebo: Add fuzzyness to the timer (ranging from 0.9 - 1.3);
		stim->m_TimeInterleave = static_cast<int>( stim->m_TimeInterleave * ( 0.9f + gameLocal.random.RandomFloat() * 0.4f ) );
		// userfriendly stim duration time
		stim->m_Duration = args.GetInt( va( "sr_duration_%u", index ), "0" );
		stim->m_Magnitude = args.GetFloat( va( "sr_magnitude_%u", index ), "1.0" );
		stim->m_MaxFireCount = args.GetInt( va( "sr_max_fire_count_%u", index ), "-1" );
		// Check if we have a timer on this stim.
		CreateTimer( args, stim, index );
	} else {	// this is only for responses
		sr->m_ChanceTimer = args.GetInt( va( "sr_chance_timeout_%u", index ), "-1" );
		resp->m_NumRandomEffects = args.GetInt( va( "sr_random_effects_%u", index ), "0" );
		// Get the name of the script function for processing the response
		args.GetString( "sr_script_" + str, "", str );
		resp->m_ScriptFunction = str;
		// Try to identify the ResponseEffect spawnargs
		int effectIdx = 1;
		while( effectIdx > 0 ) {
			// Try to find a string like "sr_effect_2_1"
			args.GetString( va( "sr_effect_%u_%u", index, effectIdx ), "", str );
			if( str.IsEmpty() ) {
				// Set the index to negative values to end the loop
				effectIdx = -1;
			} else {
				// Assemble the postfix of this effect for later key/value lookup
				// This is passed to the effect script eventually
				DM_LOG( LC_STIM_RESPONSE, LT_DEBUG )LOGSTRING( "Adding response effect\r" );
				resp->AddResponseEffect( str, va( "%u_%u", index, effectIdx ), args );
				effectIdx++;
			}
		}
//.........这里部分代码省略.........
开发者ID:SL987654,项目名称:The-Darkmod-Experimental,代码行数:101,代码来源:StimResponseCollection.cpp

示例11: AddItems


//.........这里部分代码省略.........
		if (mapDict.FindKey(itemPrefix + diffLevelStr + "_qty") != NULL)
		{
			quantity = mapDict.GetInt(itemPrefix + diffLevelStr + "_qty");
		}

		// put the item in the shop
		if (quantity > 0)
		{
			// grayman (#2376) - Special handling for weapon quantities.

			int index = itemName.Find("weapon_");
			if (index >= 0)
			{
				// A shop entity should use atdm:weapon_*, but there's at least one
				// that uses weapon_*, so convert the latter to the former.

				idStr weaponName;
				if (index == 0)
				{
					weaponName = "atdm:" + itemName;
				}
				else
				{
					weaponName = itemName;
				}

				// Weapon quantities have limits. (Arrows in particular.)

				int max_ammo = GetMaxAmmo(weaponName);
				quantity = (quantity > max_ammo) ? max_ammo : quantity;
			}

			/* grayman (#2376) - Since a lockpick_set comprises individual picks, putting one
								 on either the shopItems or startingItems list means we don't
								 have to put individual picks on the same list.
								 For now, just register whether a lockpick_set is being added
								 to either list. We'll post-process after the lists are built.
			 */

			if (isShopList)
			{
				if (!_pickSetShop && (itemName.Find("lockpick_set") >= 0))
				{
					_pickSetShop = true;
				}
			}
			else
			{
				if (!_pickSetStarting && (itemName.Find("lockpick_set") >= 0))
				{
					_pickSetStarting = true;
				}
			}

			// look for price
			int price = mapDict.GetInt(itemPrefix + "_price");

			if (mapDict.FindKey(itemPrefix + diffLevelStr + "_price") != NULL)
			{
				price = mapDict.GetInt(itemPrefix + diffLevelStr + "_price");
			}

			// look for persistency
			bool persistent = mapDict.GetBool(itemPrefix + "_persistent");

			if (mapDict.FindKey(itemPrefix + diffLevelStr + "_persistent") != NULL)
			{
				persistent = mapDict.GetBool(itemPrefix + diffLevelStr + "_persistent");
			}

			// look for canDrop flag 
			bool canDrop = mapDict.GetBool(itemPrefix + "_canDrop", "1"); // items can be dropped by default

			if (mapDict.FindKey(itemPrefix + diffLevelStr + "_canDrop") != NULL)
			{
				canDrop = mapDict.GetBool(itemPrefix + diffLevelStr + "_canDrop", "1");
			}

			CShopItemPtr found = FindShopItemDefByClassName(itemName);

			if (found != NULL) 
			{
				// grayman - TODO: If there are multiple shops, you can get multiple
				// entries for the same item. You need to group them into a single item.

				CShopItemPtr anItem(new CShopItem(*found, quantity, price, persistent));
				anItem->SetCanDrop(canDrop);
				list.Append(anItem);

				itemsAdded++;
			}
			else
			{
				gameLocal.Warning("Could not add item to shop: %s", itemName.c_str());
			}
		}
	}

	return itemsAdded;
}
开发者ID:dolanor,项目名称:TheDarkMod,代码行数:101,代码来源:Shop.cpp

示例12: InitFromSpawnArgs

void Conversation::InitFromSpawnArgs( const idDict &dict, int index ) {
	idStr prefix = va( "conv_%d_", index );
	// A non-empty name is mandatory for a conversation
	if( !dict.GetString( prefix + "name", "", _name ) || _name.IsEmpty() ) {
		// No conv_N_name spawnarg found, bail out
		_isValid = false;
		return;
	}
	// Parse "global" conversation settings
	_talkDistance = dict.GetFloat( prefix + "talk_distance", "60" );
	// Parse participant actors
	// Check if this entity can be used by others.
	idStr actorPrefix = prefix + "actor_";
	for( const idKeyValue *kv = dict.MatchPrefix( actorPrefix ); kv != NULL; kv = dict.MatchPrefix( actorPrefix, kv ) ) {
		// Add each actor name to the list
		DM_LOG( LC_CONVERSATION, LT_DEBUG )LOGSTRING( "Adding actor %s to conversation %s.\r", kv->GetValue().c_str(), _name.c_str() );
		_actors.AddUnique( kv->GetValue() );
	}
	DM_LOG( LC_CONVERSATION, LT_DEBUG )LOGSTRING( "Conversation %s has %d actors.\r", _name.c_str(), _actors.Num() );
	if( _actors.Num() == 0 ) {
		_isValid = false; // no actors, no conversation
		gameLocal.Warning( "Ignoring conversation %s as it has no actors.", _name.c_str() );
		return;
	}
	// Start parsing the conversation scripts (i.e. the commands), start with index 1
	for( int i = 1; i < INT_MAX; i++ ) {
		idStr cmdPrefix = va( prefix + "cmd_%d_", i );
		DM_LOG( LC_CONVERSATION, LT_DEBUG )LOGSTRING( "Attempting to find command with index %d matching prefix %s.\r", i, cmdPrefix.c_str() );
		if( dict.MatchPrefix( cmdPrefix ) != NULL ) {
			// Found a matching "conv_N_cmd_M..." spawnarg, start parsing
			ConversationCommandPtr cmd( new ConversationCommand );
			// Let the command parse itself
			if( cmd->Parse( dict, cmdPrefix ) ) {
				// Parsing succeeded, add this to the command list
				_commands.Append( cmd );
			}
		} else {
			DM_LOG( LC_CONVERSATION, LT_DEBUG )LOGSTRING( "No match found, terminating loop on index %d.\r", i );
			break;
		}
	}
	DM_LOG( LC_CONVERSATION, LT_DEBUG )LOGSTRING( "%d Commands found for Conversation %s.\r", _commands.Num(), _name.c_str() );
	// Sanity check the commands
	if( _commands.Num() == 0 ) {
		// No commands, what kind of conversation is this?
		_isValid = false;
		gameLocal.Warning( "Ignoring conversation %s as it has no commands.", _name.c_str() );
		return;
	}
	// Sanity check the talk distance
	if( _talkDistance <= 0.0f ) {
		_isValid = false;
		gameLocal.Warning( "Ignoring conversation %s as it has a talk distance <= 0.", _name.c_str() );
		return;
	}
	// get max play count, default is -1, which means infinitely often
	_maxPlayCount = dict.GetInt( prefix + "max_play_count", "-1" );
	// per default, the actors should be within talk distance before they start talking
	_actorsMustBeWithinTalkDistance = dict.GetBool( prefix + "actors_must_be_within_talkdistance", "1" );
	_actorsAlwaysFaceEachOtherWhileTalking = dict.GetBool( prefix + "actors_always_face_each_other_while_talking", "1" );
	// greebo: For conversations with one actor some flags don't make sense
	if( _actors.Num() == 1 ) {
		_actorsMustBeWithinTalkDistance = false;
		_actorsAlwaysFaceEachOtherWhileTalking = false;
	}
	// Seems like we have everything we need
	_isValid = true;
}
开发者ID:,项目名称:,代码行数:68,代码来源:


注:本文中的idDict::GetBool方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。