Esempio n. 1
0
//设置目标变量GUID的值
double CScript::SetDestGuidVar(const char* cmd, char* retStr)
{
	double dbRet = 0;
	CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_DesShape);
	if(!pMoveShape)	return dbRet;

	char* szValueName= GetStringParam(cmd,0);
	if(szValueName)
	{
		if( strlen(szValueName) >= 2 && szValueName[0]=='@')
		{
			char* szGuidName = GetStringParam(cmd,1);
			if(szGuidName )
			{
				if(p_SrcShape)
				{
					const CGUID& guid = GetScriptGuidValue((CMoveShape*)p_SrcShape, szGuidName);
					pMoveShape->GetVariableList()->SetGuidValue(szValueName,&guid);
				}
				M_FREE( szGuidName, sizeof(char)*MAX_VAR_LEN );
			}
		}
		M_FREE( szValueName, sizeof(char)*MAX_VAR_LEN );
	}

	return dbRet;
}
Esempio n. 2
0
//设置目标整形变量的值,$bound默认为0
double CScript::SetDestIntVar(const char* cmd, char* retStr)
{
	double dbRet = 0;
	CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_DesShape);
	if(!pMoveShape)	return dbRet;

	char* szValueName= GetStringParam(cmd,0);
	if(szValueName)
	{
		if( strlen(szValueName) >= 2 && szValueName[0]=='$')
		{
			long lValue =  GetIntParam(cmd,1);
			if(lValue != ERROR_CODE)
			{
				long lBound = GetIntParam(cmd,2);
				if(lBound == ERROR_CODE)
				{
					lBound = 0;
				}
				dbRet = pMoveShape->GetVariableList()->SetVarValue(szValueName,0,lValue);
			}
		}
		M_FREE( szValueName, sizeof(char)*MAX_VAR_LEN );
	}
	
	return dbRet;
}
Esempio n. 3
0
//得到目标字符串变量的值
double CScript::GetDestStrVar(const char* cmd, char* retStr)
{
	double dbRet = 0;
	CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_DesShape);
	if(!pMoveShape)	return dbRet;
	
	char* szValueName= GetStringParam(cmd,0);
	if(szValueName)
	{
		if( strlen(szValueName) >= 2 && szValueName[0]=='#')
		{
			char* szRetName = GetStringParam(cmd,1);
			if(szRetName)
			{
				const char* szValue = pMoveShape->GetVariableList()->GetVarValue(szValueName);
				if(szValue && p_SrcShape)
				{
					SetScriptVarValue(dynamic_cast<CMoveShape*>(p_SrcShape),szRetName,szValue);
				}
				M_FREE( szRetName, sizeof(char)*MAX_VAR_LEN );
			}
		}
		M_FREE( szValueName, sizeof(char)*MAX_VAR_LEN );
	}

	return dbRet;
}
Esempio n. 4
0
double CScript::DestUndefine(const char* cmd, char* retStr)
{
    CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_DesShape);
    if(!pMoveShape)	return false;

    char* varname=GetStringParam(cmd,0);
    if (varname)
    {
        if(pMoveShape->GetType() == TYPE_PLAYER || pMoveShape->GetType() == TYPE_MONSTER )
        {
            if(varname[0] == '$')
                pMoveShape->GetVariableList()->RemoveVar(varname);
            else if(varname[0] == '@'
                    ||varname[0] == '#' )
            {
                // 数组下标值
                int lArray = CVariableList::VAR_NOT_FOUND;
                char MainVarName[256];
                char InnVarName[256];

                // m_Var[num].c_str() 第一个字符作为整数数组和字符串数组的标识符
                char* MainVarNamePtr = MainVarName;
                char* InnVarNamePtr = InnVarName;
                char* varTypeFlag = (char*)varname;
                long tempPos = 0;

                double ret = CheckParamStringForArray(varTypeFlag, strlen(varname), &MainVarNamePtr, 256, &InnVarNamePtr, 256, tempPos);
                if(1.0f == ret)
                {
                    if(InnVarNamePtr[0] == '$') // 下标是变量
                        lArray = GetScriptVarValue((CMoveShape*)pMoveShape, InnVarName, 0);
                    else
                        lArray = atoi(InnVarName);

                    for(int i=0; i<lArray; i++)
                    {
                        char szStrNewName[128];
                        _snprintf(szStrNewName, 128, "%s%d", MainVarNamePtr, i);
                        if(MainVarNamePtr[0] == '#')
                            pMoveShape->GetVariableList()->RemoveVar(szStrNewName);
                        else if(MainVarNamePtr[0] == '@')
                            pMoveShape->GetVariableList()->RemoveGuid(szStrNewName);
                    }
                }
                else if(0.0f == ret)
                {
                    if(varname[0] == '#')
                        pMoveShape->GetVariableList()->RemoveVar(varname);
                    else if(varname[0] == '@')
                        pMoveShape->GetVariableList()->RemoveGuid(varname);
                }
            }

            if( pMoveShape->GetType() == TYPE_PLAYER )
            {
                GetGame()->UpdateSavePlayer((CPlayer*)pMoveShape, SAVE_DETAIL_ATTRVARLIST);
            }
            M_FREE( varname, sizeof(char)*MAX_VAR_LEN );
            return 1.0f;
        }
    }
    M_FREE( varname, sizeof(char)*MAX_VAR_LEN );
    return 0;
}