mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-05-07 11:13:47 +03:00
Finalized actor_machinegunner
This commit is contained in:
parent
69df583508
commit
5a5cc4ea17
1 changed files with 140 additions and 137 deletions
|
@ -45,11 +45,21 @@ void Actor::Begin_MachineGunner(void)
|
||||||
m_csMood = STRING_ALERT;
|
m_csMood = STRING_ALERT;
|
||||||
m_csIdleMood = STRING_NERVOUS;
|
m_csIdleMood = STRING_NERVOUS;
|
||||||
|
|
||||||
if (m_pTurret) {
|
if (!m_pTurret) {
|
||||||
|
Com_Printf(
|
||||||
|
"^~^~^ Actor (entnum %d, radnum %d, targetname '%s') has no turret specified\n",
|
||||||
|
entnum,
|
||||||
|
radnum,
|
||||||
|
targetname.c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Sentient *pOwner;
|
Sentient *pOwner;
|
||||||
m_pTurret->m_bHadOwner = true;
|
m_pTurret->m_bHadOwner = true;
|
||||||
pOwner = m_pTurret->GetOwner();
|
pOwner = m_pTurret->GetOwner();
|
||||||
if (pOwner) {
|
if (m_pTurret->GetOwner()) {
|
||||||
Com_Printf(
|
Com_Printf(
|
||||||
"^~^~^ Actor (entnum %d, radnum %d, targetname '%s') cannot use turret (entnum %d, radnum %d, "
|
"^~^~^ Actor (entnum %d, radnum %d, targetname '%s') cannot use turret (entnum %d, radnum %d, "
|
||||||
"targetname '%s')"
|
"targetname '%s')"
|
||||||
|
@ -59,24 +69,16 @@ void Actor::Begin_MachineGunner(void)
|
||||||
targetname.c_str(),
|
targetname.c_str(),
|
||||||
m_pTurret->entnum,
|
m_pTurret->entnum,
|
||||||
m_pTurret->radnum,
|
m_pTurret->radnum,
|
||||||
m_pTurret->TargetName().c_str(),
|
m_pTurret->targetname.c_str(),
|
||||||
pOwner->entnum,
|
m_pTurret->GetOwner()->entnum,
|
||||||
pOwner->radnum,
|
m_pTurret->GetOwner()->radnum,
|
||||||
pOwner->TargetName().c_str()
|
m_pTurret->GetOwner()->targetname.c_str()
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
Holster();
|
Holster();
|
||||||
|
|
||||||
m_pTurret->TurretBeginUsed(this);
|
m_pTurret->TurretBeginUsed(this);
|
||||||
TransitionState(1200, 0);
|
TransitionState(ACTOR_STATE_MACHINE_GUNNER_READY);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Com_Printf(
|
|
||||||
"^~^~^ Actor (entnum %d, radnum %d, targetname '%s') has no turret specified\n",
|
|
||||||
entnum,
|
|
||||||
radnum,
|
|
||||||
targetname.c_str()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,92 +89,87 @@ void Actor::End_MachineGunner(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Unholster();
|
Unholster();
|
||||||
if (m_pTurret) {
|
if (m_pTurret && m_pTurret->GetOwner() == this) {
|
||||||
if (m_pTurret->GetOwner() == this) {
|
|
||||||
m_pTurret->TurretEndUsed();
|
m_pTurret->TurretEndUsed();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Actor::ThinkHoldGun_TurretGun(void)
|
void Actor::ThinkHoldGun_TurretGun(void)
|
||||||
{
|
{
|
||||||
Vector end;
|
|
||||||
trace_t trace;
|
|
||||||
float temp;
|
|
||||||
float temp2;
|
|
||||||
float machine_gunner_hands_up_stand;
|
|
||||||
float heightDiff;
|
|
||||||
float right;
|
|
||||||
//vec3_t newOrigin;
|
|
||||||
Vector offset;
|
|
||||||
Vector start;
|
|
||||||
//vec3_t new_angles;
|
|
||||||
Vector vForward;
|
Vector vForward;
|
||||||
|
vec3_t new_angles;
|
||||||
|
vec3_t offset;
|
||||||
|
vec3_t newOrigin;
|
||||||
|
float right;
|
||||||
|
float heightDiff;
|
||||||
|
float machine_gunner_hands_up_stand;
|
||||||
|
float temp;
|
||||||
|
trace_t trace;
|
||||||
|
Vector end;
|
||||||
|
|
||||||
UpdateEyeOrigin();
|
if (m_State != ACTOR_STATE_MACHINE_GUNNER_READY) {
|
||||||
m_pszDebugState = "";
|
DesiredAnimation(ANIM_MODE_FROZEN, STRING_ANIM_MG42_RELOAD_SCR);
|
||||||
if (m_State == 1200) {
|
m_bAnimScriptSet = false;
|
||||||
if (m_pTurret->IsFiring()) {
|
} else if (m_pTurret->IsFiring()) {
|
||||||
if (m_pTurret->aim_target == G_GetEntity(0)) {
|
if (m_pTurret->aim_target == G_GetEntity(0)) {
|
||||||
m_bNoSurprise = true;
|
m_bNoSurprise = true;
|
||||||
}
|
}
|
||||||
m_csNextAnimString = STRING_ANIM_MG42_SHOOT_SCR;
|
|
||||||
|
DesiredAnimation(ANIM_MODE_FROZEN, STRING_ANIM_MG42_SHOOT_SCR);
|
||||||
} else {
|
} else {
|
||||||
m_csNextAnimString = STRING_ANIM_MG42_IDLE_SCR;
|
DesiredAnimation(ANIM_MODE_FROZEN, STRING_ANIM_MG42_IDLE_SCR);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
m_csNextAnimString = STRING_ANIM_MG42_RELOAD_SCR;
|
|
||||||
m_bAnimScriptSet = false;
|
|
||||||
}
|
|
||||||
m_eNextAnimMode = ANIM_MODE_FROZEN;
|
|
||||||
m_bNextForceStart = false;
|
|
||||||
|
|
||||||
CheckUnregister();
|
CheckUnregister();
|
||||||
|
|
||||||
StopTurning();
|
StopTurning();
|
||||||
|
|
||||||
setAngles(Vector(0, m_pTurret->angles[1], 0));
|
VectorSet(new_angles, 0, m_pTurret->angles[1], 0);
|
||||||
|
setAngles(new_angles);
|
||||||
|
|
||||||
vForward = Vector(m_pTurret->orientation[0]) * -39 + m_pTurret->origin;
|
VectorScale(m_pTurret->orientation[0], -39, offset);
|
||||||
|
VectorAdd(m_pTurret->origin, offset, newOrigin);
|
||||||
|
|
||||||
if (m_State == 1201) {
|
if (m_State == ACTOR_STATE_MACHINE_GUNNER_RELOADING) {
|
||||||
heightDiff = 71.6f;
|
heightDiff = 71.6f;
|
||||||
} else {
|
} else {
|
||||||
heightDiff = 71.8f;
|
heightDiff = 71.8f;
|
||||||
}
|
}
|
||||||
|
|
||||||
machine_gunner_hands_up_stand = origin[2] - (m_pTurret->origin[2] - heightDiff);
|
newOrigin[2] -= heightDiff;
|
||||||
|
machine_gunner_hands_up_stand = origin[2] - newOrigin[2];
|
||||||
|
|
||||||
if (machine_gunner_hands_up_stand < 0) {
|
if (machine_gunner_hands_up_stand < 0) {
|
||||||
if (m_State == 1201) {
|
if (m_State == ACTOR_STATE_MACHINE_GUNNER_RELOADING) {
|
||||||
temp = (machine_gunner_hands_up_stand - m_pTurret->origin[2]) / 39;
|
m_fCrouchWeight = 0;
|
||||||
|
|
||||||
|
temp = (origin[2] + 71.6f - m_pTurret->origin[2]) / 39.f;
|
||||||
if (temp >= -1.0 && temp <= 1.0) {
|
if (temp >= -1.0 && temp <= 1.0) {
|
||||||
right = atan2(temp / sqrt(temp * -temp + 1), 1) * 180 / M_PI;
|
m_pTurret->angles[0] = RAD2DEG(atan(temp / sqrt(temp * -temp + 1)));
|
||||||
m_pTurret->setAngles(Vector(right, m_pTurret->angles[1], m_pTurret->angles[2]));
|
m_pTurret->setAngles(m_pTurret->angles);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
m_fCrouchWeight = machine_gunner_hands_up_stand / 17.1;
|
m_fCrouchWeight = machine_gunner_hands_up_stand / 17.1f;
|
||||||
if (m_fCrouchWeight < -1.0) {
|
if (m_fCrouchWeight < -1.0) {
|
||||||
m_fCrouchWeight = -1.0;
|
m_fCrouchWeight = -1.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
temp2 = m_fCrouchWeight * 2.6;
|
|
||||||
offset.x = (-(-9.3 * m_fCrouchWeight + 23.4)) * orientation[0][0] + vForward.x;
|
VectorScale2D(orientation[0], m_fCrouchWeight * -9.3f + 23.4f, offset);
|
||||||
offset.y = (-(-9.3 * m_fCrouchWeight + 23.4)) * orientation[0][0] + vForward.y;
|
VectorAdd2D(newOrigin, offset, newOrigin);
|
||||||
|
VectorScale2D(orientation[1], m_fCrouchWeight * 2.6f + 10.3f, offset);
|
||||||
|
VectorAdd2D(newOrigin, offset, newOrigin);
|
||||||
} else {
|
} else {
|
||||||
m_fCrouchWeight = machine_gunner_hands_up_stand / (heightDiff - 38.7);
|
m_fCrouchWeight = machine_gunner_hands_up_stand / (heightDiff - 38.7f);
|
||||||
if (m_fCrouchWeight > 1.0) {
|
if (m_fCrouchWeight > 1.0) {
|
||||||
m_fCrouchWeight = 1.0;
|
m_fCrouchWeight = 1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
temp2 = m_fCrouchWeight * -1.6;
|
VectorScale2D(orientation[0], m_fCrouchWeight * -3.f + 23.4f, offset);
|
||||||
offset.x = (-(-3 * m_fCrouchWeight + 23.4)) * orientation[0][0] + vForward.x;
|
VectorAdd2D(newOrigin, offset, newOrigin);
|
||||||
offset.y = (-(-3 * m_fCrouchWeight + 23.4)) * orientation[0][0] + vForward.y;
|
VectorScale2D(orientation[1], m_fCrouchWeight * -1.6f + 10.3f, offset);
|
||||||
|
VectorAdd2D(newOrigin, offset, newOrigin);
|
||||||
}
|
}
|
||||||
|
|
||||||
start.x = (temp2 + 10.3) * orientation[1][0] + offset.x;
|
|
||||||
start.y = (temp2 + 10.3) * orientation[1][1] + offset.y;
|
|
||||||
|
|
||||||
if (m_fCrouchWeight >= 0.5) {
|
if (m_fCrouchWeight >= 0.5) {
|
||||||
m_csCurrentPosition = STRING_CROUCH;
|
m_csCurrentPosition = STRING_CROUCH;
|
||||||
} else {
|
} else {
|
||||||
|
@ -181,32 +178,23 @@ void Actor::ThinkHoldGun_TurretGun(void)
|
||||||
|
|
||||||
UpdateAimMotion();
|
UpdateAimMotion();
|
||||||
UpdateAnim();
|
UpdateAnim();
|
||||||
start.z = origin.z + 18.0;
|
|
||||||
|
|
||||||
end = start;
|
end[0] = newOrigin[0];
|
||||||
end.z = origin.z - 94.0;
|
end[1] = newOrigin[1];
|
||||||
|
end[2] = newOrigin[2] - 94;
|
||||||
trace = G_Trace(start, MINS, MAXS, end, this, 1107437825, qfalse, "Actor::ThinkHoldGun_TurretGun");
|
trace = G_Trace(newOrigin, MINS, MAXS, end, this, MASK_PATHSOLID, qfalse, "Actor::ThinkHoldGun_TurretGun");
|
||||||
|
|
||||||
if (trace.fraction != 1.0 && !trace.startsolid && !trace.allsolid && trace.ent) {
|
if (trace.fraction != 1.0 && !trace.startsolid && !trace.allsolid && trace.ent) {
|
||||||
SafeSetOrigin(trace.endpos);
|
SafeSetOrigin(trace.endpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
velocity = vec_zero;
|
VectorClear(velocity);
|
||||||
|
|
||||||
UpdateBoneControllers();
|
UpdateBoneControllers();
|
||||||
UpdateFootsteps();
|
UpdateFootsteps();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::Think_MachineGunner_TurretGun(void)
|
void Actor::Think_MachineGunner_TurretGun(void)
|
||||||
{
|
{
|
||||||
// FIXME: unimplemented
|
|
||||||
}
|
|
||||||
|
|
||||||
void Actor::Think_MachineGunner(void)
|
|
||||||
{
|
|
||||||
if (RequireThink()) {
|
|
||||||
if (m_pTurret && m_pTurret->GetOwner() == this && !m_bNoPlayerCollision) {
|
|
||||||
if (!m_bEnableEnemy) {
|
if (!m_bEnableEnemy) {
|
||||||
ThinkHoldGun_TurretGun();
|
ThinkHoldGun_TurretGun();
|
||||||
return;
|
return;
|
||||||
|
@ -217,55 +205,70 @@ void Actor::Think_MachineGunner(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_iEnemyCheckTime = level.inttime;
|
UpdateEnemyInternal();
|
||||||
|
|
||||||
if (m_pTurret->AI_CanTarget(G_GetEntity(0)->centroid)) {
|
if (m_pTurret->AI_CanTarget(G_GetEntity(0)->centroid)) {
|
||||||
ThinkHoldGun_TurretGun();
|
ThinkHoldGun_TurretGun();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!m_pGrenade || m_fGrenadeAwareness < rand() * 0.000000046566129) {
|
|
||||||
|
if (m_pGrenade && rand() / 21474836.f <= m_fGrenadeAwareness) {
|
||||||
|
BecomeTurretGuy();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!G_SightTrace(
|
if (!G_SightTrace(
|
||||||
EyePosition(),
|
EyePosition(),
|
||||||
vec_zero,
|
vec_zero,
|
||||||
vec_zero,
|
vec_zero,
|
||||||
G_GetEntity(0)->centroid,
|
static_cast<Sentient *>(G_GetEntity(0))->EyePosition(),
|
||||||
this,
|
this,
|
||||||
G_GetEntity(0),
|
G_GetEntity(0),
|
||||||
33819417,
|
MASK_CANSEE,
|
||||||
qfalse,
|
qfalse,
|
||||||
"Actor::Think_MachineGunner"
|
"Actor::Think_MachineGunner"
|
||||||
)) {
|
)) {
|
||||||
ThinkHoldGun_TurretGun();
|
ThinkHoldGun_TurretGun();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ThinkStates[THINKLEVEL_IDLE] != THINKSTATE_IDLE) {
|
if (m_ThinkStates[THINKLEVEL_IDLE] != THINKSTATE_IDLE) {
|
||||||
BecomeTurretGuy();
|
BecomeTurretGuy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_Enemy && !m_Enemy->IsSubclassOfActor() && !EnemyIsDisguised()
|
if (m_Enemy && !(m_Enemy->flags & FL_NOTARGET) && !EnemyIsDisguised() && m_PotentialEnemies.IsEnemyConfirmed()) {
|
||||||
&& m_PotentialEnemies.GetCurrentVisibility() >= 1) {
|
|
||||||
BecomeTurretGuy();
|
BecomeTurretGuy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_Enemy || !m_Enemy->IsSubclassOfActor() || EnemyIsDisguised()
|
if (m_Enemy && m_iCuriousTime || (m_Enemy && !EnemyIsDisguised() && !m_PotentialEnemies.IsEnemyConfirmed())) {
|
||||||
|| m_PotentialEnemies.GetCurrentVisibility() > 1) {
|
m_iCuriousAnimHint = 6;
|
||||||
ThinkHoldGun_TurretGun();
|
BecomeTurretGuy();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCuriousAnimHint(6);
|
ThinkHoldGun_TurretGun();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Actor::Think_MachineGunner(void)
|
||||||
|
{
|
||||||
|
if (!RequireThink()) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_pTurret && m_pTurret->GetOwner() == this && !m_bNoPlayerCollision) {
|
||||||
|
UpdateEyeOrigin();
|
||||||
|
Think_MachineGunner_TurretGun();
|
||||||
|
} else {
|
||||||
BecomeTurretGuy();
|
BecomeTurretGuy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Actor::FinishedAnimation_MachineGunner(void)
|
void Actor::FinishedAnimation_MachineGunner(void)
|
||||||
{
|
{
|
||||||
if (!m_bAnimScriptSet && m_State == 1201) {
|
if (!m_bAnimScriptSet && m_State == ACTOR_STATE_MACHINE_GUNNER_RELOADING) {
|
||||||
TransitionState(1200, 0);
|
TransitionState(ACTOR_STATE_MACHINE_GUNNER_READY, 0);
|
||||||
Unregister(STRING_ANIMDONE);
|
Unregister(STRING_ANIMDONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue