Example #1
0
/*static*/ void CAntiCheatManager::Xml_SetCheatType(XmlNodeRef xmlNode, TCheatType eCheatType)
{
	xmlNode->setAttr("cheat_type", s_cheatTypeNames[eCheatType]);
}
Example #2
0
/*static*/ void CAntiCheatManager::Xml_SetActionType(XmlNodeRef xmlNode, ECheatAction eCheatAction)
{
	xmlNode->setAttr("type", s_cheatActionNames[eCheatAction]);
}
Example #3
0
/*static*/ void CAntiCheatManager::Xml_SetDisplayName(XmlNodeRef xmlNode, uint16 channelId)
{
	CryFixedStringT<DISPLAY_NAME_LENGTH> displayName = "Unknown";
	xmlNode->setAttr("user_name", displayName);
}
Example #4
0
/*static*/ void CAntiCheatManager::Xml_SetGuid(XmlNodeRef xmlNode, const char * pGuid)
{
	xmlNode->setAttr("user_guid", pGuid);
}
Example #5
0
	CMethodBase* LoadMethod(const char* value_)
	{
		//Self.test_ns::AgentActionTest::Action2(0)
		char agentIntanceName[kNameLength];
		char agentClassName[kNameLength];
		char methodName[kNameLength];

		const char* pBeginP = ParseMethodNames(value_, agentIntanceName, agentClassName, methodName);

		//propertyName = FormatString("%s::%s", agentClassName, methodName);
		CStringID agentClassId(agentClassName);
		CStringID methodId(methodName);

		CMethodBase* method = Agent::CreateMethod(agentClassId, methodId);

		if (!method)
		{
			BEHAVIAC_LOGWARNING("No Method %s::%s registered\n", agentClassName, methodName);
			BEHAVIAC_ASSERT(0, "No Method %s::%s registered\n", agentClassName, methodName);
		}
		else
		{
			if (Agent::IsNameRegistered(agentIntanceName))
			{
				method->SetInstanceNameString(agentIntanceName, PT_INSTANCE);
			}
			else
			{
				//BEHAVIAC_ASSERT(agentIntanceName == "Self");
			}

			BEHAVIAC_ASSERT(method, "No Method %s::%s registered", agentClassName, methodName);
			const char* params = pBeginP;

			BEHAVIAC_ASSERT(params[0] == '(');

			behaviac::vector<behaviac::string> tokens;

			{
				int len = strlen(params);

				BEHAVIAC_ASSERT (params[len - 1] == ')');

				behaviac::string text = behaviac::string(params + 1, len - 2);
				//behaviac::StringUtils::SplitIntoArray(text, ",", tokens);
				ParseForParams(text, tokens);
			}

			if (tokens.size() > 0)
			{
				XmlNodeRef xmlNode = CreateXmlNode("Method");

				for (uint32_t i = 0; i < tokens.size(); ++i)
				{
					const behaviac::string& token = tokens[i];
					behaviac::string attriName = FormatString("param%d", i + 1);
					xmlNode->setAttr(attriName.c_str(), token);
				}

				CTextNode node(xmlNode);
				method->LoadFromXML(0, node);
			}
		}

		return method;
	}
bool CScriptSurfaceType::Load( int nId )
{
	m_nId = nId;
	IScriptSystem *pScriptSystem = gEnv->pScriptSystem;

	SmartScriptTable mtlTable;

	if (!pScriptSystem->GetGlobalValue("Materials", mtlTable))
	{
		return false;
	}

	//////////////////////////////////////////////////////////////////////////
	if (!pScriptSystem->ExecuteFile( m_script,true ))
	{
		GetISystem()->Warning(
			VALIDATOR_MODULE_3DENGINE,VALIDATOR_WARNING,
			VALIDATOR_FLAG_FILE|VALIDATOR_FLAG_SCRIPT,
			m_script.c_str(),
			"'%s' failed to load surface type definition script",m_name.c_str() );
		return false;
	}

	if (!mtlTable->GetValue( m_name,m_pScriptTable ))
		return false;

	XmlNodeRef matNode = m_root->newChild("SurfaceType");
	matNode->setAttr( "name",m_name );

	// Load physics params.
	SmartScriptTable pPhysicsTable,props;
	float fBouncyness = 0.0f;
	float fFriction = 1.0f;
	int		iPiercingResistence = sf_max_pierceable;	// physics traces range 0-15
	int   imatBreakable = -1, bManuallyBreakable=0;
	m_iBreakability=0; m_nHitpoints=0; m_breakEnergy=0;
	if (m_pScriptTable->GetValue("physics",pPhysicsTable))
	{
		pPhysicsTable->GetValue("friction",fFriction);
		pPhysicsTable->GetValue("bouncyness",fBouncyness);
		pPhysicsTable->GetValue("breakable_id",imatBreakable);
		if (pPhysicsTable->GetValue("pierceability",iPiercingResistence))
		{
			if(iPiercingResistence>sf_max_pierceable)
				iPiercingResistence = sf_max_pierceable;
		}
		int nBreakable2d = 0;
		int bNoCollide = 0;
		pPhysicsTable->GetValue("no_collide", bNoCollide);
		if (pPhysicsTable->GetValue("break_energy",m_breakEnergy))
		{
			bManuallyBreakable = sf_manually_breakable;
			m_iBreakability = 2;
			pPhysicsTable->GetValue("hit_points",m_nHitpoints);
		} else if (m_pScriptTable->GetValue("breakable_2d",props))
		{
			nBreakable2d = 1;
			bManuallyBreakable = sf_manually_breakable;
			m_iBreakability = 1;
			props->GetValue("break_energy",m_breakEnergy);
			props->GetValue("hit_points",m_nHitpoints);
		}

		m_nFlags &= ~SURFACE_TYPE_NO_COLLIDE;
		if (bNoCollide)
			m_nFlags |= SURFACE_TYPE_NO_COLLIDE;

		XmlNodeRef physNode = matNode->newChild("Physics");
		physNode->setAttr( "friction",fFriction );
		physNode->setAttr( "elasticity",fBouncyness );
		physNode->setAttr( "breakable_id",imatBreakable );
		physNode->setAttr( "pierceability",iPiercingResistence );
		physNode->setAttr( "no_collide",bNoCollide );
		physNode->setAttr( "break_energy",m_breakEnergy );
		physNode->setAttr( "hit_points",m_nHitpoints );
		physNode->setAttr( "breakable_2d",nBreakable2d );
	}

	SmartScriptTable pAITable;
	if (m_pScriptTable->GetValue("AI",pAITable))
	{
		XmlNodeRef aiNode = matNode->newChild("AI");
		float fImpactRadius = 1;
		float fFootStepRadius = 1;
		float proneMult = 1;
		float crouchMult = 1;
		float movingMult = 1;
		pAITable->GetValue( "fImpactRadius",fImpactRadius );
		pAITable->GetValue( "fFootStepRadius",fFootStepRadius );
		pAITable->GetValue( "proneMult",proneMult );
		pAITable->GetValue( "crouchMult",crouchMult );
		pAITable->GetValue( "movingMult",movingMult );

		aiNode->setAttr( "fImpactRadius",fImpactRadius );
		aiNode->setAttr( "fFootStepRadius",fFootStepRadius );
		aiNode->setAttr( "proneMult",proneMult );
		aiNode->setAttr( "crouchMult",crouchMult );
		aiNode->setAttr( "movingMult",movingMult );
	}
	gEnv->pPhysicalWorld->SetSurfaceParameters(m_nId,fBouncyness,fFriction,
		(uint32)(sf_pierceability(iPiercingResistence) | sf_matbreakable(imatBreakable) | bManuallyBreakable));


	return true;
}
Example #7
0
        XmlNodeRef MakeXmlNodeStruct(const char* str, const behaviac::string& typeNameT)
        {
            behaviac::string src = str;

            //{color=0;id=;type={bLive=false;name=0;weight=0;};}
            //the first char is '{'
            //the last char is '}'
            behaviac::string::size_type posCloseBrackets = behaviac::StringUtils::Private::SkipPairedBrackets(src);
            BEHAVIAC_ASSERT(posCloseBrackets != behaviac::string::npos);

            bool bIsStructMember = false;
            XmlNodeRef xmlNode = CreateXmlNode(typeNameT.c_str());

            //{color=0;id=;type={bLive=false;name=0;weight=0;};}
            behaviac::string::size_type posBegin = 1;
            behaviac::string::size_type posEnd = src.find_first_of(';', posBegin);

            while (posEnd != behaviac::string::npos)
            {
                BEHAVIAC_ASSERT(src[posEnd] == ';');

                //the last one might be empty
                if (posEnd > posBegin)
                {
                    behaviac::string::size_type posEqual = src.find_first_of('=', posBegin);
                    BEHAVIAC_ASSERT(posEqual > posBegin);

                    int length = posEqual - posBegin;
                    behaviac::string memmberName = src.substr(posBegin, length);
                    behaviac::string memmberValue;
                    char c = src[posEqual + 1];

                    if (c != '{')
                    {
                        length = posEnd - posEqual - 1;
                        memmberValue = src.substr(posEqual + 1, length);

                    }
                    else
                    {
                        bIsStructMember = true;

                        const char* pStructBegin = src.c_str();
                        pStructBegin += posEqual + 1;
                        const char* posCloseBrackets_ = behaviac::StringUtils::Private::SkipPairedBrackets(pStructBegin);
                        length = posCloseBrackets_ - pStructBegin + 1;

                        memmberValue = src.substr(posEqual + 1, length);

                        posEnd = posEqual + 1 + length;
                    }

                    if (bIsStructMember)
                    {
                        XmlNodeRef memberNode = MakeXmlNodeStruct(memmberValue.c_str(), memmberName);

                        xmlNode->addChild(memberNode);

                    }
                    else
                    {
                        //behaviac::string memmberNameFull = typeNameT + "::" + memmberName;
                        //xmlNode->setAttr(memmberNameFull.c_str(), memmberValue.c_str());
                        xmlNode->setAttr(memmberName.c_str(), memmberValue.c_str());
                    }
                }

                bIsStructMember = false;

                //skip ';'
                posBegin = posEnd + 1;

                //{color=0;id=;type={bLive=false;name=0;weight=0;};}
                posEnd = src.find_first_of(';', posBegin);

                if (posEnd > posCloseBrackets)
                {
                    break;
                }
            }

            return xmlNode;
        }