Merge pull request #16 from openmoh/dev

Reversing Actor p3
This commit is contained in:
Ley0k 2018-08-19 15:12:00 +02:00 committed by GitHub
commit e510c115e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
29 changed files with 4690 additions and 484 deletions

File diff suppressed because it is too large Load diff

View file

@ -478,7 +478,7 @@ public:
void AddToBodyQue( void );
Vector GetAntiBunchPoint( void );
static void InitVoid( GlobalFuncs_t *func );
virtual char *DumpCallTrace( const char *pszFmt, ... ) const;
virtual const char *DumpCallTrace( const char *pszFmt, ... ) const;
static void Init( void );
void FixAIParameters( void );
bool AttackEntryAnimation( void );
@ -579,18 +579,18 @@ public:
static void InitNoClip( GlobalFuncs_t *func );
bool IsNoClipState( int state );
void Think_NoClip( void );
bool ValidGrenadePath( Vector& vFrom, Vector& vTo, Vector& vVel ) const;
bool ValidGrenadePath( Vector& vFrom, Vector& vTo, Vector& vVel );
static Vector CalcThrowVelocity( Vector& vFrom, Vector& vTo );
Vector CanThrowGrenade( Vector& vFrom, Vector& vTo ) const;
Vector CanThrowGrenade( Vector& vFrom, Vector& vTo );
static Vector CalcRollVelocity( Vector& vFrom, Vector& vTo );
Vector CanRollGrenade( Vector& vFrom, Vector& vTo ) const;
bool CanTossGrenadeThroughHint( GrenadeHint *pHint, Vector& vFrom, Vector& vTo, bool bDesperate, Vector *pvVel, eGrenadeTossMode *peMode ) const;
static Vector GrenadeThrowPoint( Vector& vFrom, Vector& vDelta, const_str csAnim );
Vector CanRollGrenade( Vector& vFrom, Vector& vTo );
bool CanTossGrenadeThroughHint( GrenadeHint *pHint, Vector& vFrom, Vector& vTo, bool bDesperate, Vector *pvVel, eGrenadeTossMode *peMode );
static Vector GrenadeThrowPoint( const Vector& vFrom, const Vector& vDelta, const_str csAnim );
Vector CalcKickVelocity( Vector& vDelta, float fDist ) const;
bool CanKickGrenade( Vector &vFrom, Vector &vTo, Vector &vFace, Vector *pvVel ) const;
bool GrenadeWillHurtTeamAt( Vector& vTo ) const;
bool CanGetGrenadeFromAToB( Vector& vFrom, Vector& vTo, bool bDesperate, Vector *pvVel, eGrenadeTossMode *peMode ) const;
bool DecideToThrowGrenade( Vector& vTo, Vector *pvVel, eGrenadeTossMode *peMode ) const;
bool CanKickGrenade( Vector &vFrom, Vector &vTo, Vector &vFace, Vector *pvVel );
bool GrenadeWillHurtTeamAt( Vector& vTo );
bool CanGetGrenadeFromAToB( Vector& vFrom, Vector& vTo, bool bDesperate, Vector *pvVel, eGrenadeTossMode *peMode );
bool DecideToThrowGrenade( Vector& vTo, Vector *pvVel, eGrenadeTossMode *peMode );
void Grenade_EventFire( Event *ev );
void GenericGrenadeTossThink( void );
static void InitGrenade( GlobalFuncs_t *func );
@ -764,7 +764,7 @@ public:
void SetGrenade( Entity *pGrenade );
void NotifySquadmateKilled( Sentient *pSquadMate, Sentient *pAttacker );
void RaiseAlertnessForEventType( int iType );
void RaiseAlertness( float fAmout );
void RaiseAlertness( float fAmount );
virtual bool CanSee( Entity *e1, float fov, float vision_distance );
virtual Vector GunPosition( void );
bool WithinVisionDistance( Entity *ent ) const;
@ -819,7 +819,7 @@ public:
void EventSetTurnDoneError( Event *ev );
void EventGetTurnDoneError( Event *ev );
void LookAround( float fFovAdd );
bool SoundSayAnim( const_str name, int bLevelSayAnim );
bool SoundSayAnim( const_str name, bool bLevelSayAnim );
void EventSetAnim( Event *ev );
void EventIdleSayAnim( Event *ev );
void EventSayAnim( Event *ev );

View file

@ -44,8 +44,11 @@ void Actor::Begin_Anim
)
{
// FIXME: stub
STUB();
m_csMood = m_csIdleMood;
ClearPath();
m_YawAchieved = true;
m_State = 1000;
m_iStateTime = level.inttime;
}
void Actor::Think_Anim

View file

@ -128,6 +128,5 @@ void Actor::SetCuriousAnimHint
)
{
// FIXME: stub
STUB();
m_iCuriousAnimHint = iAnimHint;
}

View file

@ -62,8 +62,17 @@ void Actor::BecomeTurretGuy
)
{
// FIXME: stub
STUB();
SetThinkIdle(8);
SetThink(THINKSTATE_ATTACK, 1);
SetThink(THINKSTATE_DISGUISE, 10);
SetThink(THINKSTATE_GRENADE, 16);
if (m_Think[m_ThinkLevel] == 1 && Turret_DecideToSelectState())
{
m_State = 100;
m_iStateTime = level.inttime;
}
}
void Actor::Think_MachineGunner
(

View file

@ -154,9 +154,7 @@ float ActorEnemySet::GetCurrentVisibility
) const
{
// FIXME: stub
STUB();
return 0;
return m_fCurrentVisibility;
}
int ActorEnemySet::GetCurrentThreat
@ -165,9 +163,7 @@ int ActorEnemySet::GetCurrentThreat
) const
{
// FIXME: stub
STUB();
return 0;
return m_iCurrentThreat;
}
qboolean ActorEnemySet::IsEnemyConfirmed

View file

@ -518,7 +518,7 @@ int ActorPath::CurrentNodeIndex
) const
{
return m_pathpos - m_path;
return m_pathpos ? m_pathpos - m_path : -1;
}
PathInfo *ActorPath::NextNode
@ -527,7 +527,7 @@ PathInfo *ActorPath::NextNode
) const
{
return m_pathpos - 1;
return m_pathpos == m_path ? NULL : m_pathpos - 1;
}
PathInfo *ActorPath::LastNode
@ -666,6 +666,14 @@ bool ActorPath::HasCompleteLookahead
return m_HasCompleteLookahead;
}
bool ActorPath::IsSide
(
void
) const
{
return m_Side;
}
void ActorPath::ForceShortLookahead
(
void

View file

@ -78,6 +78,7 @@ public:
void TrimPathFromEnd( int nNodesPop );
void Shorten( float fDistRemove );
bool HasCompleteLookahead( void ) const;
bool IsSide( void ) const;
void ForceShortLookahead( void );
virtual void Archive( Archiver& arc );

View file

@ -500,6 +500,30 @@ void Animate::SetSyncTime( float s )
}
}
void Animate::UseSyncTime(int slot, int sync)
{
int v3; // eax
unsigned int v4; // eax
int v5; // eax
if (sync)
{
v3 = animFlags[slot];
if (animFlags[slot] & ANIM_SYNC)
return;
animFlags[slot] = (animFlags[slot] | (ANIM_SYNC | ANIM_NODELTA)) & ANIM_FINISHED;
}
else
{
v5 = animFlags[slot];
if (animFlags[slot] & ANIM_SYNC)
{
animFlags[slot] = (animFlags[slot] | ANIM_NODELTA) & (ANIM_FINISHED | ANIM_SYNC);
}
}
}
void Animate::PreAnimate( void )
{
int i;

View file

@ -122,6 +122,7 @@ public:
void SetOnceType( int slot = 0 );
void SetSyncRate( float rate );
void SetSyncTime( float s );
void UseSyncTime(int slot, int sync);
void Pause( int slot = 0, int pause = 1 );
void StopAnimating( int slot = 0 );

View file

@ -74,7 +74,7 @@ typedef enum
//deadflag
#define DEAD_NO 0
#define DEAD_DYING 1
#define DEAD_DEAD 2
#define DEAD_DEAD 2
#define DEAD_RESPAWNABLE 3
// Generic entity events

View file

@ -294,6 +294,7 @@ void RestoreMusicVolume( float fade_time );
void ChangeSoundtrack( const char * soundtrack );
void RestoreSoundtrack( void );
int G_AIEventTypeFromString( const char *pszType );
const char * G_AIEventStringFromType(int iType );
float G_AIEventRadius( int iType );
void G_BroadcastAIEvent( Entity *originator, Vector origin, char *pszType );
void G_BroadcastAIEvent( Entity *originator, Vector origin, int iType, float radius );

View file

@ -733,7 +733,6 @@ void G_SetMovedir( vec3_t angles, vec3_t movedir ) {
VectorClear( angles );
}
float vectoyaw( const vec3_t vec ) {
float yaw;
@ -1980,6 +1979,49 @@ void RestoreSoundtrack( void )
}
}
const char * G_AIEventStringFromType(int iType)
{
switch (iType)
{
case AI_EVENT_WEAPON_FIRE:
return "weapon_fire";
break;
case AI_EVENT_WEAPON_IMPACT:
return "weapon_impact";
break;
case AI_EVENT_EXPLOSION:
return "explosion";
break;
case AI_EVENT_AMERICAN_VOICE:
return "american_voice";
break;
case AI_EVENT_GERMAN_VOICE:
return "german_voice";
break;
case AI_EVENT_AMERICAN_URGENT:
return "american_urgent";
break;
case AI_EVENT_GERMAN_URGENT:
return "german_urgent";
break;
case AI_EVENT_MISC:
return "misc";
break;
case AI_EVENT_MISC_LOUD:
return "misc_loud";
break;
case AI_EVENT_FOOTSTEP:
return "footstep";
break;
case AI_EVENT_GRENADE:
return "grenade";
break;
default:
return "????";
break;
}
}
int G_AIEventTypeFromString
(
const char *pszType

View file

@ -464,11 +464,21 @@ SimpleEntity *G_FindTarget( SimpleEntity *ent, const char *name )
SimpleEntity *G_FindRandomSimpleTarget( const char *name )
{
//int nFound;
// FIXME: stub
STUB();
return NULL;
SimpleEntity *found = NULL, *ent = NULL;
if (name && *name)
{
while (1)
{
ent = world->GetNextEntity(name, ent);
if (!ent)
{
break;
}
rand();
found = ent;
}
}
return found;
}
void G_TouchTriggers( Entity *ent )

View file

@ -2015,6 +2015,24 @@ void Level::EventGetFlags
{
}
str Level::GetRandomHeadModel(const char *model)
{
//FIXME: macros
char s[1024];
int num = random() * 0.000030517578 * gi.NumHeadModels(model);
gi.GetHeadModel(model, num, s);
return s;
}
str Level::GetRandomHeadSkin(const char *model)
{
//FIXME: macros
char s[1024];
int num = random() * 0.000030517578 * gi.NumHeadSkins(model);
gi.GetHeadSkin(model, num, s);
return s;
}
CLASS_DECLARATION( Listener, Level, NULL )
{
{ &EV_Level_GetTime, &Level::GetTime },

View file

@ -69,6 +69,7 @@ void cMoveGrid::CalculateBoxPoints
{
// FIXME: stub
STUB();
}
gridpoint_t *cMoveGrid::GetGridPoint
@ -106,8 +107,9 @@ void cMoveGrid::Move
}
}
// FIXME: stub
// this is not called anyways
// FIXME: stub
STUB();
}
qboolean cMoveGrid::CheckStuck

View file

@ -74,8 +74,8 @@ char *PathSearch::last_error;
byte *bulkNavMemory = NULL;
byte *startBulkNavMemory = NULL;
static Vector PLAYER_BASE_MIN( -15.5f, -15.5f, 0 );
static Vector PLAYER_BASE_MAX( 15.5f, 15.5f, 0 );
Vector PLAYER_BASE_MIN( -15.5f, -15.5f, 0 );
Vector PLAYER_BASE_MAX( 15.5f, 15.5f, 0 );
Vector testpos[ 200 ];
Vector ai_startpath;
Vector ai_endpath;

View file

@ -4535,5 +4535,71 @@ void Sentient::UpdateFootsteps
)
{
// FIXME
//FIXME: macros
int iTagNum, iAnimFlags = 0, iAnimNum;
for (int i = 0; i < MAX_FRAMEINFOS; i++)
{
if (edict->s.frameInfo[i].weight != 0 && CurrentAnim(i) >= 0)
{
iAnimNum = CurrentAnim(i);
iAnimFlags |= gi.Anim_Flags(edict->tiki, iAnimNum);
}
}
//FIXME: macros
if ((iAnimFlags & 0xC00) != 3072)
{
m_bFootOnGround_Right = true;
m_bFootOnGround_Left = true;
return;
}
if (m_bFootOnGround_Right)
{
iTagNum = gi.Tag_NumForName(edict->tiki, "Bip01 R Foot");
if (iTagNum >= 0)
{
m_bFootOnGround_Right = G_TIKI_IsOnGround(edict, iTagNum, 13.653847);
}
else
{
m_bFootOnGround_Right = true;
}
}
else
{
iTagNum = gi.Tag_NumForName(edict->tiki, "Bip01 R Foot");
if (iTagNum >= 0)
{
if (G_TIKI_IsOnGround(edict, iTagNum, 13.461539))
{
BroadcastAIEvent(10, G_AIEventRadius(10));
}
}
m_bFootOnGround_Right = true;
}
if (m_bFootOnGround_Left)
{
iTagNum = gi.Tag_NumForName(edict->tiki, "Bip01 L Foot");
if (iTagNum >= 0)
{
m_bFootOnGround_Left = G_TIKI_IsOnGround(edict, iTagNum, 13.653847);
}
else
{
m_bFootOnGround_Left = true;
}
}
else
{
iTagNum = gi.Tag_NumForName(edict->tiki, "Bip01 R Foot");
if (iTagNum >= 0)
{
if (G_TIKI_IsOnGround(edict, iTagNum, 13.461539))
{
BroadcastAIEvent(10, G_AIEventRadius(10));
}
}
m_bFootOnGround_Left = true;
}
}

View file

@ -1067,7 +1067,7 @@ bool SimpleActor::UpdateSelectedAnimation
return false;
}
char *SimpleActor::DumpCallTrace
const char *SimpleActor::DumpCallTrace
(
const char *pszFmt,
...

View file

@ -235,5 +235,5 @@ public:
void Anim_Emotion( int eEmotionMode );
void Anim_Say( const_str csSayAnimScript, int iMinTimeSinceLastSay, bool bCanInterrupt );
void Anim_FullBody( const_str csFullBodyAnim, int eAnimMode );
virtual char *DumpCallTrace( const char *pszFmt, ... ) const;
virtual const char *DumpCallTrace( const char *pszFmt, ... ) const;
};

View file

@ -1489,6 +1489,18 @@ void Projectile::ExplodeOnTouch
m_bExplodeOnTouch = true;
}
Sentient *Projectile::GetOwner
(
void
)
{
Sentient *pOwner = (Sentient *)G_GetEntity(owner);
if (!pOwner || !pOwner->IsSubclassOfSentient())
return NULL;
else
return pOwner;
}
void Projectile::Stopped
(
Event *ev

View file

@ -132,7 +132,7 @@ public:
void RemoveWhenStopped( Event *ev );
void ExplodeOnTouch( Event *ev );
void Stopped( Event *ev );
Sentient *GetOwner();
Sentient *GetOwner( void );
void SetMartyr( int entnum );
bool CheckTeams( void );
void SetOwner( Entity *owner );

View file

@ -1045,6 +1045,27 @@ bool ScriptThreadLabel::TrySetScript( const_str label )
return TrySetScript( Director.GetString( label ) );
}
void ScriptThreadLabel::GetScriptValue(ScriptVariable *var)
{
//FIXME: macro: 2 ?
ScriptVariable var_array[2];
if (m_Script)
{
var_array[0].setConstStringValue(m_Script->ConstFilename());
var_array[1].setConstStringValue(m_Label);
var->setConstArrayValue(var_array, 2);
for (int i = 0; i < 2; i++)
{
var_array[i].Clear();
}
}
else
{
var->Clear();
}
}
bool ScriptThreadLabel::IsSet( void )
{
return m_Script != NULL ? true : false;

View file

@ -171,8 +171,7 @@ public:
bool TrySetScript( const_str label );
bool TrySetScript( const char *label );
void GetScriptValue(Event *ev);
void SetScriptValue(Event *ev);
void GetScriptValue(ScriptVariable *var);
bool IsSet( void );

View file

@ -8816,6 +8816,16 @@ void ScriptThread::Execute
}
}
void ScriptThread::Execute
(
ScriptVariable *data,
int dataSize
)
{
ScriptExecuteInternal(data, dataSize);
}
void ScriptThread::DelayExecute
(
Event& ev
@ -8857,6 +8867,11 @@ ScriptClass *ScriptThread::GetScriptClass( void )
return m_ScriptVM->m_ScriptClass;
}
str ScriptThread::FileName(void)
{
return m_ScriptVM->Filename();
}
int ScriptThread::GetThreadState( void )
{
return m_ScriptVM->ThreadState();
@ -8994,6 +9009,29 @@ void ScriptThread::Wait( float time )
m_ScriptVM->Suspend();
}
void ScriptThread::StartTiming(float time)
{
if (m_ScriptVM->ThreadState() == THREAD_WAITING)
{
m_ScriptVM->m_ThreadState = THREAD_RUNNING;
Director.RemoveTiming(this);
}
else if (m_ScriptVM->ThreadState() == THREAD_SUSPENDED)
{
m_ScriptVM->m_ThreadState = THREAD_RUNNING;
CancelWaitingAll();
}
m_ScriptVM->m_ThreadState = THREAD_WAITING;
Director.AddTiming(this, time);
}
void ScriptThread::StartTiming(void)
{
StartTiming(level.inttime);
}
CLASS_DECLARATION( Listener, ScriptThread, NULL )
{
{ &EV_Listener_CreateReturnThread, &ScriptThread::CreateReturnThread },

View file

@ -211,12 +211,14 @@ public:
void Execute( Event &ev );
void Execute( Event *ev = NULL );
void Execute(ScriptVariable *data, int dataSize);
void DelayExecute( Event& ev );
void DelayExecute( Event *ev = NULL );
void AllowContextSwitch( bool allow = true );
ScriptClass *GetScriptClass( void );
str ScriptThread::FileName(void);
int GetThreadState( void );
ScriptThread *GetWaitingContext( void );
void SetWaitingContext( ScriptThread *thread );
@ -227,6 +229,8 @@ public:
void ScriptExecute( ScriptVariable *data, int dataSize, ScriptVariable &returnValue );
void Stop( void );
void Wait( float time );
void StartTiming( float time );
void StartTiming( void );
void CanSwitchTeams( Event *ev );
bool CanScriptTracePrint( void );

View file

@ -553,7 +553,7 @@ inline float Vector::lengthfast( void ) const
//
// Returns: float - length of the vector in the xy plane
//----------------------------------------------------------------
inline float Vector::lengthXY( bool squared = false ) const
inline float Vector::lengthXY( bool squared ) const
{
return squared ? (x * x) + (y * y) : sqrt(( x * x ) + ( y * y ));
}

View file

@ -1964,8 +1964,7 @@ vec_t VectorNormalize2( const vec3_t v, vec3_t out ) {
vec_t VectorNormalize2D( vec2_t v ) {
float length, ilength;
length = v[ 0 ] * v[ 0 ] + v[ 1 ] * v[ 1 ];
length = sqrt( length );
length = VectorLength2D(v);
if( length ) {
ilength = 1 / length;

View file

@ -575,10 +575,15 @@ void ByteToDir( int b, vec3_t dir );
#define DotProduct(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1]+(x)[2]*(y)[2])
#define DotProduct2D(x,y) ((x)[0]*(y)[0]+(x)[1]*(y)[1])
#define CrossProduct2D(a,b) ((a)[0]*(b)[1]-(b)[0]*(a)[1])
#define VectorSubtract(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]=(a)[1]-(b)[1],(c)[2]=(a)[2]-(b)[2])
#define VectorAdd(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1],(c)[2]=(a)[2]+(b)[2])
#define VectorAdd2D(a,b,c) ((c)[0]=(a)[0]+(b)[0],(c)[1]=(a)[1]+(b)[1])
#define VectorSub2D(a,b,c) ((c)[0]=(a)[0]-(b)[0],(c)[1]-(a)[1]-(b)[1])
#define VectorCopy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2])
#define VectorCopy2D(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1])
#define VectorScale(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s),(o)[2]=(v)[2]*(s))
#define VectorScale2D(v, s, o) ((o)[0]=(v)[0]*(s),(o)[1]=(v)[1]*(s))
#define VectorMA(v, s, b, o) ((o)[0]=(v)[0]+(b)[0]*(s),(o)[1]=(v)[1]+(b)[1]*(s),(o)[2]=(v)[2]+(b)[2]*(s))
#else