예제 #1
0
void MotionMaster::UpdateMotion(uint32 diff) {
	if (i_owner->HasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED)) // what about UNIT_STAT_DISTRACTED? Why is this not included?
		return;
	ASSERT(!empty());
	m_cleanFlag |= MMCF_UPDATE;
	if (!top()->Update(*i_owner, diff)) {
		m_cleanFlag &= ~MMCF_UPDATE;
		MovementExpired();
	} else
		m_cleanFlag &= ~MMCF_UPDATE;

	if (m_expList) {
		for (size_t i = 0; i < m_expList->size(); ++i) {
			MovementGenerator* mg = (*m_expList)[i];
			DirectDelete(mg);
		}

		delete m_expList;
		m_expList = NULL;

		if (empty())
			Initialize();
		else if (needInitTop())
			InitTop();
		else if (m_cleanFlag & MMCF_RESET)
			top()->Reset(*i_owner);

		m_cleanFlag &= ~MMCF_RESET;
	}
}
예제 #2
0
void MotionMaster::DirectClean(bool reset)
{
    while (size() > 1)
    {
        MovementGenerator *curr = top();
        pop();
        if (curr) DirectDelete(curr);
    }

    if (needInitTop())
        InitTop();
    else if (reset)
        top()->Reset(*_owner);
}
예제 #3
0
void MotionMaster::UpdateMotion(uint32 diff)
{
    if (!_owner)
        return;
	// zhang hong chao add flee condition
	if (_owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED) && 
		GetCurrentMovementGeneratorType() != ASSISTANCE_MOTION_TYPE &&
		GetCurrentMovementGeneratorType() != TIMED_FLEEING_MOTION_TYPE &&
		GetCurrentMovementGeneratorType() != FLEEING_MOTION_TYPE) {  // what about UNIT_STATE_DISTRACTED? Why is this not included?
		return;
	}

    ASSERT(!empty());

    _cleanFlag |= MMCF_UPDATE;
    if (!top()->Update(_owner, diff))
    {
        _cleanFlag &= ~MMCF_UPDATE;
        MovementExpired();
    }
    else
        _cleanFlag &= ~MMCF_UPDATE;

    if (_expList)
    {
        for (size_t i = 0; i < _expList->size(); ++i)
        {
            MovementGenerator* mg = (*_expList)[i];
            DirectDelete(mg);
        }

        delete _expList;
        _expList = NULL;

        if (empty())
            Initialize();
        else if (needInitTop())
            InitTop();
        else if (_cleanFlag & MMCF_RESET)
            top()->Reset(_owner);

        _cleanFlag &= ~MMCF_RESET;
    }

    // probably not the best place to pu this but im not really sure where else to put it.
    _owner->UpdateUnderwaterState(_owner->GetMap(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
}
예제 #4
0
void MotionMaster::DirectExpire(bool reset) {
	if (size() > 1) {
		MovementGenerator *curr = top();
		pop();
		removeEmptyTops();
		DirectDelete(curr);
	}

	while (!top())
		--i_top;

	if (empty())
		Initialize();
	else if (needInitTop())
		InitTop();
	else if (reset)
		top()->Reset(*i_owner);
}
예제 #5
0
void MotionMaster::UpdateMotion(uint32 diff)
{
    if (!_owner)
        return;

    if (_owner->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED)) // what about UNIT_STATE_DISTRACTED? Why is this not included?
        return;

    ASSERT(!empty());

    _cleanFlag |= MMCF_UPDATE;
    if (!top()->Update(_owner, diff))
    {
        _cleanFlag &= ~MMCF_UPDATE;
        MovementExpired();
    }
    else
        _cleanFlag &= ~MMCF_UPDATE;

    if (!_expList.empty())
    {
        for (ExpireList::iterator i = _expList.begin(); i != _expList.end(); ++i)
            DirectDelete(*i);

        _expList.clear();

        if (empty())
            Initialize();
        else if (needInitTop())
            InitTop();
        else if (_cleanFlag & MMCF_RESET)
            top()->Reset(_owner);

        _cleanFlag &= ~MMCF_RESET;
    }

#if 0
    // probably not the best place to pu this but im not really sure where else to put it.
    _owner->UpdateUnderwaterState(_owner->GetMap(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
#endif
}
예제 #6
0
void
MotionMaster::UpdateMotion(uint32 diff)
{
    if( i_owner->hasUnitState(UNIT_STAT_ROOT | UNIT_STAT_STUNNED) )
        return;
    assert( !empty() );
    m_cleanFlag |= MMCF_UPDATE;
    if (!top()->Update(*i_owner, diff))
    {
        m_cleanFlag &= ~MMCF_UPDATE;
        MovementExpired();
    }
    else
        m_cleanFlag &= ~MMCF_UPDATE;

    if (m_expList)
    {
        for (int i = 0; i < m_expList->size(); ++i)
        {
            MovementGenerator* mg = (*m_expList)[i];
            DirectDelete(mg);
        }

        delete m_expList;
        m_expList = NULL;

        if(empty())
            Initialize();
        else if(needInitTop())
            InitTop();
        else if (m_cleanFlag & MMCF_RESET)
            top()->Reset(*i_owner);

        m_cleanFlag &= ~MMCF_RESET;
    }
}