Пример #1
0
bool CPathFind::WarpTo(position_t point, float maxDistance)
{
	Clear();

	position_t newPoint = nearPosition(point, maxDistance, M_PI);

	m_PTarget->loc.p.x = newPoint.x;
	m_PTarget->loc.p.y = newPoint.y;
	m_PTarget->loc.p.z = newPoint.z;
	m_PTarget->loc.p.moving = 0;

	LookAt(point);
    m_PTarget->updatemask |= UPDATE_POS;

	return true;
}
Пример #2
0
void CMobController::FollowRoamPath()
{
    if (PMob->PAI->CanFollowPath())
    {
        PMob->PAI->PathFind->FollowPath();

        CBattleEntity* PPet = PMob->PPet;
        if (PPet != nullptr && !PPet->PAI->IsEngaged())
        {
            // pet should follow me if roaming
            position_t targetPoint = nearPosition(PMob->loc.p, 2.1f, (float)M_PI);

            PPet->PAI->PathFind->PathTo(targetPoint);
        }

        // if I just finished reset my last action time
        if (!PMob->PAI->PathFind->IsFollowingPath())
        {
            uint16 roamRandomness = (uint16)(PMob->getBigMobMod(MOBMOD_ROAM_COOL) / PMob->GetRoamRate());
            m_LastActionTime = m_Tick - std::chrono::milliseconds(dsprand::GetRandomNumber(roamRandomness));

            // i'm a worm pop back up
            if (PMob->m_roamFlags & ROAMFLAG_WORM)
            {
                PMob->animationsub = 0;
                PMob->HideName(false);
                PMob->Untargetable(false);
            }

            // face spawn rotation if I just moved back to spawn
            // used by dynamis mobs, bcnm mobs etc
            if ((PMob->m_roamFlags & ROAMFLAG_EVENT) &&
                distance(PMob->loc.p, PMob->m_SpawnPoint) <= PMob->m_maxRoamDistance)
            {
                PMob->loc.p.rotation = PMob->m_SpawnPoint.rotation;
            }
        }


        if (PMob->PAI->PathFind->OnPoint()) {
            luautils::OnPath(PMob);
        }
    }
}
Пример #3
0
void SpawnCatch(CCharEntity* PChar, uint32 mobid)
	{
		CBattleEntity* TargetID = (CBattleEntity*)PChar;
		CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB);
		
		if (PMob->PBattleAI->GetCurrentAction() == ACTION_NONE)
		{
			PMob->SetDespawnTimer(3);
			PMob->m_AllowRespawn = false;
			PMob->m_Type = MOBTYPE_FISHED;
			PMob->CanDetectTarget(TargetID, true);
			PMob->m_Behaviour = BEHAVIOUR_NO_TURN;
			PMob->m_SpawnPoint = nearPosition(PChar->loc.p, 2.2f, M_PI);
			PMob->PBattleAI->SetLastActionTime(gettick());
			PMob->PBattleAI->SetCurrentAction(ACTION_SPAWN);
			PMob->PBattleAI->CheckCurrentAction(gettick());
			PMob->PEnmityContainer->AddBaseEnmity(TargetID);
		}

	}