示例#1
0
文件: CBase.cpp 项目: roberpot/Source
bool CBaseBaseDef::r_LoadVal( CScript & s )
{
	ADDTOCALLSTACK("CBaseBaseDef::r_LoadVal");
	EXC_TRY("LoadVal");
	if ( s.IsKeyHead( "TAG.", 4 ))
	{
		bool fQuoted = false;
		m_TagDefs.SetStr( s.GetKey()+4, fQuoted, s.GetArgStr( &fQuoted ), false );
		return( true );
	}
	if ( s.IsKeyHead( "TAG0.", 5 ))
	{
		bool fQuoted = false;
		m_TagDefs.SetStr( s.GetKey()+5, fQuoted, s.GetArgStr( &fQuoted ), true );
		return( true );
	}

	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
		//Set as Strings
		case OBC_HITSPELL:
		case OBC_SLAYER:
		case OBC_SLAYERLESSER:
		case OBC_SLAYERMISC:
		case OBC_SLAYERSUPER:
		case OBC_ABILITYPRIMARY:
		case OBC_ABILITYSECONDARY:
		case OBC_MANABURST:
			{
				bool fQuoted = false;
				SetDefStr(s.GetKey(), s.GetArgStr( &fQuoted ), fQuoted);
			}
			break;
		//Set as number only
		case OBC_BALANCED:
		case OBC_BANE:
		case OBC_BATTLELUST:
		case OBC_BLOODDRINKER:
		case OBC_CASTINGFOCUS:
		case OBC_DAMCHAOS:
		case OBC_DAMCOLD:
		case OBC_DAMDIRECT:
		case OBC_DAMENERGY:
		case OBC_DAMFIRE:
		case OBC_DAMMODIFIER:
		case OBC_DAMPHYSICAL:
		case OBC_DECREASEHITCHANCE:
		case OBC_DAMPOISON:
		case OBC_EATERCOLD:
		case OBC_EATERDAM:
		case OBC_EATERENERGY:
		case OBC_EATERFIRE:
		case OBC_EATERKINETIC:
		case OBC_EATERPOISON:
		case OBC_ENHANCEPOTIONS:
		case OBC_EXPANSION:
		case OBC_FASTERCASTING:
		case OBC_FASTERCASTRECOVERY:
		case OBC_HITAREACOLD:
		case OBC_HITAREAENERGY:
		case OBC_HITAREAFIRE:
		case OBC_HITAREAPHYSICAL:
		case OBC_HITAREAPOISON:
		case OBC_HITCURSE:
		case OBC_HITDISPEL:
		case OBC_HITFATIGUE:
		case OBC_HITFIREBALL:
		case OBC_HITHARM:
		case OBC_HITLEECHLIFE:
		case OBC_HITLEECHMANA:
		case OBC_HITLEECHSTAM:
		case OBC_HITLIGHTNING:
		case OBC_HITLOWERATK:
		case OBC_HITLOWERDEF:
		case OBC_HITMAGICARROW:
		case OBC_HITMANADRAIN:
		case OBC_INCREASEDAM:
		case OBC_INCREASEDEFCHANCE:
		case OBC_INCREASEDEFCHANCEMAX:
		case OBC_INCREASEHITCHANCE:
		case OBC_INCREASEGOLD:
		case OBC_INCREASEKARMALOSS:
		case OBC_INCREASESPELLDAM:
		case OBC_INCREASESWINGSPEED:
		case OBC_LOWERAMMOCOST:
		case OBC_LOWERMANACOST:
		case OBC_LOWERREAGENTCOST:
		case OBC_LOWERREQ:
		case OBC_LUCK:
		case OBC_MANABURSTFREQUENCY:
		case OBC_MANABURSTKARMA:
		case OBC_NIGHTSIGHT:
		case OBC_RAGEFOCUS:
		case OBC_REACTIVEPARALYZE:
		case OBC_REFLECTPHYSICALDAM:
		case OBC_REGENFOOD:
		case OBC_REGENHITS:
		case OBC_REGENMANA:
		case OBC_REGENSTAM:
		case OBC_REGENVALFOOD:
		case OBC_REGENVALHITS:
		case OBC_REGENVALMANA:
		case OBC_REGENVALSTAM:
		case OBC_RESCOLD:
		case OBC_RESFIRE:
		case OBC_RESENERGY:
		case OBC_RESPHYSICAL:
		case OBC_RESPOISON:
		case OBC_RESCOLDMAX:
		case OBC_RESFIREMAX:
		case OBC_RESENERGYMAX:
		case OBC_RESPHYSICALMAX:
		case OBC_RESPOISONMAX:
		case OBC_RESONANCECOLD:
		case OBC_RESONANCEENERGY:
		case OBC_RESONANCEFIRE:
		case OBC_RESONANCEKINETIC:
		case OBC_RESONANCEPOISON:
		case OBC_SOULCHARGE:
		case OBC_SOULCHARGECOLD:
		case OBC_SOULCHARGEENERGY:
		case OBC_SOULCHARGEFIRE:
		case OBC_SOULCHARGEKINETIC:
		case OBC_SOULCHARGEPOISON:
		case OBC_SPELLCONSUMPTION:
		case OBC_SPELLFOCUSING:
		case OBC_SPLINTERINGWEAPON:
		case OBC_VELOCITY:
		case OBC_SPELLCHANNELING:
		case OBC_NAMELOC:
		case OBC_HITSPELLSTR:
		case OBC_WEIGHTREDUCTION:
		case OBC_COMBATBONUSSTAT:
		case OBC_COMBATBONUSPERCENT:
			{
				SetDefNum(s.GetKey(),s.GetArgVal());
				return true;
			}
		case OBC_CATEGORY://*
		case OBC_SUBSECTION://*
		case OBC_DESCRIPTION://*
			{
				bool fQuoted = false;
				SetDefStr(s.GetKey(), s.GetArgStr( &fQuoted ), fQuoted);
				if ( !strcmpi(GetDefStr(sm_szLoadKeys[OBC_DESCRIPTION]), "@") )
					SetDefStr(sm_szLoadKeys[OBC_DESCRIPTION], GetDefStr(sm_szLoadKeys[OBC_SUBSECTION]));
			}
			return true;
		case OBC_ARMOR:
			{
				INT64 piVal[2];
				size_t iQty = Str_ParseCmds( s.GetArgStr(), piVal, COUNTOF(piVal));
				m_defenseBase = static_cast<unsigned char>(piVal[0]);
				if ( iQty > 1 )
				{
					m_defenseRange = static_cast<unsigned char>(piVal[1]) - m_defenseBase;
				}
				else
				{
					m_defenseRange = 0;
				}
			}
			return( true );
		case OBC_DAM:
			{
				INT64 piVal[2];
				size_t iQty = Str_ParseCmds( s.GetArgStr(), piVal, COUNTOF(piVal));
				m_attackBase = static_cast<unsigned char>(piVal[0]);
				if ( iQty > 1 )
				{
					m_attackRange = static_cast<unsigned char>(piVal[1]) - m_attackBase;
				}
				else
				{
					m_attackRange = 0;
				}
			}
			return( true );
		case OBC_BASEID:
			return( false );
		case OBC_CAN:
			m_Can = s.GetArgVal();// | ( m_Can & ( CAN_C_INDOORS|CAN_C_EQUIP|CAN_C_USEHANDS|CAN_C_NONHUMANOID )); //Fixed #2326 ?
			return( true );

		case OBC_DEFNAME:
		case OBC_DEFNAME2:
			return SetResourceName( s.GetArgStr());
		case OBC_HEIGHT:
			m_Height = static_cast<height_t>(s.GetArgVal());
			return( true );
		case OBC_INSTANCES:
			return( false );
		case OBC_NAME:
			SetTypeName( s.GetArgStr());
			return( true );
		case OBC_RANGE:
			{
				INT64 piVal[2];
				size_t iQty = Str_ParseCmds( s.GetArgStr(), piVal, COUNTOF(piVal));
				if ( iQty > 1 )
				{
					INT64 iRange = ((piVal[0] & 0xff) << 8) & 0xff00;
					iRange |= (piVal[1] & 0xff);
					SetDefNum(s.GetKey(),iRange, false);
					//m_range	 = ((piVal[0] & 0xff) << 8) & 0xff00;
					//m_range	|= (piVal[1] & 0xff);
				}
				else
				{
					SetDefNum(s.GetKey(),piVal[0], false);
					//m_range	= static_cast<WORD>(piVal[0]);
				}
			}
			return( true );
		case OBC_RESOURCES:
			m_BaseResources.Load( s.GetArgStr());
			return( true );
		case OBC_RESLEVEL:
			return( SetResLevel(static_cast<unsigned char>(s.GetArgVal())) );
		case OBC_RESDISPDNHUE:
			SetResDispDnHue(static_cast<HUE_TYPE>(s.GetArgVal()));
			return( true );
		case OBC_TEVENTS:
			return( m_TEvents.r_LoadVal( s, RES_EVENTS ));
	}
	return( CScriptObj::r_LoadVal(s));
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
示例#2
0
bool CBaseBaseDef::r_LoadVal(CScript &s)
{
	ADDTOCALLSTACK("CBaseBaseDef::r_LoadVal");
	EXC_TRY("LoadVal");
	if ( s.IsKeyHead("TAG.", 4) )
	{
		bool fQuoted = false;
		m_TagDefs.SetStr(s.GetKey() + 4, fQuoted, s.GetArgStr(&fQuoted), false);
		return true;
	}
	if ( s.IsKeyHead("TAG0.", 5) )
	{
		bool fQuoted = false;
		m_TagDefs.SetStr(s.GetKey() + 5, fQuoted, s.GetArgStr(&fQuoted), true);
		return true;
	}

	switch ( FindTableSorted(s.GetKey(), sm_szLoadKeys, COUNTOF(sm_szLoadKeys) - 1) )
	{
		// Set as numeric
		case OBC_COMBATBONUSPERCENT:
		case OBC_COMBATBONUSSTAT:
		case OBC_DAMCHAOS:
		case OBC_DAMDIRECT:
		case OBC_EXPANSION:
		case OBC_NAMELOC:
		case OBC_REGENFOOD:
		case OBC_REGENHITS:
		case OBC_REGENMANA:
		case OBC_REGENSTAM:
		case OBC_REGENVALFOOD:
		case OBC_REGENVALHITS:
		case OBC_REGENVALMANA:
		case OBC_REGENVALSTAM:
		{
			SetDefNum(s.GetKey(), s.GetArgVal());
			return true;
		}
		case OBC_CATEGORY:
		case OBC_SUBSECTION:
		case OBC_DESCRIPTION:
		{
			bool fQuoted = false;
			SetDefStr(s.GetKey(), s.GetArgStr(&fQuoted), fQuoted);
			if ( !strcmpi(GetDefStr(sm_szLoadKeys[OBC_DESCRIPTION]), "@") )
				SetDefStr(sm_szLoadKeys[OBC_DESCRIPTION], GetDefStr(sm_szLoadKeys[OBC_SUBSECTION]));
			return true;
		}
		case OBC_ARMOR:
		{
			INT64 piVal[2];
			size_t iQty = Str_ParseCmds(s.GetArgStr(), piVal, COUNTOF(piVal));
			m_defenseBase = static_cast<WORD>(piVal[0]);
			if ( iQty > 1 )
				m_defenseRange = static_cast<WORD>(piVal[1]) - m_defenseBase;
			else
				m_defenseRange = 0;
			return true;
		}
		case OBC_BASEID:
			return false;
		case OBC_CAN:
			m_Can = s.GetArgVal();	//| (m_Can & (CAN_C_INDOORS|CAN_C_EQUIP|CAN_C_USEHANDS|CAN_C_NONHUMANOID));	//fixed #2326?
			return true;
		case OBC_DAM:
		{
			INT64 piVal[2];
			size_t iQty = Str_ParseCmds(s.GetArgStr(), piVal, COUNTOF(piVal));
			m_attackBase = static_cast<WORD>(piVal[0]);
			if ( iQty > 1 )
				m_attackRange = static_cast<WORD>(piVal[1]) - m_attackBase;
			else
				m_attackRange = 0;
			return true;
		}
		case OBC_DAMCOLD:
			m_DamCold = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_DAMENERGY:
			m_DamEnergy = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_DAMFIRE:
			m_DamFire = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_DAMPHYSICAL:
			m_DamPhysical = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_DAMPOISON:
			m_DamPoison = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_DEFNAME:
		case OBC_DEFNAME2:
			return SetResourceName(s.GetArgStr());
		case OBC_ENHANCEPOTIONS:
			m_EnhancePotions = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_FASTERCASTING:
			m_FasterCasting = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_FASTERCASTRECOVERY:
			m_FasterCastRecovery = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_HEIGHT:
			m_Height = static_cast<height_t>(s.GetArgVal());
			return true;
		case OBC_HITLEECHLIFE:
			m_HitLifeLeech = static_cast<int>(s.GetArgVal());
			break;
		case OBC_HITLEECHMANA:
			m_HitManaLeech = static_cast<int>(s.GetArgVal());
			break;
		case OBC_HITLEECHSTAM:
			m_HitStaminaLeech = static_cast<int>(s.GetArgVal());
			break;
		case OBC_HITMANADRAIN:
			m_HitManaDrain = static_cast<int>(s.GetArgVal());
			break;
		case OBC_INCREASEDAM:
			m_DamIncrease = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_INCREASEDEFCHANCE:
			m_DefChanceIncrease = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_INCREASEDEFCHANCEMAX:
			m_DefChanceIncreaseMax = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_INCREASEHITCHANCE:
			m_HitChanceIncrease = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_INCREASESPELLDAM:
			m_SpellDamIncrease = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_INCREASESWINGSPEED:
			m_SwingSpeedIncrease = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_INSTANCES:
			return false;
		case OBC_LOWERMANACOST:
			m_LowerManaCost = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_LOWERREAGENTCOST:
			m_LowerReagentCost = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_LUCK:
			m_Luck = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_NAME:
			SetTypeName(s.GetArgStr());
			return true;
		case OBC_NIGHTSIGHT:
			m_NightSight = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_REFLECTPHYSICALDAM:
			m_ReflectPhysicalDamage = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RANGE:
		{
			INT64 piVal[2];
			size_t iQty = Str_ParseCmds(s.GetArgStr(), piVal, COUNTOF(piVal));
			if ( iQty > 1 )
			{
				INT64 iRange = ((piVal[0] & 0xFF) << 8) & 0xFF00;
				iRange |= (piVal[1] & 0xFF);
				SetDefNum(s.GetKey(), iRange, false);
				//m_range = ((piVal[0] & 0xFF) << 8) & 0xFF00;
				//m_range |= (piVal[1] & 0xFF);
			}
			else
			{
				SetDefNum(s.GetKey(), piVal[0], false);
				//m_range = static_cast<WORD>(piVal[0]);
			}
			return true;
		}
		case OBC_RESCOLD:
			m_ResCold = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESCOLDMAX:
			m_ResColdMax = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESDISPDNHUE:
			SetResDispDnHue(static_cast<HUE_TYPE>(s.GetArgVal()));
			return true;
		case OBC_RESENERGY:
			m_ResEnergy = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESENERGYMAX:
			m_ResEnergyMax = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESFIRE:
			m_ResFire = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESFIREMAX:
			m_ResFireMax = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESLEVEL:
			return SetResLevel(minimum(maximum(s.GetArgVal(), RDS_NONE), RDS_QTY - 1));
		case OBC_RESOURCES:
			m_BaseResources.Load(s.GetArgStr());
			return true;
		case OBC_RESPHYSICAL:
			m_ResPhysical = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESPHYSICALMAX:
			m_ResPhysicalMax = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESPOISON:
			m_ResPoison = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_RESPOISONMAX:
			m_ResPoisonMax = static_cast<int>(s.GetArgVal());
			return true;
		case OBC_TEVENTS:
			return m_TEvents.r_LoadVal(s, RES_EVENTS);
	}
	return CScriptObj::r_LoadVal(s);
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}