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

@ -2541,7 +2541,7 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_Actor_GetVisibilityThreshold, &Actor::EventGetVisibilityThreshold },
{&EV_Actor_SetVisibilityThreshold, &Actor::EventSetVisibilityThreshold },
{&EV_Actor_SetVisibilityThreshold2, &Actor::EventSetVisibilityThreshold },
{&EV_Actor_SetDefaultVisibilityThreshold, &Actor::EventSetDefaultVisibilityThreshold },
{&EV_Actor_SetDefaultVisibilityThreshold, &Actor::EventSetDefaultVisibilityThreshold},
{&EV_Actor_GetSuppressChance, &Actor::EventGetSuppressChance },
{&EV_Actor_SetSuppressChance, &Actor::EventSetSuppressChance },
{&EV_Actor_SetSuppressChance2, &Actor::EventSetSuppressChance },
@ -3142,7 +3142,7 @@ void Actor::GetMoveInfo(mmove_t *mm)
PLAYER_BASE_MIN,
PLAYER_BASE_MAX,
m_Dest - Vector(0, 0, 16384),
(Entity*)NULL,
(Entity *)NULL,
MASK_MOVEINFO,
qfalse,
"Actor::GetMoveInfo"
@ -3150,9 +3150,9 @@ void Actor::GetMoveInfo(mmove_t *mm)
DoFailSafeMove(trace.endpos);
} else if (mm->hit_temp_obstacle & 1) {
Player* p;
Player *p;
p = static_cast<Player*>(G_GetEntity(0));
p = static_cast<Player *>(G_GetEntity(0));
if (!IsTeamMate(p)) {
if (!m_bEnableEnemy) {
@ -3169,10 +3169,10 @@ void Actor::GetMoveInfo(mmove_t *mm)
case ANIM_MODE_PATH_GOAL:
if (mm->hit_temp_obstacle) {
if (mm->hit_temp_obstacle & 1) {
Player* p;
Player *p;
m_Path.Clear();
p = static_cast<Player*>(G_GetEntity(0));
p = static_cast<Player *>(G_GetEntity(0));
if (!IsTeamMate(p)) {
if (!m_bEnableEnemy) {
@ -3190,9 +3190,11 @@ void Actor::GetMoveInfo(mmove_t *mm)
if (level.inttime >= m_Path.Time() + 1000) {
m_Path.ReFindPath(origin, this);
} 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();
VectorClear(velocity);
return;
@ -3318,8 +3320,7 @@ void Actor::UpdateBoneControllers(void)
orientation_t tag_or;
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");
tag_or = G_TIKI_Orientation(edict, tagnum & TAG_MASK);
AnglesToAxis(angles, myAxis);
@ -3336,7 +3337,7 @@ void Actor::UpdateBoneControllers(void)
vEndPoint = m_vDesiredLookDest;
} else if (m_pLookEntity) {
if (m_pLookEntity->IsSubclassOfSentient()) {
Sentient* sent = static_cast<Sentient*>(m_pLookEntity.Pointer());
Sentient *sent = static_cast<Sentient *>(m_pLookEntity.Pointer());
vEndPoint = sent->EyePosition();
} else {
vEndPoint = m_pLookEntity->centroid;
@ -3461,7 +3462,9 @@ void Actor::UpdateBoneControllers(void)
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, 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;
@ -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, 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;
// clamp head yaw to 60 degrees
@ -3517,7 +3521,8 @@ void Actor::UpdateBoneControllers(void)
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;
// clamp head pitch to 35 degrees
headAngles[0] = Q_clamp_float(headAngles[0], -35, 35);
@ -3544,7 +3549,8 @@ void Actor::UpdateBoneControllers(void)
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
new_angles[0] = m_vLUpperArmDesiredAngles[0];
new_angles[1] = tmp_angles[1] + max_change;
@ -3629,7 +3635,8 @@ void Actor::DoMove(void)
mmove_t mm;
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;
}
@ -3871,7 +3878,7 @@ bool Actor::CanShoot(Entity *ent)
if (FriendlyInLineOfFire(ent)) {
bCanShoot = false;
} else if (ent->IsSubclassOfSentient()) {
Sentient* sen = static_cast<Sentient*>(ent);
Sentient *sen = static_cast<Sentient *>(ent);
vGunPos = GunPosition();
bCanShoot = false;
@ -4001,7 +4008,7 @@ bool Actor::FriendlyInLineOfFire(Entity *other)
delta = other->origin - origin;
inverseDot = 1.0 / (delta * delta);
for (Sentient* pSquad = m_pNextSquadMate; pSquad != this; pSquad = pSquad->m_pNextSquadMate) {
for (Sentient *pSquad = m_pNextSquadMate; pSquad != this; pSquad = pSquad->m_pNextSquadMate) {
Vector squadDelta;
float squadDot;
@ -4391,7 +4398,7 @@ void Actor::LookAtLookEntity(void)
Vector dir;
if (m_pLookEntity->IsSubclassOfSentient()) {
Sentient* sen = static_cast<Sentient*>(m_pLookEntity.Pointer());
Sentient *sen = static_cast<Sentient *>(m_pLookEntity.Pointer());
dir = sen->EyePosition() - EyePosition();
} else {
dir = m_pLookEntity->centroid - EyePosition();
@ -4503,19 +4510,19 @@ void Actor::LookAt(Listener *l)
}
if (l != this) {
l = (SimpleEntity*)l;
l = (SimpleEntity *)l;
if (g_showlookat->integer == entnum || g_showlookat->integer == -1) {
Com_Printf(
"Script lookat: %i %i %s looking at point %.0f %.0f %.0f\n",
entnum,
radnum,
targetname.c_str(),
((SimpleEntity*)l)->origin.x,
((SimpleEntity*)l)->origin.y,
((SimpleEntity*)l)->origin.z
((SimpleEntity *)l)->origin.x,
((SimpleEntity *)l)->origin.y,
((SimpleEntity *)l)->origin.z
);
}
m_pLookEntity = (SimpleEntity*)l;
m_pLookEntity = (SimpleEntity *)l;
}
}
@ -4648,7 +4655,7 @@ void Actor::PointAt(Listener *l)
}
if (l != this) {
m_pPointEntity = static_cast<SimpleEntity*>(l);
m_pPointEntity = static_cast<SimpleEntity *>(l);
}
}
}
@ -4773,7 +4780,7 @@ void Actor::TurnTo(Listener *l)
);
}
m_pTurnEntity = (SimpleEntity*)l;
m_pTurnEntity = (SimpleEntity *)l;
}
/*
@ -4911,14 +4918,14 @@ void Actor::HandlePain(Event *ev)
int i;
Event event(EV_Listener_ExecuteScript);
int num;
Entity* attacker;
Entity *attacker;
if (!m_bEnablePain) {
return;
}
attacker = ev->GetEntity(1);
if (attacker && attacker->IsSubclassOfSentient() && IsTeamMate(static_cast<Sentient*>(attacker))) {
if (attacker && attacker->IsSubclassOfSentient() && IsTeamMate(static_cast<Sentient *>(attacker))) {
return;
}
@ -4938,7 +4945,7 @@ void Actor::HandlePain(Event *ev)
m_PainTime = level.inttime;
if (attacker && attacker->IsSubclassOfSentient() && !IsTeamMate(static_cast<Sentient*>(attacker))) {
if (attacker && attacker->IsSubclassOfSentient() && !IsTeamMate(static_cast<Sentient *>(attacker))) {
m_pLastAttacker = attacker;
m_iCuriousLevel = 9;
@ -5053,27 +5060,27 @@ Killed event.
*/
void Actor::EventKilled(Event *ev)
{
Entity* attacker;
Sentient* pBuddy;
Sentient* sent;
Player* player;
Entity *attacker;
Sentient *pBuddy;
Sentient *sent;
Player *player;
DispatchEventKilled(ev, true);
attacker = ev->GetEntity(1);
if (attacker && attacker->IsSubclassOfPlayer()) {
player = static_cast<Player*>(attacker);
player = static_cast<Player *>(attacker);
if (player->m_Team != m_Team) {
player->m_iNumEnemiesKilled++;
}
}
if (attacker && attacker->IsSubclassOfSentient()) {
sent = static_cast<Sentient*>(attacker);
sent = static_cast<Sentient *>(attacker);
for (pBuddy = level.m_HeadSentient[m_Team]; pBuddy; pBuddy = pBuddy->m_NextSentient) {
if (pBuddy != this && pBuddy->IsSubclassOfActor()) {
Actor* actor = static_cast<Actor*>(pBuddy);
Actor *actor = static_cast<Actor *>(pBuddy);
actor->NotifySquadmateKilled(this, sent);
}
}
@ -5244,7 +5251,7 @@ Move on path.
void Actor::MovePath(float fMoveSpeed)
{
mmove_t mm;
const float* dir;
const float *dir;
vec2_t delta;
SetMoveInfo(&mm);
@ -5258,7 +5265,7 @@ void Actor::MovePath(float fMoveSpeed)
if (ai_debugpath->integer) {
Vector pos, dest;
PathInfo* current_path;
PathInfo *current_path;
pos = origin;
pos.z += 32;
@ -5312,8 +5319,7 @@ void Actor::MovePath(float fMoveSpeed)
m_WallDir = -1;
mm.desired_dir[0] = -mm.obstacle_normal[1];
mm.desired_dir[1] = mm.obstacle_normal[0];
}
else {
} else {
mm.desired_dir[0] = mm.obstacle_normal[1];
mm.desired_dir[1] = -mm.obstacle_normal[0];
}
@ -5381,8 +5387,7 @@ void Actor::MovePath(float fMoveSpeed)
m_WallDir = 1;
mm.desired_dir[0] = mm.obstacle_normal[1];
mm.desired_dir[1] = -mm.obstacle_normal[0];
}
else {
} else {
m_WallDir = -1;
mm.desired_dir[0] = -mm.obstacle_normal[1];
mm.desired_dir[1] = mm.obstacle_normal[0];
@ -5527,7 +5532,8 @@ Set current mood.
void Actor::EventSetMood(Event *ev)
{
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;
ScriptError("invalid mood - setting to bored");
}
@ -5594,8 +5600,8 @@ Set current weapon's aim tagret.
*/
void Actor::EventSetAimTarget(Event *ev)
{
Entity* ent;
Weapon* weap;
Entity *ent;
Weapon *weap;
ent = ev->GetEntity(1);
if (!ent) {
@ -5611,7 +5617,7 @@ void Actor::EventSetAimTarget(Event *ev)
// Added in 2.0
// Make the ent an enemy
if (ev->NumArgs() > 1 && ev->GetInteger(2) == 1 && ent->IsSubclassOfSentient()) {
SetEnemy(static_cast<Sentient*>(ent), false);
SetEnemy(static_cast<Sentient *>(ent), false);
}
}
@ -5785,7 +5791,7 @@ void Actor::SetPatrolCurrentNode(Listener *l)
);
}
m_patrolCurrentNode = static_cast<SimpleEntity*>(l);
m_patrolCurrentNode = static_cast<SimpleEntity *>(l);
}
/*
@ -5877,9 +5883,9 @@ Move on path with squad.
*/
bool Actor::MoveOnPathWithSquad(void)
{
const float* pvMyDir, *pvHisDir;
const float *pvMyDir, *pvHisDir;
vec2_t vDelta;
Sentient* pSquadMate;
Sentient *pSquadMate;
float fIntervalSquared;
vec2_t vMyNormalDir;
float fDistSquared;
@ -5898,7 +5904,7 @@ bool Actor::MoveOnPathWithSquad(void)
fIntervalSquared *= 2;
}
pSquadMate = static_cast<Sentient*>(G_GetEntity(0));
pSquadMate = static_cast<Sentient *>(G_GetEntity(0));
if (IsTeamMate(pSquadMate)) {
VectorSub2D(pSquadMate->origin, origin, vDelta);
@ -5920,7 +5926,7 @@ bool Actor::MoveOnPathWithSquad(void)
continue;
}
Actor* pActorSquadMate = static_cast<Actor*>(pSquadMate);
Actor *pActorSquadMate = static_cast<Actor *>(pSquadMate);
VectorSub2D(pActorSquadMate->origin, origin, vDelta);
fDistSquared = VectorLength2DSquared(vDelta);
@ -5964,7 +5970,7 @@ bool Actor::MoveToWaypointWithPlayer(void)
float fIntervalSquared;
vec2_t vMyNormalDir;
float fDistSquared;
Sentient* pSquadMate;
Sentient *pSquadMate;
if (level.inttime < m_iSquadStandTime + 500) {
return false;
@ -5975,13 +5981,12 @@ bool Actor::MoveToWaypointWithPlayer(void)
fIntervalSquared += fIntervalSquared;
}
pSquadMate = static_cast<Sentient*>(G_GetEntity(0));
pSquadMate = static_cast<Sentient *>(G_GetEntity(0));
if (!IsTeamMate(pSquadMate)) {
return true;
}
vDelta[0] = pSquadMate->origin[0] - origin[0];
vDelta[1] = pSquadMate->origin[1] - origin[1];
VectorSub2D(pSquadMate->origin, origin, vDelta);
fDistSquared = VectorLength2DSquared(vDelta);
if (fDistSquared >= fIntervalSquared) {
@ -6091,8 +6096,7 @@ bool Actor::MoveToPatrolCurrentNode(void)
vec2_t delta;
VectorSub2D(m_patrolCurrentNode->origin, origin, delta);
return VectorLength2DSquared(delta) <= m_fMoveDoneRadiusSquared;
}
else {
} else {
SetPath(m_patrolCurrentNode->origin, "Actor::MoveToPatrolCurrentNode", 0, NULL, 0);
if (!PathExists()) {
@ -6422,7 +6426,7 @@ Actor::DetectSmokeGrenades
*/
void Actor::DetectSmokeGrenades(void)
{
SmokeSprite* sprite;
SmokeSprite *sprite;
if (m_Enemy) {
return;
@ -6436,7 +6440,17 @@ void Actor::DetectSmokeGrenades(void)
eyePos = VirtualEyePosition();
fDistSquared = (sprite->origin - eyePos).lengthSquared();
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);
}
}
@ -6523,78 +6537,54 @@ Set animation event.
*/
void Actor::EventSetAnim(Event *ev)
{
//"anim slot weight flagged"
int numArgs = ev->NumArgs(), slot = 0, animnum;
const_str name = 0;
float weight = 1;
const_str anim, flagVal;
qboolean flagged = qfalse;
int slot = 0;
int anim;
const_str flagVal;
qboolean flagged;
//FIXME: better notation, but this works for now.
if (numArgs < 1 || numArgs > 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) {
switch (ev->NumArgs()) {
case 4:
flagVal = ev->GetConstString(4);
flagged = qtrue;
if (flagVal != STRING_FLAGGED) {
ScriptError("unknown keyword '%s', expected 'flagged'", Director.GetString(flagVal).c_str());
}
case 3:
weight = ev->GetFloat(3);
if (weight < 0) {
ScriptError("Negative anim weight not allowed");
}
if (weight != 0) {
if (!weight) {
return;
}
case 2:
slot = ev->GetInteger(2);
if (slot > 2) {
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);
}
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);
}
break;
default:
ScriptError("bad number of arguments");
break;
}
if (!slot) {
flagged = qtrue;
}
if (flagged) {
parm.motionfail = qtrue;
}
if (!m_bLevelMotionAnim) {
if (slot) {
m_weightType[GetMotionSlot(slot)] = 0;
@ -6602,7 +6592,8 @@ void Actor::EventSetAnim(Event *ev)
ChangeMotionAnim();
m_bMotionAnimSet = true;
}
StartMotionAnimSlot(slot, animnum, weight);
StartMotionAnimSlot(slot, anim, weight);
if (flagged) {
m_iMotionSlot = GetMotionSlot(slot);
parm.motionfail = qfalse;
@ -6635,26 +6626,31 @@ Set motion animation.
*/
void Actor::EventSetMotionAnim(Event *ev)
{
gi.DPrintf("Actor::EventSetMotionAnim\n");
int anim;
const_str name;
if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments");
}
const_str anim = ev->GetConstString(1);
str animstr = Director.GetString(anim);
int animnum = gi.Anim_NumForName(edict->tiki, animstr.c_str());
if (animnum == -1) {
UnknownAnim(animstr.c_str(), edict->tiki);
name = ev->GetConstString(1);
anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (anim == -1) {
UnknownAnim(Director.GetString(name), edict->tiki);
}
gi.DPrintf("Actor::EventSetMotionAnim %s %d\n", animstr.c_str(), animnum);
parm.motionfail = qtrue;
if (!m_bLevelMotionAnim) {
ChangeMotionAnim();
// start the animation
m_bMotionAnimSet = true;
StartMotionAnimSlot(0, animnum, 1.0);
StartMotionAnimSlot(0, anim, 1.0);
// set the slot
m_iMotionSlot = GetMotionSlot(0);
parm.motionfail = qfalse;
}
}
@ -6668,41 +6664,43 @@ Set aim motion animation.
*/
void Actor::EventSetAimMotionAnim(Event *ev)
{
int anim_crouch, anim_stand, anim_high;
const_str name;
int anim_crouch, anim_stand, anim_high;
if (ev->NumArgs() != 3) {
ScriptError("bad number of arguments");
}
//FIXME: maybe inline func ?
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) {
UnknownAnim(Director.GetString(name).c_str(), edict->tiki);
UnknownAnim(Director.GetString(name), edict->tiki);
}
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) {
UnknownAnim(Director.GetString(name).c_str(), edict->tiki);
UnknownAnim(Director.GetString(name), edict->tiki);
}
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) {
UnknownAnim(Director.GetString(name).c_str(), edict->tiki);
UnknownAnim(Director.GetString(name), edict->tiki);
}
parm.motionfail = qtrue;
if (!m_bLevelMotionAnim) {
ChangeMotionAnim();
m_bMotionAnimSet = true;
UpdateAimMotion();
StartAimMotionAnimSlot(0, anim_crouch);
StartAimMotionAnimSlot(1, anim_stand);
StartAimMotionAnimSlot(2, anim_high);
m_iMotionSlot = GetMotionSlot(1);
parm.motionfail = qfalse;
}
@ -6717,12 +6715,17 @@ Set action animation.
*/
void Actor::EventSetActionAnim(Event *ev)
{
const_str name;
int anim_forward, anim_up, anim_down;
str derivedName;
if (ev->NumArgs() != 3) {
ScriptError("bad number of arguments");
}
name = ev->GetConstString(1);
m_fAimLimit_down = ev->GetFloat(2);
if (m_fAimLimit_down > 0) {
if (m_fAimLimit_down >= 0) {
m_fAimLimit_down = -0.001f;
ScriptError("Positive lower_limit not allowed");
}
@ -6733,22 +6736,21 @@ void Actor::EventSetActionAnim(Event *ev)
ScriptError("Negative upper_limit not allowed");
}
const_str anim = ev->GetConstString(1);
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str());
if (animnum == -1) {
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
anim_forward = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (anim_forward == -1) {
UnknownAnim(Director.GetString(name), edict->tiki);
}
const_str anim2 = ev->GetConstString(2);
int animnum2 = gi.Anim_NumForName(edict->tiki, Director.GetString(anim2));
if (animnum2 == -1) {
UnknownAnim(Director.GetString(anim2).c_str(), edict->tiki);
derivedName = Director.GetString(name) + "_up";
anim_up = gi.Anim_NumForName(edict->tiki, derivedName);
if (anim_up == -1) {
UnknownAnim(derivedName, edict->tiki);
}
const_str anim3 = ev->GetConstString(3);
int animnum3 = gi.Anim_NumForName(edict->tiki, Director.GetString(anim3));
if (animnum3 == -1) {
UnknownAnim(Director.GetString(anim3).c_str(), edict->tiki);
derivedName = Director.GetString(name) + "_down";
anim_down = gi.Anim_NumForName(edict->tiki, derivedName);
if (anim_down == -1) {
UnknownAnim(derivedName, edict->tiki);
}
parm.upperfail = qtrue;
@ -6758,9 +6760,9 @@ void Actor::EventSetActionAnim(Event *ev)
m_bActionAnimSet = true;
UpdateAim();
StartAimAnimSlot(0, animnum);
StartAimAnimSlot(1, anim2);
StartAimAnimSlot(2, anim3);
StartAimAnimSlot(0, anim_up);
StartAimAnimSlot(1, anim_forward);
StartAimAnimSlot(2, anim_down);
m_iActionSlot = GetActionSlot(0);
parm.upperfail = qfalse;
}
@ -6775,17 +6777,21 @@ Set upper body.
*/
void Actor::EventUpperAnim(Event *ev)
{
int anim;
const_str name;
if (ev->NumArgs()) {
if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments");
}
const_str anim = ev->GetConstString(1);
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str());
if (animnum == -1) {
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
name = ev->GetConstString(1);
anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (anim == -1) {
UnknownAnim(Director.GetString(name), edict->tiki);
}
m_csUpperAnim = anim;
m_csUpperAnim = name;
} else if (m_bLevelActionAnim) {
AnimFinished(m_iActionSlot, true);
}
@ -6800,21 +6806,24 @@ Set upper body animation.
*/
void Actor::EventSetUpperAnim(Event *ev)
{
int anim;
const_str name;
if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments");
}
const_str anim = ev->GetConstString(1);
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(anim).c_str());
if (animnum == -1) {
UnknownAnim(Director.GetString(anim).c_str(), edict->tiki);
name = ev->GetConstString(1);
anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
if (anim == -1) {
UnknownAnim(Director.GetString(name), edict->tiki);
}
parm.upperfail = qtrue;
if (!m_bLevelActionAnim) {
ChangeActionAnim();
m_bActionAnimSet = true;
StartActionAnimSlot(animnum);
StartActionAnimSlot(anim);
m_iActionSlot = SimpleActor::GetActionSlot(0);
parm.upperfail = qfalse;
}
@ -6829,12 +6838,14 @@ Returns true if animation not found.
*/
bool Actor::SoundSayAnim(const_str name, byte bLevelSayAnim)
{
int animnum = gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str());
if (animnum == -1) {
if (gi.Anim_NumForName(edict->tiki, Director.GetString(name).c_str()) != -1) {
return false;
}
ChangeSayAnim();
m_bSayAnimSet = true;
m_iSaySlot = -2;
m_bLevelSayAnim = bLevelSayAnim;
m_iSaySlot = -2;
Com_Printf(
"Couldn't find animation '%s' in '%s' - trying sound alias instead.\n",
@ -6845,8 +6856,6 @@ bool Actor::SoundSayAnim(const_str name, byte bLevelSayAnim)
Sound(Director.GetString(name), 0, 0, 0, NULL, 0, 1, 1, -1);
return true;
}
return false;
}
/*
@ -6859,26 +6868,22 @@ Play idle say dialogue.
void Actor::EventIdleSayAnim(Event *ev)
{
const_str name;
if (ev->NumArgs()) {
if (!ev->NumArgs() && m_bLevelSayAnim == 1) {
AnimFinished(m_iSaySlot, true);
return;
}
if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments");
}
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;
//FIXME: macro
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)
{
const_str name;
if (ev->NumArgs()) {
if (!ev->NumArgs() && m_bLevelSayAnim) {
AnimFinished(m_iSaySlot, true);
return;
}
if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments");
}
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;
//FIXME: macro
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)
{
int anim;
int animflags;
const_str name;
str sName;
if (ev->NumArgs() != 1) {
ScriptError("bad number of arguments");
}
if (m_bLevelSayAnim == 0) {
if (m_bLevelSayAnim) {
return;
}
name = ev->GetConstString(1);
parm.sayfail = qtrue;
sName = Director.GetString(name);
int animnum = gi.Anim_NumForName(edict->tiki, sName.c_str());
anim = gi.Anim_NumForName(edict->tiki, Director.GetString(name));
Com_Printf("EventSetSayAnim sName: %s, animnum: %d, mVoiceType: %d\n", sName.c_str(), animnum, mVoiceType);
if (!SoundSayAnim(name, m_bLevelSayAnim)) {
int flags = gi.Anim_FlagsSkel(edict->tiki, animnum);
if (flags & TAF_HASUPPER) {
if (anim == -1) {
ChangeSayAnim();
m_bSayAnimSet = true;
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_bSayAnimSet) {
m_iSaySlot = m_iActionSlot;
}
return;
}
if (flags & TAF_HASDELTA) {
if (m_bLevelMotionAnim) {
if (!m_bSayAnimSet) {
@ -6952,29 +6970,30 @@ void Actor::EventSetSayAnim(Event *ev)
}
return;
}
ChangeActionAnim();
ChangeMotionAnim();
StartMotionAnimSlot(0, animnum, 1.0);
StartMotionAnimSlot(0, anim, 1.0);
m_iMotionSlot = m_iActionSlot = GetMotionSlot(0);
} else {
ChangeActionAnim();
m_bActionAnimSet = true;
StartActionAnimSlot(animnum);
StartActionAnimSlot(anim);
m_iActionSlot = GetActionSlot(0);
}
ChangeSayAnim();
m_bSayAnimSet = true;
m_iSaySlot = m_iActionSlot;
} else {
ChangeSayAnim();
m_bSayAnimSet = true;
StartSayAnimSlot(animnum);
StartSayAnimSlot(anim);
m_iSaySlot = GetSaySlot();
}
}
parm.sayfail = qfalse;
}
}
/*
@ -6987,7 +7006,7 @@ Change current animation.
void Actor::ChangeAnim(void)
{
bool v3; // zf
bool v3;
if (m_pAnimThread) {
if (g_scripttrace->integer) {
@ -8727,12 +8746,9 @@ void Actor::DefaultReceiveAIEvent(
return;
}
if (originator
&& !originator->IsDead()
&& originator->IsSubclassOfSentient()
&& ((Sentient*)originator)->m_Team == m_Team
&& !IsSquadMate((Sentient*)originator)) {
MergeWithSquad((Sentient*)originator);
if (originator && !originator->IsDead() && originator->IsSubclassOfSentient()
&& ((Sentient *)originator)->m_Team == m_Team && !IsSquadMate((Sentient *)originator)) {
MergeWithSquad((Sentient *)originator);
}
switch (iType) {
@ -8770,7 +8786,7 @@ void Actor::DefaultReceiveAIEvent(
break;
default:
{
char assertStr[16317] = { 0 };
char assertStr[16317] = {0};
strcpy(assertStr, "\"unknown ai_event type\"\n\tMessage: ");
Q_strcat(assertStr, sizeof(assertStr), DumpCallTrace("iType = %i", iType));
assert(false && assertStr);
@ -8869,8 +8885,7 @@ void Actor::CuriousSound(int iType, vec3_t sound_origin, float fDistSquared, flo
float v7, v8, fRangeFactor = 1.0;
int iPriority;
if (m_bEnableEnemy) {
if (m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE
|| m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS) {
if (m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE || m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS) {
//FIXME: name variables.
if (fMaxDistSquared != 0.0) {
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)
{
if (originator->IsSubclassOfSentient()) {
if ((m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE
|| m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS)
if ((m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_IDLE || m_ThinkStates[THINKLEVEL_IDLE] == THINKSTATE_CURIOUS)
&& m_bEnableEnemy) {
if (NoticeFootstep((Sentient *)originator)) {
CuriousSound(AI_EVENT_FOOTSTEP, sound_origin, fDistSquared, fMaxDistSquared);
@ -11696,7 +11710,13 @@ void Actor::SetNationality(Event *ev)
str name;
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);
@ -11714,7 +11734,10 @@ void Actor::SetNationality(Event *ev)
} else if (!str::icmpn(name, "ussr", 5)) {
m_iNationality = ACTOR_NATIONALITY_RUSSIAN;
} 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()
);
}
}