示例#1
0
void CStateMachinen::DoScriptMove(CMonster& monster, eStateEvent event)
{
	StateParameter& stateParamter = monster.mStateParamter;

	switch(event)
	{
	case eSEVENT_Enter:
		{
			VECTOR3 position = {
				float(monster.GetFiniteStateMachine().GetMemory().GetVariable("__move_x__")),
				0,
				float(monster.GetFiniteStateMachine().GetMemory().GetVariable("__move_z__")),
			};
			monster.OnMove(
				&position);

			stateParamter.nextTime = gCurTime + CCharMove::GetMoveEstimateTime(
				&monster);
			break;
		}
	case eSEVENT_Process:
		{
			if( stateParamter.nextTime > gCurTime )
			{
				break;
			}

			SetState(
				&monster,
				eMA_STAND);
			break;
		}
	}
}
示例#2
0
void CStateMachinen::DoRunAway(CMonster& monster, eStateEvent evt)
{
	StateParameter& stateParamter = monster.mStateParamter;
	
	if( monster.GetAbnormalStatus()->IsStun ||
		monster.GetAbnormalStatus()->IsFreezing ||
		monster.GetAbnormalStatus()->IsStone ||
		monster.GetAbnormalStatus()->IsSlip ||
		monster.GetAbnormalStatus()->IsMoveStop ||
		monster.GetAbnormalStatus()->IsParalysis )
	{
		return;
	}

	switch(evt)
	{
	case eSEVENT_Enter:
		{
			monster.RemoveAllAggro();
			monster.SetTObject(0);

			VECTOR3 position = {0};
			position.x = float(monster.GetFiniteStateMachine().GetMemory().GetVariable(
				"__runaway_x__"));
			position.z = float(monster.GetFiniteStateMachine().GetMemory().GetVariable(
				"__runaway_z__"));
			monster.OnMove(
				&position);

			stateParamter.nextTime = gCurTime + CCharMove::GetMoveEstimateTime(&monster) + 1000;
			break;
		}
	case eSEVENT_Process:
		{
			if(gCurTime > stateParamter.nextTime)
			{
				SetState(
					&monster,
					eMA_STAND);
				break;
			}

			break;
		}
	}
}