mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-09 03:58:14 +03:00
Reversing Actor Final Part
This commit is contained in:
parent
cb239c3c7f
commit
6528ba4dac
40 changed files with 3983 additions and 779 deletions
|
@ -29,7 +29,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
ActorEnemy::ActorEnemy()
|
||||
{
|
||||
//no need
|
||||
m_pEnemy = NULL;
|
||||
m_vLastKnownPos = vec_zero;
|
||||
}
|
||||
|
||||
ActorEnemy::~ActorEnemy()
|
||||
|
@ -81,8 +82,12 @@ int ActorEnemy::UpdateThreat
|
|||
)
|
||||
|
||||
{
|
||||
//FIXME: macro
|
||||
static float fRangeThreatSquared[15];
|
||||
static int iWeaponThreat[7][5];
|
||||
int iWeapon;
|
||||
int iZone;
|
||||
Vector vDelta;
|
||||
|
||||
m_iThreat = 0;
|
||||
m_fCurrentRangeSquared = 1e38;
|
||||
|
@ -94,10 +99,138 @@ int ActorEnemy::UpdateThreat
|
|||
if (m_bVisible == true)
|
||||
m_iThreat = 10500;
|
||||
|
||||
vDelta = m_pEnemy->origin - pSelf->origin;
|
||||
m_fCurrentRangeSquared = vDelta.lengthSquared();
|
||||
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
return NULL;
|
||||
if (m_fCurrentRangeSquared >= 65536.0)
|
||||
{
|
||||
if (m_fCurrentRangeSquared >= 589824.0)
|
||||
{
|
||||
if (m_fCurrentRangeSquared >= 1638400.0)
|
||||
{
|
||||
if (m_fCurrentRangeSquared >= 4194304.0)
|
||||
iZone = 4;
|
||||
else
|
||||
iZone = 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
iZone = 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iZone = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iZone = 0;
|
||||
}
|
||||
|
||||
Weapon *pEnemyWeapon = m_pEnemy->GetActiveWeapon(WEAPON_MAIN);
|
||||
iWeapon = 0;
|
||||
|
||||
if (pEnemyWeapon)
|
||||
{
|
||||
int iWeapClass = pEnemyWeapon->GetWeaponClass();
|
||||
if (iWeapClass & WEAPON_CLASS_PISTOL)
|
||||
{
|
||||
iWeapon = 1;
|
||||
}
|
||||
else if (iWeapClass & WEAPON_CLASS_RIFLE)
|
||||
{
|
||||
iWeapon = 2;
|
||||
}
|
||||
else if (iWeapClass & WEAPON_CLASS_SMG)
|
||||
{
|
||||
iWeapon = 3;
|
||||
}
|
||||
else if (iWeapClass & WEAPON_CLASS_MG)
|
||||
{
|
||||
iWeapon = 4;
|
||||
}
|
||||
else if(iWeapClass & WEAPON_CLASS_GRENADE)
|
||||
{
|
||||
iWeapon = 5;
|
||||
}
|
||||
else
|
||||
{
|
||||
iWeapon = 6;
|
||||
}
|
||||
}
|
||||
|
||||
int i=0;
|
||||
if (m_fCurrentRangeSquared > 4194304)
|
||||
{
|
||||
for (; i < 15 && fRangeThreatSquared[i] > m_fCurrentRangeSquared; i++)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
m_iThreat += iWeaponThreat[iZone][iWeapon] + m_pEnemy->m_iThreatBias + i;
|
||||
|
||||
float fMinSafeDistSquared = 1.21 * pSelf->m_fMinDistanceSquared + 16384;
|
||||
|
||||
if (m_fCurrentRangeSquared < fMinSafeDistSquared)
|
||||
{
|
||||
m_iThreat -= (sqrt(m_fCurrentRangeSquared / fMinSafeDistSquared) * 500) + 500;
|
||||
}
|
||||
|
||||
Vector vLine = m_vLastKnownPos - pSelf->origin;
|
||||
float fDot = DotProduct2D(vLine, m_vLastKnownPos);
|
||||
for (Sentient *pSquadMate = m_pEnemy->m_pNextSquadMate; pSquadMate != m_pEnemy; pSquadMate = pSquadMate->m_pNextSquadMate)
|
||||
{
|
||||
if (fDot > DotProduct2D(vLine, pSquadMate->origin))
|
||||
{
|
||||
m_iThreat -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
Actor *pAEnemy = (Actor *)m_pEnemy.Pointer();
|
||||
if (pAEnemy->IsSubclassOfActor() && pAEnemy->m_ThinkState == THINKSTATE_PAIN)
|
||||
{
|
||||
m_iThreat -= 2;
|
||||
}
|
||||
|
||||
fDot = Vector::Dot(vDelta, pSelf->orientation[0]);
|
||||
if (fDot <= 0 )
|
||||
{
|
||||
if (m_fCurrentRangeSquared * 0.5 > Square(fDot))
|
||||
{
|
||||
m_iThreat++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_fCurrentRangeSquared * 0.5 >= Square(fDot))
|
||||
{
|
||||
if (m_fCurrentRangeSquared * 0.5 > Square(fDot))
|
||||
{
|
||||
m_iThreat++;
|
||||
}
|
||||
}
|
||||
}
|
||||
int iEnemyDiscount = m_pEnemy->m_iAttackerCount;
|
||||
|
||||
if (m_pEnemy == pSelf->m_Enemy)
|
||||
{
|
||||
iEnemyDiscount -= 2;
|
||||
if (level.inttime < pSelf->m_iEnemyChangeTime + 1000)
|
||||
m_iThreat += 5;
|
||||
}
|
||||
|
||||
if (iEnemyDiscount > 4)
|
||||
iEnemyDiscount = 4;
|
||||
m_iThreat -= iEnemyDiscount;
|
||||
|
||||
if (m_pEnemy == pSelf->m_pLastAttacker)
|
||||
{
|
||||
m_iThreat += 5;
|
||||
}
|
||||
if (m_pEnemy == pSelf->m_FavoriteEnemy)
|
||||
m_iThreat += 250;
|
||||
return m_iThreat;
|
||||
}
|
||||
|
||||
Sentient *ActorEnemy::GetEnemy
|
||||
|
@ -224,9 +357,41 @@ ActorEnemy *ActorEnemySet::AddPotentialEnemy
|
|||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
return NULL;
|
||||
ActorEnemy NewEnemy;
|
||||
|
||||
if (pEnemy->IsDead() || pEnemy->m_iThreatBias == THREATBIAS_IGNOREME)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (int i = 0; i < m_Enemies.NumObjects(); i++)
|
||||
{
|
||||
ActorEnemy *pActorEnemy = &m_Enemies[i];
|
||||
if (pActorEnemy->m_pEnemy == pEnemy)
|
||||
{
|
||||
pActorEnemy->m_iAddTime = level.inttime;
|
||||
return pActorEnemy;
|
||||
}
|
||||
}
|
||||
|
||||
NewEnemy.m_fVisibility = 0.0;
|
||||
NewEnemy.m_fTotalVisibility = 0.0;
|
||||
NewEnemy.m_iAddTime = level.inttime;
|
||||
NewEnemy.m_fLastLookTime = level.time;
|
||||
NewEnemy.m_iThreat = 0;
|
||||
|
||||
NewEnemy.m_pEnemy = pEnemy;
|
||||
|
||||
NewEnemy.m_fCurrentRangeSquared = 1e38;
|
||||
|
||||
NewEnemy.m_iLastSightChangeTime = 0;
|
||||
NewEnemy.m_vLastKnownPos = vec_zero;
|
||||
|
||||
NewEnemy.m_bVisible = false;
|
||||
|
||||
|
||||
|
||||
return &m_Enemies[m_Enemies.AddObject(NewEnemy)-1];
|
||||
}
|
||||
|
||||
void ActorEnemySet::FlagBadEnemy
|
||||
|
@ -235,8 +400,37 @@ void ActorEnemySet::FlagBadEnemy
|
|||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
ActorEnemy *pActorEnemy;
|
||||
for (int i = 0; i < m_Enemies.NumObjects(); i++)
|
||||
{
|
||||
pActorEnemy = &m_Enemies[i];
|
||||
if (pActorEnemy->m_pEnemy == pEnemy)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
if (i+1 == m_Enemies.NumObjects())
|
||||
return;
|
||||
}
|
||||
|
||||
pActorEnemy->m_iThreat = 0;
|
||||
pActorEnemy->m_fVisibility = 0.0;
|
||||
pActorEnemy->m_fTotalVisibility = 0.0;
|
||||
pActorEnemy->m_fLastLookTime = level.time;
|
||||
|
||||
pActorEnemy->m_bVisible = false;
|
||||
pActorEnemy->m_iLastSightChangeTime = level.inttime;
|
||||
|
||||
if (pEnemy == m_pCurrentEnemy)
|
||||
{
|
||||
if (m_pCurrentEnemy)
|
||||
{
|
||||
delete m_pCurrentEnemy;
|
||||
m_pCurrentEnemy = NULL;
|
||||
}
|
||||
m_fCurrentVisibility = 0.0;
|
||||
m_iCurrentThreat = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void ActorEnemySet::CheckEnemies
|
||||
|
@ -245,8 +439,148 @@ void ActorEnemySet::CheckEnemies
|
|||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
float fRangeSquared;
|
||||
bool bVisible;
|
||||
bool bInFovAndRange = false;
|
||||
int nChecked;
|
||||
int iThreat;
|
||||
float fVisibility;
|
||||
|
||||
ActorEnemy *pActorEnemy;
|
||||
for (int i = 1; i < m_Enemies.NumObjects();i++)
|
||||
{
|
||||
pActorEnemy = &m_Enemies[i];
|
||||
if (!pActorEnemy->m_pEnemy
|
||||
|| pActorEnemy->m_pEnemy->m_Team != pSelf->m_Team
|
||||
|| pActorEnemy->m_pEnemy->IsDead()
|
||||
|| level.inttime > pActorEnemy->m_iAddTime + 10000
|
||||
|| pActorEnemy->m_pEnemy->m_iThreatBias == THREATBIAS_IGNOREME)
|
||||
{
|
||||
m_Enemies.RemoveObjectAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
if (!m_Enemies.NumObjects())
|
||||
{
|
||||
m_iCurrentThreat = 0;
|
||||
if (m_pCurrentEnemy)
|
||||
{
|
||||
delete m_pCurrentEnemy;
|
||||
m_pCurrentEnemy = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; !bInFovAndRange && i < m_Enemies.NumObjects(); i++)
|
||||
{
|
||||
m_iCheckCount++;
|
||||
if (m_iCheckCount > m_Enemies.NumObjects())
|
||||
m_iCheckCount = 1;
|
||||
|
||||
pActorEnemy = &m_Enemies[m_iCheckCount-1];
|
||||
|
||||
fVisibility = pActorEnemy->UpdateVisibility(pSelf, &bInFovAndRange, &bVisible);
|
||||
if (fVisibility <= 0.0)
|
||||
{
|
||||
if (pActorEnemy->m_pEnemy == m_pCurrentEnemy)
|
||||
{
|
||||
m_iCurrentThreat = 0;
|
||||
if (m_pCurrentEnemy)
|
||||
{
|
||||
delete m_pCurrentEnemy;
|
||||
m_pCurrentEnemy = NULL;
|
||||
}
|
||||
m_fCurrentVisibility = 0.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fVisibility < m_fCurrentVisibility)
|
||||
{
|
||||
if (pActorEnemy->m_pEnemy == m_pCurrentEnemy)
|
||||
{
|
||||
m_iCurrentThreat = 0;
|
||||
if (m_pCurrentEnemy)
|
||||
{
|
||||
delete m_pCurrentEnemy;
|
||||
m_pCurrentEnemy = NULL;
|
||||
}
|
||||
m_fCurrentVisibility = fVisibility;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pCurrentEnemy = pActorEnemy->m_pEnemy;
|
||||
}
|
||||
|
||||
if (g_showawareness->integer)
|
||||
{
|
||||
Com_Printf(
|
||||
"ent #%3i: enemy #%i: awareness = %5.1f%%, threat = %i\n",
|
||||
pSelf->entnum,
|
||||
pActorEnemy->m_pEnemy->entnum,
|
||||
(fVisibility * 100.0),
|
||||
0);
|
||||
}
|
||||
}
|
||||
|
||||
if (bVisible)
|
||||
{
|
||||
if (!pActorEnemy->m_bVisible)
|
||||
{
|
||||
pActorEnemy->m_bVisible = true;
|
||||
pActorEnemy->m_iLastSightChangeTime = level.inttime;
|
||||
}
|
||||
pActorEnemy->m_vLastKnownPos = pActorEnemy->m_pEnemy->origin;
|
||||
}
|
||||
else if (pActorEnemy->m_bVisible)
|
||||
{
|
||||
pActorEnemy->m_bVisible = false;
|
||||
pActorEnemy->m_iLastSightChangeTime = level.inttime;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_pCurrentEnemy && m_pCurrentEnemy->IsDead())
|
||||
{
|
||||
if (m_pCurrentEnemy)
|
||||
{
|
||||
delete m_pCurrentEnemy;
|
||||
m_pCurrentEnemy = NULL;
|
||||
}
|
||||
m_iCurrentThreat = 0;
|
||||
m_fCurrentVisibility = 0.0;
|
||||
}
|
||||
|
||||
m_iCurrentThreat = 0;
|
||||
|
||||
fRangeSquared = 1e37;
|
||||
|
||||
if (m_fCurrentVisibility >= 1)
|
||||
{
|
||||
for (int i = 0;i < m_Enemies.NumObjects(); i++)
|
||||
{
|
||||
pActorEnemy = &m_Enemies[i];
|
||||
pActorEnemy->UpdateThreat(pSelf);
|
||||
if (m_iCurrentThreat < pActorEnemy->m_iThreat || m_iCheckCount == pActorEnemy->m_iThreat && fRangeSquared > pActorEnemy->m_fCurrentRangeSquared)
|
||||
{
|
||||
m_iCurrentThreat = pActorEnemy->m_iThreat;
|
||||
m_pCurrentEnemy = pActorEnemy->m_pEnemy;
|
||||
fRangeSquared = pActorEnemy->m_fCurrentRangeSquared;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((!m_pCurrentEnemy || !m_pCurrentEnemy->m_bIsDisguised) && m_iCurrentThreat <= 0)
|
||||
{
|
||||
if (m_pCurrentEnemy)
|
||||
{
|
||||
delete m_pCurrentEnemy;
|
||||
m_pCurrentEnemy = NULL;
|
||||
}
|
||||
m_iCurrentThreat = 0;
|
||||
m_fCurrentVisibility = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Sentient *ActorEnemySet::GetCurrentEnemy
|
||||
|
@ -282,7 +616,7 @@ qboolean ActorEnemySet::IsEnemyConfirmed
|
|||
) const
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
// not found in ida
|
||||
STUB();
|
||||
return false;
|
||||
}
|
||||
|
@ -293,8 +627,15 @@ bool ActorEnemySet::HasAlternateEnemy
|
|||
) const
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
ActorEnemy *pActorEnemy;
|
||||
for (int i = 0; i < m_Enemies.NumObjects(); i++)
|
||||
{
|
||||
pActorEnemy = &m_Enemies[i];
|
||||
if (pActorEnemy->m_pEnemy != m_pCurrentEnemy)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -304,8 +645,15 @@ void ActorEnemySet::RemoveAll
|
|||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
m_Enemies.ClearObjectList();
|
||||
m_iCheckCount = 0;
|
||||
if (m_pCurrentEnemy)
|
||||
{
|
||||
delete m_pCurrentEnemy;
|
||||
m_pCurrentEnemy = NULL;
|
||||
}
|
||||
m_fCurrentVisibility = 0.0;
|
||||
m_iCurrentThreat = 0;
|
||||
}
|
||||
|
||||
void ActorEnemySet::ConfirmEnemy
|
||||
|
@ -315,8 +663,20 @@ void ActorEnemySet::ConfirmEnemy
|
|||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
pSelf->m_bEnemyIsDisguised = false;
|
||||
ActorEnemy *pActorEnemy = ActorEnemySet::AddPotentialEnemy(pEnemy);
|
||||
if (pActorEnemy)
|
||||
{
|
||||
pActorEnemy->m_fVisibility = 1.0;
|
||||
pActorEnemy->m_fTotalVisibility = 1.0;
|
||||
pActorEnemy->m_vLastKnownPos = pEnemy->origin;
|
||||
if (m_fCurrentVisibility < 1.0)
|
||||
{
|
||||
m_iCurrentThreat = pActorEnemy->UpdateThreat(pSelf);
|
||||
m_fCurrentVisibility = 1.0;
|
||||
m_pCurrentEnemy = pEnemy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActorEnemySet::ConfirmEnemyIfCanSeeSharerOrEnemy
|
||||
|
@ -327,8 +687,33 @@ void ActorEnemySet::ConfirmEnemyIfCanSeeSharerOrEnemy
|
|||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
pSelf->m_bEnemyIsDisguised = false;
|
||||
ActorEnemy *pActorEnemy = ActorEnemySet::AddPotentialEnemy(pEnemy);
|
||||
if (pActorEnemy)
|
||||
{
|
||||
if (pActorEnemy->m_fTotalVisibility > 0)
|
||||
{
|
||||
pActorEnemy->m_vLastKnownPos = pEnemy->origin;
|
||||
return;
|
||||
}
|
||||
if (!pActorEnemy->m_bVisible)
|
||||
{
|
||||
if (!pSelf->CanSee(
|
||||
pSharer,
|
||||
pSelf->m_bSilent ? 1119092736 : NULL,
|
||||
0.828 * world->farplane_distance))
|
||||
return;
|
||||
}
|
||||
pActorEnemy->m_fVisibility = 1.0;
|
||||
pActorEnemy->m_fTotalVisibility = 1.0;
|
||||
pActorEnemy->m_vLastKnownPos = pEnemy->origin;
|
||||
if (m_fCurrentVisibility < 1.0)
|
||||
{
|
||||
m_iCurrentThreat = pActorEnemy->UpdateThreat(pSelf);
|
||||
m_fCurrentVisibility = 1.0;
|
||||
m_pCurrentEnemy = pEnemy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool ActorEnemySet::CaresAboutPerfectInfo
|
||||
|
@ -337,7 +722,13 @@ bool ActorEnemySet::CaresAboutPerfectInfo
|
|||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
ActorEnemy *pActorEnemy = ActorEnemySet::AddPotentialEnemy(pEnemy);
|
||||
if (pActorEnemy)
|
||||
{
|
||||
if (pActorEnemy->m_fTotalVisibility < 1.0 || (pEnemy->origin - pActorEnemy->m_vLastKnownPos).lengthSquared() > 262144)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue