Fix actor mVoiceType initialization.

This commit is contained in:
mohabhassan 2019-07-01 20:17:46 +02:00
parent 71be2f3dda
commit d6d29a7a0b
5 changed files with 119 additions and 54 deletions

View file

@ -2724,6 +2724,7 @@ Actor::Actor()
m_iCurrentHistory = 0;
m_bDog = false;
m_bBecomeRunner = false;
mVoiceType = -1;
}
/*
@ -8434,7 +8435,7 @@ bool Actor::SoundSayAnim
Director.GetString(name).c_str(),
edict->tiki->a->name);
Sound(Director.GetString(name), 0, 0, 0, NULL, 0, 0, 1, -1);
Sound(Director.GetString(name), 0, 0, 0, NULL, 0, 1, 1, -1);
return true;
}
@ -8675,27 +8676,78 @@ void Actor::EventSetSayAnim
{
const_str name;
if (ev->NumArgs())
{
str sName;
if (ev->NumArgs() != 1)
{
ScriptError("bad number of arguments");
}
if (m_bLevelSayAnim == 0)
{
name = ev->GetConstString(1);
parm.sayfail = qtrue;
sName = Director.GetString(name);
int animnum = gi.Anim_NumForName(edict->tiki, sName.c_str());
if (!SoundSayAnim(name, true))
Com_Printf("EventSetSayAnim sName: %s, animnum: %d, mVoiceType: %d\n", sName.c_str(), animnum, mVoiceType);
if (animnum == -1)
{
//FIXME: assumption, not sure. I think it's an inline func inside UpdateSayAnim()
UpdateSayAnim();
SoundSayAnim(name, m_bLevelSayAnim);
}
else
{
int flags = gi.Anim_FlagsSkel(edict->tiki, animnum);
if (flags & 256)
{
if (m_bLevelActionAnim)
{
if (!m_bSayAnimSet)
{
m_iSaySlot = m_iActionSlot;
}
return;
}
if (flags & TAF_HASDELTA)
{
if (m_bLevelMotionAnim)
{
if (!m_bSayAnimSet)
{
m_iSaySlot = m_iMotionSlot;
}
return;
}
ChangeActionAnim();
ChangeMotionAnim();
StartMotionAnimSlot(0, animnum, 1.0);
m_iMotionSlot = m_iActionSlot = GetMotionSlot(0);
}
else
{
ChangeActionAnim();
m_bActionAnimSet = true;
StartActionAnimSlot(animnum);
m_iActionSlot = GetActionSlot(0);
}
ChangeSayAnim();
m_bSayAnimSet = true;
m_iSaySlot = m_iActionSlot;
}
else
{
ChangeSayAnim();
m_bSayAnimSet = true;
StartSayAnimSlot(animnum);
m_iSaySlot = GetSaySlot();
}
}
parm.sayfail = qfalse;
}
}
}
/*
===============
@ -8739,7 +8791,7 @@ void Actor::EventSetMotionAnim
/*
===============
Actor::EventSetSayAnim
Actor::EventSetAimMotionAnim
Set aim motion animation.
===============
@ -8799,7 +8851,7 @@ void Actor::EventSetAimMotionAnim
/*
===============
Actor::EventSetSayAnim
Actor::EventSetActionAnim
Set action animation.
===============
@ -8868,7 +8920,7 @@ void Actor::EventSetActionAnim
/*
===============
Actor::EventSetSayAnim
Actor::EventUpperAnim
Set upper body.
===============
@ -14333,9 +14385,9 @@ void Actor::SetVoiceType
{
//voice type in actor is a char.
str vType = ev->GetString(1);
if (*vType.c_str())
if (vType[0])
{
mVoiceType = *vType.c_str();
mVoiceType = vType[0];
}
else
{
@ -14354,59 +14406,60 @@ void Actor::ResolveVoiceType
if (mVoiceType == -1)
{
int d = 3.0 * random();
int d = 3.0 * 0.99 * random();
if (m_Team == TEAM_AMERICAN)
{
mVoiceType = *gAmericanVoices[d];
mVoiceType = gAmericanVoices[d][0];
}
else
{
mVoiceType = *gGermanVoices[d];
mVoiceType = gGermanVoices[d][0];
}
}
else
{
if (m_Team == TEAM_AMERICAN)
{
for (int i = 0; *gAmericanVoices[i] != mVoiceType ; i++)
for (int i = 0; i < 3 ; i++)
{
if (i > 3)
if (gAmericanVoices[i][0] == mVoiceType)
{
return;
}
}
sprintf(validVoice, "");
for (int j = 0; j <= 2 ; j++)
for (int i = 0; i < 3; i++)
{
strcat(validVoice, gAmericanVoices[j]);
strcat(validVoice, gAmericanVoices[i]);
strcat(validVoice, " ");
}
Com_Printf("ERROR: Bad voice type %c. Valid American voicetypes are: %s\n", mVoiceType, validVoice);
mVoiceType = -1;
int d = 3.0 * random();
mVoiceType = *gAmericanVoices[d];
}
}
int d = 3.0 * 0.99 * random();
mVoiceType = gAmericanVoices[d][0];
}
else
{
for (int i = 0; *gGermanVoices[i] != mVoiceType; i++)
for (int i = 0; i < 3; i++)
{
if (i > 3)
if (gGermanVoices[i][0] == mVoiceType)
{
return;
}
}
sprintf(validVoice, "");
for (int j = 0; j <= 2; j++)
for (int i = 0; i < 3; i++)
{
strcat(validVoice, gGermanVoices[j]);
strcat(validVoice, gGermanVoices[i]);
strcat(validVoice, " ");
}
Com_Printf("ERROR: Bad voice type %c. Valid German voicetypes are: %s\n", mVoiceType, validVoice);
mVoiceType = -1;
int d = 3.0 * random();
mVoiceType = *gGermanVoices[d];
}
}
int d = 3.0 * 0.99 * random();
mVoiceType = gGermanVoices[d][0];
}
}

View file

@ -553,6 +553,8 @@ Event EV_Level_GetFlags
EV_GETTER
);
extern Event EV_Entity_Start;
Level::Level()
{
Init();
@ -1350,9 +1352,10 @@ void Level::Precache( void )
void Level::SpawnEntities( char *entities, int svsTime )
{
int inhibit, simple = 0, count = 0;
int inhibit, radnum = 0, count = 0;
int enttime;
const char *value;
char name[128];
SpawnArgs args;
Listener *listener;
Entity *ent;
@ -1410,16 +1413,20 @@ void Level::SpawnEntities( char *entities, int svsTime )
if( listener )
{
simple++;
radnum++;
if( listener->isSubclassOf( Entity ) )
{
count++;
ent = ( Entity * )listener;
ent->radnum = simple;
ent->radnum = radnum;
Q_strncpyz( ent->edict->entname, ent->getClassID(), sizeof( ent->edict->entname ) );
ent->PostEvent(EV_Entity_Start, -1.0, 0);
sprintf(name, "i%d", radnum);
gi.LoadResource(name);
}
}
}
@ -1449,7 +1456,7 @@ void Level::SpawnEntities( char *entities, int svsTime )
m_LoopProtection = true;
Com_Printf( "%i entities spawned\n", count );
Com_Printf( "%i simple entities spawned\n", simple );
Com_Printf( "%i simple entities spawned\n", radnum );
Com_Printf( "%i entities inhibited\n", inhibit );
Com_Printf( "-------------------- Spawning Entities Done ------------------ %i ms\n", gi.Milliseconds() - enttime );

View file

@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#include "player.h"
#include "object.h"
#include <g_spawn.h>
extern Event EV_Entity_Start;
//====================
//Player::ActorInfo
//====================
@ -424,6 +424,9 @@ void Player::SpawnEntity
e = new Event( EV_SetAnim );
e->AddString( "idle" );
ent->PostEvent( e, EV_SPAWNARG );
ent->ProcessPendingEvents();
ent->ProcessEvent(EV_Entity_Start);
}
//====================

View file

@ -1251,7 +1251,7 @@ void SimpleActor::ChangeActionAnim
animFlags[i] |= ANIM_NOACTION;
StartCrossBlendAnimSlot(i);
}
m_AnimDialogHigh ^= 1; // toggle
m_AnimDialogHigh = !m_AnimDialogHigh; // toggle
}
iSlot = GetActionSlot(0);

View file

@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define scriptcheck g_scriptcheck
#endif
extern Event EV_Entity_Start;
CLASS_DECLARATION( Class, SpawnArgs, NULL )
{
{ NULL, NULL }
@ -383,6 +384,7 @@ Listener *SpawnArgs::Spawn( void )
if( ent )
{
ent->ProcessPendingEvents();
ent->ProcessEvent(EV_Entity_Start);
}
return ent;