mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-30 06:37:57 +03:00
Finalized actor_cover source file
This commit is contained in:
parent
ae33155ed3
commit
6a210fa212
1 changed files with 269 additions and 281 deletions
|
@ -24,80 +24,96 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "actor.h"
|
||||
|
||||
static int Cover_HideTime(int iTeam)
|
||||
{
|
||||
if (iTeam == TEAM_AMERICAN) {
|
||||
return rand() % 2001 + 2000;
|
||||
} else {
|
||||
return rand() % 11001 + 4000;
|
||||
}
|
||||
}
|
||||
|
||||
bool Actor::Cover_IsValid(PathNode *node)
|
||||
{
|
||||
if (!node->IsClaimedByOther(this)) {
|
||||
Vector sight_origin = node->origin + eyeposition;
|
||||
if (node->IsClaimedByOther(this)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node->nodeflags & AI_CONCEALMENT) {
|
||||
return true;
|
||||
} else if (CanSeeFrom(origin + eyeposition, m_Enemy)) {
|
||||
}
|
||||
|
||||
if (!CanSeeFrom(sight_origin, m_Enemy)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!(node->nodeflags & AI_DUCK)) {
|
||||
return false;
|
||||
} else if (CanSeeFrom(origin + eyeposition - Vector(0, 0, 32), m_Enemy)) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (CanSee(sight_origin - Vector(0, 0, 32), 0, 0, false)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Actor::Cover_SetPath(PathNode *node)
|
||||
{
|
||||
float origin_ratio;
|
||||
Vector enemy_offset;
|
||||
PathInfo *current_node;
|
||||
Vector enemy_origin;
|
||||
vec2_t vDelta;
|
||||
float fMinDistSquared;
|
||||
float fPathDist;
|
||||
|
||||
SetPathWithLeash(node, NULL, 0);
|
||||
|
||||
if (!PathExists()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float origin_ratio;
|
||||
Vector enemy_offset;
|
||||
PathInfo *current_node;
|
||||
Vector enemy_origin;
|
||||
Vector vDelta;
|
||||
float fMinDistSquared;
|
||||
float fPathDist;
|
||||
|
||||
fPathDist = PathDist();
|
||||
fMinDistSquared = fPathDist * fPathDist;
|
||||
vDelta = node->origin - origin;
|
||||
fMinDistSquared = Square(fPathDist);
|
||||
|
||||
if (fMinDistSquared >= vDelta.lengthSquared() * 4.0f) {
|
||||
if (fPathDist > 128.0f) {
|
||||
if (fMinDistSquared >= (node->origin - origin).lengthSquared() * 4.0f && fPathDist > 128.0f) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (PathComplete()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!PathComplete()) {
|
||||
enemy_origin = m_Enemy->origin;
|
||||
vDelta = enemy_origin - origin;
|
||||
VectorSub2D(enemy_origin, origin, vDelta);
|
||||
|
||||
if (VectorLength2DSquared(vDelta) * 0.64f > 192 * 192) {
|
||||
origin_ratio = 192 * 192;
|
||||
if (VectorLength2DSquared(vDelta) * 0.64f > Square(192)) {
|
||||
origin_ratio = Square(192);
|
||||
}
|
||||
|
||||
for (current_node = CurrentPathNode() - 1; current_node >= LastPathNode(); current_node--) {
|
||||
vDelta[0] = origin[0] - current_node->point[0];
|
||||
vDelta[1] = origin[1] - current_node->point[1];
|
||||
VectorSub2D(enemy_origin, current_node->point, enemy_offset);
|
||||
|
||||
if (origin_ratio >= VectorLength2DSquared(vDelta)) {
|
||||
if (VectorLength2DSquared(enemy_offset) <= origin_ratio) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float fDot = DotProduct2D(vDelta, current_node->dir);
|
||||
if (fDot < 0.0f && -current_node->dist <= fDot) {
|
||||
if ((vDelta[0] * current_node->dir[0] - vDelta[1] * current_node->dir[1])
|
||||
* (vDelta[0] * current_node->dir[0] - vDelta[1] * current_node->dir[1])) {
|
||||
if (DotProduct2D(enemy_offset, current_node->dir) >= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (DotProduct2D(enemy_offset, current_node->dir) < -current_node->dist) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (Square(CrossProduct2D(enemy_offset, current_node->dir)) <= origin_ratio) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
return PathAvoidsSquadMates() != false;
|
||||
}
|
||||
|
||||
void Actor::Cover_FindCover(bool bCheckAll)
|
||||
|
@ -115,8 +131,11 @@ void Actor::Cover_FindCover(bool bCheckAll)
|
|||
m_iPotentialCoverCount = PathManager.FindPotentialCover(this, origin, m_Enemy, m_pPotentialCoverNode, 16);
|
||||
}
|
||||
|
||||
if (m_iPotentialCoverCount) {
|
||||
PathNode *pNode = NULL;
|
||||
if (!m_iPotentialCoverCount) {
|
||||
return;
|
||||
}
|
||||
|
||||
PathNode *pNode;
|
||||
|
||||
while (m_iPotentialCoverCount) {
|
||||
m_iPotentialCoverCount--;
|
||||
|
@ -127,7 +146,7 @@ void Actor::Cover_FindCover(bool bCheckAll)
|
|||
break;
|
||||
}
|
||||
|
||||
if (!bCheckAll) {
|
||||
if (!bCheckAll || !m_iPotentialCoverCount) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +156,6 @@ void Actor::Cover_FindCover(bool bCheckAll)
|
|||
memset(m_pPotentialCoverNode, 0, sizeof(m_pPotentialCoverNode));
|
||||
m_iPotentialCoverCount = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::InitCover(GlobalFuncs_t *func)
|
||||
{
|
||||
|
@ -158,18 +176,18 @@ void Actor::Begin_Cover(void)
|
|||
m_csMood = STRING_ALERT;
|
||||
|
||||
if (m_pCoverNode) {
|
||||
TransitionState(302, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_TAKE_COVER, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
TransitionState(300, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_START, 0);
|
||||
|
||||
if (level.inttime < m_iEnemyChangeTime + 200) {
|
||||
SetLeashHome(origin);
|
||||
|
||||
if (AttackEntryAnimation()) {
|
||||
m_bLockThinkState = true;
|
||||
TransitionState(312, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_LOOP, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -194,22 +212,21 @@ void Actor::Suspend_Cover(void)
|
|||
m_pCoverNode = NULL;
|
||||
}
|
||||
|
||||
TransitionState(301, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_COVER, 0);
|
||||
}
|
||||
|
||||
void Actor::State_Cover_NewEnemy(void)
|
||||
{
|
||||
m_bHasDesiredLookAngles = true;
|
||||
|
||||
ForwardLook();
|
||||
Cover_FindCover(true);
|
||||
|
||||
if (m_pCoverNode && PathExists() && PathComplete()) {
|
||||
Anim_RunToCover(3);
|
||||
TransitionState(302, 0);
|
||||
if (m_pCoverNode && PathExists() && !PathComplete()) {
|
||||
Anim_RunToCover(ANIM_MODE_PATH_GOAL);
|
||||
TransitionState(ACTOR_STATE_COVER_TAKE_COVER, 0);
|
||||
} else {
|
||||
Anim_Aim();
|
||||
AimAtTargetPos();
|
||||
TransitionState(307, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_TARGET, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -219,17 +236,13 @@ void Actor::State_Cover_FindCover(void)
|
|||
AimAtTargetPos();
|
||||
Cover_FindCover(false);
|
||||
|
||||
if (m_pCoverNode) {
|
||||
if (PathExists() && !PathComplete()) {
|
||||
Anim_RunToCover(3);
|
||||
TransitionState(302, 0);
|
||||
} else {
|
||||
TransitionState(307, 0);
|
||||
}
|
||||
} else {
|
||||
if (!m_iPotentialCoverCount) {
|
||||
if (!m_pCoverNode && !m_iPotentialCoverCount) {
|
||||
SetThink(THINKSTATE_ATTACK, THINK_TURRET);
|
||||
}
|
||||
} else if (PathExists() && !PathComplete()) {
|
||||
Anim_RunToCover(ANIM_MODE_PATH_GOAL);
|
||||
TransitionState(ACTOR_STATE_COVER_TAKE_COVER, 0);
|
||||
} else {
|
||||
TransitionState(ACTOR_STATE_COVER_TARGET, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -237,67 +250,58 @@ void Actor::State_Cover_TakeCover(void)
|
|||
{
|
||||
if (PathExists() && !PathComplete()) {
|
||||
FaceEnemyOrMotion(level.inttime - m_iStateTime);
|
||||
Anim_RunToCover(3);
|
||||
m_csPathGoalEndAnimScript = m_bInReload ? STRING_ANIM_RUNTO_COVER_SCR : STRING_ANIM_IDLE_SCR;
|
||||
Anim_RunToCover(ANIM_MODE_PATH_GOAL);
|
||||
SetPathGoalEndAnim(m_bInReload ? STRING_ANIM_RUNTO_COVER_SCR : STRING_ANIM_IDLE_SCR);
|
||||
} else {
|
||||
ClearPath();
|
||||
m_eAnimMode = ANIM_MODE_NORMAL;
|
||||
TransitionState(303, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FINISH_RELOADING, 0);
|
||||
State_Cover_FinishReloading();
|
||||
}
|
||||
}
|
||||
|
||||
static int Cover_HideTime(int iTeam)
|
||||
{
|
||||
if (iTeam == TEAM_AMERICAN) {
|
||||
return rand() % 2001 + 2000;
|
||||
} else {
|
||||
return rand() % 11001 + 4000;
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::State_Cover_FinishReloading(void)
|
||||
{
|
||||
Weapon *pWeapon;
|
||||
firetype_t eFireType;
|
||||
|
||||
if (m_bInReload) {
|
||||
ContinueAnimation();
|
||||
AimAtTargetPos();
|
||||
return;
|
||||
}
|
||||
|
||||
Weapon *pWeap = GetWeapon(0);
|
||||
pWeapon = GetWeapon(WEAPON_MAIN);
|
||||
if (pWeapon) {
|
||||
eFireType = pWeapon->GetFireType(FIRE_PRIMARY);
|
||||
}
|
||||
|
||||
if (!pWeap || pWeap->GetFireType(FIRE_PRIMARY) == FT_PROJECTILE
|
||||
|| pWeap->GetFireType(FIRE_PRIMARY) == FT_SPECIAL_PROJECTILE) {
|
||||
if (pWeapon && eFireType != FT_PROJECTILE && eFireType != FT_SPECIAL_PROJECTILE
|
||||
&& (m_csSpecialAttack = m_pCoverNode->GetSpecialAttack(this)) != 0) {
|
||||
if (m_pCoverNode->nodeflags & AI_DUCK) {
|
||||
Anim_Crouch();
|
||||
} else {
|
||||
Anim_Stand();
|
||||
}
|
||||
|
||||
m_sCurrentPathNodeIndex = -1;
|
||||
|
||||
TransitionState(308, Cover_HideTime(m_Team));
|
||||
TransitionState(ACTOR_STATE_COVER_HIDE, Cover_HideTime(m_Team));
|
||||
|
||||
Anim_Aim();
|
||||
AimAtTargetPos();
|
||||
return;
|
||||
} else {
|
||||
SetDesiredYaw(m_pCoverNode->angles.yaw());
|
||||
SafeSetOrigin(m_pCoverNode->origin);
|
||||
DesiredAnimation(ANIM_MODE_NORMAL, m_csSpecialAttack);
|
||||
TransitionState(ACTOR_STATE_COVER_SPECIAL_ATTACK, 0);
|
||||
}
|
||||
|
||||
SetDesiredYaw(angles[1]);
|
||||
|
||||
SafeSetOrigin(origin);
|
||||
m_eNextAnimMode = ANIM_MODE_NORMAL;
|
||||
m_bNextForceStart = false;
|
||||
m_csNextAnimString = m_csSpecialAttack;
|
||||
TransitionState(304, 0);
|
||||
}
|
||||
|
||||
void Actor::State_Cover_Target(void)
|
||||
{
|
||||
DontFaceWall();
|
||||
|
||||
if (m_eDontFaceWallMode <= 8) {
|
||||
TransitionState(305, 0);
|
||||
if (AvoidingFacingWall()) {
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_ENEMY, 0);
|
||||
State_Cover_FindEnemy();
|
||||
return;
|
||||
}
|
||||
|
@ -305,31 +309,40 @@ void Actor::State_Cover_Target(void)
|
|||
Anim_Aim();
|
||||
AimAtTargetPos();
|
||||
|
||||
if (level.inttime > m_iStateTime + 300 && fabs(m_DesiredYaw - angles[1]) < 0.001f) {
|
||||
Vector end = m_vLastEnemyPos + velocity;
|
||||
if (DecideToThrowGrenade(end, &m_vGrenadeVel, &m_eGrenadeMode, false)) {
|
||||
SetDesiredYawDir(m_vGrenadeVel);
|
||||
m_eNextAnimMode = ANIM_MODE_NORMAL;
|
||||
m_bNextForceStart = false;
|
||||
m_csNextAnimString =
|
||||
m_eGrenadeMode == AI_GREN_TOSS_ROLL ? STRING_ANIM_GRENADETOSS_SCR : STRING_ANIM_GRENADETHROW_SCR;
|
||||
TransitionState(310, 0);
|
||||
} else if (CanSeeEnemy(500) && CanShootEnemy(500)) {
|
||||
TransitionState(309, 0);
|
||||
} else {
|
||||
TransitionState(308, Cover_HideTime(m_Team));
|
||||
if (level.inttime < m_iStateTime + 300) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fabs(m_DesiredYaw - angles[1]) >= 0.001f) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DecideToThrowGrenade(m_vLastEnemyPos + velocity, &m_vGrenadeVel, &m_eGrenadeMode, false)) {
|
||||
SetDesiredYawDir(m_vGrenadeVel);
|
||||
DesiredAnimation(
|
||||
ANIM_MODE_NORMAL,
|
||||
m_eGrenadeMode == AI_GREN_TOSS_ROLL ? STRING_ANIM_GRENADETOSS_SCR : STRING_ANIM_GRENADETHROW_SCR
|
||||
);
|
||||
TransitionState(ACTOR_STATE_COVER_GRENADE);
|
||||
} else if (CanSeeEnemy(500) && CanShootEnemy(500)) {
|
||||
TransitionState(ACTOR_STATE_COVER_SHOOT, 0);
|
||||
} else {
|
||||
TransitionState(ACTOR_STATE_COVER_HIDE, Cover_HideTime(m_Team));
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::State_Cover_Hide(void)
|
||||
{
|
||||
PathNode *pNode;
|
||||
trace_t trace;
|
||||
bool bCanShoot, bCanSee;
|
||||
|
||||
if (m_Enemy) {
|
||||
SetEnemyPos(origin);
|
||||
}
|
||||
|
||||
if (!m_pCoverNode) {
|
||||
TransitionState(301, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_COVER, 0);
|
||||
State_Cover_FindCover();
|
||||
return;
|
||||
}
|
||||
|
@ -338,42 +351,36 @@ void Actor::State_Cover_Hide(void)
|
|||
MPrintf("special: %d", m_csSpecialAttack);
|
||||
|
||||
if (m_csSpecialAttack) {
|
||||
SetDesiredYaw(m_pCoverNode->angles[1]);
|
||||
SetDesiredYaw(m_pCoverNode->angles.yaw());
|
||||
SafeSetOrigin(m_pCoverNode->origin);
|
||||
m_eNextAnimMode = ANIM_MODE_NORMAL;
|
||||
m_bNextForceStart = false;
|
||||
m_csNextAnimString = m_csSpecialAttack;
|
||||
TransitionState(304, 0);
|
||||
DesiredAnimation(ANIM_MODE_NORMAL, m_csSpecialAttack);
|
||||
TransitionState(ACTOR_STATE_COVER_SPECIAL_ATTACK, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
bool bCanShoot = CanShootEnemy(500);
|
||||
if (CanSeeEnemy(500)) {
|
||||
if (bCanShoot) {
|
||||
Vector vDelta = m_Enemy->origin - origin;
|
||||
bCanSee = CanSeeEnemy(500);
|
||||
bCanShoot = CanShootEnemy(500);
|
||||
|
||||
if (VectorLength2DSquared(vDelta) * 0.75f <= Square(DotProduct2D(vDelta, orientation[0]))) {
|
||||
TransitionState(307, 0);
|
||||
if (bCanSee && bCanShoot) {
|
||||
vec2_t vDelta;
|
||||
|
||||
VectorSub2D(m_Enemy->origin, origin, vDelta);
|
||||
if (VectorLength2DSquared(vDelta) * 0.75f > Square(DotProduct2D(vDelta, orientation[0]))) {
|
||||
TransitionState(ACTOR_STATE_COVER_SHOOT);
|
||||
} else {
|
||||
TransitionState(309, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_TARGET);
|
||||
}
|
||||
|
||||
State_Cover_Shoot();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (bCanShoot || bCanShoot) {
|
||||
m_pCoverNode->Relinquish();
|
||||
m_pCoverNode->MarkTemporarilyBad();
|
||||
m_pCoverNode = NULL;
|
||||
TransitionState(305, 0);
|
||||
State_Cover_FindEnemy();
|
||||
return;
|
||||
}
|
||||
|
||||
if (bCanShoot) {
|
||||
m_pCoverNode->Relinquish();
|
||||
m_pCoverNode->MarkTemporarilyBad();
|
||||
m_pCoverNode = NULL;
|
||||
TransitionState(305, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_ENEMY);
|
||||
State_Cover_FindEnemy();
|
||||
return;
|
||||
}
|
||||
|
@ -381,49 +388,32 @@ void Actor::State_Cover_Hide(void)
|
|||
if (m_Team == TEAM_AMERICAN) {
|
||||
if (level.inttime >= m_iLastFaceDecideTime + 1000) {
|
||||
m_iLastFaceDecideTime = level.inttime;
|
||||
PathNode *node = PathManager.FindCornerNodeForExactPath(this, m_Enemy, m_fLeash + m_fMaxDistance);
|
||||
pNode = PathManager.FindCornerNodeForExactPath(this, m_Enemy, m_fLeash + m_fMaxDistance);
|
||||
|
||||
if (!node) {
|
||||
m_bHasDesiredLookAngles = false;
|
||||
if (!pNode) {
|
||||
ForwardLook();
|
||||
Anim_Stand();
|
||||
m_PotentialEnemies.FlagBadEnemy(m_Enemy);
|
||||
UpdateEnemy(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
Vector vDelta = node->m_PathPos - origin;
|
||||
|
||||
if (vDelta[0] || vDelta[1]) {
|
||||
SetDesiredYawDir(vDelta);
|
||||
}
|
||||
SetDesiredYawDest(pNode->m_PathPos);
|
||||
}
|
||||
|
||||
Anim_Aim();
|
||||
} else {
|
||||
if (level.inttime >= m_iLastFaceDecideTime + 1000) {
|
||||
m_iLastFaceDecideTime = level.inttime;
|
||||
Vector eyepos = EyePosition();
|
||||
Vector end = m_vLastEnemyPos + eyeposition;
|
||||
trace_t trace = G_Trace(
|
||||
eyepos,
|
||||
vec_zero,
|
||||
vec_zero,
|
||||
end,
|
||||
this,
|
||||
(CONTENTS_SOLID | CONTENTS_SLIME | CONTENTS_LAVA),
|
||||
false,
|
||||
"State_Cover"
|
||||
|
||||
trace = G_Trace(
|
||||
EyePosition(), vec_zero, vec_zero, m_vLastEnemyPos + eyeposition, this, MASK_LOOK, false, "State_Cover"
|
||||
);
|
||||
|
||||
PathNode *node = PathManager.FindCornerNodeForWall(origin, m_vLastEnemyPos, this, 0.0f, trace.plane.normal);
|
||||
|
||||
if (node) {
|
||||
Vector vDelta = node->m_PathPos - origin;
|
||||
|
||||
if (vDelta[0] || vDelta[1]) {
|
||||
SetDesiredYawDir(vDelta);
|
||||
}
|
||||
pNode = PathManager.FindCornerNodeForWall(origin, m_vLastEnemyPos, this, 0.0f, trace.plane.normal);
|
||||
|
||||
if (pNode) {
|
||||
SetDesiredYawDest(pNode->m_PathPos);
|
||||
m_eDontFaceWallMode = 6;
|
||||
} else {
|
||||
AimAtTargetPos();
|
||||
|
@ -431,7 +421,7 @@ void Actor::State_Cover_Hide(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (m_eDontFaceWallMode <= 8) {
|
||||
if (m_eDontFaceWallMode == 7 || m_eDontFaceWallMode == 8) {
|
||||
Anim_Stand();
|
||||
} else {
|
||||
Anim_Aim();
|
||||
|
@ -442,28 +432,27 @@ void Actor::State_Cover_Hide(void)
|
|||
return;
|
||||
}
|
||||
|
||||
PathNode *pNode = (PathNode *)G_FindRandomSimpleTarget(m_pCoverNode->target);
|
||||
pNode = (PathNode *)G_FindRandomSimpleTarget(m_pCoverNode->Target());
|
||||
|
||||
m_pCoverNode->Relinquish();
|
||||
m_pCoverNode = NULL;
|
||||
|
||||
if (!pNode) {
|
||||
Anim_Stand();
|
||||
TransitionState(305, rand() & 0x7FF);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_ENEMY, rand() & 0x7FF);
|
||||
return;
|
||||
}
|
||||
|
||||
assert(pNode->IsSubclassOfPathNode());
|
||||
if (pNode->IsSubclassOfPathNode()) {
|
||||
if (!pNode->IsClaimedByOther(this)) {
|
||||
|
||||
if (pNode->IsSubclassOfPathNode() && !pNode->IsClaimedByOther(this)) {
|
||||
SetPath(pNode, "Actor::State_Cover_Target", 0);
|
||||
|
||||
if (PathExists()) {
|
||||
m_pCoverNode = pNode;
|
||||
pNode->Claim(this);
|
||||
Anim_RunToDanger(3);
|
||||
TransitionState(306, 0);
|
||||
}
|
||||
Anim_RunToDanger(ANIM_MODE_PATH_GOAL);
|
||||
TransitionState(ACTOR_STATE_COVER_SEARCH_NODE, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -474,9 +463,9 @@ void Actor::State_Cover_Shoot(void)
|
|||
Cover_FindCover(true);
|
||||
|
||||
if (m_pCoverNode) {
|
||||
Anim_RunToCover(3);
|
||||
Anim_RunToCover(ANIM_MODE_PATH_GOAL);
|
||||
FaceEnemyOrMotion(0);
|
||||
TransitionState(302, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_TAKE_COVER, 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -488,7 +477,7 @@ void Actor::State_Cover_Shoot(void)
|
|||
gi.cvar_set("g_monitornum", va("%i", entnum));
|
||||
assert(!"anim/shoot.scr took over 10 seconds");
|
||||
Com_Error(
|
||||
ERR_DROP, "anim/shoot.scr took over 10 seconds, entnum = %i, targetname = %s", entnum, targetname.c_str()
|
||||
ERR_DROP, "anim/shoot.scr took over 10 seconds, entnum = %i, targetname = %s", entnum, TargetName().c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -500,11 +489,11 @@ void Actor::State_Cover_Grenade(void)
|
|||
|
||||
void Actor::State_Cover_SpecialAttack(void)
|
||||
{
|
||||
m_bHasDesiredLookAngles = false;
|
||||
ForwardLook();
|
||||
|
||||
assert(m_pCoverNode);
|
||||
if (!m_pCoverNode) {
|
||||
TransitionState(305, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_ENEMY, 0);
|
||||
State_Cover_FindEnemy();
|
||||
return;
|
||||
}
|
||||
|
@ -515,85 +504,80 @@ void Actor::State_Cover_SpecialAttack(void)
|
|||
m_pCoverNode = NULL;
|
||||
}
|
||||
|
||||
TransitionState(305, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_ENEMY, 0);
|
||||
State_Cover_FindEnemy();
|
||||
return;
|
||||
}
|
||||
|
||||
if (level.inttime >= m_iLastEnemyPosChangeTime + level.intframetime || !m_csSpecialAttack) {
|
||||
m_csSpecialAttack = m_pCoverNode->GetSpecialAttack(this);
|
||||
}
|
||||
|
||||
if (!m_csSpecialAttack) {
|
||||
TransitionState(305, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_ENEMY, 0);
|
||||
State_Cover_FindEnemy();
|
||||
return;
|
||||
}
|
||||
|
||||
if (m_csSpecialAttack > STRING_ANIM_HIGHWALL_SCR || m_csSpecialAttack < STRING_ANIM_LOWWALL_SCR) {
|
||||
SetDesiredYaw(m_pCoverNode->angles.yaw());
|
||||
} else {
|
||||
AimAtTargetPos();
|
||||
}
|
||||
|
||||
SetDesiredYaw(angles[1]);
|
||||
|
||||
m_eNextAnimMode = ANIM_MODE_NORMAL;
|
||||
m_csNextAnimString = m_csSpecialAttack;
|
||||
m_bNextForceStart = false;
|
||||
DesiredAnimation(ANIM_MODE_NORMAL, m_csSpecialAttack);
|
||||
}
|
||||
|
||||
void Actor::State_Cover_FindEnemy(void)
|
||||
{
|
||||
if (m_Team == TEAM_AMERICAN) {
|
||||
m_bHasDesiredLookAngles = false;
|
||||
|
||||
__setpath:
|
||||
ForwardLook();
|
||||
Anim_Stand();
|
||||
SetPathWithLeash(m_vLastEnemyPos, NULL, 0);
|
||||
ShortenPathToAvoidSquadMates();
|
||||
if (PathExists() && !PathComplete() && PathAvoidsSquadMates()) {
|
||||
TransitionState(311, 0);
|
||||
} else {
|
||||
m_bTurretNoInitialCover = true;
|
||||
SetThink(THINKSTATE_ATTACK, THINK_TURRET);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
AimAtTargetPos();
|
||||
Anim_Aim();
|
||||
DontFaceWall();
|
||||
|
||||
if (CanSeeEnemy(200)) {
|
||||
if (m_eDontFaceWallMode > 8) {
|
||||
TransitionState(307, 0);
|
||||
if (CanSeeEnemy(200) && !AvoidingFacingWall()) {
|
||||
TransitionState(ACTOR_STATE_COVER_TARGET);
|
||||
} else if (!AvoidingFacingWall() && level.inttime <= m_iStateTime + 500) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
goto __setpath;
|
||||
}
|
||||
SetPathWithLeash(m_vLastEnemyPos, NULL, 0);
|
||||
ShortenPathToAvoidSquadMates();
|
||||
|
||||
if (m_eDontFaceWallMode <= 8 || level.inttime > m_iStateTime + 500) {
|
||||
goto __setpath;
|
||||
if (PathExists() && !PathComplete() && PathAvoidsSquadMates()) {
|
||||
TransitionState(ACTOR_STATE_COVER_HUNT_ENEMY);
|
||||
} else {
|
||||
m_bTurretNoInitialCover = true;
|
||||
SetThink(THINKSTATE_ATTACK, THINK_TURRET);
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::State_Cover_SearchNode(void)
|
||||
{
|
||||
m_bHasDesiredLookAngles = false;
|
||||
ForwardLook();
|
||||
|
||||
if (CanSeeEnemy(200)) {
|
||||
Anim_Aim();
|
||||
AimAtTargetPos();
|
||||
TransitionState(307, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_TARGET, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
if (PathExists() && !PathComplete()) {
|
||||
FaceEnemyOrMotion(level.inttime - m_iStateTime);
|
||||
Anim_RunToDanger(3);
|
||||
} else {
|
||||
Anim_RunToDanger(ANIM_MODE_PATH_GOAL);
|
||||
return;
|
||||
}
|
||||
|
||||
Anim_Aim();
|
||||
AimAtTargetPos();
|
||||
|
||||
if (level.inttime > m_iStateTime + 3000) {
|
||||
TransitionState(301, 0);
|
||||
}
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_COVER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -604,17 +588,18 @@ void Actor::State_Cover_HuntEnemy(void)
|
|||
|
||||
if (PathExists() && !PathComplete()) {
|
||||
if (CanSeeEnemy(300)) {
|
||||
TransitionState(307, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_TARGET, 0);
|
||||
}
|
||||
} else {
|
||||
TransitionState(305, rand() & 0x7FF);
|
||||
return;
|
||||
}
|
||||
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_ENEMY, rand() & 0x7FF);
|
||||
|
||||
if (m_pCoverNode) {
|
||||
m_pCoverNode->Relinquish();
|
||||
m_pCoverNode = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::State_Cover_FakeEnemy(void)
|
||||
{
|
||||
|
@ -636,70 +621,70 @@ void Actor::Think_Cover(void)
|
|||
NoPoint();
|
||||
UpdateEnemy(500);
|
||||
|
||||
if (m_State == 312) {
|
||||
if (m_State == ACTOR_STATE_COVER_LOOP) {
|
||||
ContinueAnimation();
|
||||
} else {
|
||||
m_bLockThinkState = false;
|
||||
if (m_Enemy) {
|
||||
if (m_State == 313) {
|
||||
TransitionState(300, 0);
|
||||
if (m_State == ACTOR_STATE_COVER_FAKE_ENEMY) {
|
||||
TransitionState(ACTOR_STATE_COVER_START, 0);
|
||||
}
|
||||
} else {
|
||||
if (m_State != 313) {
|
||||
TransitionState(313, (rand() & 0x7FF) + 1000);
|
||||
if (m_State != ACTOR_STATE_COVER_FAKE_ENEMY) {
|
||||
TransitionState(ACTOR_STATE_COVER_FAKE_ENEMY, (rand() & 0x7FF) + 1000);
|
||||
}
|
||||
}
|
||||
|
||||
switch (m_State) {
|
||||
case 300:
|
||||
case ACTOR_STATE_COVER_START:
|
||||
m_pszDebugState = "NewEnemy";
|
||||
State_Cover_NewEnemy();
|
||||
break;
|
||||
case 301:
|
||||
case ACTOR_STATE_COVER_FIND_COVER:
|
||||
m_pszDebugState = "FindCover";
|
||||
State_Cover_FindCover();
|
||||
break;
|
||||
case 302:
|
||||
case ACTOR_STATE_COVER_TAKE_COVER:
|
||||
m_pszDebugState = "TakeCover";
|
||||
State_Cover_TakeCover();
|
||||
break;
|
||||
case 303:
|
||||
case ACTOR_STATE_COVER_FINISH_RELOADING:
|
||||
m_pszDebugState = "FinishReloading";
|
||||
State_Cover_FinishReloading();
|
||||
break;
|
||||
case 304:
|
||||
case ACTOR_STATE_COVER_SPECIAL_ATTACK:
|
||||
m_pszDebugState = "SpecialAttack";
|
||||
State_Cover_SpecialAttack();
|
||||
break;
|
||||
case 305:
|
||||
case ACTOR_STATE_COVER_FIND_ENEMY:
|
||||
m_pszDebugState = "FindEnemy";
|
||||
State_Cover_FindEnemy();
|
||||
break;
|
||||
case 306:
|
||||
case ACTOR_STATE_COVER_SEARCH_NODE:
|
||||
m_pszDebugState = "SearchNode";
|
||||
State_Cover_SearchNode();
|
||||
break;
|
||||
case 307:
|
||||
case ACTOR_STATE_COVER_TARGET:
|
||||
m_pszDebugState = "Target";
|
||||
State_Cover_Target();
|
||||
break;
|
||||
case 308:
|
||||
case ACTOR_STATE_COVER_HIDE:
|
||||
m_pszDebugState = "Hide";
|
||||
State_Cover_Hide();
|
||||
break;
|
||||
case 309:
|
||||
case ACTOR_STATE_COVER_SHOOT:
|
||||
m_pszDebugState = "Shoot";
|
||||
State_Cover_Shoot();
|
||||
break;
|
||||
case 310:
|
||||
case ACTOR_STATE_COVER_GRENADE:
|
||||
m_pszDebugState = "Grenade";
|
||||
State_Cover_Grenade();
|
||||
break;
|
||||
case 311:
|
||||
case ACTOR_STATE_COVER_HUNT_ENEMY:
|
||||
m_pszDebugState = "HuntEnemy";
|
||||
State_Cover_HuntEnemy();
|
||||
break;
|
||||
case 313:
|
||||
case ACTOR_STATE_COVER_FAKE_ENEMY:
|
||||
m_pszDebugState = "FakeEnemy";
|
||||
State_Cover_FakeEnemy();
|
||||
break;
|
||||
|
@ -709,30 +694,33 @@ void Actor::Think_Cover(void)
|
|||
break;
|
||||
}
|
||||
|
||||
CheckForTransition(THINKSTATE_GRENADE, THINKLEVEL_IDLE);
|
||||
if (!CheckForTransition(THINKSTATE_GRENADE, THINKLEVEL_IDLE)) {
|
||||
CheckForTransition(THINKSTATE_BADPLACE, THINKLEVEL_IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_State != 305 && m_State != 307 && m_State != 308 && m_State != 309) {
|
||||
PostThink(true);
|
||||
} else {
|
||||
if (m_State == ACTOR_STATE_COVER_HIDE || m_State == ACTOR_STATE_COVER_FIND_ENEMY
|
||||
|| m_State == ACTOR_STATE_COVER_TARGET || m_State == ACTOR_STATE_COVER_SHOOT) {
|
||||
PostThink(false);
|
||||
} else {
|
||||
PostThink(true);
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::FinishedAnimation_Cover(void)
|
||||
{
|
||||
if (m_State == 309) {
|
||||
if (m_State == ACTOR_STATE_COVER_SHOOT) {
|
||||
if (m_Enemy && !m_Enemy->IsDead() && CanSeeEnemy(500) && CanShootEnemy(500)) {
|
||||
TransitionState(309, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_SHOOT, 0);
|
||||
} else {
|
||||
TransitionState(301, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_COVER, 0);
|
||||
}
|
||||
} else if (m_State == 310 || m_State == 312) {
|
||||
TransitionState(301, 0);
|
||||
} else if (m_State == ACTOR_STATE_COVER_GRENADE || m_State == ACTOR_STATE_COVER_LOOP) {
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_COVER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void Actor::PathnodeClaimRevoked_Cover(void)
|
||||
{
|
||||
TransitionState(301, 0);
|
||||
TransitionState(ACTOR_STATE_COVER_FIND_COVER, 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue