mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-30 14:47:57 +03:00
Fix actor mVoiceType initialization.
This commit is contained in:
parent
71be2f3dda
commit
d6d29a7a0b
5 changed files with 119 additions and 54 deletions
|
@ -2724,6 +2724,7 @@ Actor::Actor()
|
||||||
m_iCurrentHistory = 0;
|
m_iCurrentHistory = 0;
|
||||||
m_bDog = false;
|
m_bDog = false;
|
||||||
m_bBecomeRunner = false;
|
m_bBecomeRunner = false;
|
||||||
|
mVoiceType = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -8434,7 +8435,7 @@ bool Actor::SoundSayAnim
|
||||||
Director.GetString(name).c_str(),
|
Director.GetString(name).c_str(),
|
||||||
edict->tiki->a->name);
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -8675,25 +8676,76 @@ void Actor::EventSetSayAnim
|
||||||
|
|
||||||
{
|
{
|
||||||
const_str name;
|
const_str name;
|
||||||
if (ev->NumArgs())
|
str sName;
|
||||||
|
if (ev->NumArgs() != 1)
|
||||||
{
|
{
|
||||||
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());
|
||||||
|
|
||||||
|
Com_Printf("EventSetSayAnim sName: %s, animnum: %d, mVoiceType: %d\n", sName.c_str(), animnum, mVoiceType);
|
||||||
|
if (animnum == -1)
|
||||||
{
|
{
|
||||||
ScriptError("bad number of arguments");
|
SoundSayAnim(name, m_bLevelSayAnim);
|
||||||
}
|
}
|
||||||
if (m_bLevelSayAnim == 0)
|
else
|
||||||
{
|
{
|
||||||
name = ev->GetConstString(1);
|
int flags = gi.Anim_FlagsSkel(edict->tiki, animnum);
|
||||||
|
if (flags & 256)
|
||||||
parm.sayfail = qtrue;
|
|
||||||
|
|
||||||
if (!SoundSayAnim(name, true))
|
|
||||||
{
|
{
|
||||||
//FIXME: assumption, not sure. I think it's an inline func inside UpdateSayAnim()
|
if (m_bLevelActionAnim)
|
||||||
UpdateSayAnim();
|
{
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
parm.sayfail = qfalse;
|
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.
|
Set aim motion animation.
|
||||||
===============
|
===============
|
||||||
|
@ -8799,7 +8851,7 @@ void Actor::EventSetAimMotionAnim
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
Actor::EventSetSayAnim
|
Actor::EventSetActionAnim
|
||||||
|
|
||||||
Set action animation.
|
Set action animation.
|
||||||
===============
|
===============
|
||||||
|
@ -8868,7 +8920,7 @@ void Actor::EventSetActionAnim
|
||||||
|
|
||||||
/*
|
/*
|
||||||
===============
|
===============
|
||||||
Actor::EventSetSayAnim
|
Actor::EventUpperAnim
|
||||||
|
|
||||||
Set upper body.
|
Set upper body.
|
||||||
===============
|
===============
|
||||||
|
@ -14333,9 +14385,9 @@ void Actor::SetVoiceType
|
||||||
{
|
{
|
||||||
//voice type in actor is a char.
|
//voice type in actor is a char.
|
||||||
str vType = ev->GetString(1);
|
str vType = ev->GetString(1);
|
||||||
if (*vType.c_str())
|
if (vType[0])
|
||||||
{
|
{
|
||||||
mVoiceType = *vType.c_str();
|
mVoiceType = vType[0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -14354,59 +14406,60 @@ void Actor::ResolveVoiceType
|
||||||
|
|
||||||
if (mVoiceType == -1)
|
if (mVoiceType == -1)
|
||||||
{
|
{
|
||||||
int d = 3.0 * random();
|
int d = 3.0 * 0.99 * random();
|
||||||
if (m_Team == TEAM_AMERICAN)
|
if (m_Team == TEAM_AMERICAN)
|
||||||
{
|
{
|
||||||
mVoiceType = *gAmericanVoices[d];
|
mVoiceType = gAmericanVoices[d][0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mVoiceType = *gGermanVoices[d];
|
mVoiceType = gGermanVoices[d][0];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (m_Team == TEAM_AMERICAN)
|
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)
|
||||||
{
|
{
|
||||||
sprintf(validVoice, "");
|
return;
|
||||||
for (int j = 0; j <= 2 ; j++)
|
|
||||||
{
|
|
||||||
strcat(validVoice, gAmericanVoices[j]);
|
|
||||||
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];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sprintf(validVoice, "");
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
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 * 0.99 * random();
|
||||||
|
mVoiceType = gAmericanVoices[d][0];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 0; *gGermanVoices[i] != mVoiceType; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
if (i > 3)
|
if (gGermanVoices[i][0] == mVoiceType)
|
||||||
{
|
{
|
||||||
sprintf(validVoice, "");
|
return;
|
||||||
for (int j = 0; j <= 2; j++)
|
|
||||||
{
|
|
||||||
strcat(validVoice, gGermanVoices[j]);
|
|
||||||
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];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sprintf(validVoice, "");
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
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 * 0.99 * random();
|
||||||
|
mVoiceType = gGermanVoices[d][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -553,6 +553,8 @@ Event EV_Level_GetFlags
|
||||||
EV_GETTER
|
EV_GETTER
|
||||||
);
|
);
|
||||||
|
|
||||||
|
extern Event EV_Entity_Start;
|
||||||
|
|
||||||
Level::Level()
|
Level::Level()
|
||||||
{
|
{
|
||||||
Init();
|
Init();
|
||||||
|
@ -1350,9 +1352,10 @@ void Level::Precache( void )
|
||||||
|
|
||||||
void Level::SpawnEntities( char *entities, int svsTime )
|
void Level::SpawnEntities( char *entities, int svsTime )
|
||||||
{
|
{
|
||||||
int inhibit, simple = 0, count = 0;
|
int inhibit, radnum = 0, count = 0;
|
||||||
int enttime;
|
int enttime;
|
||||||
const char *value;
|
const char *value;
|
||||||
|
char name[128];
|
||||||
SpawnArgs args;
|
SpawnArgs args;
|
||||||
Listener *listener;
|
Listener *listener;
|
||||||
Entity *ent;
|
Entity *ent;
|
||||||
|
@ -1410,16 +1413,20 @@ void Level::SpawnEntities( char *entities, int svsTime )
|
||||||
|
|
||||||
if( listener )
|
if( listener )
|
||||||
{
|
{
|
||||||
simple++;
|
radnum++;
|
||||||
|
|
||||||
if( listener->isSubclassOf( Entity ) )
|
if( listener->isSubclassOf( Entity ) )
|
||||||
{
|
{
|
||||||
count++;
|
count++;
|
||||||
|
|
||||||
ent = ( Entity * )listener;
|
ent = ( Entity * )listener;
|
||||||
ent->radnum = simple;
|
ent->radnum = radnum;
|
||||||
|
|
||||||
Q_strncpyz( ent->edict->entname, ent->getClassID(), sizeof( ent->edict->entname ) );
|
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;
|
m_LoopProtection = true;
|
||||||
|
|
||||||
Com_Printf( "%i entities spawned\n", count );
|
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( "%i entities inhibited\n", inhibit );
|
||||||
|
|
||||||
Com_Printf( "-------------------- Spawning Entities Done ------------------ %i ms\n", gi.Milliseconds() - enttime );
|
Com_Printf( "-------------------- Spawning Entities Done ------------------ %i ms\n", gi.Milliseconds() - enttime );
|
||||||
|
|
|
@ -26,7 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
#include "object.h"
|
#include "object.h"
|
||||||
#include <g_spawn.h>
|
#include <g_spawn.h>
|
||||||
|
extern Event EV_Entity_Start;
|
||||||
//====================
|
//====================
|
||||||
//Player::ActorInfo
|
//Player::ActorInfo
|
||||||
//====================
|
//====================
|
||||||
|
@ -424,6 +424,9 @@ void Player::SpawnEntity
|
||||||
e = new Event( EV_SetAnim );
|
e = new Event( EV_SetAnim );
|
||||||
e->AddString( "idle" );
|
e->AddString( "idle" );
|
||||||
ent->PostEvent( e, EV_SPAWNARG );
|
ent->PostEvent( e, EV_SPAWNARG );
|
||||||
|
|
||||||
|
ent->ProcessPendingEvents();
|
||||||
|
ent->ProcessEvent(EV_Entity_Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
//====================
|
//====================
|
||||||
|
|
|
@ -1251,7 +1251,7 @@ void SimpleActor::ChangeActionAnim
|
||||||
animFlags[i] |= ANIM_NOACTION;
|
animFlags[i] |= ANIM_NOACTION;
|
||||||
StartCrossBlendAnimSlot(i);
|
StartCrossBlendAnimSlot(i);
|
||||||
}
|
}
|
||||||
m_AnimDialogHigh ^= 1; // toggle
|
m_AnimDialogHigh = !m_AnimDialogHigh; // toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
iSlot = GetActionSlot(0);
|
iSlot = GetActionSlot(0);
|
||||||
|
|
|
@ -40,6 +40,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
#define scriptcheck g_scriptcheck
|
#define scriptcheck g_scriptcheck
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
extern Event EV_Entity_Start;
|
||||||
CLASS_DECLARATION( Class, SpawnArgs, NULL )
|
CLASS_DECLARATION( Class, SpawnArgs, NULL )
|
||||||
{
|
{
|
||||||
{ NULL, NULL }
|
{ NULL, NULL }
|
||||||
|
@ -383,6 +384,7 @@ Listener *SpawnArgs::Spawn( void )
|
||||||
if( ent )
|
if( ent )
|
||||||
{
|
{
|
||||||
ent->ProcessPendingEvents();
|
ent->ProcessPendingEvents();
|
||||||
|
ent->ProcessEvent(EV_Entity_Start);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ent;
|
return ent;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue