Fixed mismatched anim methods up to Actor::EventSetSayAnim

This commit is contained in:
smallmodel 2023-10-16 00:29:41 +02:00
parent ea0c4b5060
commit ce59e5e6a7
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -3192,7 +3192,9 @@ void Actor::GetMoveInfo(mmove_t *mm)
} else { } else {
PathInfo *node = m_Path.NextNode(); PathInfo *node = m_Path.NextNode();
if (!node || !m_Path.IsAccurate() && (node == m_Path.LastNode() && m_Path.CurrentNode() != m_Path.StartNode())) { if (!node
|| !m_Path.IsAccurate()
&& (node == m_Path.LastNode() && m_Path.CurrentNode() != m_Path.StartNode())) {
m_Path.Clear(); m_Path.Clear();
VectorClear(velocity); VectorClear(velocity);
return; return;
@ -3318,8 +3320,7 @@ void Actor::UpdateBoneControllers(void)
orientation_t tag_or; orientation_t tag_or;
Vector vError; Vector vError;
if (g_showlookat->integer == entnum || g_showlookat->integer == -1) if (g_showlookat->integer == entnum || g_showlookat->integer == -1) {
{
tagnum = gi.Tag_NumForName(edict->tiki, "eyes bone"); tagnum = gi.Tag_NumForName(edict->tiki, "eyes bone");
tag_or = G_TIKI_Orientation(edict, tagnum & TAG_MASK); tag_or = G_TIKI_Orientation(edict, tagnum & TAG_MASK);
AnglesToAxis(angles, myAxis); AnglesToAxis(angles, myAxis);
@ -3461,7 +3462,9 @@ void Actor::UpdateBoneControllers(void)
min_accel_change = m_fTorsoCurrentTurnSpeed - level.frametime * 15; min_accel_change = m_fTorsoCurrentTurnSpeed - level.frametime * 15;
max_change = Q_clamp_float(max_change, min_accel_change, max_accel_change); max_change = Q_clamp_float(max_change, min_accel_change, max_accel_change);
max_change = Q_clamp_float(max_change, level.frametime * -m_fTorsoCurrentTurnSpeed, level.frametime * m_fTorsoCurrentTurnSpeed); max_change = Q_clamp_float(
max_change, level.frametime * -m_fTorsoCurrentTurnSpeed, level.frametime * m_fTorsoCurrentTurnSpeed
);
torsoAngles[1] += max_change; torsoAngles[1] += max_change;
@ -3497,7 +3500,8 @@ void Actor::UpdateBoneControllers(void)
max_change = Q_clamp_float(max_change, yawError, -headAngles[1]); max_change = Q_clamp_float(max_change, yawError, -headAngles[1]);
} }
max_change = Q_clamp_float(max_change, level.frametime * -m_fHeadMaxTurnSpeed, level.frametime * m_fHeadMaxTurnSpeed); max_change =
Q_clamp_float(max_change, level.frametime * -m_fHeadMaxTurnSpeed, level.frametime * m_fHeadMaxTurnSpeed);
headAngles[1] += max_change; headAngles[1] += max_change;
// clamp head yaw to 60 degrees // clamp head yaw to 60 degrees
@ -3517,7 +3521,8 @@ void Actor::UpdateBoneControllers(void)
max_change = 0; max_change = 0;
} }
max_change = Q_clamp_float(max_change, level.frametime * -m_fHeadMaxTurnSpeed, level.frametime * m_fHeadMaxTurnSpeed); max_change =
Q_clamp_float(max_change, level.frametime * -m_fHeadMaxTurnSpeed, level.frametime * m_fHeadMaxTurnSpeed);
headAngles[0] += max_change; headAngles[0] += max_change;
// clamp head pitch to 35 degrees // clamp head pitch to 35 degrees
headAngles[0] = Q_clamp_float(headAngles[0], -35, 35); headAngles[0] = Q_clamp_float(headAngles[0], -35, 35);
@ -3544,7 +3549,8 @@ void Actor::UpdateBoneControllers(void)
max_change += 360; max_change += 360;
} }
max_change = Q_clamp_float(max_change, level.frametime * -m_fLUpperArmTurnSpeed, level.frametime * m_fLUpperArmTurnSpeed); max_change =
Q_clamp_float(max_change, level.frametime * -m_fLUpperArmTurnSpeed, level.frametime * m_fLUpperArmTurnSpeed);
// set the new arms angles // set the new arms angles
new_angles[0] = m_vLUpperArmDesiredAngles[0]; new_angles[0] = m_vLUpperArmDesiredAngles[0];
new_angles[1] = tmp_angles[1] + max_change; new_angles[1] = tmp_angles[1] + max_change;
@ -3629,7 +3635,8 @@ void Actor::DoMove(void)
mmove_t mm; mmove_t mm;
trace_t trace; trace_t trace;
if (m_eAnimMode != ANIM_MODE_ATTACHED && (!m_bDoPhysics || m_iOriginTime == level.inttime || m_pGlueMaster || bindmaster)) { if (m_eAnimMode != ANIM_MODE_ATTACHED
&& (!m_bDoPhysics || m_iOriginTime == level.inttime || m_pGlueMaster || bindmaster)) {
return; return;
} }
@ -5312,8 +5319,7 @@ void Actor::MovePath(float fMoveSpeed)
m_WallDir = -1; m_WallDir = -1;
mm.desired_dir[0] = -mm.obstacle_normal[1]; mm.desired_dir[0] = -mm.obstacle_normal[1];
mm.desired_dir[1] = mm.obstacle_normal[0]; mm.desired_dir[1] = mm.obstacle_normal[0];
} } else {
else {
mm.desired_dir[0] = mm.obstacle_normal[1]; mm.desired_dir[0] = mm.obstacle_normal[1];
mm.desired_dir[1] = -mm.obstacle_normal[0]; mm.desired_dir[1] = -mm.obstacle_normal[0];
} }
@ -5381,8 +5387,7 @@ void Actor::MovePath(float fMoveSpeed)
m_WallDir = 1; m_WallDir = 1;
mm.desired_dir[0] = mm.obstacle_normal[1]; mm.desired_dir[0] = mm.obstacle_normal[1];
mm.desired_dir[1] = -mm.obstacle_normal[0]; mm.desired_dir[1] = -mm.obstacle_normal[0];
} } else {
else {
m_WallDir = -1; m_WallDir = -1;
mm.desired_dir[0] = -mm.obstacle_normal[1]; mm.desired_dir[0] = -mm.obstacle_normal[1];
mm.desired_dir[1] = mm.obstacle_normal[0]; mm.desired_dir[1] = mm.obstacle_normal[0];
@ -5527,7 +5532,8 @@ Set current mood.
void Actor::EventSetMood(Event *ev) void Actor::EventSetMood(Event *ev)
{ {
m_csMood = ev->GetConstString(1); m_csMood = ev->GetConstString(1);
if (m_csMood != STRING_BORED && m_csMood != STRING_NERVOUS && m_csMood != STRING_CURIOUS && m_csMood != STRING_ALERT) { if (m_csMood != STRING_BORED && m_csMood != STRING_NERVOUS && m_csMood != STRING_CURIOUS
&& m_csMood != STRING_ALERT) {
m_csMood = STRING_BORED; m_csMood = STRING_BORED;
ScriptError("invalid mood - setting to bored"); ScriptError("invalid mood - setting to bored");
} }
@ -5980,8 +5986,7 @@ bool Actor::MoveToWaypointWithPlayer(void)
return true; return true;
} }
vDelta[0] = pSquadMate->origin[0] - origin[0]; VectorSub2D(pSquadMate->origin, origin, vDelta);
vDelta[1] = pSquadMate->origin[1] - origin[1];
fDistSquared = VectorLength2DSquared(vDelta); fDistSquared = VectorLength2DSquared(vDelta);
if (fDistSquared >= fIntervalSquared) { if (fDistSquared >= fIntervalSquared) {
@ -6091,8 +6096,7 @@ bool Actor::MoveToPatrolCurrentNode(void)
vec2_t delta; vec2_t delta;
VectorSub2D(m_patrolCurrentNode->origin, origin, delta); VectorSub2D(m_patrolCurrentNode->origin, origin, delta);
return VectorLength2DSquared(delta) <= m_fMoveDoneRadiusSquared; return VectorLength2DSquared(delta) <= m_fMoveDoneRadiusSquared;
} } else {
else {
SetPath(m_patrolCurrentNode->origin, "Actor::MoveToPatrolCurrentNode", 0, NULL, 0); SetPath(m_patrolCurrentNode->origin, "Actor::MoveToPatrolCurrentNode", 0, NULL, 0);
if (!PathExists()) { if (!PathExists()) {
@ -6436,7 +6440,17 @@ void Actor::DetectSmokeGrenades(void)
eyePos = VirtualEyePosition(); eyePos = VirtualEyePosition();
fDistSquared = (sprite->origin - eyePos).lengthSquared(); fDistSquared = (sprite->origin - eyePos).lengthSquared();
if (fDistSquared > 65536 || InFOV(sprite->origin) == true) { if (fDistSquared > 65536 || InFOV(sprite->origin) == true) {
if (G_SightTrace(eyePos, vec_zero, vec_zero, sprite->origin, this, NULL, MASK_CANSEE, qfalse, "Actor::DetectSmokeGrenades")) { if (G_SightTrace(
eyePos,
vec_zero,
vec_zero,
sprite->origin,
this,
NULL,
MASK_CANSEE,
qfalse,
"Actor::DetectSmokeGrenades"
)) {
m_PotentialEnemies.ConfirmEnemy(this, sprite->owner); m_PotentialEnemies.ConfirmEnemy(this, sprite->owner);
} }
} }
@ -6523,78 +6537,54 @@ Set animation event.
*/ */
void Actor::EventSetAnim(Event *ev) void Actor::EventSetAnim(Event *ev)
{ {
//"anim slot weight flagged" const_str name = 0;
int numArgs = ev->NumArgs(), slot = 0, animnum;
float weight = 1; float weight = 1;
const_str anim, flagVal; int slot = 0;
qboolean flagged = qfalse; int anim;
const_str flagVal;
qboolean flagged;
//FIXME: better notation, but this works for now. switch (ev->NumArgs()) {
if (numArgs < 1 || numArgs > 4) { case 4:
ScriptError("bad number of arguments");
} else if (numArgs == 1) {
anim = ev->GetConstString(1);
animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str());
if (animnum == -1) {
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
}
} else if (numArgs == 2) {
anim = ev->GetConstString(1);
animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str());
if (animnum == -1) {
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
}
slot = ev->GetInteger(2);
if (slot > 2) {
ScriptError("Bad animation slot, only 0 and 1 supported");
}
} else if (numArgs == 3) {
weight = ev->GetFloat(3);
if (weight < 0) {
ScriptError("Negative anim weight not allowed");
}
if (weight != 0) {
slot = ev->GetInteger(2);
if (slot > 2) {
ScriptError("Bad animation slot, only 0 and 1 supported");
}
}
anim = ev->GetConstString(1);
animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str());
if (animnum == -1) {
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
}
} else if (numArgs == 4) {
flagVal = ev->GetConstString(4); flagVal = ev->GetConstString(4);
flagged = qtrue; flagged = qtrue;
if (flagVal != STRING_FLAGGED) { if (flagVal != STRING_FLAGGED) {
ScriptError("unknown keyword '%s', expected 'flagged'", Director.GetString(flagVal).c_str()); ScriptError("unknown keyword '%s', expected 'flagged'", Director.GetString(flagVal).c_str());
} }
case 3:
weight = ev->GetFloat(3); weight = ev->GetFloat(3);
if (weight < 0) { if (weight < 0) {
ScriptError("Negative anim weight not allowed"); ScriptError("Negative anim weight not allowed");
} }
if (weight != 0) {
if (!weight) {
return;
}
case 2:
slot = ev->GetInteger(2); slot = ev->GetInteger(2);
if (slot > 2) { if (slot > 2) {
ScriptError("Bad animation slot, only 0 and 1 supported"); ScriptError("Bad animation slot, only 0 and 1 supported");
} }
case 1:
name = ev->GetConstString(1);
anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str());
if (anim == -1) {
UnknownAnim(Director.GetString(name).c_str(), edict->tiki);
} }
break;
anim = ev->GetConstString(1); default:
animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str()); ScriptError("bad number of arguments");
if (animnum == -1) { break;
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
}
} }
if (!slot) { if (!slot) {
flagged = qtrue; flagged = qtrue;
} }
if (flagged) { if (flagged) {
parm.motionfail = qtrue; parm.motionfail = qtrue;
} }
if (!m_bLevelMotionAnim) { if (!m_bLevelMotionAnim) {
if (slot) { if (slot) {
m_weightType[GetMotionSlot(slot)] = 0; m_weightType[GetMotionSlot(slot)] = 0;
@ -6602,7 +6592,8 @@ void Actor::EventSetAnim(Event *ev)
ChangeMotionAnim(); ChangeMotionAnim();
m_bMotionAnimSet = true; m_bMotionAnimSet = true;
} }
StartMotionAnimSlot(slot, animnum, weight);
StartMotionAnimSlot(slot, anim, weight);
if (flagged) { if (flagged) {
m_iMotionSlot = GetMotionSlot(slot); m_iMotionSlot = GetMotionSlot(slot);
parm.motionfail = qfalse; parm.motionfail = qfalse;
@ -6635,26 +6626,31 @@ Set motion animation.
*/ */
void Actor::EventSetMotionAnim(Event *ev) void Actor::EventSetMotionAnim(Event *ev)
{ {
gi.DPrintf("Actor::EventSetMotionAnim\n"); int anim;
const_str name;
if (ev->NumArgs() != 1) { if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
const_str anim = ev->GetConstString(1);
str animstr = Director.GetString(anim); name = ev->GetConstString(1);
int animnum = gi.Anim_NumForName(edict->tiki, animstr.c_str()); anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (animnum == -1) {
UnknownAnim(animstr.c_str(), edict->tiki); if (anim == -1) {
UnknownAnim(Director.GetString(name), edict->tiki);
} }
gi.DPrintf("Actor::EventSetMotionAnim %s %d\n", animstr.c_str(), animnum);
parm.motionfail = qtrue; parm.motionfail = qtrue;
if (!m_bLevelMotionAnim) { if (!m_bLevelMotionAnim) {
ChangeMotionAnim(); ChangeMotionAnim();
// start the animation
m_bMotionAnimSet = true; m_bMotionAnimSet = true;
StartMotionAnimSlot(0, animnum, 1.0); StartMotionAnimSlot(0, anim, 1.0);
// set the slot
m_iMotionSlot = GetMotionSlot(0); m_iMotionSlot = GetMotionSlot(0);
parm.motionfail = qfalse; parm.motionfail = qfalse;
} }
} }
@ -6668,41 +6664,43 @@ Set aim motion animation.
*/ */
void Actor::EventSetAimMotionAnim(Event *ev) void Actor::EventSetAimMotionAnim(Event *ev)
{ {
int anim_crouch, anim_stand, anim_high;
const_str name; const_str name;
int anim_crouch, anim_stand, anim_high;
if (ev->NumArgs() != 3) { if (ev->NumArgs() != 3) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
//FIXME: maybe inline func ?
name = ev->GetConstString(1); name = ev->GetConstString(1);
anim_crouch = gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str()); anim_crouch = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (anim_crouch == -1) { if (anim_crouch == -1) {
UnknownAnim(Director.GetString(name).c_str(), edict->tiki); UnknownAnim(Director.GetString(name), edict->tiki);
} }
name = ev->GetConstString(2); name = ev->GetConstString(2);
anim_stand = gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str()); anim_stand = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (anim_stand == -1) { if (anim_stand == -1) {
UnknownAnim(Director.GetString(name).c_str(), edict->tiki); UnknownAnim(Director.GetString(name), edict->tiki);
} }
name = ev->GetConstString(3); name = ev->GetConstString(3);
anim_high = gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str()); anim_high = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (anim_high == -1) { if (anim_high == -1) {
UnknownAnim(Director.GetString(name).c_str(), edict->tiki); UnknownAnim(Director.GetString(name), edict->tiki);
} }
parm.motionfail = qtrue; parm.motionfail = qtrue;
if (!m_bLevelMotionAnim) { if (!m_bLevelMotionAnim) {
ChangeMotionAnim(); ChangeMotionAnim();
m_bMotionAnimSet = true; m_bMotionAnimSet = true;
UpdateAimMotion(); UpdateAimMotion();
StartAimMotionAnimSlot(0, anim_crouch); StartAimMotionAnimSlot(0, anim_crouch);
StartAimMotionAnimSlot(1, anim_stand); StartAimMotionAnimSlot(1, anim_stand);
StartAimMotionAnimSlot(2, anim_high); StartAimMotionAnimSlot(2, anim_high);
m_iMotionSlot = GetMotionSlot(1); m_iMotionSlot = GetMotionSlot(1);
parm.motionfail = qfalse; parm.motionfail = qfalse;
} }
@ -6717,12 +6715,17 @@ Set action animation.
*/ */
void Actor::EventSetActionAnim(Event *ev) void Actor::EventSetActionAnim(Event *ev)
{ {
const_str name;
int anim_forward, anim_up, anim_down;
str derivedName;
if (ev->NumArgs() != 3) { if (ev->NumArgs() != 3) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
name = ev->GetConstString(1);
m_fAimLimit_down = ev->GetFloat(2); m_fAimLimit_down = ev->GetFloat(2);
if (m_fAimLimit_down > 0) { if (m_fAimLimit_down >= 0) {
m_fAimLimit_down = -0.001f; m_fAimLimit_down = -0.001f;
ScriptError("Positive lower_limit not allowed"); ScriptError("Positive lower_limit not allowed");
} }
@ -6733,22 +6736,21 @@ void Actor::EventSetActionAnim(Event *ev)
ScriptError("Negative upper_limit not allowed"); ScriptError("Negative upper_limit not allowed");
} }
const_str anim = ev->GetConstString(1); anim_forward = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str()); if (anim_forward == -1) {
if (animnum == -1) { UnknownAnim(Director.GetString(name), edict->tiki);
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
} }
const_str anim2 = ev->GetConstString(2); derivedName = Director.GetString(name) + "_up";
int animnum2 = gi.Anim_NumForName(edict->tiki, Director.GetString(anim2)); anim_up = gi.Anim_NumForName(edict->tiki, derivedName);
if (animnum2 == -1) { if (anim_up == -1) {
UnknownAnim(Director.GetString(anim2).c_str(), edict->tiki); UnknownAnim(derivedName, edict->tiki);
} }
const_str anim3 = ev->GetConstString(3); derivedName = Director.GetString(name) + "_down";
int animnum3 = gi.Anim_NumForName(edict->tiki, Director.GetString(anim3)); anim_down = gi.Anim_NumForName(edict->tiki, derivedName);
if (animnum3 == -1) { if (anim_down == -1) {
UnknownAnim(Director.GetString(anim3).c_str(), edict->tiki); UnknownAnim(derivedName, edict->tiki);
} }
parm.upperfail = qtrue; parm.upperfail = qtrue;
@ -6758,9 +6760,9 @@ void Actor::EventSetActionAnim(Event *ev)
m_bActionAnimSet = true; m_bActionAnimSet = true;
UpdateAim(); UpdateAim();
StartAimAnimSlot(0, animnum); StartAimAnimSlot(0, anim_up);
StartAimAnimSlot(1, anim2); StartAimAnimSlot(1, anim_forward);
StartAimAnimSlot(2, anim3); StartAimAnimSlot(2, anim_down);
m_iActionSlot = GetActionSlot(0); m_iActionSlot = GetActionSlot(0);
parm.upperfail = qfalse; parm.upperfail = qfalse;
} }
@ -6775,17 +6777,21 @@ Set upper body.
*/ */
void Actor::EventUpperAnim(Event *ev) void Actor::EventUpperAnim(Event *ev)
{ {
int anim;
const_str name;
if (ev->NumArgs()) { if (ev->NumArgs()) {
if (ev->NumArgs() != 1) { if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
const_str anim = ev->GetConstString(1);
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str()); name = ev->GetConstString(1);
if (animnum == -1) { anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki); if (anim == -1) {
UnknownAnim(Director.GetString(name), edict->tiki);
} }
m_csUpperAnim = anim; m_csUpperAnim = name;
} else if (m_bLevelActionAnim) { } else if (m_bLevelActionAnim) {
AnimFinished(m_iActionSlot, true); AnimFinished(m_iActionSlot, true);
} }
@ -6800,21 +6806,24 @@ Set upper body animation.
*/ */
void Actor::EventSetUpperAnim(Event *ev) void Actor::EventSetUpperAnim(Event *ev)
{ {
int anim;
const_str name;
if (ev->NumArgs() != 1) { if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
const_str anim = ev->GetConstString(1); name = ev->GetConstString(1);
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str()); anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (animnum == -1) { if (anim == -1) {
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki); UnknownAnim(Director.GetString(name), edict->tiki);
} }
parm.upperfail = qtrue; parm.upperfail = qtrue;
if (!m_bLevelActionAnim) { if (!m_bLevelActionAnim) {
ChangeActionAnim(); ChangeActionAnim();
m_bActionAnimSet = true; m_bActionAnimSet = true;
StartActionAnimSlot(animnum); StartActionAnimSlot(anim);
m_iActionSlot = SimpleActor::GetActionSlot(0); m_iActionSlot = SimpleActor::GetActionSlot(0);
parm.upperfail = qfalse; parm.upperfail = qfalse;
} }
@ -6829,12 +6838,14 @@ Returns true if animation not found.
*/ */
bool Actor::SoundSayAnim(const_str name, byte bLevelSayAnim) bool Actor::SoundSayAnim(const_str name, byte bLevelSayAnim)
{ {
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str()); if (gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str()) != -1) {
if (animnum == -1) { return false;
}
ChangeSayAnim(); ChangeSayAnim();
m_bSayAnimSet = true; m_bSayAnimSet = true;
m_iSaySlot = -2;
m_bLevelSayAnim = bLevelSayAnim; m_bLevelSayAnim = bLevelSayAnim;
m_iSaySlot = -2;
Com_Printf( Com_Printf(
"Couldn't find animation '%s' in '%s' - trying sound alias instead.\n", "Couldn't find animation '%s' in '%s' - trying sound alias instead.\n",
@ -6846,8 +6857,6 @@ bool Actor::SoundSayAnim(const_str name, byte bLevelSayAnim)
return true; return true;
} }
return false;
}
/* /*
=============== ===============
@ -6859,26 +6868,22 @@ Play idle say dialogue.
void Actor::EventIdleSayAnim(Event *ev) void Actor::EventIdleSayAnim(Event *ev)
{ {
const_str name; const_str name;
if (ev->NumArgs()) {
if (!ev->NumArgs() && m_bLevelSayAnim == 1) {
AnimFinished(m_iSaySlot, true);
return;
}
if (ev->NumArgs() != 1) { if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
name = ev->GetConstString(1); name = ev->GetConstString(1);
if (m_ThinkState <= THINKSTATE_ATTACK || IsGrenadeState(m_ThinkState)) { if (m_ThinkState == THINKSTATE_KILLED || m_ThinkState == THINKSTATE_PAIN || m_ThinkState == THINKSTATE_ATTACK
|| m_ThinkState == THINKSTATE_BADPLACE || !SoundSayAnim(name, 1)) {
m_csSayAnim = name; m_csSayAnim = name;
//FIXME: macro
m_bNextLevelSayAnim = 1; m_bNextLevelSayAnim = 1;
} else {
if (!SoundSayAnim(name, 1)) {
m_csSayAnim = name;
//FIXME: macro
m_bNextLevelSayAnim = 1;
}
}
} else if (m_bLevelSayAnim == 1) {
AnimFinished(m_iSaySlot, true);
} }
} }
@ -6892,25 +6897,22 @@ Play idle dialogue.
void Actor::EventSayAnim(Event *ev) void Actor::EventSayAnim(Event *ev)
{ {
const_str name; const_str name;
if (ev->NumArgs()) {
if (!ev->NumArgs() && m_bLevelSayAnim) {
AnimFinished(m_iSaySlot, true);
return;
}
if (ev->NumArgs() != 1) { if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
name = ev->GetConstString(1); name = ev->GetConstString(1);
if (m_ThinkState <= THINKSTATE_KILLED || !SoundSayAnim(name, 2)) { if (m_ThinkState == THINKSTATE_KILLED || m_ThinkState == THINKSTATE_PAIN || !SoundSayAnim(name, 2)) {
m_csSayAnim = name; m_csSayAnim = name;
//FIXME: macro
m_bNextLevelSayAnim = 2; m_bNextLevelSayAnim = 2;
gi.DPrintf("Actor::EventSayAnim: 1 %s\n", targetname.c_str());
} }
gi.DPrintf("Actor::EventSayAnim: 2 %s\n", targetname.c_str());
} else if (m_bLevelSayAnim == 1) {
AnimFinished(m_iSaySlot, true);
gi.DPrintf("Actor::EventSayAnim: 3 %s\n", targetname.c_str());
}
gi.DPrintf("Actor::EventSayAnim: 4 %s\n", targetname.c_str());
} }
/* /*
@ -6922,29 +6924,45 @@ Set say animation.
*/ */
void Actor::EventSetSayAnim(Event *ev) void Actor::EventSetSayAnim(Event *ev)
{ {
int anim;
int animflags;
const_str name; const_str name;
str sName;
if (ev->NumArgs() != 1) { if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments"); ScriptError("bad number of arguments");
} }
if (m_bLevelSayAnim == 0) { if (m_bLevelSayAnim) {
return;
}
name = ev->GetConstString(1); name = ev->GetConstString(1);
parm.sayfail = qtrue; parm.sayfail = qtrue;
sName = Director.GetString(name); anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
int animnum = gi.Anim_NumForName(edict->tiki, sName.c_str());
Com_Printf("EventSetSayAnim sName: %s, animnum: %d, mVoiceType: %d\n", sName.c_str(), animnum, mVoiceType); if (anim == -1) {
if (!SoundSayAnim(name, m_bLevelSayAnim)) { ChangeSayAnim();
int flags = gi.Anim_FlagsSkel(edict->tiki, animnum); m_bSayAnimSet = true;
if (flags & TAF_HASUPPER) { m_iSaySlot = -2;
Com_Printf(
"Couldn't find animation '%s' in '%s' - trying sound alias instead.\n",
Director.GetString(name),
edict->tiki->a->name
);
Sound(Director.GetString(name), CHAN_AUTO, 0, 0, NULL, 0, 0, true, true);
return;
}
animflags = gi.Anim_FlagsSkel(edict->tiki, anim);
if (animflags & TAF_HASUPPER) {
if (m_bLevelActionAnim) { if (m_bLevelActionAnim) {
if (!m_bSayAnimSet) { if (!m_bSayAnimSet) {
m_iSaySlot = m_iActionSlot; m_iSaySlot = m_iActionSlot;
} }
return; return;
} }
if (flags & TAF_HASDELTA) { if (flags & TAF_HASDELTA) {
if (m_bLevelMotionAnim) { if (m_bLevelMotionAnim) {
if (!m_bSayAnimSet) { if (!m_bSayAnimSet) {
@ -6952,30 +6970,31 @@ void Actor::EventSetSayAnim(Event *ev)
} }
return; return;
} }
ChangeActionAnim(); ChangeActionAnim();
ChangeMotionAnim(); ChangeMotionAnim();
StartMotionAnimSlot(0, animnum, 1.0); StartMotionAnimSlot(0, anim, 1.0);
m_iMotionSlot = m_iActionSlot = GetMotionSlot(0); m_iMotionSlot = m_iActionSlot = GetMotionSlot(0);
} else { } else {
ChangeActionAnim(); ChangeActionAnim();
m_bActionAnimSet = true; m_bActionAnimSet = true;
StartActionAnimSlot(animnum); StartActionAnimSlot(anim);
m_iActionSlot = GetActionSlot(0); m_iActionSlot = GetActionSlot(0);
} }
ChangeSayAnim(); ChangeSayAnim();
m_bSayAnimSet = true; m_bSayAnimSet = true;
m_iSaySlot = m_iActionSlot; m_iSaySlot = m_iActionSlot;
} else { } else {
ChangeSayAnim(); ChangeSayAnim();
m_bSayAnimSet = true; m_bSayAnimSet = true;
StartSayAnimSlot(animnum); StartSayAnimSlot(anim);
m_iSaySlot = GetSaySlot(); m_iSaySlot = GetSaySlot();
} }
}
parm.sayfail = qfalse; parm.sayfail = qfalse;
} }
}
/* /*
=============== ===============
@ -6987,7 +7006,7 @@ Change current animation.
void Actor::ChangeAnim(void) void Actor::ChangeAnim(void)
{ {
bool v3; // zf bool v3;
if (m_pAnimThread) { if (m_pAnimThread) {
if (g_scripttrace->integer) { if (g_scripttrace->integer) {
@ -8727,11 +8746,8 @@ void Actor::DefaultReceiveAIEvent(
return; return;
} }
if (originator if (originator && !originator->IsDead() && originator->IsSubclassOfSentient()
&& !originator->IsDead() && ((Sentient *)originator)->m_Team == m_Team && !IsSquadMate((Sentient *)originator)) {
&& originator->IsSubclassOfSentient()
&& ((Sentient*)originator)->m_Team == m_Team
&& !IsSquadMate((Sentient*)originator)) {
MergeWithSquad((Sentient *)originator); MergeWithSquad((Sentient *)originator);
} }
@ -8869,8 +8885,7 @@ void Actor::CuriousSound(int iType, vec3_t sound_origin, float fDistSquared, flo
float v7, v8, fRangeFactor = 1.0; float v7, v8, fRangeFactor = 1.0;
int iPriority; int iPriority;
if (m_bEnableEnemy) { if (m_bEnableEnemy) {
if (m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE if (m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE || m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS) {
|| m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS) {
//FIXME: name variables. //FIXME: name variables.
if (fMaxDistSquared != 0.0) { if (fMaxDistSquared != 0.0) {
v7 = 1 * (1.0 / 3) - fDistSquared * (1 * (1.0 / 3)) / fMaxDistSquared; v7 = 1 * (1.0 / 3) - fDistSquared * (1 * (1.0 / 3)) / fMaxDistSquared;
@ -9007,8 +9022,7 @@ Handles footstep sound.
void Actor::FootstepSound(vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator) void Actor::FootstepSound(vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator)
{ {
if (originator->IsSubclassOfSentient()) { if (originator->IsSubclassOfSentient()) {
if ((m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE if ((m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE || m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS)
|| m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS)
&& m_bEnableEnemy) { && m_bEnableEnemy) {
if (NoticeFootstep((Sentient *)originator)) { if (NoticeFootstep((Sentient *)originator)) {
CuriousSound(AI_EVENT_FOOTSTEP, sound_origin, fDistSquared, fMaxDistSquared); CuriousSound(AI_EVENT_FOOTSTEP, sound_origin, fDistSquared, fMaxDistSquared);
@ -11696,7 +11710,13 @@ void Actor::SetNationality(Event *ev)
str name; str name;
if (ev->NumArgs() != 1) { if (ev->NumArgs() != 1) {
ScriptError("Bad bad nationality specified for '%s' at (%f %f %f)\n", TargetName().c_str(), origin[0], origin[1], origin[2]); ScriptError(
"Bad bad nationality specified for '%s' at (%f %f %f)\n",
TargetName().c_str(),
origin[0],
origin[1],
origin[2]
);
} }
name = ev->GetString(1); name = ev->GetString(1);
@ -11714,7 +11734,10 @@ void Actor::SetNationality(Event *ev)
} else if (!str::icmpn(name, "ussr", 5)) { } else if (!str::icmpn(name, "ussr", 5)) {
m_iNationality = ACTOR_NATIONALITY_RUSSIAN; m_iNationality = ACTOR_NATIONALITY_RUSSIAN;
} else { } else {
ScriptError("Bad bad nationality specified for '%s', must be one of: ger, it, usa, uk, ussr or default\n", TargetName().c_str()); ScriptError(
"Bad bad nationality specified for '%s', must be one of: ger, it, usa, uk, ussr or default\n",
TargetName().c_str()
);
} }
} }