本文整理汇总了C++中PlayerObject::disableAutoAttack方法的典型用法代码示例。如果您正苦于以下问题:C++ PlayerObject::disableAutoAttack方法的具体用法?C++ PlayerObject::disableAutoAttack怎么用?C++ PlayerObject::disableAutoAttack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerObject
的用法示例。
在下文中一共展示了PlayerObject::disableAutoAttack方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: enqueueAutoAttack
void ObjectController::enqueueAutoAttack(uint64 targetId)
{
if (mCommandQueue.empty())
{
uint32 sequence = 0;
uint32 opcode = opOCattack;
CreatureObject* creature = dynamic_cast<CreatureObject*>(mObject);
if (!creature)
{
assert(false && "ObjectController::enqueueAutoAttack mObject is not a CreatureObject");
}
uint32 reply1 = 0;
uint32 reply2 = 0;
ObjectControllerCmdProperties* cmdProperties = NULL;
if (_validateEnqueueCommand(reply1,reply2,targetId,opcode,cmdProperties))
{
ObjControllerCommandMessage* cmdMsg = new(mCmdMsgPool.malloc()) ObjControllerCommandMessage(opcode, cmdProperties->mDefaultTime, targetId);
cmdMsg->setSequence(sequence);
cmdMsg->setData(NULL);
cmdMsg->setCmdProperties(cmdProperties);
// Are there any cooldown left from previous command?
uint64 now = Anh_Utils::Clock::getSingleton()->getLocalTime();
if (mNextCommandExecution <= now)
{
uint64 underrun = now - mNextCommandExecution;
if (underrun <= mUnderrunTime)
{
mUnderrunTime -= underrun;
}
else
{
mUnderrunTime = 0;
}
// This command are to be handled as fast as possible.
mNextCommandExecution = now;
}
// add it
mCommandQueue.push_front(cmdMsg);
// add us to the scheduler, if we aren't queued already
if(!mTaskId)
{
mTaskId = gWorldManager->addObjControllerToProcess(this);
}
}
// not qualified for this command
else
{
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if (player)
{
player->disableAutoAttack();
DLOG(INFO) << "ObjectController::enqueueAutoAttack() Error adding command.";
}
}
}
}
示例2: incap
//=============================================================================
//
// incap
//
void CreatureObject::incap()
{
// sanity check
if (isIncapacitated() || isDead())
{
return;
}
if (this->getType() == ObjType_Player)
{
// gLogger->logMsgF("Player incapped, mIncapCount = %u.", MSG_NORMAL, mIncapCount);
// first incap, update the initial time
uint64 localTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
if(!mIncapCount)
{
mFirstIncapTime = localTime;
}
// reset the counter if the reset time has passed
else if(mIncapCount != 0 && (localTime - mFirstIncapTime) >= gWorldConfig->getIncapResetTime() * 1000)
{
// gLogger->logMsgF("Time since first incap = %"PRIu64"", MSG_NORMAL, localTime - mFirstIncapTime);
// gLogger->logMsgF("Resetting mFirstIncapTime", MSG_NORMAL);
mIncapCount = 0;
mFirstIncapTime = localTime;
}
/*
if (mIncapCount != 0)
{
gLogger->logMsgF("Time since first incap = %"PRIu64"", MSG_NORMAL, localTime - mFirstIncapTime);
}
*/
PlayerObject* player = dynamic_cast<PlayerObject*>(this);
if (player)
{
player->disableAutoAttack();
}
//See if our player is mounted -- if so dismount him
if(player->checkIfMounted())
{
//Get the player's mount
if(Vehicle* vehicle = dynamic_cast<Vehicle*>(gWorldManager->getObjectById(player->getMount()->getPetController())))
{
//Now dismount
vehicle->dismountPlayer();
}
}
// advance incaps counter
if(++mIncapCount < gWorldConfig->getConfiguration("Player_Incapacitation",3))
{
// gLogger->logMsgF("Player incapped, mIncapCount set to = %u, setting timer..", MSG_NORMAL, mIncapCount);
// update the posture
mPosture = CreaturePosture_Incapacitated;
// send timer updates
mCurrentIncapTime = gWorldConfig->getBaseIncapTime() * 1000;
gMessageLib->sendIncapTimerUpdate(this);
// schedule recovery event
mObjectController.addEvent(new IncapRecoveryEvent(),mCurrentIncapTime);
// reset states
mState = 0;
// reset ham regeneration
mHam.updateRegenRates();
gWorldManager->removeCreatureHamToProcess(mHam.getTaskId());
mHam.setTaskId(0);
updateMovementProperties();
gMessageLib->sendPostureAndStateUpdate(this);
if(PlayerObject* player = dynamic_cast<PlayerObject*>(this))
{
gMessageLib->sendUpdateMovementProperties(player);
gMessageLib->sendSelfPostureUpdate(player);
}
}
// we hit the max -> death
else
{
// gLogger->logMsgF("Player died.", MSG_NORMAL);
die();
}
}
else if (this->getType() == ObjType_Creature) // A Creature.
{
die();
}
//.........这里部分代码省略.........
示例3: _processCommandQueue
//=============================================================================
//
// process command queue
//
bool ObjectController::_processCommandQueue()
{
mHandlerCompleted = false;
// init timers
uint64 startTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
uint64 currentTime = startTime;
uint64 processTime = 0;
// uint64 currentTime = Anh_Utils::Clock::getSingleton()->getLocalTime();
PlayerObject* player = dynamic_cast<PlayerObject*>(mObject);
if (!player)
{
assert(false && "ObjectController::_processCommandQueue mObject is not a PlayerObject");
return false;
}
// If queue empty and we are in combat, insert player initiated auto-attack when the previous command has run out it's cooldown.
if (mCommandQueue.empty() && player->autoAttackEnabled() && (mNextCommandExecution <= currentTime))
{
// Auto attack current target.
uint64 autoTargetId = player->getCombatTargetId();
if (autoTargetId != 0)
{
this->enqueueAutoAttack(autoTargetId);
}
else
{
player->disableAutoAttack();
}
}
// For debug
int16 loopCounter = 0;
// loop until empty or our time is up
while (!mCommandQueue.empty() && (processTime < mCommandQueueProcessTimeLimit))
{
mInUseCommandQueue = true;
if (++loopCounter > 1)
{
}
// see if we got something to execute yet
ObjControllerCommandMessage* cmdMsg = mCommandQueue.front();
// we might need to execute the command directly if it is part of the combat queue
// and our queue execution timer permits it
// or it is not part of the combat queue and can be executed directly in any case
if ((mNextCommandExecution <= currentTime) || !cmdMsg->getCmdProperties()->mAddToCombatQueue)
{
if (cmdMsg->getCmdProperties()->mAddToCombatQueue)
{
// Compensate combat command for any lag, i.e. command arriving late.
mUnderrunTime += (currentTime - mNextCommandExecution);
}
// get the commands data
Message* message = cmdMsg->getData(); // Be aware, internally created messages are NULL (auto-attack)
uint32 command = cmdMsg->getOpcode();
uint64 targetId = cmdMsg->getTargetId();
uint32 reply1 = 0;
uint32 reply2 = 0;
ObjectControllerCmdProperties* cmdProperties = cmdMsg->getCmdProperties();
// validate if we are still able to execute
if (cmdProperties && _validateProcessCommand(reply1,reply2,targetId,command,cmdProperties))
{
// Do not mess with cooldowns for non combat commands, those timer values are for preventing spam of the same message,
// and spam preventing is not implemented yet.
uint64 timeToNextCommand = 0;
if (cmdMsg->getCmdProperties()->mAddToCombatQueue)
{
// Set up the cooldown time.
if (mUnderrunTime < cmdProperties->mDefaultTime)
{
timeToNextCommand = (cmdProperties->mDefaultTime - mUnderrunTime);
mUnderrunTime = 0;
}
else
{
// Compensate as much as we can.
timeToNextCommand = cmdProperties->mDefaultTime / 2;
mUnderrunTime -= timeToNextCommand;
}
}
// keep a pointer to the start
uint16 paramsIndex = 0;
if (message)
{
paramsIndex = message->getIndex();
}
//.........这里部分代码省略.........