mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Actor Improvements p3_4
This commit is contained in:
parent
d6d29a7a0b
commit
2d71dc0d36
7 changed files with 180 additions and 167 deletions
|
@ -10190,10 +10190,9 @@ void Actor::ResetBoneControllers
|
|||
Actor::UpdateBoneControllers
|
||||
|
||||
Update Bone Controllers.
|
||||
Reversed correctly, since decompiled output has same behaviour as reversed output.
|
||||
Reversed incorrectly, since decompiled output has different behaviour as reversed output.
|
||||
===============
|
||||
*/
|
||||
/*
|
||||
void Actor::UpdateBoneControllers
|
||||
(
|
||||
void
|
||||
|
@ -11165,7 +11164,8 @@ ACTOR_UPDATEBONECONTROLLERS_43:
|
|||
v178[2] = 0.0;
|
||||
SetControllerAngles(2, v178);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void Actor::UpdateBoneControllers()
|
||||
{
|
||||
Vector torsoAngles, headAngles, LocalLookAngles, vec1, vLookDest, vec2, vLookDir, lineVec, eyePosition;
|
||||
|
@ -11561,6 +11561,8 @@ void Actor::UpdateBoneControllers()
|
|||
return;
|
||||
/////////////////////////////////////////////
|
||||
}
|
||||
|
||||
*/
|
||||
/*
|
||||
===============
|
||||
Actor::ReadyToFire
|
||||
|
@ -11577,10 +11579,9 @@ void Actor::ReadyToFire
|
|||
bool ready;
|
||||
|
||||
Weapon *weap = GetActiveWeapon(WEAPON_MAIN);
|
||||
if (weap)
|
||||
ready = weap->ReadyToFire(FIRE_PRIMARY, true);
|
||||
else
|
||||
ready = false;
|
||||
|
||||
ready = weap && weap->ReadyToFire(FIRE_PRIMARY, true);
|
||||
|
||||
ev->AddInteger(ready);
|
||||
}
|
||||
|
||||
|
|
|
@ -570,72 +570,58 @@ void Actor::Turret_NextRetarget
|
|||
|
||||
|
||||
m_State++;
|
||||
if (m_State > 120)
|
||||
|
||||
if (Turret_IsRetargeting())
|
||||
{
|
||||
m_iStateTime = level.inttime;
|
||||
return;
|
||||
}
|
||||
|
||||
VectorSub2D(origin, m_vHome, vDelta);
|
||||
fDistSquared = VectorLength2DSquared(vDelta);
|
||||
|
||||
if (fDistSquared >= m_fLeashSquared)
|
||||
{
|
||||
VectorSub2D(origin, m_vHome, vDelta);
|
||||
fDistSquared = VectorLength2DSquared(vDelta);
|
||||
if (fDistSquared < m_fLeashSquared
|
||||
|| (SetPath(
|
||||
m_vHome,
|
||||
NULL,
|
||||
0,
|
||||
NULL,
|
||||
0.0),
|
||||
ShortenPathToAvoidSquadMates(),
|
||||
!PathExists())
|
||||
|| PathComplete())
|
||||
{
|
||||
if (m_Team == TEAM_AMERICAN)
|
||||
{
|
||||
if (!CanSeeEnemy(200))
|
||||
{
|
||||
m_PotentialEnemies.FlagBadEnemy(m_Enemy);
|
||||
UpdateEnemy(-1);
|
||||
}
|
||||
if (!m_Enemy)
|
||||
{
|
||||
Anim_Stand();
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!CanSeeEnemy(200))
|
||||
{
|
||||
m_State = 112;
|
||||
m_iStateTime = level.inttime;
|
||||
State_Turret_Wait();
|
||||
return;
|
||||
}
|
||||
m_pszDebugState = "Retarget->Combat";
|
||||
}
|
||||
TransitionState(100, 0);
|
||||
State_Turret_Combat();
|
||||
return;
|
||||
}
|
||||
TransitionState(104, 0);
|
||||
SetPath(m_vHome, NULL, 0, NULL, 0.0);
|
||||
ShortenPathToAvoidSquadMates();
|
||||
if (!PathExists() || PathComplete())
|
||||
if (PathExists() && !PathComplete())
|
||||
{
|
||||
Com_Printf(
|
||||
"^~^~^ (entnum %i, radnum %i, targetname '%s') cannot reach his leash home\n",
|
||||
entnum,
|
||||
radnum,
|
||||
targetname.c_str());
|
||||
m_pszDebugState = "home->combat";
|
||||
TransitionState(104, 0);
|
||||
State_Turret_RunHome(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (m_Team == TEAM_AMERICAN)
|
||||
{
|
||||
if (!CanSeeEnemy(200))
|
||||
{
|
||||
m_PotentialEnemies.FlagBadEnemy(m_Enemy);
|
||||
UpdateEnemy(-1);
|
||||
}
|
||||
if (!m_Enemy)
|
||||
{
|
||||
Anim_Stand();
|
||||
return;
|
||||
}
|
||||
TransitionState(100, 0);
|
||||
State_Turret_Combat();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CanSeeEnemy(200))
|
||||
{
|
||||
m_pszDebugState = "Retarget->Combat";
|
||||
TransitionState(100, 0);
|
||||
State_Turret_Combat();
|
||||
}
|
||||
else
|
||||
{
|
||||
FaceMotion();
|
||||
Anim_RunToInOpen(2);
|
||||
TransitionState(112, 0);
|
||||
State_Turret_Wait();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
m_iStateTime = level.inttime;
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::Turret_SideStep
|
||||
|
@ -648,8 +634,11 @@ void Actor::Turret_SideStep
|
|||
AimAtEnemyBehavior();
|
||||
//v3 = iStepSize;
|
||||
StrafeToAttack(iStepSize, vDir);
|
||||
if (PathExists() && !PathComplete() && PathAvoidsSquadMates()
|
||||
|| (Actor::StrafeToAttack(-iStepSize, vDir), SimpleActor::PathExists())
|
||||
if (PathExists()
|
||||
&& !PathComplete()
|
||||
&& PathAvoidsSquadMates()
|
||||
|| (StrafeToAttack(-iStepSize, vDir),
|
||||
PathExists())
|
||||
&& !PathComplete()
|
||||
&& PathAvoidsSquadMates())
|
||||
{
|
||||
|
@ -687,23 +676,27 @@ void Actor::State_Turret_Combat
|
|||
ClearPath();
|
||||
ShortenPathToAvoidSquadMates();
|
||||
}
|
||||
if (PathExists() && !PathComplete() && PathAvoidsSquadMates())
|
||||
if (!PathExists()
|
||||
|| PathComplete()
|
||||
|| !PathAvoidsSquadMates())
|
||||
{
|
||||
m_pszDebugState = "combat->move";
|
||||
if (MovePathWithLeash())
|
||||
{
|
||||
Turret_CheckRetarget();
|
||||
return;
|
||||
}
|
||||
m_pszDebugState = "combat->move->aim";
|
||||
m_pszDebugState = "combat->chill";
|
||||
Turret_BeginRetarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pszDebugState = "combat->chill";
|
||||
m_pszDebugState = "combat->move";
|
||||
if (!MovePathWithLeash())
|
||||
{
|
||||
m_pszDebugState = "combat->move->aim";
|
||||
Turret_BeginRetarget();
|
||||
}
|
||||
else
|
||||
{
|
||||
Turret_CheckRetarget();
|
||||
}
|
||||
}
|
||||
|
||||
Turret_BeginRetarget();
|
||||
|
||||
}
|
||||
|
||||
void Actor::State_Turret_Reacquire
|
||||
|
|
|
@ -3159,15 +3159,73 @@ PathNode *PathSearch::FindCornerNodeForWall
|
|||
|
||||
PathNode *PathSearch::FindCornerNodeForExactPath
|
||||
(
|
||||
SimpleActor *self,
|
||||
SimpleActor *pSelf,
|
||||
Sentient *enemy,
|
||||
float fMaxPath
|
||||
)
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
return NULL;
|
||||
PathNode *pPathNode[4096];
|
||||
|
||||
if (!PathSearch::FindPath(enemy->origin, pSelf->origin, pSelf, fMaxPath, 0, 0.0, 100))
|
||||
return NULL;
|
||||
int iDepth;
|
||||
for (PathNode* pParentNode = Node->Parent; pParentNode; pParentNode = pParentNode->Parent, iDepth++)
|
||||
{
|
||||
pPathNode[iDepth] = pParentNode;
|
||||
}
|
||||
|
||||
Node = pPathNode[iDepth -1];
|
||||
|
||||
|
||||
if (iDepth == 0)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
size_t i;
|
||||
for (i = 0; i < iDepth; i += 2)
|
||||
{
|
||||
if (!G_SightTrace(
|
||||
pSelf->EyePosition(),
|
||||
vec_zero,
|
||||
vec_zero,
|
||||
pSelf->EyePosition() - pSelf->origin + pPathNode[i]->m_PathPos,
|
||||
pSelf,
|
||||
enemy,
|
||||
0x2040B19,
|
||||
0,
|
||||
"FindCornerNodeFoExactPath 1"))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
int index = i - 1;
|
||||
if (index < iDepth)
|
||||
{
|
||||
if (index)
|
||||
{
|
||||
if (!G_SightTrace(
|
||||
pSelf->EyePosition(),
|
||||
vec_zero,
|
||||
vec_zero,
|
||||
pSelf->EyePosition() - pSelf->origin + pPathNode[i]->m_PathPos,
|
||||
pSelf,
|
||||
enemy,
|
||||
0x2040B19,
|
||||
0,
|
||||
"FindCornerNodeFoExactPath 2"))
|
||||
{
|
||||
index--;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
index = iDepth - 1;
|
||||
}
|
||||
|
||||
return pPathNode[index];
|
||||
}
|
||||
|
||||
int PathSearch::FindPotentialCover
|
||||
|
|
|
@ -310,7 +310,7 @@ void SimpleActor::SetPath
|
|||
if (!PathExists()
|
||||
|| ( ( level.inttime >= m_Path.Time() + iMaxDirtyTime
|
||||
|| m_Path.Complete(origin) )
|
||||
&& m_Path.LastNode()->point != vDestPos)
|
||||
&& PathGoal() != vDestPos)
|
||||
)
|
||||
{
|
||||
m_Path.FindPath(origin,
|
||||
|
@ -320,7 +320,7 @@ void SimpleActor::SetPath
|
|||
vLeashHome,
|
||||
fLeashDistSquared);
|
||||
|
||||
if (!m_Path.LastNode())
|
||||
if (!PathExists())
|
||||
{
|
||||
if (g_patherror->integer)
|
||||
{
|
||||
|
@ -396,47 +396,7 @@ void SimpleActor::SetPathWithinDistance
|
|||
)
|
||||
|
||||
{
|
||||
if (!PathExists()
|
||||
|| ((level.inttime >= m_Path.Time() + iMaxDirtyTime
|
||||
|| m_Path.Complete(origin)) && m_Path.LastNode()->point != vDestPos)
|
||||
)
|
||||
{
|
||||
m_Path.FindPath(origin,
|
||||
vDestPos,
|
||||
this,
|
||||
fMaxPath,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if (!m_Path.LastNode())
|
||||
{
|
||||
if (g_patherror->integer)
|
||||
{
|
||||
if (description)
|
||||
{
|
||||
int thinkState = ((Actor *)this)->m_ThinkState;
|
||||
if (g_patherror->integer == 1 || g_patherror->integer == 2 && (thinkState == THINKSTATE_IDLE || thinkState == THINKSTATE_CURIOUS))
|
||||
{
|
||||
if (m_bPathErrorTime + 5000 < level.inttime)
|
||||
{
|
||||
m_bPathErrorTime = level.inttime;
|
||||
Com_Printf(
|
||||
"^~^~^ Path not found in '%s' for '%s' from (%f %f %f) to (%f %f %f)\n",
|
||||
description,
|
||||
targetname.c_str(),
|
||||
origin.x,
|
||||
origin.y,
|
||||
origin.z,
|
||||
vDestPos.x,
|
||||
vDestPos.y,
|
||||
vDestPos.z);
|
||||
Com_Printf("Reason: %s\n", PathSearch::last_error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SetPath(vDestPos, description, iMaxDirtyTime, NULL, 0);
|
||||
}
|
||||
|
||||
void SimpleActor::FindPathAway
|
||||
|
@ -491,6 +451,7 @@ bool SimpleActor::PathIsValid
|
|||
) const
|
||||
|
||||
{
|
||||
//Called by SetPath...
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -500,6 +461,9 @@ bool SimpleActor::PathAvoidsSquadMates
|
|||
) const
|
||||
|
||||
{
|
||||
// FIXME: stub
|
||||
UNIMPLEMENTED();
|
||||
STUB();
|
||||
|
||||
Entity* player;
|
||||
float fDelta;
|
||||
|
@ -523,8 +487,8 @@ bool SimpleActor::PathAvoidsSquadMates
|
|||
return true;
|
||||
}
|
||||
|
||||
player = G_GetEntity(0);
|
||||
player = G_GetEntity(0);
|
||||
//player = G_GetEntity(0);
|
||||
//player = G_GetEntity(0);
|
||||
|
||||
fDelta = (player->origin - origin).lengthXYSquared();
|
||||
if (fDelta > Square(ai_pathcheckdist->value))
|
||||
|
@ -533,20 +497,19 @@ bool SimpleActor::PathAvoidsSquadMates
|
|||
}
|
||||
|
||||
fDistSoFar = 0;
|
||||
for (auto pNode = CurrentPathNode(); pNode >= LastPathNode(); pNode--)
|
||||
for (auto pNode = CurrentPathNode() -1 ; pNode >= LastPathNode(); pNode--)
|
||||
{
|
||||
if (fDistSoFar <= 0)
|
||||
if (fDistSoFar <= (ai_pathchecktime->value * 250.0))
|
||||
{
|
||||
break;
|
||||
}
|
||||
//fDistCap = (ai_pathchecktime->value * 250.0) + 0.001 - fDistSoFar;
|
||||
|
||||
//if (pNode->point[2] > fDistCap)
|
||||
fDistCap = (ai_pathchecktime->value * 250.0) + 0.001 - fDistSoFar;
|
||||
|
||||
if (pNode->point[2] > fDistCap)
|
||||
{
|
||||
}
|
||||
}
|
||||
// FIXME: stub
|
||||
STUB();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -560,8 +523,10 @@ void SimpleActor::ShortenPathToAvoidSquadMates
|
|||
{
|
||||
Vector vBuddyPos;
|
||||
Vector vDelta;
|
||||
Vector vGoal;
|
||||
do
|
||||
{
|
||||
vGoal = PathGoal();
|
||||
Actor *pSquadMate = (Actor *)m_pNextSquadMate.Pointer();
|
||||
if (pSquadMate == this)
|
||||
{
|
||||
|
@ -570,16 +535,17 @@ void SimpleActor::ShortenPathToAvoidSquadMates
|
|||
|
||||
while (true)
|
||||
{
|
||||
vGoal = PathGoal();
|
||||
vBuddyPos = pSquadMate->origin;
|
||||
if (pSquadMate->IsSubclassOfActor() && pSquadMate->PathExists())
|
||||
{
|
||||
vBuddyPos = pSquadMate->LastPathNode()->point;
|
||||
vBuddyPos = pSquadMate->PathGoal();
|
||||
}
|
||||
vDelta.x = LastPathNode()->point[0] - vBuddyPos.x;
|
||||
vDelta.x = vGoal[0] - vBuddyPos.x;
|
||||
if (vDelta.x >= -15.0 && vDelta.x <= 15.0)
|
||||
{
|
||||
vDelta.y = LastPathNode()->point[1] - vBuddyPos.y;
|
||||
vDelta.z = LastPathNode()->point[2] - vBuddyPos.z;
|
||||
vDelta.y = vGoal[1] - vBuddyPos.y;
|
||||
vDelta.z = vGoal[2] - vBuddyPos.z;
|
||||
|
||||
if (vDelta.y >= -15.0 && vDelta.y <= 15.0 && vDelta.z >= 0.0 && vDelta.z <= 94.0)
|
||||
break;
|
||||
|
@ -638,7 +604,7 @@ Vector SimpleActor::PathGoal
|
|||
) const
|
||||
|
||||
{
|
||||
return m_Path.CurrentPathGoal();
|
||||
return LastPathNode()->point;
|
||||
}
|
||||
|
||||
float *SimpleActor::PathDelta
|
||||
|
@ -665,7 +631,7 @@ void SimpleActor::SetDest
|
|||
)
|
||||
|
||||
{
|
||||
VectorCopy(m_Dest, dest);
|
||||
VectorCopy(dest, m_Dest);
|
||||
}
|
||||
|
||||
void SimpleActor::StopTurning
|
||||
|
@ -704,6 +670,7 @@ void SimpleActor::SetDesiredYawDest
|
|||
)
|
||||
|
||||
{
|
||||
//FIXME: something's wrong here
|
||||
m_bHasDesiredLookDest = true;
|
||||
VectorCopy(vec, m_vDesiredLookDest);
|
||||
}
|
||||
|
@ -1126,19 +1093,7 @@ void SimpleActor::UpdateLastFrameSlot
|
|||
)
|
||||
|
||||
{
|
||||
m_weightType[slot] = 0;
|
||||
DoExitCommands(slot);
|
||||
|
||||
if (edict->s.frameInfo[slot].index || gi.TIKI_NumAnims(edict->tiki) <= 1)
|
||||
edict->s.frameInfo[slot].index = 0;
|
||||
else
|
||||
edict->s.frameInfo[slot].index = 1;
|
||||
|
||||
animFlags[slot] = ANIM_PAUSED | ANIM_NOEXIT | ANIM_NODELTA | ANIM_LOOP;
|
||||
|
||||
edict->s.frameInfo[slot].weight = 0.0;
|
||||
|
||||
animFlags[slot] = (animFlags[slot] | ANIM_NODELTA) & ~ANIM_FINISHED;
|
||||
StopAnimating(slot);
|
||||
}
|
||||
|
||||
void SimpleActor::UpdateAnimSlot
|
||||
|
@ -1186,7 +1141,7 @@ void SimpleActor::StopAllAnimating
|
|||
|
||||
for (int slot = 0; slot < MAX_FRAMEINFOS; slot++)
|
||||
{
|
||||
UpdateLastFrameSlot(slot);
|
||||
StopAnimating(slot);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1283,7 +1238,7 @@ void SimpleActor::ChangeSayAnim
|
|||
iSlot = GetSaySlot();
|
||||
StartCrossBlendAnimSlot(iSlot);
|
||||
|
||||
m_AnimDialogHigh ^= 1; // toggle
|
||||
m_AnimDialogHigh = !m_AnimDialogHigh; // toggle
|
||||
}
|
||||
|
||||
iSlot = GetSaySlot();
|
||||
|
@ -1304,23 +1259,12 @@ void SimpleActor::UpdateAim
|
|||
|
||||
if (m_bAimAnimSet)
|
||||
{
|
||||
dir = -m_DesiredGunDir[0];
|
||||
dir = AngleNormalize180(-m_DesiredGunDir[0]);
|
||||
|
||||
aimForwardSlot = GetActionSlot(0);
|
||||
aimUpSlot = aimForwardSlot + 1;
|
||||
aimDownSlot = aimForwardSlot + 2;
|
||||
|
||||
if (dir <= 180)
|
||||
{
|
||||
if (dir < -180)
|
||||
{
|
||||
dir += 360;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dir -= 360;
|
||||
}
|
||||
|
||||
float factor;
|
||||
if (dir < 0)
|
||||
|
@ -1396,12 +1340,20 @@ void SimpleActor::EventGetWeaponGroup
|
|||
)
|
||||
|
||||
{
|
||||
const_str csWeaponGroup;
|
||||
Weapon *weapon = GetActiveWeapon(WEAPON_MAIN);
|
||||
const_str csWeaponGroup = weapon->GetWeaponGroup();
|
||||
if (csWeaponGroup == STRING_NONE)
|
||||
if (!weapon)
|
||||
{
|
||||
csWeaponGroup = STRING_UNARMED;
|
||||
}
|
||||
else
|
||||
{
|
||||
csWeaponGroup = weapon->GetWeaponGroup();
|
||||
if (csWeaponGroup == STRING_EMPTY)
|
||||
{
|
||||
csWeaponGroup = STRING_UNARMED;
|
||||
}
|
||||
}
|
||||
ev->AddConstString(csWeaponGroup);
|
||||
}
|
||||
|
||||
|
@ -1810,6 +1762,7 @@ void SimpleActor::SetPathGoalEndAnim
|
|||
)
|
||||
|
||||
{
|
||||
//fixme: this is an inline function
|
||||
m_csPathGoalEndAnimScript = csEndAnim;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,6 +111,9 @@
|
|||
<IgnoreSpecificDefaultLibraries>
|
||||
</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>$(OutDir)\copy.bat +d $(outdir)</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
|
|
Binary file not shown.
|
@ -8515,4 +8515,9 @@ typedef struct ScriptException_s {
|
|||
str string;
|
||||
int bAbort;
|
||||
int bIsForAnim;
|
||||
} ScriptException_t;
|
||||
} ScriptException_t;
|
||||
|
||||
typedef struct PathSearch_s {
|
||||
Listener_t baseListener;
|
||||
//in here....
|
||||
} PathSearch_t;
|
Loading…
Add table
Add a link
Reference in a new issue