本文整理汇总了C++中Mutate函数的典型用法代码示例。如果您正苦于以下问题:C++ Mutate函数的具体用法?C++ Mutate怎么用?C++ Mutate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Mutate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
void MotionMaster::MoveKnockbackFrom(float srcX, float srcY, float speedXY, float speedZ)
{
//this function may make players fall below map
if (_owner->GetTypeId() == TYPEID_PLAYER)
return;
float x, y, z;
float moveTimeHalf = speedZ / Movement::gravity;
float dist = 2 * moveTimeHalf * speedXY;
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
_owner->GetNearPoint(_owner, x, y, z, _owner->GetObjectSize(), dist, _owner->GetAngle(srcX, srcY) + M_PI);
Movement::MoveSplineInit init(*_owner);
init.MoveTo(x, y, z);
init.SetParabolic(max_height, 0);
init.SetOrientationFixed(true);
init.SetVelocity(speedXY);
init.Launch();
Mutate(new EffectMovementGenerator(0), MOTION_SLOT_CONTROLLED);
}
示例2: init
void MotionMaster::MoveFall(uint32 id/*=0*/)
{
// use larger distance for vmap height search than in most other cases
float tz = _owner->GetMap()->GetHeight(_owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ(), true, MAX_FALL_DISTANCE);
if (tz <= INVALID_HEIGHT)
{
sLog->outStaticDebug("MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).",
_owner->GetMap()->GetId(), _owner->GetPositionX(), _owner->GetPositionX(), _owner->GetPositionZ());
return;
}
// Abort too if the ground is very near
if (fabs(_owner->GetPositionZ() - tz) < 0.1f)
return;
Movement::MoveSplineInit init(*_owner);
init.MoveTo(_owner->GetPositionX(), _owner->GetPositionY(),tz);
init.SetFall();
init.Launch();
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
}
示例3: init
void MotionMaster::MoveFall()
{
// use larger distance for vmap height search than in most other cases
float tz = m_owner->GetMap()->GetHeight(m_owner->GetPhaseMask(), m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ(), true, MAX_FALL_DISTANCE);
if (tz <= INVALID_HEIGHT)
{
sLog.outError("MotionMaster::MoveFall: unable retrive a proper height at map %u (x: %f, y: %f, z: %f).",
m_owner->GetMap()->GetId(), m_owner->GetPositionX(), m_owner->GetPositionY(), m_owner->GetPositionZ());
return;
}
// Abort too if the ground is very near
if (fabs(m_owner->GetPositionZ() - tz) < 0.1f)
return;
Movement::MoveSplineInit init(*m_owner);
init.MoveTo(m_owner->GetPositionX(),m_owner->GetPositionY(),tz);
init.SetFall();
init.Launch();
Mutate(new EffectMovementGenerator(0), UNIT_ACTION_EFFECT);
}
示例4: FlightPathMovementGenerator
void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if (_owner->GetTypeId() == TYPEID_PLAYER)
{
if (path < sTaxiPathNodesByPath.size())
{
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path], pathnode);
Mutate(mgen, MOTION_SLOT_CONTROLLED);
}
else
{
TC_LOG_ERROR("misc", "%s attempt taxi to (not existed Path %u node %u)",
_owner->GetName().c_str(), path, pathnode);
}
}
else
{
TC_LOG_ERROR("misc", "Creature (Entry: %u GUID: %u) attempt taxi to (Path %u node %u)",
_owner->GetEntry(), _owner->GetGUIDLow(), path, pathnode);
}
}
示例5: DEBUG_FILTER_LOG
void MotionMaster::MoveTargetedHome()
{
// if (m_owner->hasUnitState(UNIT_STAT_LOST_CONTROL))
// return;
if (m_owner->GetTypeId() == TYPEID_UNIT && !((Creature*)m_owner)->GetCharmerOrOwnerGuid())
{
// Manual exception for linked mobs
if (m_owner->IsLinkingEventTrigger() && m_owner->GetMap()->GetCreatureLinkingHolder()->TryFollowMaster((Creature*)m_owner))
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "MotionMaster: %s refollowed linked master", m_owner->GetGuidStr().c_str());
else
{
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "MotionMaster: %s targeted home", m_owner->GetGuidStr().c_str());
Mutate(new HomeMovementGenerator<Creature>(), UNIT_ACTION_HOME);
}
}
else if (m_owner->GetTypeId() == TYPEID_UNIT && ((Creature*)m_owner)->GetCharmerOrOwnerGuid())
{
if (Unit* target = ((Creature*)m_owner)->GetCharmerOrOwner())
{
float angle = ((Creature*)m_owner)->IsPet() ? ((Pet*)m_owner)->GetPetFollowAngle() : PET_FOLLOW_ANGLE;
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "MotionMaster: %s follow to %s", m_owner->GetGuidStr().c_str(), target->GetGuidStr().c_str());
switch (((Creature*)m_owner)->GetCharmState(CHARM_STATE_COMMAND))
{
case COMMAND_STAY:
MoveIdle();
break;
case COMMAND_FOLLOW:
case COMMAND_ATTACK:
default:
MoveFollow(target, PET_FOLLOW_DIST, angle);
break;
}
}
else
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s attempt but fail to follow owner", m_owner->GetGuidStr().c_str());
}
else
sLog.outError("MotionMaster: %s attempt targeted home", m_owner->GetGuidStr().c_str());
}
示例6: DEBUG_FILTER_LOG
void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if (m_owner->GetTypeId() == TYPEID_PLAYER)
{
if (path < sTaxiPathNodesByPath.size())
{
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s taxi to (Path %u node %u)", m_owner->GetGuidStr().c_str(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path], pathnode);
Mutate(mgen);
}
else
{
sLog.outError("%s attempt taxi to (nonexistent Path %u node %u)",
m_owner->GetGuidStr().c_str(), path, pathnode);
}
}
else
{
sLog.outError("%s attempt taxi to (Path %u node %u)",
m_owner->GetGuidStr().c_str(), path, pathnode);
}
}
示例7: top
void MotionMaster::MovePath(uint32 path_id, bool repeatable)
{
if (!path_id)
return;
//We set waypoint movement as new default movement generator
// clear ALL movement generators (including default)
/*while (!empty())
{
MovementGenerator *curr = top();
curr->Finalize(*_owner);
pop();
if (!isStatic(curr))
delete curr;
}*/
//_owner->GetTypeId() == TYPEID_PLAYER ?
//Mutate(new WaypointMovementGenerator<Player>(path_id, repeatable)):
Mutate(new WaypointMovementGenerator<Creature>(path_id, repeatable), MOTION_SLOT_IDLE);
TC_LOG_DEBUG("misc", "%s start moving over path (Id:%u, repeatable: %s)",
_owner->GetGUID().ToString().c_str(), path_id, repeatable ? "YES" : "NO");
}
示例8: to
void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if(i_owner->GetTypeId() == TYPEID_PLAYER)
{
if(path < sTaxiPathNodesByPath.size())
{
sLog->outStaticDebug("%s taxi to (Path %u node %u)", i_owner->GetName(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path], pathnode);
Mutate(mgen, MOTION_SLOT_CONTROLLED);
}
else
{
sLog->outError("%s attempt taxi to (not existed Path %u node %u)",
i_owner->GetName(), path, pathnode);
}
}
else
{
sLog->outError("Creature (Entry: %u GUID: %u) attempt taxi to (Path %u node %u)",
i_owner->GetEntry(), i_owner->GetGUIDLow(), path, pathnode);
}
}
示例9: MoveWaypoint
void MotionMaster::MoveWaypoint(int32 id /*=0*/, uint32 source /*=0==PATH_NO_PATH*/, uint32 initialDelay /*=0*/, uint32 overwriteEntry /*=0*/)
{
if (m_owner->GetTypeId() == TYPEID_UNIT)
{
if (GetCurrentMovementGeneratorType() == WAYPOINT_MOTION_TYPE)
{
sLog.outError("%s attempt to MoveWaypoint() but is already using waypoint", m_owner->GetGuidStr().c_str());
return;
}
Creature* creature = (Creature*)m_owner;
DEBUG_FILTER_LOG(LOG_FILTER_AI_AND_MOVEGENSS, "%s start MoveWaypoint()", m_owner->GetGuidStr().c_str());
WaypointMovementGenerator<Creature>* newWPMMgen = new WaypointMovementGenerator<Creature>(*creature);
Mutate(newWPMMgen);
newWPMMgen->InitializeWaypointPath(*creature, id, (WaypointPathOrigin)source, initialDelay, overwriteEntry);
}
else
{
sLog.outError("Non-creature %s attempt to MoveWaypoint()", m_owner->GetGuidStr().c_str());
}
}
示例10: Mutate
int CONTROLLER::Mutate_Biased(double mutationProbability) {
int mutationOccurred = false;
for (int i=0; i<numTimeSteps; i++) {
for (int j=0; j<numMotorGroups; j++) {
if ( Rand(0,1) < mutationProbability ) {
Mutate(i,j);
mutationOccurred = true;
}
}
}
motors->Print();
printf("\n");
return( mutationOccurred );
}
示例11: Crossover
//! Reproduce candidates to create the next generation.
void CNE::Reproduce()
{
// Sort fitness values. Smaller fitness value means better performance.
index = arma::sort_index(fitnessValues);
// First parent.
size_t mom;
// Second parent.
size_t dad;
for (size_t i = numElite; i < populationSize - 1; i++)
{
// Select 2 different parents from elite group randomly [0, numElite).
mom = mlpack::math::RandInt(0, numElite);
dad = mlpack::math::RandInt(0, numElite);
// Making sure both parents are not the same.
if (mom == dad)
{
if (dad != numElite - 1)
{
dad++;
}
else
{
dad--;
}
}
// Parents generate 2 children replacing the dropped-out candidates.
// Also finding the index of these candidates in the population matrix.
Crossover(index[mom], index[dad], index[i], index[i + 1]);
}
// Mutating the weights with small noise values.
// This is done to bring change in the next generation.
Mutate();
}
示例12: point
void MotionMaster::MoveJump(float x, float y, float z, float speedXY, float speedZ, uint32 id)
{
sLog->outDebug(LOG_FILTER_GENERAL, "Unit (GUID: %u) jump to point (X: %f Y: %f Z: %f)", _owner->GetGUIDLow(), x, y, z);
if (speedXY <= 0.1f)
return;
float moveTimeHalf = speedZ / Movement::gravity;
float max_height = -Movement::computeFallElevation(moveTimeHalf, false, -speedZ);
int32 timerToDestination = 0;
Movement::MoveSplineInit init(_owner);
init.MoveTo(x, y, z, false);
init.SetParabolic(max_height, 0);
init.SetVelocity(speedXY);
timerToDestination = init.Launch();
if (_owner->ToPlayer())
_owner->ToPlayer()->SetJumpTimerDestination(timerToDestination + 100);
Mutate(new EffectMovementGenerator(id), MOTION_SLOT_CONTROLLED);
}
示例13: DEBUG_LOG
void
MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if(i_owner->GetTypeId()==TYPEID_PLAYER)
{
if(path < sTaxiPathNodesByPath.size())
{
DEBUG_LOG("Player (GUID: %u) taxi to (Path %u node %u)", i_owner->GetGUIDLow(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path],pathnode);
Mutate(mgen);
}
else
{
sLog.outError("Creature (Entry: %u GUID: %u) attempt taxi to (Path %u node %u)",
i_owner->GetEntry(), i_owner->GetGUIDLow(), path, pathnode );
}
}
else
{
sLog.outError("%u attempt taxi to (Path %u node %u)",
i_owner->GetGUIDLow(), path, pathnode );
}
}
示例14: DEBUG_LOG
void
MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if(i_owner->GetTypeId()==TYPEID_PLAYER)
{
if(path < sTaxiPathNodesByPath.size())
{
DEBUG_LOG("%s taxi to (Path %u node %u)", i_owner->GetObjectGuid().GetString().c_str(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(sTaxiPathNodesByPath[path],pathnode);
Mutate(mgen);
}
else
{
sLog.outError("%s attempt taxi to (not existed Path %u node %u)",
i_owner->GetObjectGuid().GetString().c_str(), path, pathnode );
}
}
else
{
sLog.outError("%s attempt taxi to (Path %u node %u)",
i_owner->GetObjectGuid().GetString().c_str(), path, pathnode );
}
}
示例15: TC_LOG_DEBUG
void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode)
{
if (_owner->GetTypeId() == TYPEID_PLAYER)
{
if (path < sTaxiPathNodesByPath.size())
{
TC_LOG_DEBUG("misc", "%s taxi to (Path %u node %u).", _owner->GetName().c_str(), path, pathnode);
FlightPathMovementGenerator* mgen = new FlightPathMovementGenerator(pathnode);
mgen->LoadPath(_owner->ToPlayer());
Mutate(mgen, MOTION_SLOT_CONTROLLED);
}
else
{
TC_LOG_ERROR("misc", "%s attempted taxi to (non-existing Path %u node %u).",
_owner->GetName().c_str(), path, pathnode);
}
}
else
{
TC_LOG_ERROR("misc", "Creature (Entry: %u GUID: %u) attempted taxi to (Path %u node %u).",
_owner->GetEntry(), _owner->GetGUID().GetCounter(), path, pathnode);
}
}