Added fields and methods from mohaas and mohaab

This commit is contained in:
smallmodel 2023-10-12 19:21:41 +02:00
parent 1fb073fd6a
commit 7b721c7849
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512
4 changed files with 1242 additions and 856 deletions

View file

@ -2394,9 +2394,11 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_Actor_AnimLoop, &Actor::PlayAnimation }, {&EV_Actor_AnimLoop, &Actor::PlayAnimation },
{&EV_Actor_Anim_Scripted, &Actor::PlayScriptedAnimation }, {&EV_Actor_Anim_Scripted, &Actor::PlayScriptedAnimation },
{&EV_Actor_Anim_Noclip, &Actor::PlayNoclipAnimation }, {&EV_Actor_Anim_Noclip, &Actor::PlayNoclipAnimation },
{&EV_Actor_Anim_Attached, &Actor::PlayAttachedAnimation },
{&EV_Actor_AnimScript, &Actor::EventAnimScript }, {&EV_Actor_AnimScript, &Actor::EventAnimScript },
{&EV_Actor_AnimScript_Scripted, &Actor::EventAnimScript_Scripted }, {&EV_Actor_AnimScript_Scripted, &Actor::EventAnimScript_Scripted },
{&EV_Actor_AnimScript_Noclip, &Actor::EventAnimScript_Noclip }, {&EV_Actor_AnimScript_Noclip, &Actor::EventAnimScript_Noclip },
{&EV_Actor_AnimScript_Attached, &Actor::EventAnimScript_Attached },
{&EV_Actor_Reload_mg42, &Actor::EventReload_mg42 }, {&EV_Actor_Reload_mg42, &Actor::EventReload_mg42 },
{&EV_Actor_Dumb, &Actor::Dumb }, {&EV_Actor_Dumb, &Actor::Dumb },
{&EV_Actor_Physics_On, &Actor::PhysicsOn }, {&EV_Actor_Physics_On, &Actor::PhysicsOn },
@ -2507,6 +2509,8 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_Actor_SetAlarmNode, &Actor::EventSetAlarmNode }, {&EV_Actor_SetAlarmNode, &Actor::EventSetAlarmNode },
{&EV_Actor_SetAlarmNode2, &Actor::EventSetAlarmNode }, {&EV_Actor_SetAlarmNode2, &Actor::EventSetAlarmNode },
{&EV_Actor_GetAlarmNode, &Actor::EventGetAlarmNode }, {&EV_Actor_GetAlarmNode, &Actor::EventGetAlarmNode },
{&EV_Actor_SetPreAlarmThread, &Actor::EventSetPreAlarmThread },
{&EV_Actor_SetPreAlarmThread2, &Actor::EventSetPreAlarmThread },
{&EV_Actor_SetAlarmThread, &Actor::EventSetAlarmThread }, {&EV_Actor_SetAlarmThread, &Actor::EventSetAlarmThread },
{&EV_Actor_SetAlarmThread2, &Actor::EventSetAlarmThread }, {&EV_Actor_SetAlarmThread2, &Actor::EventSetAlarmThread },
{&EV_Actor_GetAlarmThread, &Actor::EventGetAlarmThread }, {&EV_Actor_GetAlarmThread, &Actor::EventGetAlarmThread },
@ -2533,12 +2537,19 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_Actor_ShareEnemy, &Actor::EventShareEnemy }, {&EV_Actor_ShareEnemy, &Actor::EventShareEnemy },
{&EV_Actor_ShareGrenade, &Actor::EventShareGrenade }, {&EV_Actor_ShareGrenade, &Actor::EventShareGrenade },
{&EV_Actor_InterruptPoint, &Actor::EventInterruptPoint }, {&EV_Actor_InterruptPoint, &Actor::EventInterruptPoint },
{&EV_Actor_GetPainHandler, &SimpleActor::EventGetPainHandler }, {&EV_Actor_GetVisibilityThreshold, &Actor::EventGetVisibilityThreshold },
{&EV_Actor_SetPainHandler, &SimpleActor::EventSetPainHandler }, {&EV_Actor_SetVisibilityThreshold, &Actor::EventSetVisibilityThreshold },
{&EV_Actor_GetDeathHandler, &SimpleActor::EventGetDeathHandler }, {&EV_Actor_SetVisibilityThreshold2, &Actor::EventSetVisibilityThreshold },
{&EV_Actor_SetDeathHandler, &SimpleActor::EventSetDeathHandler }, {&EV_Actor_SetDefaultVisibilityThreshold, &Actor::EventSetDefaultVisibilityThreshold },
{&EV_Actor_GetAttackHandler, &SimpleActor::EventGetAttackHandler }, {&EV_Actor_GetSuppressChance, &Actor::EventGetSuppressChance },
{&EV_Actor_SetAttackHandler, &SimpleActor::EventSetAttackHandler }, {&EV_Actor_SetSuppressChance, &Actor::EventSetSuppressChance },
{&EV_Actor_SetSuppressChance2, &Actor::EventSetSuppressChance },
{&EV_Actor_GetPainHandler, &Actor::EventGetPainHandler },
{&EV_Actor_SetPainHandler, &Actor::EventSetPainHandler },
{&EV_Actor_GetDeathHandler, &Actor::EventGetDeathHandler },
{&EV_Actor_SetDeathHandler, &Actor::EventSetDeathHandler },
{&EV_Actor_GetAttackHandler, &Actor::EventGetAttackHandler },
{&EV_Actor_SetAttackHandler, &Actor::EventSetAttackHandler },
{&EV_Actor_SetHeadModel, &Actor::EventSetHeadModel }, {&EV_Actor_SetHeadModel, &Actor::EventSetHeadModel },
{&EV_Actor_GetHeadModel, &Actor::EventGetHeadModel }, {&EV_Actor_GetHeadModel, &Actor::EventGetHeadModel },
{&EV_Actor_SetHeadSkin, &Actor::EventSetHeadSkin }, {&EV_Actor_SetHeadSkin, &Actor::EventSetHeadSkin },
@ -2557,7 +2568,7 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_SoundDone, &Actor::EventSoundDone }, {&EV_SoundDone, &Actor::EventSoundDone },
{&EV_Sound, &Actor::EventSound }, {&EV_Sound, &Actor::EventSound },
{&EV_Actor_IsEnemyVisible, &Actor::EventIsEnemyVisible }, {&EV_Actor_IsEnemyVisible, &Actor::EventIsEnemyVisible },
{&EV_Actor_GetEnemyVisibleChangeTime, &Actor::EventGetEnemyVisibleChangeTime}, {&EV_Actor_GetEnemyVisibleChangeTime, &Actor::EventGetEnemyVisibleChangeTime },
{&EV_Actor_GetLastEnemyVisibleTime, &Actor::EventGetLastEnemyVisibleTime }, {&EV_Actor_GetLastEnemyVisibleTime, &Actor::EventGetLastEnemyVisibleTime },
{&EV_Actor_SetFallHeight, &Actor::EventSetFallHeight }, {&EV_Actor_SetFallHeight, &Actor::EventSetFallHeight },
{&EV_Actor_GetFallHeight, &Actor::EventGetFallHeight }, {&EV_Actor_GetFallHeight, &Actor::EventGetFallHeight },
@ -2586,10 +2597,12 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_Actor_GetMumble, &Actor::EventGetMumble }, {&EV_Actor_GetMumble, &Actor::EventGetMumble },
{&EV_Actor_SetMumble, &Actor::EventSetMumble }, {&EV_Actor_SetMumble, &Actor::EventSetMumble },
{&EV_Actor_SetMumble2, &Actor::EventSetMumble }, {&EV_Actor_SetMumble2, &Actor::EventSetMumble },
{&EV_Actor_GetBreathSteam, &Actor::EventGetBreathSteam }, // FIXME: removed since 2.0?
{&EV_Actor_SetBreathSteam, &Actor::EventSetBreathSteam }, //{&EV_Actor_GetBreathSteam, &Actor::EventGetBreathSteam },
{&EV_Actor_SetBreathSteam2, &Actor::EventSetBreathSteam }, //{&EV_Actor_SetBreathSteam, &Actor::EventSetBreathSteam },
//{&EV_Actor_SetBreathSteam2, &Actor::EventSetBreathSteam },
{&EV_Actor_CalcGrenadeToss, &Actor::EventCalcGrenadeToss }, {&EV_Actor_CalcGrenadeToss, &Actor::EventCalcGrenadeToss },
{&EV_Actor_CalcGrenadeToss2, &Actor::EventCalcGrenadeToss },
{&EV_Actor_GetNoSurprise, &Actor::EventGetNoSurprise }, {&EV_Actor_GetNoSurprise, &Actor::EventGetNoSurprise },
{&EV_Actor_SetNoSurprise, &Actor::EventSetNoSurprise }, {&EV_Actor_SetNoSurprise, &Actor::EventSetNoSurprise },
{&EV_Actor_SetNoSurprise2, &Actor::EventSetNoSurprise }, {&EV_Actor_SetNoSurprise2, &Actor::EventSetNoSurprise },
@ -2600,6 +2613,7 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_Actor_SetAvoidPlayer, &Actor::EventSetAvoidPlayer }, {&EV_Actor_SetAvoidPlayer, &Actor::EventSetAvoidPlayer },
{&EV_Actor_SetAvoidPlayer2, &Actor::EventSetAvoidPlayer }, {&EV_Actor_SetAvoidPlayer2, &Actor::EventSetAvoidPlayer },
{&EV_Actor_SetMoveDoneRadius, &Actor::EventSetMoveDoneRadius }, {&EV_Actor_SetMoveDoneRadius, &Actor::EventSetMoveDoneRadius },
{&EV_Actor_GetMoveDoneRadius, &Actor::EventGetMoveDoneRadius },
{&EV_Actor_BeDead, &Actor::EventBeDead }, {&EV_Actor_BeDead, &Actor::EventBeDead },
{&EV_Actor_GetLookAroundAngle, &Actor::EventGetLookAroundAngle }, {&EV_Actor_GetLookAroundAngle, &Actor::EventGetLookAroundAngle },
{&EV_Actor_SetLookAroundAngle, &Actor::EventSetLookAroundAngle }, {&EV_Actor_SetLookAroundAngle, &Actor::EventSetLookAroundAngle },
@ -2615,7 +2629,22 @@ CLASS_DECLARATION(SimpleActor, Actor, "Actor") {
{&EV_Actor_SetBalconyHeight, &Actor::EventSetBalconyHeight }, {&EV_Actor_SetBalconyHeight, &Actor::EventSetBalconyHeight },
{&EV_Actor_SetBalconyHeight2, &Actor::EventSetBalconyHeight }, {&EV_Actor_SetBalconyHeight2, &Actor::EventSetBalconyHeight },
{&EV_Actor_GetBalconyHeight, &Actor::EventGetBalconyHeight }, {&EV_Actor_GetBalconyHeight, &Actor::EventGetBalconyHeight },
{&EV_CanSee, &Actor::CanSee }, {&EV_Actor_SetIgnoreBadPlace, &Actor::EventSetIgnoreBadPlace },
{&EV_Actor_SetIgnoreBadPlace2, &Actor::EventSetIgnoreBadPlace },
{&EV_Actor_GetIgnoreBadPlace, &Actor::EventGetIgnoreBadPlace },
{&EV_Actor_FindEnemy, &Actor::EventFindEnemy },
{&EV_Actor_EnableEnemySwitch, &Actor::EventEnableEnemySwitch },
{&EV_Actor_DisableEnemySwitch, &Actor::EventDisableEnemySwitch },
{&EV_Actor_SetRunAnimRate, &Actor::EventSetRunAnimRate },
{&EV_Actor_SetRunAnimRate2, &Actor::EventSetRunAnimRate },
{&EV_Actor_GetRunAnimRate, &Actor::EventGetRunAnimRate },
{&EV_Stop, &Actor::Landed },
{&EV_Actor_SetNationality, &Actor::SetNationality },
{&EV_Actor_SetNationality2, &Actor::SetNationality },
{&EV_Actor_GetNationality, &Actor::GetNationality },
{&EV_Actor_WriteStats, &Actor::EventWriteStats },
{&EV_Actor_CuriousOff, &Actor::EventCuriousOff },
{&EV_Actor_CuriousOn, &Actor::EventCuriousOn },
{NULL, NULL } {NULL, NULL }
}; };
@ -4374,6 +4403,31 @@ bool Actor::CanSee(Entity *e1, float fov, float vision_distance, bool bNoEnts)
return canSee; return canSee;
} }
/*
===============
Actor::InFOV
Returns true if positin is within fov.
===============
*/
bool Actor::InFOV(Vector pos, float check_fov, float check_fovdot)
{
bool bInFov = true;
if (check_fov != 360.0) {
Vector delta = pos - EyePosition();
if (delta.x == 0 && delta.y == 0) {
return bInFov;
}
bInFov = false;
float fDot = DotProduct2D(delta, orientation[0]);
if (fDot >= 0) {
bInFov = Square(fDot) > delta.lengthXYSquared() * Square(check_fovdot);
}
}
return bInFov;
}
/* /*
=============== ===============
Actor::CanShoot Actor::CanShoot
@ -4507,70 +4561,16 @@ bool Actor::CanShootEnemy(int iMaxDirtyTime)
return m_bCanShootEnemy; return m_bCanShootEnemy;
} }
/* bool Actor::FriendlyInLineOfFire(Entity *other)
===============
Actor::TransitionState
===============
*/
void Actor::TransitionState(int iNewState, int iPadTime)
{ {
//fixme: this is an inline function. // FIXME: unimplemented
m_State = iNewState; return false;
m_iStateTime = level.inttime + iPadTime;
} }
/* Vector Actor::VirtualEyePosition()
===============
Actor::CanSee
Returns true to script if actor cansee entity.
===============
*/
void Actor::CanSee(Event *ev)
{ {
float fov = 0; // FIXME: unimplemented
float vision_distance = 0; return Vector();
if (m_Think[m_ThinkLevel] != THINK_MACHINEGUNNER || !m_pTurret) {
return Entity::CanSee(ev);
}
switch (ev->NumArgs()) {
case 1:
{
//do nothing
}
break;
case 2:
{
fov = ev->GetFloat(2);
if (fov < 0 || fov > 360) {
ScriptError("fov must be in range 0 <= fov <= 360");
}
}
break;
case 3:
{
vision_distance = ev->GetFloat(3);
if (vision_distance < 0) {
ScriptError("vision distance must be >= 0");
}
}
break;
default:
{
ScriptError("cansee should have 1, 2, or 3 arguments");
}
break;
}
Entity *ent = ev->GetEntity(1);
if (!ent) {
ScriptError("NULL entity in parameter 1");
} else {
int cansee = MachineGunner_CanSee(ent, fov, vision_distance);
ev->AddInteger(cansee);
}
} }
/* /*
@ -4606,66 +4606,6 @@ bool Actor::IsDogState(int state)
return true; return true;
} }
/*
===============
Actor::IgnoreSoundSet
Make actor ignore iType sound.
===============
*/
void Actor::IgnoreSoundSet(int iType)
{
m_iIgnoreSoundsMask |= 1 << iType;
}
/*
===============
Actor::IgnoreSoundSetAll
Make actor ignore all types of sound.
===============
*/
void Actor::IgnoreSoundSetAll(void)
{
m_iIgnoreSoundsMask = ~AI_EVENT_NONE;
}
/*
===============
Actor::IgnoreSoundClear
Don't ignore iType of sound.
===============
*/
void Actor::IgnoreSoundClear(int iType)
{
m_iIgnoreSoundsMask &= ~iType;
}
/*
===============
Actor::IgnoreSoundClearAll
Make actor ignore no type of sound.
===============
*/
void Actor::IgnoreSoundClearAll(void)
{
m_iIgnoreSoundsMask = 0;
}
/*
===============
Actor::IgnoreSoundClearAll
returns true if actor should ignore iType of sound.
===============
*/
bool Actor::IgnoreSound(int iType)
{
return (m_iIgnoreSoundsMask >> iType) & 1;
}
/* /*
=============== ===============
Actor::WithinVisionDistance Actor::WithinVisionDistance
@ -4693,91 +4633,6 @@ bool Actor::WithinVisionDistance(Entity *ent) const
return false; return false;
} }
/*
===============
Actor::InFOV
Returns true if positin is within fov.
===============
*/
bool Actor::InFOV(Vector pos, float check_fov, float check_fovdot)
{
bool bInFov = true;
if (check_fov != 360.0) {
Vector delta = pos - EyePosition();
if (delta.x == 0 && delta.y == 0) {
return bInFov;
}
bInFov = false;
float fDot = DotProduct2D(delta, orientation[0]);
if (fDot >= 0) {
bInFov = Square(fDot) > delta.lengthXYSquared() * Square(check_fovdot);
}
}
return bInFov;
}
/*
===============
Actor::InFOV
Returns true if pos is within fov.
===============
*/
bool Actor::InFOV(Vector pos)
{
return InFOV(pos, m_fFov, m_fFovDot);
}
/*
===============
Actor::InFOV
Returns true if ent is within fov.
===============
*/
bool Actor::InFOV(Entity *ent)
{
if (ent == m_Enemy) {
return EnemyInFOV(0);
} else {
return InFOV(ent->centroid, m_fFov, m_fFovDot);
}
}
bool Actor::CanSeeNoFOV(Entity *ent)
{
if (ent == m_Enemy) {
return CanSeeEnemy(0);
} else {
bool bCanSee = false;
if (gi.AreasConnected(edict->r.areanum, ent->edict->r.areanum)) {
bCanSee = CanSeeFrom(EyePosition(), ent);
}
return bCanSee;
}
}
bool Actor::CanSeeFOV(Entity *ent)
{
//fixme: this is an inline function.
if (ent == m_Enemy) {
return CanSeeEnemyFOV(0, 0);
} else {
bool bCanSee = false;
if (InFOV(ent->centroid, m_fFov, m_fFovDot) && gi.AreasConnected(edict->r.areanum, ent->edict->r.areanum)) {
bCanSee = CanSeeFrom(EyePosition(), ent);
}
return bCanSee;
}
}
bool Actor::CanSeeEnemyFOV(int iMaxFovDirtyTime, int iMaxSightDirtyTime)
{
return EnemyInFOV(iMaxFovDirtyTime) && CanSeeEnemy(iMaxSightDirtyTime);
}
/* /*
=============== ===============
Actor::CanTarget Actor::CanTarget
@ -5906,6 +5761,21 @@ void Actor::PlayNoclipAnimation(Event *ev)
ExecuteScript(&e1); ExecuteScript(&e1);
} }
/*
===============
Actor::PlayAttachedAnimation
Play attached animation
===============
*/
void Actor::PlayAttachedAnimation(Event *ev)
{
Event e1(EV_Listener_ExecuteScript);
e1.AddConstString(STRING_GLOBAL_ANIM_ATTACHED_SCR);
e1.AddValue(ev->GetValue(1));
ExecuteScript(&e1);
}
/* /*
=============== ===============
Actor::MoveDest Actor::MoveDest
@ -7115,6 +6985,16 @@ void Actor::UpdateEnemy(int iMaxDirtyTime)
} }
} }
/*
===============
Actor::DetectSmokeGrenades
===============
*/
void Actor::DetectSmokeGrenades(void)
{
// FIXME: unimplemented
}
/* /*
=============== ===============
Actor::SetEnemy Actor::SetEnemy
@ -8341,6 +8221,15 @@ void Actor::EventGetAlarmNode(Event *ev)
ev->AddListener(m_AlarmNode); ev->AddListener(m_AlarmNode);
} }
void Actor::EventSetPreAlarmThread(Event *ev)
{
if (ev->IsFromScript()) {
m_PreAlarmThread.SetThread(ev->GetValue());
} else {
m_PreAlarmThread.Set(ev->GetString(1));
}
}
void Actor::EventSetAlarmThread(Event *ev) void Actor::EventSetAlarmThread(Event *ev)
{ {
if (ev->IsFromScript()) { if (ev->IsFromScript()) {
@ -8965,6 +8854,22 @@ bool Actor::PassesTransitionConditions_Grenade(void)
return false; return false;
} }
/*
===============
Actor::PassesTransitionConditions_BadPlace
Should actor transition think state to bad place?
===============
*/
bool Actor::PassesTransitionConditions_BadPlace(void)
{
if (m_bLockThinkState) {
return false;
}
return m_iBadPlaceIndex != 0;
}
/* /*
=============== ===============
Actor::PassesTransitionConditions_Attack Actor::PassesTransitionConditions_Attack
@ -9764,6 +9669,25 @@ void Actor::SetGrenade(Entity *pGrenade)
m_vGrenadePos = pGrenade->origin; m_vGrenadePos = pGrenade->origin;
} }
/*
===============
Actor::UpdateBadPlaces
Update bad places, with a new path
===============
*/
void Actor::UpdateBadPlaces(void)
{
m_iBadPlaceIndex = 0;
if (!m_bIgnoreBadPlace) {
if (PathExists()) {
m_Path.ReFindPath(origin, this);
}
m_iBadPlaceIndex = level.GetNearestBadPlace(origin, 64, 1 << m_Team);
}
}
/* /*
=============== ===============
Actor::NotifySquadmateKilled Actor::NotifySquadmateKilled
@ -10626,6 +10550,50 @@ void Actor::EventInterruptPoint(Event *ev)
} }
} }
void Actor::EventGetVisibilityThreshold(Event *ev)
{
ev->AddFloat(m_fVisibilityThreshold);
}
void Actor::EventSetVisibilityThreshold(Event *ev)
{
float threshold;
threshold = ev->GetFloat(1);
if (threshold < 0 || threshold > 1) {
ScriptError("DefaultNonVisLevel must be in range 0-1");
}
m_bHasVisibilityThreshold = true;
m_fVisibilityThreshold = threshold;
}
void Actor::EventSetDefaultVisibilityThreshold(Event *ev)
{
float threshold;
threshold = ev->GetFloat(1);
if (threshold < 0 || threshold > 1) {
ScriptError("DefaultNonVisLevel must be in range 0-1");
}
if (!m_bHasVisibilityThreshold) {
m_fVisibilityThreshold = threshold;
}
}
void Actor::EventGetSuppressChance(Event *ev)
{
ev->AddInteger(m_iSuppressChance);
}
void Actor::EventSetSuppressChance(Event *ev)
{
// FIXME: unimplemented
}
void Actor::EventAnimScript(Event *ev) void Actor::EventAnimScript(Event *ev)
{ {
m_bAnimScriptSet = true; m_bAnimScriptSet = true;
@ -10658,6 +10626,11 @@ void Actor::EventAnimScript_Noclip(Event *ev)
SetThinkIdle(THINK_ANIM); SetThinkIdle(THINK_ANIM);
} }
void Actor::EventAnimScript_Attached(Event *ev)
{
// FIXME: unimplemented
}
void Actor::EventReload_mg42(Event *ev) void Actor::EventReload_mg42(Event *ev)
{ {
//FIXME: macos/enum //FIXME: macos/enum
@ -11094,11 +11067,18 @@ void Actor::Holster(void)
} }
} }
void Actor::HolsterOffHand(void)
{
if (activeWeaponList[WEAPON_OFFHAND]) {
DeactivateWeapon(WEAPON_OFFHAND);
}
}
void Actor::Unholster(void) void Actor::Unholster(void)
{ {
Weapon *weap; Weapon *weap;
if (!activeWeaponList[0]) { if (!activeWeaponList[WEAPON_MAIN]) {
weap = GetWeapon(WEAPON_MAIN); weap = GetWeapon(WEAPON_MAIN);
if (weap) { if (weap) {
useWeapon(weap, WEAPON_MAIN); useWeapon(weap, WEAPON_MAIN);
@ -11107,6 +11087,19 @@ void Actor::Unholster(void)
} }
} }
void Actor::UnholsterOffHand(void)
{
Weapon *weap;
if (!activeWeaponList[WEAPON_OFFHAND]) {
weap = GetWeapon(WEAPON_OFFHAND);
if (weap) {
useWeapon(weap, WEAPON_OFFHAND);
ActivateNewWeapon();
}
}
}
void Actor::EventHolster(Event *ev) void Actor::EventHolster(Event *ev)
{ {
if (activeWeaponList[WEAPON_MAIN]) { if (activeWeaponList[WEAPON_MAIN]) {
@ -11581,6 +11574,11 @@ bool Actor::IsGrenadeState(int state)
return state == THINKSTATE_GRENADE; return state == THINKSTATE_GRENADE;
} }
bool Actor::IsBadPlaceState(int state)
{
return state == THINKSTATE_BADPLACE;
}
bool Actor::IsPainState(int state) bool Actor::IsPainState(int state)
{ {
return state == THINKSTATE_PAIN; return state == THINKSTATE_PAIN;
@ -11629,6 +11627,15 @@ void Actor::EventSetFavoriteEnemy(Event *ev)
m_FavoriteEnemy = fEnemy; m_FavoriteEnemy = fEnemy;
} }
void Actor::EventFindEnemy(Event *ev)
{
if (level.inttime > m_iEnemyCheckTime + 200) {
UpdateEnemyInternal();
}
ev->AddEntity(m_Enemy);
}
void Actor::EventGetMumble(Event *ev) void Actor::EventGetMumble(Event *ev)
{ {
ev->AddInteger(m_bMumble); ev->AddInteger(m_bMumble);
@ -11639,6 +11646,11 @@ void Actor::EventSetMumble(Event *ev)
m_bMumble = ev->GetInteger(1); m_bMumble = ev->GetInteger(1);
} }
void Actor::EventCalcGrenadeToss2(Event *ev)
{
// FIXME: unimplemented
}
void Actor::EventCalcGrenadeToss(Event *ev) void Actor::EventCalcGrenadeToss(Event *ev)
{ {
//FIXME: macros //FIXME: macros
@ -11982,6 +11994,11 @@ void Actor::EventSetMoveDoneRadius(Event *ev)
m_fMoveDoneRadiusSquared = Square(moveDoneR); m_fMoveDoneRadiusSquared = Square(moveDoneR);
} }
void Actor::EventGetMoveDoneRadius(Event *ev)
{
ev->AddFloat(sqrtf(m_fMoveDoneRadiusSquared));
}
/* /*
=============== ===============
Actor::StoppedWaitFor Actor::StoppedWaitFor
@ -12063,6 +12080,22 @@ void Actor::EventSetBalconyHeight(Event *ev)
m_fBalconyHeight = ev->GetFloat(1); m_fBalconyHeight = ev->GetFloat(1);
} }
void Actor::EventSetIgnoreBadPlace(Event *ev)
{
if (m_bIgnoreBadPlace != ev->GetBoolean(1)) {
m_bIgnoreBadPlace = ev->GetBoolean(1);
if (level.m_badPlaces.NumObjects() && m_bIgnoreBadPlace) {
UpdateBadPlaces();
}
}
}
void Actor::EventGetIgnoreBadPlace(Event *ev)
{
ev->AddInteger(m_bIgnoreBadPlace);
}
void Actor::EventGetBalconyHeight(Event *ev) void Actor::EventGetBalconyHeight(Event *ev)
{ {
ev->AddFloat(m_fBalconyHeight); ev->AddFloat(m_fBalconyHeight);
@ -12098,96 +12131,110 @@ void Actor::AimAtEnemyBehavior(void)
/* /*
=============== ===============
Actor::ForwardLook Actor::EventEnableEnemySwitch
=============== ===============
*/ */
void Actor::ForwardLook(void) void Actor::EventEnableEnemySwitch(Event *ev)
{ {
//fixme: this is an inline function. m_bEnemySwitch = true;
m_bHasDesiredLookAngles = false;
} }
/* /*
=============== ===============
Actor::SetDesiredLookDir Actor::EventDisableEnemySwitch
Change desired look direction.
=============== ===============
*/ */
void Actor::SetDesiredLookDir(vec3_t dir) void Actor::EventDisableEnemySwitch(Event *ev)
{ {
m_bHasDesiredLookAngles = true; m_bEnemySwitch = false;
vectoangles(dir, m_DesiredLookAngles);
m_DesiredLookAngles[1] = m_DesiredLookAngles[1] - angles[1];
m_DesiredLookAngles[1] = AngleNormalize180(m_DesiredLookAngles[1]);
m_DesiredLookAngles[0] = AngleNormalize180(m_DesiredLookAngles[0]);
} }
/* /*
=============== ===============
Actor::SetDesiredLookAnglesRelative Actor::EventSetRunAnimRate
Change desired look angles relatively.
=============== ===============
*/ */
void Actor::SetDesiredLookAnglesRelative(vec3_t ang) void Actor::EventSetRunAnimRate(Event *ev)
{ {
m_bHasDesiredLookAngles = true; m_fRunAnimRate = ev->GetFloat(1);
m_DesiredLookAngles[0] = AngleNormalize180(ang[0]);
m_DesiredLookAngles[1] = AngleNormalize180(ang[1]);
m_DesiredLookAngles[2] = AngleNormalize180(ang[2]);
} }
/* /*
=============== ===============
Actor::AimAtTargetPos Actor::EventGetRunAnimRate
Aim at mTargetPos.
=============== ===============
*/ */
void Actor::AimAtTargetPos(void) void Actor::EventGetRunAnimRate(Event *ev)
{ {
Vector vDir = mTargetPos - EyePosition() + Vector(0, 0, 16); ev->AddFloat(m_fRunAnimRate);
SetDesiredLookDir(vDir);
m_DesiredGunDir[0] = 360.0f - vDir.toPitch();
m_DesiredGunDir[1] = vDir.toYaw();
m_DesiredGunDir[2] = 0;
SetDesiredYawDir(vDir);
} }
/* /*
=============== ===============
Actor::AimAtAimNode Actor::Landed
Aim at m_aimNode.
=============== ===============
*/ */
void Actor::AimAtAimNode(void) void Actor::Landed(Event *ev)
{ {
mTargetPos = m_aimNode->origin; // FIXME: unimplemented
}
AimAtTargetPos(); bool Actor::IsOnFloor(void)
{
// FIXME: unimplemented
return false;
} }
/* /*
=============== ===============
Actor::NextUpdateTime Actor::GetNationality
Returns next update time.
=============== ===============
*/ */
int Actor::NextUpdateTime(int iLastUpdateTime, int iUpdatePeriod) void Actor::GetNationality(Event *ev)
{ {
int i = iLastUpdateTime; // FIXME: unimplemented
}
do { /*
i += iUpdatePeriod; ===============
} while (i < level.inttime); Actor::SetNationality
===============
*/
void Actor::SetNationality(Event *ev)
{
// FIXME: unimplemented
}
return i; /*
===============
Actor::EventWriteStats
===============
*/
void Actor::EventWriteStats(Event *ev)
{
if (g_aistats->integer) {
level.OpenActorStats();
}
}
/*
===============
Actor::EventCuriousOff
===============
*/
void Actor::EventCuriousOff(Event *ev)
{
m_bIsCurious = false;
}
/*
===============
Actor::EventCuriousOn
===============
*/
void Actor::EventCuriousOn(Event *ev)
{
m_bIsCurious = true;
} }
/* /*
@ -12589,30 +12636,6 @@ void Actor::UpdateBoneControllers()
*/ */
/*
===============
Actor::CurrentThink
Current think.
===============
*/
int Actor::CurrentThink(void) const
{
return m_Think[m_ThinkLevel];
}
/*
===============
Actor::IsAttacking
Returns true if actor is in attack state.
===============
*/
bool Actor::IsAttacking(void) const
{
return m_ThinkStates[THINKLEVEL_NORMAL] == THINKSTATE_ATTACK;
}
void Actor::EventSetDestIdle(Event *ev) void Actor::EventSetDestIdle(Event *ev)
{ {
// not found in ida // not found in ida
@ -12642,13 +12665,13 @@ void Actor::EventSetNextBreathTime(Event *ev)
t->Execute(&sVar, 1); t->Execute(&sVar, 1);
} }
bool Actor::AvoidingFacingWall(void) const
{
return m_eDontFaceWallMode <= 8;
}
bool Actor::EnemyIsDisguised(void) bool Actor::EnemyIsDisguised(void)
{ {
return (m_bEnemyIsDisguised || (m_Enemy && m_Enemy->m_bIsDisguised)) return (m_bEnemyIsDisguised || (m_Enemy && m_Enemy->m_bIsDisguised))
&& (!m_bForceAttackPlayer && m_ThinkState != THINKSTATE_ATTACK); && (!m_bForceAttackPlayer && m_ThinkState != THINKSTATE_ATTACK);
} }
bool Actor::IsDisabled() const
{
return !m_bDoAI;
}

View file

@ -329,6 +329,7 @@ enum eThinkState {
THINKSTATE_CURIOUS, THINKSTATE_CURIOUS,
THINKSTATE_DISGUISE, THINKSTATE_DISGUISE,
THINKSTATE_GRENADE, THINKSTATE_GRENADE,
THINKSTATE_BADPLACE, // Added in 2.0
THINKSTATE_NOCLIP, THINKSTATE_NOCLIP,
NUM_THINKSTATES, NUM_THINKSTATES,
}; };
@ -382,6 +383,8 @@ enum eThinkNum {
THINK_WEAPONLESS, THINK_WEAPONLESS,
THINK_NOCLIP, THINK_NOCLIP,
THINK_DEAD, THINK_DEAD,
THINK_BADPLACE, // Added in 2.0
THINK_RUN_AND_SHOOT, // Added in 2.30
NUM_THINKS, NUM_THINKS,
}; };
@ -458,6 +461,10 @@ public:
bool m_bAnimating; bool m_bAnimating;
/* Am I a doggo ? */ /* Am I a doggo ? */
bool m_bDog; bool m_bDog;
/* 2.0: ignore bad place? */
bool m_bIgnoreBadPlace;
/* 2.0: bad place index? (0=none) */
int m_iBadPlaceIndex;
/* char refereing to voice type, chec gAmericanVoices and gGermanVoices */ /* char refereing to voice type, chec gAmericanVoices and gGermanVoices */
int mVoiceType; int mVoiceType;
/* check EV_Actor_GetSilent, EV_Actor_SetSilent and EV_Actor_SetSilent2 */ /* check EV_Actor_GetSilent, EV_Actor_SetSilent and EV_Actor_SetSilent2 */
@ -488,6 +495,10 @@ public:
int m_iEnemyVisibleChangeTime; int m_iEnemyVisibleChangeTime;
/* last time a visible(CanSee) enemy was seen */ /* last time a visible(CanSee) enemy was seen */
int m_iLastEnemyVisibleTime; int m_iLastEnemyVisibleTime;
/* 2.0: visibility alpha */
float m_fVisibilityAlpha;
/* 2.0: max visibility threshold */
float m_fVisibilityThreshold;
/* last time a visible(CanSee + infov) enemy was checked */ /* last time a visible(CanSee + infov) enemy was checked */
int m_iEnemyFovCheckTime; int m_iEnemyFovCheckTime;
/* last time a visible(CanSee + infov) enemy was changed */ /* last time a visible(CanSee + infov) enemy was changed */
@ -500,6 +511,8 @@ public:
float m_fMaxShareDistSquared; float m_fMaxShareDistSquared;
/* can actor shoot enemy ? */ /* can actor shoot enemy ? */
bool m_bCanShootEnemy; bool m_bCanShootEnemy;
/* 2.0: does it has visibility threshold set? */
bool m_bHasVisibilityThreshold;
/* last time m_bCanShootEnemy was changed */ /* last time m_bCanShootEnemy was changed */
int m_iCanShootCheckTime; int m_iCanShootCheckTime;
/* desired enable enemy(changed from script) */ /* desired enable enemy(changed from script) */
@ -530,6 +543,8 @@ public:
const_str m_csAnimScript; const_str m_csAnimScript;
/* anim mode */ /* anim mode */
int m_AnimMode; int m_AnimMode;
/* 2.0: the run anim rate */
float m_fRunAnimRate;
/* Don't Face Wall request yaw. */ /* Don't Face Wall request yaw. */
float m_fDfwRequestedYaw; float m_fDfwRequestedYaw;
/* Don't Face Wall derived yaw. */ /* Don't Face Wall derived yaw. */
@ -594,6 +609,10 @@ public:
SafePtr<SimpleEntity> m_AlarmNode; SafePtr<SimpleEntity> m_AlarmNode;
/* alarm thread for actor */ /* alarm thread for actor */
ScriptThreadLabel m_AlarmThread; ScriptThreadLabel m_AlarmThread;
/* 2.30: pre-alarm thread for actor */
ScriptThreadLabel m_PreAlarmThread;
/* 2.0: Suppress chance */
int m_iSuppressChance;
/* used for turret actot to run back to home Turret_SelectState() */ /* used for turret actot to run back to home Turret_SelectState() */
int m_iRunHomeTime; int m_iRunHomeTime;
/* no cover path for initial turret state */ /* no cover path for initial turret state */
@ -612,6 +631,8 @@ public:
bool m_bNeedReload; bool m_bNeedReload;
/* should break(stop) special attack ? */ /* should break(stop) special attack ? */
bool mbBreakSpecialAttack; bool mbBreakSpecialAttack;
/* 2.30: is the AI curious? */
bool m_bIsCurious;
/* grenade has bounced ? (usually means actor should flee) */ /* grenade has bounced ? (usually means actor should flee) */
bool m_bGrenadeBounced; bool m_bGrenadeBounced;
/* current grenade */ /* current grenade */
@ -723,6 +744,10 @@ public:
float m_fLeashSquared; float m_fLeashSquared;
/* if true, leash will not change. */ /* if true, leash will not change. */
bool m_bFixedLeash; bool m_bFixedLeash;
/* 2.0: if true, enemy switch will be disabled. */
bool m_bEnemySwitch;
/* 2.30: the nationality index. */
int m_iNationality;
public: public:
CLASS_PROTOTYPE(Actor); CLASS_PROTOTYPE(Actor);
@ -751,6 +776,7 @@ public:
bool RequireThink(void); bool RequireThink(void);
void UpdateEnemy(int iMaxDirtyTime); void UpdateEnemy(int iMaxDirtyTime);
void UpdateEnemyInternal(void); void UpdateEnemyInternal(void);
void DetectSmokeGrenades(void);
void SetEnemy(Sentient *pEnemy, bool bForceConfirmed); void SetEnemy(Sentient *pEnemy, bool bForceConfirmed);
void SetEnemyPos(Vector vPos); void SetEnemyPos(Vector vPos);
static void ResetBodyQueue(void); static void ResetBodyQueue(void);
@ -764,6 +790,7 @@ public:
void CheckForThinkStateTransition(void); void CheckForThinkStateTransition(void);
bool CheckForTransition(eThinkState state, eThinkLevel level); bool CheckForTransition(eThinkState state, eThinkLevel level);
bool PassesTransitionConditions_Grenade(void); bool PassesTransitionConditions_Grenade(void);
bool PassesTransitionConditions_BadPlace(void); // Added in 2.0
bool PassesTransitionConditions_Attack(void); bool PassesTransitionConditions_Attack(void);
bool PassesTransitionConditions_Disguise(void); bool PassesTransitionConditions_Disguise(void);
bool PassesTransitionConditions_Curious(void); bool PassesTransitionConditions_Curious(void);
@ -805,6 +832,8 @@ public:
void State_Turret_Grenade(void); void State_Turret_Grenade(void);
void State_Turret_FakeEnemy(void); void State_Turret_FakeEnemy(void);
void State_Turret_Wait(void); void State_Turret_Wait(void);
void State_Turret_Retarget_Shoot(void); // Added in 2.0
void State_Turret_Retarget_Suppress(void); // Added in 2.0
void State_Turret_Retarget_Sniper_Node(void); void State_Turret_Retarget_Sniper_Node(void);
void State_Turret_Retarget_Step_Side_Small(void); void State_Turret_Retarget_Step_Side_Small(void);
void State_Turret_Retarget_Path_Exact(void); void State_Turret_Retarget_Path_Exact(void);
@ -951,11 +980,12 @@ public:
void Begin_MachineGunner(void); void Begin_MachineGunner(void);
void End_MachineGunner(void); void End_MachineGunner(void);
void BecomeTurretGuy(void); void BecomeTurretGuy(void);
void ThinkHoldGun_TurretGun(void); // Added in 2.0
void Think_MachineGunner_TurretGun(void); // Added in 2.0
void Think_MachineGunner(void); void Think_MachineGunner(void);
void ThinkHoldGun(void); void ThinkHoldGun(void);
void FinishedAnimation_MachineGunner(void); void FinishedAnimation_MachineGunner(void);
bool MachineGunner_CanSee(Entity *ent, float fov, float vision_distance); bool MachineGunner_CanSee(Entity *ent, float fov, float vision_distance);
void CanSee(Event *ev);
static void InitDogIdle(GlobalFuncs_t *func); static void InitDogIdle(GlobalFuncs_t *func);
static void InitDogAttack(GlobalFuncs_t *func); static void InitDogAttack(GlobalFuncs_t *func);
static void InitDogCurious(GlobalFuncs_t *func); static void InitDogCurious(GlobalFuncs_t *func);
@ -1014,6 +1044,24 @@ public:
void FinishedAnimation_Weaponless(void); void FinishedAnimation_Weaponless(void);
void State_Weaponless_Normal(void); void State_Weaponless_Normal(void);
void State_Weaponless_Grenade(void); void State_Weaponless_Grenade(void);
static void InitBadPlace(GlobalFuncs_t *func);
// Added in 2.0
//====
void Begin_BadPlace(void);
void End_BadPlace(void);
void Think_BadPlace(void);
//====
// Added in 2.30
//====
static void InitRunAndShot(GlobalFuncs_t *func);
void Begin_RunAndShoot(void);
void End_RunAndShoot(void);
void Resume_RunAndShoot(void);
void Think_RunAndShoot(void);
void ShowInfo_RunAndShoot(void);
void State_RunAndShoot_Running(void);
void RunAndShoot_MoveToPatrolCurrentNode(void);
//====
virtual void Think(void) override; virtual void Think(void) override;
void PostThink(bool bDontFaceWall); void PostThink(bool bDontFaceWall);
virtual void SetMoveInfo(mmove_t *mm) override; virtual void SetMoveInfo(mmove_t *mm) override;
@ -1025,6 +1073,8 @@ public:
void EventGiveWeapon(Event *ev); void EventGiveWeapon(Event *ev);
void EventGetWeapon(Event *ev); void EventGetWeapon(Event *ev);
void FireWeapon(Event *ev); void FireWeapon(Event *ev);
bool FriendlyInLineOfFire(Entity *other); // Added in 2.0
Vector VirtualEyePosition(); // Added in 2.0
virtual bool CanTarget(void) override; virtual bool CanTarget(void) override;
virtual bool IsImmortal(void) override; virtual bool IsImmortal(void) override;
static bool IsVoidState(int state); static bool IsVoidState(int state);
@ -1033,6 +1083,7 @@ public:
static bool IsDisguiseState(int state); static bool IsDisguiseState(int state);
static bool IsAttackState(int state); static bool IsAttackState(int state);
static bool IsGrenadeState(int state); static bool IsGrenadeState(int state);
static bool IsBadPlaceState(int state); // Added in 2.0
static bool IsPainState(int state); static bool IsPainState(int state);
static bool IsKilledState(int state); static bool IsKilledState(int state);
static bool IsMachineGunnerState(int state); static bool IsMachineGunnerState(int state);
@ -1055,6 +1106,7 @@ public:
void VoiceSound(int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator); void VoiceSound(int iType, vec3_t sound_origin, float fDistSquared, float fMaxDistSquared, Entity *originator);
void GrenadeNotification(Entity *originator); void GrenadeNotification(Entity *originator);
void SetGrenade(Entity *pGrenade); void SetGrenade(Entity *pGrenade);
void UpdateBadPlaces(void); // Added in 2.0
void NotifySquadmateKilled(Sentient *pSquadMate, Sentient *pAttacker); void NotifySquadmateKilled(Sentient *pSquadMate, Sentient *pAttacker);
void RaiseAlertnessForEventType(int iType); void RaiseAlertnessForEventType(int iType);
void RaiseAlertness(float fAmount); void RaiseAlertness(float fAmount);
@ -1131,6 +1183,7 @@ public:
void PlayAnimation(Event *ev); void PlayAnimation(Event *ev);
void PlayScriptedAnimation(Event *ev); void PlayScriptedAnimation(Event *ev);
void PlayNoclipAnimation(Event *ev); void PlayNoclipAnimation(Event *ev);
void PlayAttachedAnimation(Event *ev); // Added in 2.0
void MoveDest(float fMoveSpeed); void MoveDest(float fMoveSpeed);
void MovePath(float fMoveSpeed); void MovePath(float fMoveSpeed);
void MovePathGoal(float fMoveSpeed); void MovePathGoal(float fMoveSpeed);
@ -1225,6 +1278,7 @@ public:
void ForceAttackPlayer(void); void ForceAttackPlayer(void);
void EventSetAlarmNode(Event *ev); void EventSetAlarmNode(Event *ev);
void EventGetAlarmNode(Event *ev); void EventGetAlarmNode(Event *ev);
void EventSetPreAlarmThread(Event *ev); // Added in 2.30
void EventSetAlarmThread(Event *ev); void EventSetAlarmThread(Event *ev);
void EventGetAlarmThread(Event *ev); void EventGetAlarmThread(Event *ev);
void EventSetSoundAwareness(Event *ev); void EventSetSoundAwareness(Event *ev);
@ -1241,9 +1295,18 @@ public:
void EventGetAmmoGrenade(Event *ev); void EventGetAmmoGrenade(Event *ev);
void EventSetAmmoGrenade(Event *ev); void EventSetAmmoGrenade(Event *ev);
void EventInterruptPoint(Event *ev); void EventInterruptPoint(Event *ev);
// Added in 2.0
//====
void EventGetVisibilityThreshold(Event *ev);
void EventSetVisibilityThreshold(Event *ev);
void EventSetDefaultVisibilityThreshold(Event *ev);
void EventGetSuppressChance(Event *ev);
void EventSetSuppressChance(Event *ev);
//====
void EventAnimScript(Event *ev); void EventAnimScript(Event *ev);
void EventAnimScript_Scripted(Event *ev); void EventAnimScript_Scripted(Event *ev);
void EventAnimScript_Noclip(Event *ev); void EventAnimScript_Noclip(Event *ev);
void EventAnimScript_Attached(Event *ev);
void EventReload_mg42(Event *ev); void EventReload_mg42(Event *ev);
void SetPathWithLeash(Vector vDestPos, const char *description, int iMaxDirtyTime); void SetPathWithLeash(Vector vDestPos, const char *description, int iMaxDirtyTime);
void SetPathWithLeash(SimpleEntity *pDestNode, const char *description, int iMaxDirtyTime); void SetPathWithLeash(SimpleEntity *pDestNode, const char *description, int iMaxDirtyTime);
@ -1267,7 +1330,9 @@ public:
void EventSetFixedLeash(Event *ev); void EventSetFixedLeash(Event *ev);
void EventGetFixedLeash(Event *ev); void EventGetFixedLeash(Event *ev);
void Holster(void); void Holster(void);
void HolsterOffHand(void); // Added in 2.0
void Unholster(void); void Unholster(void);
void UnholsterOffHand(void); // Added in 2.0
void EventHolster(Event *ev); void EventHolster(Event *ev);
void EventUnholster(Event *ev); void EventUnholster(Event *ev);
void EventSoundDone(Event *ev); void EventSoundDone(Event *ev);
@ -1290,11 +1355,13 @@ public:
void EventSetNoLongPain(Event *ev); void EventSetNoLongPain(Event *ev);
void EventGetFavoriteEnemy(Event *ev); void EventGetFavoriteEnemy(Event *ev);
void EventSetFavoriteEnemy(Event *ev); void EventSetFavoriteEnemy(Event *ev);
void EventFindEnemy(Event *ev); // Added in 2.0
void EventGetMumble(Event *ev); void EventGetMumble(Event *ev);
void EventSetMumble(Event *ev); void EventSetMumble(Event *ev);
void EventGetBreathSteam(Event *ev); void EventGetBreathSteam(Event *ev);
void EventSetBreathSteam(Event *ev); void EventSetBreathSteam(Event *ev);
void EventSetNextBreathTime(Event *ev); void EventSetNextBreathTime(Event *ev);
void EventCalcGrenadeToss2(Event *ev);
void EventCalcGrenadeToss(Event *ev); void EventCalcGrenadeToss(Event *ev);
void EventGetNoSurprise(Event *ev); void EventGetNoSurprise(Event *ev);
void EventSetNoSurprise(Event *ev); void EventSetNoSurprise(Event *ev);
@ -1317,6 +1384,25 @@ public:
void ResolveVoiceType(void); void ResolveVoiceType(void);
void EventSetBalconyHeight(Event *ev); void EventSetBalconyHeight(Event *ev);
void EventGetBalconyHeight(Event *ev); void EventGetBalconyHeight(Event *ev);
// Added in 2.0
//====
void EventSetIgnoreBadPlace(Event *ev);
void EventGetIgnoreBadPlace(Event *ev);
void EventEnableEnemySwitch(Event *ev);
void EventDisableEnemySwitch(Event *ev);
void EventSetRunAnimRate(Event *ev);
void EventGetRunAnimRate(Event *ev);
void Landed(Event *ev);
bool IsOnFloor(void);
//====
// Added in 2.30
//====
void GetNationality(Event *ev);
void SetNationality(Event *ev);
void EventWriteStats(Event *ev);
void EventCuriousOff(Event *ev);
void EventCuriousOn(Event *ev);
//====
PathNode *FindSniperNodeAndSetPath(bool *pbTryAgain); PathNode *FindSniperNodeAndSetPath(bool *pbTryAgain);
void Remove(Event *ev); void Remove(Event *ev);
void DontFaceWall(void); void DontFaceWall(void);
@ -1328,13 +1414,15 @@ public:
virtual void PathnodeClaimRevoked(PathNode *node) override; virtual void PathnodeClaimRevoked(PathNode *node) override;
void SetPathToNotBlockSentient(Sentient *pOther); void SetPathToNotBlockSentient(Sentient *pOther);
void EventSetMoveDoneRadius(Event *ev); void EventSetMoveDoneRadius(Event *ev);
void EventGetMoveDoneRadius(Event *ev); // Added in 2.0
virtual void ClearEnemies(void) override; virtual void ClearEnemies(void) override;
bool EnemyIsDisguised(void); bool EnemyIsDisguised(void);
virtual void setOriginEvent(Vector org) override; virtual void setOriginEvent(Vector org) override;
virtual void DumpAnimInfo(void) override; virtual void DumpAnimInfo(void) override;
static void ArchiveStatic(Archiver &arc); static void ArchiveStatic(Archiver &arc);
virtual void Archive(Archiver &arc) override; virtual void Archive(Archiver& arc) override;
virtual bool AutoArchiveModel(void) override; virtual bool AutoArchiveModel(void) override;
virtual bool IsDisabled() const override; // Added in 2.30
}; };
#define SAVE_FLAG_NEW_ANIM (1 << 0) #define SAVE_FLAG_NEW_ANIM (1 << 0)
@ -1361,6 +1449,213 @@ public:
#define SAVE_FLAG_PAIN (1 << 21) #define SAVE_FLAG_PAIN (1 << 21)
#define SAVE_FLAG_SPAWN_ITEMS (1 << 22) #define SAVE_FLAG_SPAWN_ITEMS (1 << 22)
/*
===============
Actor::TransitionState
===============
*/
inline void Actor::TransitionState(int iNewState, int iPadTime)
{
//fixme: this is an inline function.
m_State = iNewState;
m_iStateTime = level.inttime + iPadTime;
}
/*
===============
Actor::NextUpdateTime
Returns next update time.
===============
*/
inline int Actor::NextUpdateTime(int iLastUpdateTime, int iUpdatePeriod)
{
int i = iLastUpdateTime;
do {
i += iUpdatePeriod;
} while (i < level.inttime);
return i;
}
/*
===============
Actor::InFOV
Returns true if pos is within fov.
===============
*/
inline bool Actor::InFOV(Vector pos)
{
return InFOV(pos, m_fFov, m_fFovDot);
}
/*
===============
Actor::InFOV
Returns true if ent is within fov.
===============
*/
inline bool Actor::InFOV(Entity *ent)
{
if (ent == m_Enemy) {
return EnemyInFOV(0);
} else {
return InFOV(ent->centroid, m_fFov, m_fFovDot);
}
}
inline bool Actor::CanSeeNoFOV(Entity *ent)
{
if (ent == m_Enemy) {
return CanSeeEnemy(0);
} else {
bool bCanSee = false;
if (gi.AreasConnected(edict->r.areanum, ent->edict->r.areanum)) {
bCanSee = CanSeeFrom(EyePosition(), ent);
}
return bCanSee;
}
}
inline bool Actor::CanSeeFOV(Entity *ent)
{
//fixme: this is an inline function.
if (ent == m_Enemy) {
return CanSeeEnemyFOV(0, 0);
} else {
bool bCanSee = false;
if (InFOV(ent->centroid, m_fFov, m_fFovDot) && gi.AreasConnected(edict->r.areanum, ent->edict->r.areanum)) {
bCanSee = CanSeeFrom(EyePosition(), ent);
}
return bCanSee;
}
}
inline bool Actor::CanSeeEnemyFOV(int iMaxFovDirtyTime, int iMaxSightDirtyTime)
{
return EnemyInFOV(iMaxFovDirtyTime) && CanSeeEnemy(iMaxSightDirtyTime);
}
/*
===============
Actor::AimAtTargetPos
Aim at mTargetPos.
===============
*/
inline void Actor::AimAtTargetPos(void)
{
Vector vDir = mTargetPos - EyePosition() + Vector(0, 0, 16);
SetDesiredLookDir(vDir);
m_DesiredGunDir[0] = 360.0f - vDir.toPitch();
m_DesiredGunDir[1] = vDir.toYaw();
m_DesiredGunDir[2] = 0;
SetDesiredYawDir(vDir);
}
/*
===============
Actor::AimAtAimNode
Aim at m_aimNode.
===============
*/
inline void Actor::AimAtAimNode(void)
{
mTargetPos = m_aimNode->origin;
AimAtTargetPos();
}
/*
===============
Actor::IgnoreSoundSet
Make actor ignore iType sound.
===============
*/
inline void Actor::IgnoreSoundSet(int iType)
{
m_iIgnoreSoundsMask |= 1 << iType;
}
/*
===============
Actor::IgnoreSoundSetAll
Make actor ignore all types of sound.
===============
*/
inline void Actor::IgnoreSoundSetAll(void)
{
m_iIgnoreSoundsMask = ~AI_EVENT_NONE;
}
/*
===============
Actor::IgnoreSoundClear
Don't ignore iType of sound.
===============
*/
inline void Actor::IgnoreSoundClear(int iType)
{
m_iIgnoreSoundsMask &= ~iType;
}
/*
===============
Actor::IgnoreSoundClearAll
Make actor ignore no type of sound.
===============
*/
inline void Actor::IgnoreSoundClearAll(void)
{
m_iIgnoreSoundsMask = 0;
}
/*
===============
Actor::IgnoreSoundClearAll
returns true if actor should ignore iType of sound.
===============
*/
inline bool Actor::IgnoreSound(int iType)
{
return (m_iIgnoreSoundsMask >> iType) & 1;
}
/*
===============
Actor::CurrentThink
Current think.
===============
*/
inline int Actor::CurrentThink(void) const
{
return m_Think[m_ThinkLevel];
}
/*
===============
Actor::IsAttacking
Returns true if actor is in attack state.
===============
*/
inline bool Actor::IsAttacking(void) const
{
return m_ThinkStates[THINKLEVEL_NORMAL] == THINKSTATE_ATTACK;
}
inline void Actor::ArchiveStatic(Archiver& arc) inline void Actor::ArchiveStatic(Archiver& arc)
{ {
for (int i = MAX_BODYQUEUE - 1; i >= 0; i--) { for (int i = MAX_BODYQUEUE - 1; i >= 0; i--) {
@ -1569,6 +1864,54 @@ inline void Actor::Archive(Archiver& arc)
setModel(); setModel();
} }
/*
===============
Actor::SetDesiredLookDir
Change desired look direction.
===============
*/
inline void Actor::SetDesiredLookDir(vec3_t dir)
{
m_bHasDesiredLookAngles = true;
vectoangles(dir, m_DesiredLookAngles);
m_DesiredLookAngles[1] = m_DesiredLookAngles[1] - angles[1];
m_DesiredLookAngles[1] = AngleNormalize180(m_DesiredLookAngles[1]);
m_DesiredLookAngles[0] = AngleNormalize180(m_DesiredLookAngles[0]);
}
/*
===============
Actor::SetDesiredLookAnglesRelative
Change desired look angles relatively.
===============
*/
inline void Actor::SetDesiredLookAnglesRelative(vec3_t ang)
{
m_bHasDesiredLookAngles = true;
m_DesiredLookAngles[0] = AngleNormalize180(ang[0]);
m_DesiredLookAngles[1] = AngleNormalize180(ang[1]);
m_DesiredLookAngles[2] = AngleNormalize180(ang[2]);
}
/*
===============
Actor::ForwardLook
===============
*/
inline void Actor::ForwardLook(void)
{
m_bHasDesiredLookAngles = false;
}
inline bool Actor::AvoidingFacingWall(void) const
{
return m_eDontFaceWallMode <= 8;
}
#if 0 #if 0
// Set destination to node with duck or cover set. Class will find a path to that node, or a closer one. // Set destination to node with duck or cover set. Class will find a path to that node, or a closer one.

View file

@ -91,6 +91,16 @@ void Actor::End_MachineGunner(void)
} }
} }
void Actor::ThinkHoldGun_TurretGun(void)
{
// FIXME: unimplemented
}
void Actor::Think_MachineGunner_TurretGun(void)
{
// FIXME: unimplemented
}
void Actor::Think_MachineGunner(void) void Actor::Think_MachineGunner(void)
{ {
if (RequireThink()) { if (RequireThink()) {

View file

@ -726,6 +726,16 @@ void Actor::State_Turret_Wait(void)
} }
} }
void Actor::State_Turret_Retarget_Shoot(void)
{
// FIXME: unimplemented
}
void Actor::State_Turret_Retarget_Suppress(void)
{
// FIXME: unimplemented
}
void Actor::State_Turret_Retarget_Sniper_Node(void) void Actor::State_Turret_Retarget_Sniper_Node(void)
{ {
PathNode *pSniperNode; PathNode *pSniperNode;