Esempio n. 1
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. 2
0
//为当前对象注册一个定时器
double CScript::RegisterTimer(const char* cmd, char* retStr)
{
	int nRet = 0;
	long lfuturetime = static_cast<long>(GetIntParam(cmd, 0));
	if(lfuturetime != ERROR_CODE && lfuturetime != INVILID_VALUE)
	{
		long lInterTime = static_cast<long>(GetIntParam(cmd, 1));
		if(lInterTime != ERROR_CODE && lInterTime != INVILID_VALUE)
		{
			char* pszScriptName=GetStringParam(cmd,2);
			if( pszScriptName )
			{
				long lUserData = static_cast<long>(GetIntParam(cmd, 3));
				if(lUserData != ERROR_CODE && lUserData != INVILID_VALUE)
				{
					CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_SrcShape);
					if( pMoveShape )
					{
						//添加提示
						nRet = pMoveShape->RegisterScriptTimer(lfuturetime,lInterTime,
							pszScriptName,lUserData);
					}
				}
				M_FREE( pszScriptName, sizeof(char)*MAX_VAR_LEN );
			}
		}
	}
	return nRet;
}
Esempio n. 3
0
	/// return true to filter shape.
	bool operator() ( CShape *pShape )
	{
		CMoveShape *pDest = static_cast<CMoveShape*>( pShape );
		if( pDest->IsDied() )
		{
			return true;
		}
		if( pOwner->Distance( pShape ) > lRange )
		{
			return true;
		}

		if (!pDest->IsVisible(pOwner) )			// ÒþÐÎ
		{
			return true;
		}

		if(  pDest->GetExID() == pOwner->GetBefoolID() )
		{
			return true;
		}

		if( AIUtilities::IsInGodState( pShape ) )
		{
			return true;
		}

		return false;
	}
void Script::CallScriptByGUID(const CGUID& shapeGuid, const char* scriptFilename)
{
	CMoveShape* shape = GetGame()->FindShape(TYPE_PLAYER, shapeGuid);
	if(shape==NULL)
	{
		CServerRegion* region = dynamic_cast<CServerRegion*>(m_RunEnv.region);
		if(region != NULL)
			shape = dynamic_cast<CMoveShape*>(region->FindChildObject(TYPE_MONSTER, shapeGuid));
	}

	if(shape != NULL) // 本地调用脚本
	{
		RunEnv env;
		env.region = dynamic_cast<CRegion*>(shape->GetFather());
		env.srcShape = shape;
		GetInst(ScriptSys).RunScript(env, scriptFilename);
	}
	else // 跨服调用脚本
	{
		CMessage msg(MSG_S2W_QUEST_PlayerRunScript);
		msg.Add(shapeGuid); // call guid
		msg.Add(scriptFilename);	 // called script name
		msg.SendToSocket(GetGame()->GetWSSocket());
	}
}
Esempio n. 5
0
//执行
void COpGood::Execute(CMoveShape* pShape)
{
    CMoveShape *pMoveShape = NULL;
    if (m_Obj==Obj_Self)
    {
        pMoveShape = m_pParam->pUser;
    }
    else
    {
        pMoveShape = pShape;
    }
    if (m_Op == MODOP_Sub)
    {
        if (m_strOrigName.size()>0)
        {
            //根据原始名删除物品
            pMoveShape->DelGoods((char*)m_strOrigName.c_str(),m_nValue);

        }
        else if(m_nPlace!=0&&m_nPos!=0)
        {
            //根据容器id和pos删除物品
            pMoveShape->DelGoodsAndSendMsg(m_nPlace,m_nPos);
        }
        else
        {
            //根据容器id和物品类别删除物品
            pMoveShape->DeleteGoods((CS2CContainerObjectMove::PLAYER_EXTEND_ID)m_nPlace,(eGoodsBaseType)m_nGoodType,m_nWeaponType,m_nValue);
        }

    }
}
Esempio n. 6
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. 7
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. 8
0
bool NormalCloseInAttackAI::StepEndAI()
{
    if(m_pSkill)
    {
        CMoveShape* pMoveshape = dynamic_cast<CMoveShape*>(GetGame()->GetRegion()->FindChildObject(m_pSkill->GetSourType(), m_pSkill->GetSourID()));
        if(pMoveshape)
        {
            AnimInfo::tagActionInfo *pActionInfo = pMoveshape->GetAnimInfo()->GetActionInfo();
            if(pActionInfo && pMoveshape->GetAction() >= CShape::ACT_PERFORM)
            {
                pActionInfo->bCurActionLooped = FALSE;
            }
        }
        if (pMoveshape->GetType() == TYPE_PET)
        {
            CPet *pPet = (CPet*)pMoveshape;
            if (pPet->IsMainPlayerPet())
            {
                tagPetSkillInfo *pPetSkill = pPet->GetPetSkillInfoByID(m_pSkill->GetSkillID());
                if(pPetSkill)
                    pPetSkill->bIsSkillUsingEnd = true;
                //pPet->SkillSuccReceived();
            }
        }
        // 删除特效
        m_pSkill->DelAllEffectListByStep(CSkillXml::STEP_START);
        m_pSkill->DelAllEffectListByStep(CSkillXml::STEP_RUN);
        m_pSkill->DelAllEffectListByStep(CSkillXml::STEP_END);
        m_pSkill->SetIsDeleted(true);
        return true;
    }
    return false;
}
Esempio n. 9
0
void NormalCloseInAttackAI::AI()
{
    //CPlayer *pPlayer = GetGame()->GetMainPlayer();
    if(!m_pSkill)
        return;
    CMoveShape* pMoveshape = dynamic_cast<CMoveShape*>(GetGame()->GetRegion()->FindChildObject(m_pSkill->GetSourType(), m_pSkill->GetSourID()));
    // 开始阶段可能有吟唱动作
    if(pMoveshape && m_pSkill && m_pSkill->GetCurStep() != CSkillXml::STEP_START && m_pSkill->GetRunStepActExQueue())
    {
        /***********************************************************************/
        /* zhaohang fix */
        /***********************************************************************/
        // 非光环类技能
        CSkillListXml::tagSkill *pSkill = CSkillListXml::GetProperty(m_pSkill->GetSkillID());
        if (pSkill && (pSkill->bLockSkill || pSkill->dwSkillState == 0))
            //tagSkillIni* pSkill = SkillAttrIniSetup::GetSkillIni(m_pSkill->GetSkillID());
            //if( pSkill && pSkill->GetSkillBaseAttr() &&
            //	 pSkill->GetSkillBaseAttr()->IsLockSkill() )
        {
            // 释放阶段无后续动作
            if(m_pSkill->GetRunStepActExQueue()->empty())
            {
                if(pMoveshape->GetAction() == ACT_STAND || pMoveshape->GetAction() == ACT_IDLE)
                    StepEndAI();
            }
        }
    }
}
Esempio n. 10
0
double CScript::ChangeAttr(const char* CmdStr, char* retStr)
{
	OBJECT_TYPE type;
	CGUID id;
	double value  = 0;
	double ret = INVILID_VALUE;

	int param = GetIntParam(CmdStr, 0);
	if(param != ERROR_CODE && param != INVILID_VALUE)
	{
		type = (OBJECT_TYPE)param;

		char* pIdName = GetStringParam(CmdStr, 1);
		if(NULL == pIdName) return ret;
		id = GetVariableList()->GetGuidValue(pIdName);
		if(id == NULL_GUID)
			id = GetGeneralVariableList()->GetGuidValue(pIdName);
		if(id == NULL_GUID)
			id = ((CPlayer*)p_SrcShape)->GetVariableList()->GetGuidValue(pIdName);

		CMoveShape* shape = GetGame()->FindShape(type, id);

		char* name = GetStringParam(CmdStr, 2);
		if(name)
		{
			value = GetIntParam(CmdStr, 3);
			if(value != ERROR_CODE && value != INVILID_VALUE)
			{

				if(NULL == shape) // 默认id=0时,直接调用SrcShape的SetAttr接口
				{
					CShape* cShape = GetSrcShape();
					if(cShape)
					{
						((CMoveShape*)cShape)->ChangeAttribute(string(name), value);
						((CMoveShape*)cShape)->UpdateAttribute();
						ret = 1;
					}
				}
				else
				{
					shape->ChangeAttribute(string(name), value);
					shape->UpdateAttribute();
					ret = 1;
				}
			}
		}

		M_FREE( pIdName, sizeof(char)*MAX_VAR_LEN );
		M_FREE( name, sizeof(char)*MAX_VAR_LEN );
	}
	else // 参数是字符串
	{
		AddErrorLogText(CStringReading::LoadString(IDS_GS_FUNCTION, STR_GS_FUNCTION_CHANGEATTRFIRSTVARISSTRING));
	}

	return ret;
}
Esempio n. 11
0
    void GuardSearch::Execute( BaseType::EntityType *entity )
    {
        CMonster *pSelf = dynamic_cast<CMonster*>( entity->GetOwner() );
        ShapeListType player_list;
        ShapeListType monster_list;
        CServerRegion *pRegion = static_cast<CServerRegion*>( pSelf->GetFather() );
        CMoveShape *pTarget = NULL;

        if( CanAttackCurrent( pSelf, entity ) )
        {
            return;
        }

        // find the around players
        pRegion->FindAroundObject( pSelf, TYPE_PLAYER, player_list );
        // find the around monsters including the guards.
        pRegion->FindAroundObject( pSelf, TYPE_MONSTER, monster_list );

        // filter the result
        Filter filter( static_cast<CMonster*>( pSelf ) );
        filter_shape( player_list, filter );
        filter_shape( monster_list, filter );


        // retrieve the ai reference
        DWORD ai_ref = pSelf->GetAIReferrence( 0 );
        if( ai_ref >= 0 )
        {
            pTarget = SearchByAIRef1( pSelf, player_list, ai_ref );
        }

        if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 1 ) ) > 0 )
        {
            pTarget = SearchByAIRef2( pSelf, player_list, ai_ref );
        }	

        if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 2 ) ) > 0 )
        {
            pTarget = SearchByAIRef3( pSelf, monster_list, ai_ref );
        }

        if( pTarget == NULL && ( ai_ref = pSelf->GetAIReferrence( 3 ) ) > 0 )
        {
            pTarget = SearchByAIRef4( pSelf, monster_list, ai_ref );
        }

        if( pTarget != NULL )
        {
            // search successfully
            entity->SetTarget( pTarget->GetExID(), pTarget->GetType() );
        }
        else if( entity->HasTarget() )
        {
            AI_EVENT_SENDER( entity ).ReturnPeace();
        }
    }
Esempio n. 12
0
void FightObj::ReturnPeace()
{
    CMoveShape *target = m_AI->GetTarget();
    if(target)
    {
        TauntEvents events(m_Owner->GetTauntHandler());
        events.TargetLost(target->GetExID(), target->GetType());
    }
    m_AI->ChangeState(ST_RETURN, ReturnEvent(m_EnterFightPos.x, m_EnterFightPos.y));
}
Esempio n. 13
0
double CScript::GetCurrentSpeed(const char* cmd, char* retStr)
{
	double dbRet = 0.0;
	CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_SrcShape);
	if(pMoveShape)
	{
		dbRet =  pMoveShape->GetSpeed();// SetChangeSpeed(nSpeed);
	}
	return dbRet;
}
Esempio n. 14
0
    int SkillTracer::Run(BaseAI *ai)
    {
        if(timeGetTime() >= m_EndTime)
        {
            return TIMEOUT;
        }
        CMoveShape *self = ai->GetOwner();
        CServerRegion *rgn = dynamic_cast<CServerRegion*>(self->GetFather());
        CMoveShape *target = AIUtils::FindShape(rgn, m_TargetID);
        if(target == NULL)
        {
            return FAILED;
        }
#ifdef MONSTER_DIS_FLOAT
        float dis = self->RealDistanceF(target);
#else
        long dis = self->Distance(target);
#endif
        long dx = target->GetTileX();
        long dy = target->GetTileY();
        if(dis > m_SkillMaxDis)
        {
            ai->Move(dx, dy);
        }
        else if(dis < m_SkillMinDis)
        {
            long dir = GetLineDir(dx, dy, self->GetTileX(), self->GetTileY());
            ai->Move(dir);
        }
        else
        {
            return Okay;
        }
        return RUNNING;
    }
Esempio n. 15
0
double CScript::GetAttr(const char* CmdStr, char* retStr)
{
	OBJECT_TYPE type;
	CGUID id;
	double value   = 0;

	if(!GetSrcShape()) return -1.0f;

	int param = GetIntParam(CmdStr, 0);
	if(param != ERROR_CODE && param != INVILID_VALUE)
	{
		type = (OBJECT_TYPE)param;

		char* pIdName = GetStringParam(CmdStr, 1);
		if(!pIdName) return -1.0f;

		id = GetScriptGuidValue((CMoveShape*)GetSrcShape(), pIdName);

		char* name = GetStringParam(CmdStr, 2);
		if(!name)
		{
			M_FREE( pIdName, sizeof(char)*MAX_VAR_LEN );
			return -1.0f;
		}

		CMoveShape* shape = NULL;
		if(NULL_GUID == id) // 默认id=0时,直接调用SrcShape的SetAttr接口
		{
			shape = (CMoveShape*)GetSrcShape();
		}
		else
			shape = GetGame()->FindShape(type, id);

		if(shape)
		{
			long lRet = shape->GetAttribute(std::string(name));
			M_FREE( pIdName, sizeof(char)*MAX_VAR_LEN );
			M_FREE( name, sizeof(char)*MAX_VAR_LEN );
			return lRet;
		}
		
		M_FREE( pIdName, sizeof(char)*MAX_VAR_LEN );
		M_FREE( name, sizeof(char)*MAX_VAR_LEN );
	}
	else // 该参数是字符串
	{
		AddErrorLogText(CStringReading::LoadString(IDS_GS_FUNCTION, STR_GS_FUNCTION_SETATTRFIRSTVARISSTRING));
	}

	return 0.0f;
}
Esempio n. 16
0
BOOL Guard::CanAttackCurrent()
{
	if( !HasTarget() )
	{
		return FALSE;
	}

	CMoveShape *pTarget = GetTarget();
	long dis = m_pOwner->Distance( pTarget );
	long attack_range = static_cast<CMonster*>( m_pOwner )->GetAttribute( string( "C_GuardRange" ) );

	if( dis > attack_range )
	{
		return FALSE;
	}

	CMonster *pSelf = static_cast<CMonster*>( m_pOwner );
	DWORD ai_ref = 0;
	
	if( pTarget->GetType() == TYPE_PLAYER )
	{
		CPlayer *pPlayer = static_cast<CPlayer*>( pTarget );
		// ai reference 1
		ai_ref = pSelf->GetAIReferrence( 0 );
		if( ai_ref >= 0 )
		{
			if( pPlayer->GetPVPValue() >= ai_ref && !IsSameCamp( pPlayer, pSelf ) )
			{
				return TRUE;
			}
		}
		// ai reference 2
		ai_ref = pSelf->GetAIReferrence( 1 );
		if( ai_ref > 0 )
		{
			if( pPlayer->GetPkValue() >= ai_ref )
			{
				return TRUE;
			}
		}
	}
	
	// actually, it's not necessary to judge monsters, that because the property for the monsters will
	// not changed .So ignored here.
	// ...

	return FALSE;
}
Esempio n. 17
0
VOID CExState1::End()
{
	if( m_pCurrentVisualEffect )
	{
		m_pCurrentVisualEffect -> UpdateVisualEffect( this, 1 );
	}
	CMoveShape* pShape = GetSufferer();
	if( pShape )
	{
		pShape->RemoveState( this );
	}
	else
	{
		//##获取不到承载者,有可能。
	}
}
Esempio n. 18
0
//执行
void COpDirec::Execute(CMoveShape* pShape)
{
    if (pShape == m_pParam->pUser && m_eDir!=eDir_Mouse)
    {
        return;
    }
    CMoveShape *pMoveShape = GetOpShape(pShape);
    long lX = 0,lY = 0;

    if(pMoveShape == NULL)
    {
        lX = m_pParam->nMouseX;
        lY = m_pParam->nMouseY;
        float fDir =GetRadianDir((float)m_pParam->pUser->GetTileX(),(float)m_pParam->pUser->GetTileY(),(float)lX,(float)lY);
        m_pParam->pUser->SetDir((long)fDir);
        //SendChangeDir(m_pParam->pUser);
        return;
    }

    if(m_eDir == eDir_Mouse)
    {
        lX = m_pParam->nMouseX;
        lY = m_pParam->nMouseY;
    }
    else if(m_eDir == eDir_Self)
    {
        lX = m_pParam->pUser->GetTileX();
        lY = m_pParam->pUser->GetTileY();
    }
    else if(m_eDir == eDir_Dest && pShape )//&&
    {
        lX = pShape->GetTileX();
        lY = pShape->GetTileY();
        if (m_pParam->pMouseShape)
        {
            lX = m_pParam->pMouseShape->GetTileX();
            lY = m_pParam->pMouseShape->GetTileY();
        }
    }
    if((lX !=0 || lY !=0) && pMoveShape)
    {
        float fDir =GetRadianDir((float)pMoveShape->GetTileX(),(float)pMoveShape->GetTileY(),(float)lX,(float)lY);
        pMoveShape->SetDirEx(fDir);
        //SendChangeDir(pMoveShape);
    }

}
Esempio n. 19
0
bool FightObj::CheckReturnPeace()
{
    if (m_Owner->GetIsFlyToPeace() == 0)
        return false;

    long dis = Distance(m_EnterFightPos.x, m_EnterFightPos.y, m_Owner->GetTileX(),
                        m_Owner->GetTileY());

    unsigned long thisTime = timeGetTime();
    if(m_AI->HasTarget())
    {
        CMoveShape *target = m_AI->GetTarget();

        if (target == NULL || PHASEMAN.PhasePlayerFilter(target,m_Owner))
        {
            ReturnPeace();
            return true;
        }

        if(target->IsDied() ||
                !target->IsAttackAble(m_Owner) ||
                !target->IsVisible(m_Owner))
        {
            ReturnPeace();
            return true;
        }

        if(dis > m_Owner->GetBaseChaseRange())
        {
            ReturnPeace();
            return true;
        }

        if(dis > m_Owner->GetReturnRange() && thisTime > m_HurtTime)
        {
            ReturnPeace();
            return true;
        }
    }
    else if(thisTime > m_GuardTime)
    {
        ReturnPeace();
        return true;
    }

    return false;
}
Esempio n. 20
0
bool CFixSummonAI::StepEndAI()
{
	DelAllEffect();
	m_pSkill->SetIsDeleted(true);
	CMoveShape* pMoveshape = dynamic_cast<CMoveShape*>(GetGame()->GetRegion()->FindChildObject(m_pSkill->GetSourType(), m_pSkill->GetSourID()));
	if(pMoveshape && pMoveshape->GetType() == TYPE_PET)
	{
		CPet *pPet = (CPet*)pMoveshape;
		if (pPet->IsMainPlayerPet())
		{
			tagPetSkillInfo *pPetSkill = pPet->GetPetSkillInfoByID(m_pSkill->GetSkillID());
			if(pPetSkill)
				pPetSkill->bIsSkillUsingEnd = true;
		}
	}
	return true;
}
Esempio n. 21
0
void CFighterPet::AI()
{
	if( m_pMaster && m_pRegion )
	{
		CMoveShape* pAimShape = m_pMaster;
		long lX = GetTileX();
		long lY = GetTileY();
		long lAimX = pAimShape->GetTileX();
		long lAimY = pAimShape->GetTileY();

		//	¸úËæÖ÷ÈËÒƶ¯
		if( abs(lX-lAimX) > 3 || abs(lY-lAimY) > 3 )
		{
			if( IsActive())
				AutoMoveAI(lAimX,lAimY);
		}
	}
}
Esempio n. 22
0
unsigned int CEffEventByParam::GetEffectObjs(list<CMoveShape*>& listObjs)
{
	listObjs.clear();	
	int nNum=0;
	if (m_pParam->pEventVar && m_pParam->pEventVar->pVar)
	{
		CMoveShape *pMoveShape = (CMoveShape*)(m_pParam->pEventVar->pVar);
			if (pMoveShape)
			{
				m_pParam->pMouseShape = pMoveShape;
				m_pParam->nMouseShapeType = pMoveShape->GetType();
				m_pParam->MouseShapeID = pMoveShape->GetExID();
				listObjs.push_back(pMoveShape);
				++nNum;
			}	
	}
	return nNum;
}
Esempio n. 23
0
//为当前对象注销一个定时器
double CScript::UnRegisterTimer(const char* cmd, char* retStr)
{
	int nRet = 0;
	long lUserData = static_cast<long>(GetIntParam(cmd, 0));
	if(lUserData != ERROR_CODE && lUserData != INVILID_VALUE)
	{
		long lTimerID = static_cast<long>(GetIntParam(cmd, 1));
		if(lTimerID != ERROR_CODE && lTimerID != INVILID_VALUE)
		{
			CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_SrcShape);
			if( pMoveShape )
			{
				//添加提示
				nRet = pMoveShape->UnRegisterScriptTimer(lUserData,lTimerID);
			}
		}
	}
	return nRet;
}
Esempio n. 24
0
double CScript::SetMoveSpeed(const char* cmd, char* retStrL)
{
	double dbRet = 1;
	int nSpeed = GetIntParam(cmd, 0);
	if(nSpeed != ERROR_CODE && nSpeed != INVILID_VALUE)
	{
		CMoveShape* pMoveShape = dynamic_cast<CMoveShape*>(p_SrcShape);
		if(pMoveShape)
		{
			pMoveShape->SetChangeSpeed(nSpeed);
			pMoveShape->SendChangedSpeedToClients();
		}
	}
	else // 参数是整数
	{
		AddErrorLogText("ERR: SetMoveSpeed(): 1st Arg is int!");
	}
	return dbRet;
}
Esempio n. 25
0
void CSummonPet::AI()
{
	if( m_pMaster && m_pRegion )
	{
		CMoveShape* pAimShape = m_pMaster;
		long lFightMode = PetFightAI();
		long lX = GetTileX();
		long lY = GetTileY();
		long lAimX = pAimShape->GetTileX();
		long lAimY = pAimShape->GetTileY();
		int nRet = -1;
		switch(lFightMode)
		{
		case FMR_Trace_Far:
			if( IsActive() )
			{
				long x = m_pCurAtkShape->GetPosX();
				long y = m_pCurAtkShape->GetPosY();
				nRet = AutoMoveAI(x,y);
			}
			break;
		case FMR_Trace_Near:
		case FMR_Attack:
			{
				UsePetSkill(m_lCurUseSkillPos);
			}
			break;
		case FMR_No_TARGET:
			{
				//	¸úËæÖ÷ÈËÒƶ¯
				if( abs(lX-lAimX) > 3 || abs(lY-lAimY) > 3 )
				{
					if( IsActive())
						AutoMoveAI(lAimX,lAimY);
				}
			}
			break;
		default: break;
		}
	}
}
Esempio n. 26
0
double CScript::ChangeBaseSpeed(const char* cmd, char* retStr)
{
	double dbRet = 1;
	int nRideState = GetIntParam(cmd, 0);
	DWORD dwSrc = GetIntParam(cmd,1);

	if(nRideState != ERROR_CODE && nRideState != INVILID_VALUE && dwSrc != ERROR_CODE && dwSrc != INVILID_VALUE)
	{
		CMoveShape* pMoveShape = (CMoveShape*)(dwSrc);
		if(pMoveShape && pMoveShape->GetType()==TYPE_PLAYER)
		{ 
			if (!pMoveShape->GetIsRide())
			{
				//骑状态
				if(!pMoveShape->GetIsRun())
				{
					pMoveShape->SetSpeed(CGlobeSetup::GetSetup()->fRidePlayerWalkSpeed);
				}
				else
				{
					pMoveShape->SetSpeed(CGlobeSetup::GetSetup()->fRidePlayerRunSpeed);
				}
			} 
			else
			{
				if(!pMoveShape->GetIsRun())
				{
					pMoveShape->SetSpeed(CGlobeSetup::GetSetup()->fPlayerWalkSpeed);
				}
				else
				{
					pMoveShape->SetSpeed(CGlobeSetup::GetSetup()->fPlayerRunSpeed);
				}
			}


			pMoveShape->SendChangedSpeedToClients();
		}
	}
	return dbRet;
}
Esempio n. 27
0
    void PetAI::OnSkillEnd(long subType)
    {
        LogoutRetPeaceAct();
        AddRetPeaceAct();
        if(eAdd_Type == subType &&
            CShape::STATE_PEACE == GetOwner()->GetState())
        {
			LogInfo(AI_MODULE, "PetAI Changed its owner\'s(id=%s) state from %s to %s",
				GetOwner()->GetExID().tostring(),
				CShape::State2Str(GetOwner()->GetState()),
				CShape::State2Str(CShape::STATE_PEACE)
);
            GetOwner()->ChangeStateTo(CShape::STATE_PEACE);

        }
        CMoveShape *target = GetTarget();
        if(target == NULL ||
            target->IsDied())
        {
            Resume(CONTINUE_TIME);
        }
    }
Esempio n. 28
0
/*
 * 功能: 技能显示
 * 摘要: -
 * 参数: -
 * 返回值: 始终true
 * 作者: -
 * 创建日期: -
 * 修改日志:
 *	2008.11.10 - lpf
 *		增加了"仪态动作可切换"
 */
bool NormalCloseInAttackAI::Display()
{
    // 获得释放者
    CMoveShape* pMoveshape = dynamic_cast<CMoveShape*>(GetGame()->GetRegion()->FindChildObject(m_pSkill->GetSourType(), m_pSkill->GetSourID()));
    if(pMoveshape)
    {
        if(m_pSkill->GetCurStep() == CSkillXml::STEP_START && m_pSkill->GetIntonateMainAct())
        {
            // 动作信息
            AnimInfo::tagActionInfo *pActionInfo = pMoveshape->GetAnimInfo()->GetActionInfo();

            // 如果处于吟唱阶段,那么在前期吟唱动作播放完之后,循环播放主要的吟唱动作
            if(pActionInfo &&
                    (pMoveshape->GetAction() == CShape::ACT_STAND ||
                     pMoveshape->GetAction() == CShape::ACT_IDLE ||
                     (pMoveshape->GetAction() >= CShape::ACT_FACEACTION &&
                      pMoveshape->GetAction() <= CShape::ACT_FACEACTIONMAX)))		//仪态动作可切换 - add by lpf(2008.11.10)
            {
                pMoveshape->SetAction(m_pSkill->GetIntonateMainAct());
                pActionInfo->bCurActionLooped = TRUE;
            }
        }
        // 释放阶段
        else if(m_pSkill->GetCurStep() == CSkillXml::STEP_RUN && m_pSkill->GetRunStepActExQueue())
        {
            // 释放阶段续动作列表不为空,且当前动作是站立,将当前动作设置为后续动作列表的第一个动作
            if(!m_pSkill->GetRunStepActExQueue()->empty() && pMoveshape->GetAction() == CShape::ACT_STAND)
            {
                pMoveshape->SetAction(m_pSkill->GetRunStepActExQueue()->front());
                m_pSkill->GetRunStepActExQueue()->pop();
                // 已经是最后一个动作
                if(m_pSkill->GetRunStepActExQueue()->empty())
                {
                    AnimInfo::tagActionInfo *pActionInfo = pMoveshape->GetAnimInfo()->GetActionInfo();
                    if(pActionInfo)
                        pActionInfo->bCurActionLooped = m_pSkill->IsActExCycle();
                }
            }
        }
    }
    return true;
}
Esempio n. 29
0
//发送技能失败消息
void COpSendMsg::CreateSKillFailMsg()
{
	CMoveShape* pUser = m_pParam->pUser;

	if(m_strVariaName !="")
	{
		//  [5/4/2009 chenxianj]	
		m_lValue = (long)m_pParam->pVariableList->GetVarValue<double>(m_strVariaName.c_str(),0);		
		//  [5/4/2009 chenxianj]
		
	}
	//技能失败重置吟唱时间
	if (pUser)
	{
		m_pParam->pUser->SetIntonateTime(timeGetTime(),0);
	}
	CMessage msg(MSG_S2C_SKILL_USE);
	msg.Add((CHAR)SKILL_USE_RESULT_FAILED);
	msg.Add( pUser->GetExID());
	//id和等级
	msg.Add((long)m_pParam->nID);
	msg.Add((BYTE)m_pParam->nLvl );
	//全局id
	msg.Add(m_pParam->dwGlobleID);
	//错误类型
	msg.Add((BYTE)m_lValue);
	CMoveShape* pPlayer = pUser;
	if( TYPE_PET == pUser->GetType() )
	{
		pPlayer = pUser->GetHost();
	}

	if(m_eRange == MsgRange_Single)
		msg.SendToPlayer(pPlayer->GetExID(), false);
	else if(m_eRange == MsgRange_Around)
		msg.SendToPlayers(m_pParam->SendMsgPlayers);
#ifdef _DEBUG
	char str[256]="";
	_snprintf(str, 256, "发送技能失败消息:技能ID:%6d,全局ID:%6d,阶段号:%d\n",m_pParam->nID,m_pParam->dwGlobleID, m_pParam->nProceNum);
	OutputDebugString(str);
#endif

}
Esempio n. 30
0
	void EscapeStateNormal::Execute(BaseType::EntityType *entity)
	{
		if (entity == NULL)
		{
			LogError(AI_MODULE, "entity is null.");
			return;
		}
		MonsterAI *monsterAI = static_cast<MonsterAI*>(entity);

		// check cycle action
		AIState *cycle_action = entity->GetState(ST_CYCLE);
		CycleStateExecutor cycleExecutor;
		if(cycleExecutor.Execute(cycle_action, entity))
		{
			return ;
		}

		// check return peace
		if(monsterAI->GetFightObj().CheckReturnPeace())
		{
			return ;
		}

		CMoveShape *target = entity->GetTarget();
		if(target == NULL)
		{
			LogError(AI_MODULE, "target is null.");
			monsterAI->GetFightObj().LoseTarget();
			entity->Resume(OPER_FAILED_TIME);
		}
		else
		{
			CMoveShape *owner = entity->GetOwner();
			long dir = GetLineDir(target->GetTileX(), target->GetTileY(),
				owner->GetTileX(), owner->GetTileY());
			entity->Move(dir);
		}
	}