Add mobile touch UI and AVA2 biology system with server tools
This commit is contained in:
@@ -288,6 +288,7 @@ void CPythonPlayer::__AutoHunt_Stop(int eReason)
|
||||
m_iAutoHuntMountState = 0;
|
||||
if (auto* main=NEW_GetMainActorPtr()) main->NEW_Stop();
|
||||
m_eAutoHuntState = AUTO_HUNT_OFF;
|
||||
m_fAutoHuntCrowdUntil = 0;
|
||||
m_eAutoHuntStopReason = eReason;
|
||||
m_dwAutoHuntTargetVID = 0;
|
||||
m_dwAutoHuntItemID = 0;
|
||||
@@ -345,11 +346,48 @@ bool CPythonPlayer::__AutoHunt_IsTargetAllowed(CInstanceBase& main, CInstanceBas
|
||||
return m_kAutoHuntConfig.bAttackBoss || !mob || mob->bRank < c_byMobRankBoss;
|
||||
}
|
||||
|
||||
// PORT: local combat can interrupt loot/blocked pursuit without changing manual input.
|
||||
void CPythonPlayer::AutoHunt_OnHit(DWORD victim)
|
||||
{
|
||||
if (AutoHunt_IsEnabled() && m_eAutoHuntState == AUTO_HUNT_ENGAGE && victim == m_dwAutoHuntTargetVID)
|
||||
m_fAutoHuntProgressTime = CTimer::Instance().GetCurrentSecond();
|
||||
}
|
||||
|
||||
bool CPythonPlayer::__AutoHunt_CanAttackHere(CInstanceBase& main, CInstanceBase& target)
|
||||
{
|
||||
if (main.IsInSafe() || !main.NEW_IsClickableDistanceDestInstance(target)) return false;
|
||||
TPixelPosition goal; target.NEW_GetPixelPosition(&goal);
|
||||
std::vector<TPixelPosition> line;
|
||||
return __AutoHunt_BuildPath(goal, 0.f, line) && line.size() == 1 && PixelDistance(line.back(), goal) < 1.f;
|
||||
}
|
||||
|
||||
DWORD CPythonPlayer::__AutoHunt_FindCloseTarget(CInstanceBase& main, int* count)
|
||||
{
|
||||
DWORD best = 0; float distance = 1e9f; int nearby = 0;
|
||||
auto& manager = CPythonCharacterManager::Instance();
|
||||
for (auto i = manager.CharacterInstanceBegin(); i != manager.CharacterInstanceEnd(); ++i) {
|
||||
auto* actor = *i;
|
||||
if (!actor || !__AutoHunt_IsTargetAllowed(main, *actor) || actor->IsStone() ||
|
||||
main.GetDistance(actor) > c_fAutoHuntSkillDistance ||
|
||||
!main.NEW_IsClickableDistanceDestInstance(*actor)) continue;
|
||||
if (!__AutoHunt_CanAttackHere(main, *actor)) continue;
|
||||
++nearby;
|
||||
if (actor->GetVirtualID() == m_dwAutoHuntTargetVID) best = actor->GetVirtualID();
|
||||
if (best == m_dwAutoHuntTargetVID && best) continue;
|
||||
const float d = main.GetDistance(actor);
|
||||
if (d < distance) { distance = d; best = actor->GetVirtualID(); }
|
||||
}
|
||||
if (count) *count = nearby;
|
||||
return best;
|
||||
}
|
||||
|
||||
// PORT: cloak collection and the server pursuit leash follow the hunting range.
|
||||
bool CPythonPlayer::__AutoHunt_RequestPull(CInstanceBase& main, float now)
|
||||
{
|
||||
const int maxHP = GetStatus(POINT_MAX_HP);
|
||||
if (m_kAutoHuntConfig.iGatherCount <= 0 || m_isAutoHuntGathering || now < m_fAutoHuntNextPullTime ||
|
||||
int nearby = 0; __AutoHunt_FindCloseTarget(main, &nearby);
|
||||
if (nearby >= 2 || now < m_fAutoHuntCrowdUntil ||
|
||||
m_kAutoHuntConfig.iGatherCount <= 0 || m_isAutoHuntGathering || now < m_fAutoHuntNextPullTime ||
|
||||
main.IsInSafe() || maxHP <= 0 || GetStatus(POINT_HP) * 100 < maxHP * c_iAutoHuntGatherHPPercent)
|
||||
return false;
|
||||
if (m_kAutoHuntConfig.bAttackStone) {
|
||||
@@ -738,6 +776,28 @@ void CPythonPlayer::__Update_AutoHunt()
|
||||
return;
|
||||
if (__AutoHunt_UpdateMount(rkInstMain,fNow)) return;
|
||||
|
||||
// PORT: finish local combat before moving through a pack to loot or pursue.
|
||||
if (m_eAutoHuntState == AUTO_HUNT_SEARCH || m_eAutoHuntState == AUTO_HUNT_RETURN ||
|
||||
m_eAutoHuntState == AUTO_HUNT_LOOT || m_eAutoHuntState == AUTO_HUNT_ENGAGE) {
|
||||
int nearby = 0;
|
||||
const DWORD close = __AutoHunt_FindCloseTarget(rkInstMain, &nearby);
|
||||
const bool stalled = m_eAutoHuntState == AUTO_HUNT_ENGAGE &&
|
||||
fNow - m_fAutoHuntProgressTime > 1.5f;
|
||||
const bool interruptLoot = m_eAutoHuntState == AUTO_HUNT_LOOT && close;
|
||||
if (nearby >= 2 || (close && stalled) || interruptLoot) {
|
||||
m_fAutoHuntCrowdUntil = fNow + 3.f;
|
||||
if (close && (m_eAutoHuntState != AUTO_HUNT_ENGAGE || close != m_dwAutoHuntTargetVID)) {
|
||||
if (m_dwAutoHuntItemID) m_kMap_dwAutoHuntSkipItem[m_dwAutoHuntItemID] = fNow + 2.f;
|
||||
m_dwAutoHuntItemID = 0;
|
||||
__ClearReservedAction(); __ClearAutoAttackTargetActorID();
|
||||
rkInstMain.NEW_Stop();
|
||||
AutoHuntTrace("local combat interrupts state %d: target %u", m_eAutoHuntState, unsigned(close));
|
||||
__AutoHunt_Engage(close, fNow);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch (m_eAutoHuntState)
|
||||
{
|
||||
case AUTO_HUNT_PAUSED:
|
||||
@@ -861,7 +921,7 @@ void CPythonPlayer::__Update_AutoHunt()
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_kAutoHuntConfig.bAttackStone && !pkInstVictim->IsStone()) {
|
||||
if (fNow >= m_fAutoHuntCrowdUntil && m_kAutoHuntConfig.bAttackStone && !pkInstVictim->IsStone()) {
|
||||
const DWORD preferred = __AutoHunt_FindTarget(rkInstMain, fNow);
|
||||
CInstanceBase* actor = NEW_FindActorPtr(preferred);
|
||||
if (actor && actor->IsStone()) {
|
||||
@@ -878,7 +938,7 @@ void CPythonPlayer::__Update_AutoHunt()
|
||||
m_fAutoHuntBestDistance = fDistance;
|
||||
m_fAutoHuntProgressTime = fNow;
|
||||
}
|
||||
if (rkInstMain.IsAttacking() || rkInstMain.IsUsingSkill())
|
||||
if (rkInstMain.IsUsingSkill() || rkInstMain.IsStun())
|
||||
{
|
||||
m_fAutoHuntProgressTime = fNow;
|
||||
}
|
||||
@@ -888,7 +948,8 @@ void CPythonPlayer::__Update_AutoHunt()
|
||||
if (isBlockedBySafeZone || fNow - m_fAutoHuntProgressTime > c_fAutoHuntNoProgressTime ||
|
||||
fNow - m_fAutoHuntStateTime > c_fAutoHuntTargetTimeout)
|
||||
{
|
||||
m_kMap_dwAutoHuntSkipVID[m_dwAutoHuntTargetVID] = fNow + c_fAutoHuntSkipTime;
|
||||
m_kMap_dwAutoHuntSkipVID[m_dwAutoHuntTargetVID] = fNow + 3.f;
|
||||
m_fAutoHuntCrowdUntil = fNow + 3.f;
|
||||
__ClearAutoAttackTargetActorID();
|
||||
__ClearReservedAction(); __AutoHunt_ResetMovement(); rkInstMain.NEW_Stop();
|
||||
m_dwAutoHuntTargetVID = 0;
|
||||
@@ -899,7 +960,10 @@ void CPythonPlayer::__Update_AutoHunt()
|
||||
|
||||
TPixelPosition goal; pkInstVictim->NEW_GetPixelPosition(&goal);
|
||||
// Use the planner even in attack range: never swing or cast through a wall.
|
||||
if (!__AutoHunt_MoveTo(goal,100.f,fNow)) {
|
||||
if (__AutoHunt_CanAttackHere(rkInstMain, *pkInstVictim)) {
|
||||
if (!m_vecAutoHuntPath.empty()) rkInstMain.NEW_Stop();
|
||||
__AutoHunt_ResetMovement();
|
||||
} else if (!__AutoHunt_MoveTo(goal,100.f,fNow)) {
|
||||
m_kMap_dwAutoHuntSkipVID[m_dwAutoHuntTargetVID]=fNow+c_fAutoHuntSkipTime;
|
||||
__ClearAutoAttackTargetActorID(); __ClearReservedAction(); rkInstMain.NEW_Stop();
|
||||
m_dwAutoHuntTargetVID=0; m_eAutoHuntState=AUTO_HUNT_SEARCH; return;
|
||||
@@ -936,10 +1000,12 @@ void CPythonPlayer::__Update_AutoHunt()
|
||||
{
|
||||
m_dwAutoHuntItemID = 0; // picked up (or gone)
|
||||
}
|
||||
else if (fNow - m_fAutoHuntProgressTime > c_fAutoHuntItemTimeout)
|
||||
else if (fNow - m_fAutoHuntProgressTime > c_fAutoHuntItemTimeout ||
|
||||
fNow - m_fAutoHuntItemStart > c_fAutoHuntLootTimeout)
|
||||
{
|
||||
m_kMap_dwAutoHuntSkipItem[m_dwAutoHuntItemID] = fNow + c_fAutoHuntItemSkipTime;
|
||||
m_dwAutoHuntItemID = 0;
|
||||
__AutoHunt_ResetMovement(); rkInstMain.NEW_Stop();
|
||||
__ClearReservedAction();
|
||||
}
|
||||
else
|
||||
@@ -970,6 +1036,7 @@ void CPythonPlayer::__Update_AutoHunt()
|
||||
|
||||
// __OnPressItem without its once-per-item guard.
|
||||
m_dwAutoHuntItemID = dwItemID;
|
||||
m_fAutoHuntItemStart = fNow;
|
||||
m_fAutoHuntProgressTime = fNow;
|
||||
__ClearReservedAction();
|
||||
if (rkInstMain.NEW_IsClickableDistanceDestPixelPosition(kPPosItem))
|
||||
@@ -995,6 +1062,7 @@ void CPythonPlayer::__AutoHunt_ResetMovement()
|
||||
m_vecAutoHuntPath.clear();
|
||||
m_fAutoHuntPathTime=0;
|
||||
m_fAutoHuntPathMoveTime=0;
|
||||
m_fAutoHuntWaypointBest=1e9f;
|
||||
m_fAutoHuntTargetScanTime=0;
|
||||
}
|
||||
|
||||
@@ -1046,8 +1114,10 @@ bool CPythonPlayer::__AutoHunt_MoveTo(const TPixelPosition& goal, float arrival,
|
||||
m_kAutoHuntPathGoal=goal; m_fAutoHuntPathTime=now;
|
||||
m_fAutoHuntPathMoveTime=0;
|
||||
}
|
||||
while (!m_vecAutoHuntPath.empty() && PixelDistance(here,m_vecAutoHuntPath.front())<=50.f)
|
||||
while (!m_vecAutoHuntPath.empty() && PixelDistance(here,m_vecAutoHuntPath.front())<=50.f) {
|
||||
m_vecAutoHuntPath.erase(m_vecAutoHuntPath.begin());
|
||||
m_fAutoHuntWaypointBest=1e9f; m_fAutoHuntProgressTime=now;
|
||||
}
|
||||
// The final planned point may be an accessible attack/pickup position beside a blocked target cell.
|
||||
if (m_vecAutoHuntPath.size()==1 && PixelDistance(here,m_vecAutoHuntPath.front())<=arrival)
|
||||
m_vecAutoHuntPath.clear();
|
||||
@@ -1059,9 +1129,10 @@ bool CPythonPlayer::__AutoHunt_MoveTo(const TPixelPosition& goal, float arrival,
|
||||
main->NEW_MoveToDestPixelPositionDirection(m_vecAutoHuntPath.front());
|
||||
}
|
||||
// Waypoint progress can temporarily increase distance to the enemy while going around a wall.
|
||||
if (main->IsWalking() && PixelDistance(here,m_kAutoHuntPathLastPosition)>30.f) {
|
||||
const float remaining=PixelDistance(here,m_vecAutoHuntPath.front());
|
||||
if (remaining < m_fAutoHuntWaypointBest-30.f) {
|
||||
m_fAutoHuntProgressTime=now;
|
||||
m_kAutoHuntPathLastPosition=here;
|
||||
m_fAutoHuntWaypointBest=remaining;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user