Ejemplo n.º 1
0
bool PVState::validate(uint32 &reply1, uint32 &reply2, uint64 targetId, uint32 opcode, ObjectControllerCmdProperties*& cmdProperties)
{
    CreatureObject* creature = dynamic_cast<CreatureObject*>(mController->getObject());

    // if this command doesn't require state checks skip it, otherwise check our states
    if(creature && cmdProperties && (cmdProperties->mStates != 0) && (creature->GetStateBitmask() & cmdProperties->mStates) != 0)
    {
		if(creature->states.checkStates(cmdProperties->mStates))
		{
			reply1 = kCannotDoWhileState;
			reply2 = mController->getLowestCommonBit(creature->GetStateBitmask(), cmdProperties->mStates);
			return false;
		}
		if (cmdProperties->mPostureMask !=0 && ((cmdProperties->mPostureMask & creature->GetPosture()) != 0))
		{
			reply1 = kCannotDoWhileLocomotion;
			reply2 = mController->getPostureValidator(creature->states.getLocomotion());
			return false;
		}
    }
    return true;
}
Ejemplo n.º 2
0
bool EVState::validate(uint32 &reply1, uint32 &reply2, uint64 targetId, uint32 opcode, ObjectControllerCmdProperties*& cmdProperties)
{
    CreatureObject* creature = dynamic_cast<CreatureObject*>(mController->getObject());
	if(creature && cmdProperties)
	{
		//gLogger->log(LogManager::DEBUG, "locomotionMask(%u) & creature->getLocomotion (%u) ==%u",
			//cmdProperties->mLocomotionMask,mController->getLocoValidator(creature->states.getLocomotion()), cmdProperties->mLocomotionMask & creature->states.getLocomotion());
		// skip over commands with no state requirement and check the rest
		if((cmdProperties->mStates != 0) && creature->states.checkStates(cmdProperties->mStates))
		{
			reply1 = kCannotDoWhileState;
			reply2 = this->mController->getLowestCommonBit(creature->states.getAction(), cmdProperties->mStates);
			return false;
		}
		if (cmdProperties->mLocomotionMask !=0 && ((cmdProperties->mLocomotionMask & creature->GetPosture()) != 0))
		{
			reply1 = kCannotDoWhileLocomotion;
			reply2 = mController->getPostureValidator(creature->states.getLocomotion());
			return false;
		}
	}
    return true;
}