From 47f09c61fcd7e1d9dd7e411aa1a112d80bbdc4ac Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 5 Oct 2023 16:50:46 +0200 Subject: [PATCH] WIP for event callback refactor --- source/games/blood/src/actor.cpp | 48 ++-- source/games/blood/src/actor.h | 2 +- source/games/blood/src/ai.cpp | 12 +- source/games/blood/src/aitchern.cpp | 2 +- source/games/blood/src/aiunicult.cpp | 4 +- source/games/blood/src/blood.h | 212 +++++++++++++++++ source/games/blood/src/callback.cpp | 112 ++------- source/games/blood/src/callback.h | 35 --- source/games/blood/src/eventq.cpp | 24 +- source/games/blood/src/eventq.h | 8 +- source/games/blood/src/fx.cpp | 130 +++++------ source/games/blood/src/messages.cpp | 4 +- source/games/blood/src/nnexts.cpp | 64 +++--- source/games/blood/src/player.cpp | 6 +- source/games/blood/src/seq.cpp | 2 +- source/games/blood/src/triggers.cpp | 6 +- source/games/blood/src/vmexports.cpp | 214 +----------------- source/games/blood/src/weapon.cpp | 6 +- .../static/zscript/games/blood/bloodactor.zs | 35 +-- 19 files changed, 400 insertions(+), 526 deletions(-) diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index db8e0ce39..b19289121 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -2190,7 +2190,7 @@ static void zombieAxeNormalDeath(DBloodActor* actor, int nSeq) else if (nSeq == 1 && Chance(0x4000)) { seqSpawn(pDudeInfo->seqStartID + 7, actor, nDudeToGibClient1); - evPostActor(actor, 0, kCallbackFXZombieSpurt); + evPostActor(actor, 0, AF(fxZombieBloodSpurt)); sfxPlay3DSound(actor, 362, -1, 0); actor->xspr.data1 = 35; actor->xspr.data2 = 5; @@ -2823,7 +2823,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) if (hitCode == 3 && actorHit && (pThingInfo || pDudeInfo)) { if (pThingInfo && actorHit->GetType() == kThingTNTBarrel && actorHit->xspr.burnTime == 0) - evPostActor(actorHit, 0, kCallbackFXFlameLick); + evPostActor(actorHit, 0, AF(fxFlameLick)); int nDamage = (50 + Random(50)) << 4; actDamageSprite(missileOwner, actorHit, kDamageBullet, nDamage); @@ -2843,7 +2843,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) if ((pThingInfo && pThingInfo->dmgControl[kDamageBurn] != 0) || (pDudeInfo && pDudeInfo->damageVal[kDamageBurn] != 0)) { if (pThingInfo && actorHit->GetType() == kThingTNTBarrel && actorHit->xspr.burnTime == 0) - evPostActor(actorHit, 0, kCallbackFXFlameLick); + evPostActor(actorHit, 0, AF(fxFlameLick)); actBurnSprite(missileOwner, actorHit, 480); actRadiusDamage(missileOwner, missileActor->spr.pos, missileActor->sector(), 16, 20, 10, kDamageBullet, 6, 480); @@ -2882,7 +2882,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) if (hitCode == 3 && actorHit && actorHit->hasX()) { if ((actorHit->spr.statnum == kStatThing || actorHit->spr.statnum == kStatDude) && actorHit->xspr.burnTime == 0) - evPostActor(actorHit, 0, kCallbackFXFlameLick); + evPostActor(actorHit, 0, AF(fxFlameLick)); actBurnSprite(missileOwner, actorHit, (4 + gGameOptions.nDifficulty) << 2); actDamageSprite(missileOwner, actorHit, kDamageBurn, 8); @@ -2894,7 +2894,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) if (hitCode == 3 && actorHit && actorHit->hasX()) { if ((actorHit->spr.statnum == kStatThing || actorHit->spr.statnum == kStatDude) && actorHit->xspr.burnTime == 0) - evPostActor(actorHit, 0, kCallbackFXFlameLick); + evPostActor(actorHit, 0, AF(fxFlameLick)); actBurnSprite(missileOwner, actorHit, (4 + gGameOptions.nDifficulty) << 2); actDamageSprite(missileOwner, actorHit, kDamageBurn, 8); @@ -2909,7 +2909,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) if (hitCode == 3 && actorHit && actorHit->hasX()) { if ((actorHit->spr.statnum == kStatThing || actorHit->spr.statnum == kStatDude) && actorHit->xspr.burnTime == 0) - evPostActor(actorHit, 0, kCallbackFXFlameLick); + evPostActor(actorHit, 0, AF(fxFlameLick)); actBurnSprite(missileOwner, actorHit, 32); actDamageSprite(missileOwner, actorHit, kDamageSpirit, 12); @@ -3871,7 +3871,7 @@ void MoveDude(DBloodActor* actor) pPlayer->posture = 1; actor->xspr.burnTime = 0; pPlayer->bubbleTime = int(abs(actor->vel.Z * 16)); - evPostActor(actor, 0, kCallbackPlayerBubble); + evPostActor(actor, 0, AF(PlayerBubble)); sfxPlay3DSound(actor, 720, -1, 0); } else @@ -3881,7 +3881,7 @@ void MoveDude(DBloodActor* actor) case kDudeCultistTommy: case kDudeCultistShotgun: actor->xspr.burnTime = 0; - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); sfxPlay3DSound(actor, 720, -1, 0); aiNewState(actor, &cultistSwimGoto); break; @@ -3895,26 +3895,26 @@ void MoveDude(DBloodActor* actor) if (fixRandomCultist) // fix burning cultists randomly switching types underwater actor->ChangeType(actor->spr.inittype); // restore back to spawned cultist type actor->xspr.burnTime = 0; - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); sfxPlay3DSound(actor, 720, -1, 0); aiNewState(actor, &cultistSwimGoto); break; } case kDudeZombieAxeNormal: actor->xspr.burnTime = 0; - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); sfxPlay3DSound(actor, 720, -1, 0); aiNewState(actor, &zombieAGoto); break; case kDudeZombieButcher: actor->xspr.burnTime = 0; - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); sfxPlay3DSound(actor, 720, -1, 0); aiNewState(actor, &zombieFGoto); break; case kDudeGillBeast: actor->xspr.burnTime = 0; - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); sfxPlay3DSound(actor, 720, -1, 0); aiNewState(actor, &gillBeastSwimGoto); @@ -3937,7 +3937,7 @@ void MoveDude(DBloodActor* actor) if (actor->GetType() == kDudeModernCustom) { - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); if (!canSwim(actor)) actKillDude(actor, actor, kDamageFall, 1000 << 4); break; } @@ -4587,12 +4587,12 @@ static void actCheckThings() if (hit.type == kHitSector) { actRadiusDamage(actor->GetOwner(), actor->spr.pos, actor->sector(), 200, 1, 20, kDamageExplode, 6, 0); - evPostActor(actor, 0, kCallbackFXPodBloodSplat); + evPostActor(actor, 0, AF(fxPodBloodSplat)); } else if (hit.type == kHitSprite) { actDamageSprite(actor->GetOwner(), hit.actor(), kDamageFall, 12); - evPostActor(actor, 0, kCallbackFXPodBloodSplat); + evPostActor(actor, 0, AF(fxPodBloodSplat)); } break; @@ -4687,7 +4687,7 @@ static void actCheckExplosion() if (pExplodeInfo->burnTime && dudeactor->hasX()) { - if (!dudeactor->xspr.burnTime) evPostActor(dudeactor, 0, kCallbackFXFlameLick); + if (!dudeactor->xspr.burnTime) evPostActor(dudeactor, 0, AF(fxFlameLick)); actBurnSprite(Owner, dudeactor, pExplodeInfo->burnTime << 2); } } @@ -4710,7 +4710,7 @@ static void actCheckExplosion() if (pExplodeInfo->burnTime) { if (thingactor->GetType() == kThingTNTBarrel && !thingactor->xspr.burnTime) - evPostActor(thingactor, 0, kCallbackFXFlameLick); + evPostActor(thingactor, 0, AF(fxFlameLick)); actBurnSprite(Owner, thingactor, pExplodeInfo->burnTime << 2); } } @@ -5230,17 +5230,17 @@ DBloodActor* actSpawnThing(sectortype* pSector, const DVector3& pos, int nThingT break; case kThingArmedTNTStick: - evPostActor(actor, 0, kCallbackFXDynPuff); + evPostActor(actor, 0, AF(fxDynPuff)); sfxPlay3DSound(actor, 450, 0, 0); break; case kThingArmedTNTBundle: sfxPlay3DSound(actor, 450, 0, 0); - evPostActor(actor, 0, kCallbackFXDynPuff); + evPostActor(actor, 0, AF(fxDynPuff)); break; case kThingArmedSpray: - evPostActor(actor, 0, kCallbackFXDynPuff); + evPostActor(actor, 0, AF(fxDynPuff)); break; } return actor; @@ -5300,7 +5300,7 @@ bool actCheckRespawn(DBloodActor* actor) actor->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; actor->spr.pos = actor->basePoint; } - evPostActor(actor, nRespawnTime, kCallbackRespawn); + evPostActor(actor, nRespawnTime, AF(Respawn)); } return 1; } @@ -5435,7 +5435,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3 } if (pVectorData->burnTime) { - if (!actor->xspr.burnTime) evPostActor(actor, 0, kCallbackFXFlameLick); + if (!actor->xspr.burnTime) evPostActor(actor, 0, AF(fxFlameLick)); actBurnSprite(shooter->GetOwner(), actor, pVectorData->burnTime); } } @@ -5463,7 +5463,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3 } if (pVectorData->burnTime) { - if (!actor->xspr.burnTime) evPostActor(actor, 0, kCallbackFXFlameLick); + if (!actor->xspr.burnTime) evPostActor(actor, 0, AF(fxFlameLick)); actBurnSprite(shooter->GetOwner(), actor, pVectorData->burnTime); } if (Chance(pVectorData->fxChance)) @@ -5518,7 +5518,7 @@ void actFireVector(DBloodActor* shooter, double offset, double zoffset, DVector3 actor->vel += dv * thrust; if (pVectorData->burnTime != 0) { - if (!actor->xspr.burnTime) evPostActor(actor, 0, kCallbackFXFlameLick); + if (!actor->xspr.burnTime) evPostActor(actor, 0, AF(fxFlameLick)); actBurnSprite(shooter->GetOwner(), actor, pVectorData->burnTime); } diff --git a/source/games/blood/src/actor.h b/source/games/blood/src/actor.h index 71753d42b..99174d089 100644 --- a/source/games/blood/src/actor.h +++ b/source/games/blood/src/actor.h @@ -190,7 +190,7 @@ extern const int16_t DudeDifficulty[]; bool IsUnderwaterSector(sectortype* pSector); -// route state callbacks through the scripting interface. +// route state, seq and event callbacks through the scripting interface. // this needs to work with incomplete data, so avoid the asserting macros. #define DEF_ANIMATOR(func) \ void func(DBloodActor*); \ diff --git a/source/games/blood/src/ai.cpp b/source/games/blood/src/ai.cpp index 135c358e4..bae4aaf01 100644 --- a/source/games/blood/src/ai.cpp +++ b/source/games/blood/src/ai.cpp @@ -1047,7 +1047,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType aiGenDudeNewState(actor, &genDudeBurnGoto); actHealDude(actor, dudeInfo[55].startHealth, dudeInfo[55].startHealth); actor->dudeExtra.time = PlayClock + 360; - evKillActor(actor, kCallbackFXFlameLick); + evKillActor(actor, AF(fxFlameLick)); } } @@ -1121,7 +1121,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType aiPlay3DSound(actor, 1031 + Random(2), AI_SFX_PRIORITY_2, -1); actor->dudeExtra.time = PlayClock + 360; actHealDude(actor, dudeInfo[40].startHealth, dudeInfo[40].startHealth); - evKillActor(actor, kCallbackFXFlameLick); + evKillActor(actor, AF(fxFlameLick)); } break; case kDudeInnocent: @@ -1132,7 +1132,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType aiPlay3DSound(actor, 361, AI_SFX_PRIORITY_0, -1); actor->dudeExtra.time = PlayClock + 360; actHealDude(actor, dudeInfo[39].startHealth, dudeInfo[39].startHealth); - evKillActor(actor, kCallbackFXFlameLick); + evKillActor(actor, AF(fxFlameLick)); } break; case kDudeBurningCultist: @@ -1168,7 +1168,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType actor->ChangeType(kDudeBurningZombieButcher); aiNewState(actor, &zombieFBurnGoto); actHealDude(actor, dudeInfo[42].startHealth, dudeInfo[42].startHealth); - evKillActor(actor, kCallbackFXFlameLick); + evKillActor(actor, AF(fxFlameLick)); } break; case kDudeTinyCaleb: @@ -1187,7 +1187,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType aiPlay3DSound(actor, 361, AI_SFX_PRIORITY_0, -1); actor->dudeExtra.time = PlayClock + 360; actHealDude(actor, dudeInfo[39].startHealth, dudeInfo[39].startHealth); - evKillActor(actor, kCallbackFXFlameLick); + evKillActor(actor, AF(fxFlameLick)); } break; case kDudeCultistBeast: @@ -1208,7 +1208,7 @@ int aiDamageSprite(DBloodActor* source, DBloodActor* actor, DAMAGE_TYPE nDmgType actor->ChangeType(kDudeBurningZombieAxe); aiNewState(actor, &zombieABurnGoto); actHealDude(actor, dudeInfo[41].startHealth, dudeInfo[41].startHealth); - evKillActor(actor, kCallbackFXFlameLick); + evKillActor(actor, AF(fxFlameLick)); } break; } diff --git a/source/games/blood/src/aitchern.cpp b/source/games/blood/src/aitchern.cpp index 1d6006179..3cf759bee 100644 --- a/source/games/blood/src/aitchern.cpp +++ b/source/games/blood/src/aitchern.cpp @@ -52,7 +52,7 @@ void tchernobogFire(DBloodActor* actor) if (!actor->ValidateTarget(__FUNCTION__)) return; auto target = actor->GetTarget(); if (target->xspr.burnTime == 0) - evPostActor(target, 0, kCallbackFXFlameLick); + evPostActor(target, 0, AF(fxFlameLick)); actBurnSprite(actor->GetOwner(), target, 40); if (Chance(0x6000)) aiNewState(actor, &tcherno13A9D4); diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index 442eba990..56e802ad3 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -376,7 +376,7 @@ static void ThrowThing(DBloodActor* actor, bool impact) spawned->xspr.stateTimer = 1; actor->genDudeExtra.pLifeLeech = spawned; - evPostActor(spawned, 80, kCallbackLeechStateTimer); + evPostActor(spawned, 80, AF(LeechStateTimer)); return; } @@ -1791,7 +1791,7 @@ void dudeLeechOperate(DBloodActor* actor, const EVENT& event) { missile->SetOwner(actor); actor->xspr.stateTimer = 1; - evPostActor(actor, t2, kCallbackLeechStateTimer); + evPostActor(actor, t2, AF(LeechStateTimer)); actor->xspr.data3 = ClipLow(actor->xspr.data3 - 1, 0); } actor->spr.Angles.Yaw = angBak; diff --git a/source/games/blood/src/blood.h b/source/games/blood/src/blood.h index e92d31d61..d89f1e27e 100644 --- a/source/games/blood/src/blood.h +++ b/source/games/blood/src/blood.h @@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #pragma once #include "build.h" +#include "vm.h" #include "gamestruct.h" #include "mapinfo.h" #include "d_net.h" @@ -59,6 +60,217 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS +// ai callbacks +DEF_ANIMATOR(aiGenDudeMoveForward) +DEF_ANIMATOR(aiMoveDodge) +DEF_ANIMATOR(aiMoveForward) +DEF_ANIMATOR(aiMoveTurn) +DEF_ANIMATOR(aiPodChase) +DEF_ANIMATOR(aiPodMove) +DEF_ANIMATOR(aiPodSearch) +DEF_ANIMATOR(aiThinkTarget) +DEF_ANIMATOR(batMoveDodgeDown) +DEF_ANIMATOR(batMoveDodgeUp) +DEF_ANIMATOR(batMoveFly) +DEF_ANIMATOR(batMoveForward) +DEF_ANIMATOR(batMoveSwoop) +DEF_ANIMATOR(batMoveToCeil) +DEF_ANIMATOR(batThinkChase) +DEF_ANIMATOR(batThinkGoto) +DEF_ANIMATOR(batThinkPonder) +DEF_ANIMATOR(batThinkSearch) +DEF_ANIMATOR(batThinkTarget) +DEF_ANIMATOR(beastMoveForward) +DEF_ANIMATOR(beastThinkChase) +DEF_ANIMATOR(beastThinkGoto) +DEF_ANIMATOR(beastThinkSearch) +DEF_ANIMATOR(beastThinkSwimChase) +DEF_ANIMATOR(beastThinkSwimGoto) +DEF_ANIMATOR(burnThinkChase) +DEF_ANIMATOR(burnThinkGoto) +DEF_ANIMATOR(burnThinkSearch) +DEF_ANIMATOR(calebThinkChase) +DEF_ANIMATOR(calebThinkGoto) +DEF_ANIMATOR(calebThinkSearch) +DEF_ANIMATOR(calebThinkSwimChase) +DEF_ANIMATOR(calebThinkSwimGoto) +DEF_ANIMATOR(cerberusThinkChase) +DEF_ANIMATOR(cerberusThinkGoto) +DEF_ANIMATOR(cerberusThinkSearch) +DEF_ANIMATOR(cerberusThinkTarget) +DEF_ANIMATOR(cultThinkChase) +DEF_ANIMATOR(cultThinkGoto) +DEF_ANIMATOR(cultThinkSearch) +DEF_ANIMATOR(eelMoveAscend) +DEF_ANIMATOR(eelMoveDodgeDown) +DEF_ANIMATOR(eelMoveDodgeUp) +DEF_ANIMATOR(eelMoveForward) +DEF_ANIMATOR(eelMoveSwoop) +DEF_ANIMATOR(eelMoveToCeil) +DEF_ANIMATOR(eelThinkChase) +DEF_ANIMATOR(eelThinkGoto) +DEF_ANIMATOR(eelThinkPonder) +DEF_ANIMATOR(eelThinkSearch) +DEF_ANIMATOR(eelThinkTarget) +DEF_ANIMATOR(entryAIdle) +DEF_ANIMATOR(entryEStand) +DEF_ANIMATOR(entryEZombie) +DEF_ANIMATOR(entryFStatue) +DEF_ANIMATOR(entrySStatue) +DEF_ANIMATOR(forcePunch) +DEF_ANIMATOR(gargMoveDodgeDown) +DEF_ANIMATOR(gargMoveDodgeUp) +DEF_ANIMATOR(gargMoveFly) +DEF_ANIMATOR(gargMoveForward) +DEF_ANIMATOR(gargMoveSlow) +DEF_ANIMATOR(gargMoveSwoop) +DEF_ANIMATOR(gargThinkChase) +DEF_ANIMATOR(gargThinkGoto) +DEF_ANIMATOR(gargThinkSearch) +DEF_ANIMATOR(gargThinkTarget) +DEF_ANIMATOR(ghostMoveDodgeDown) +DEF_ANIMATOR(ghostMoveDodgeUp) +DEF_ANIMATOR(ghostMoveFly) +DEF_ANIMATOR(ghostMoveForward) +DEF_ANIMATOR(ghostMoveSlow) +DEF_ANIMATOR(ghostMoveSwoop) +DEF_ANIMATOR(ghostThinkChase) +DEF_ANIMATOR(ghostThinkGoto) +DEF_ANIMATOR(ghostThinkSearch) +DEF_ANIMATOR(ghostThinkTarget) +DEF_ANIMATOR(gillThinkChase) +DEF_ANIMATOR(gillThinkGoto) +DEF_ANIMATOR(gillThinkSearch) +DEF_ANIMATOR(gillThinkSwimChase) +DEF_ANIMATOR(gillThinkSwimGoto) +DEF_ANIMATOR(handThinkChase) +DEF_ANIMATOR(handThinkGoto) +DEF_ANIMATOR(handThinkSearch) +DEF_ANIMATOR(houndThinkChase) +DEF_ANIMATOR(houndThinkGoto) +DEF_ANIMATOR(houndThinkSearch) +DEF_ANIMATOR(innocThinkChase) +DEF_ANIMATOR(innocThinkGoto) +DEF_ANIMATOR(innocThinkSearch) +DEF_ANIMATOR(MorphToBeast) +DEF_ANIMATOR(myThinkSearch) +DEF_ANIMATOR(myThinkTarget) +DEF_ANIMATOR(playStatueBreakSnd) +DEF_ANIMATOR(ratThinkChase) +DEF_ANIMATOR(ratThinkGoto) +DEF_ANIMATOR(ratThinkSearch) +DEF_ANIMATOR(spidThinkChase) +DEF_ANIMATOR(spidThinkGoto) +DEF_ANIMATOR(spidThinkSearch) +DEF_ANIMATOR(sub_628A0) +DEF_ANIMATOR(sub_62AE0) +DEF_ANIMATOR(sub_62D7C) +DEF_ANIMATOR(sub_65D04) +DEF_ANIMATOR(sub_65F44) +DEF_ANIMATOR(sub_661E0) +DEF_ANIMATOR(sub_6CB00) +DEF_ANIMATOR(sub_6CD74) +DEF_ANIMATOR(sub_6D03C) +DEF_ANIMATOR(sub_72580) +DEF_ANIMATOR(sub_725A4) +DEF_ANIMATOR(sub_72850) +DEF_ANIMATOR(tchernobogThinkChase) +DEF_ANIMATOR(unicultThinkChase) +DEF_ANIMATOR(unicultThinkGoto) +DEF_ANIMATOR(unicultThinkSearch) +DEF_ANIMATOR(zombaThinkChase) +DEF_ANIMATOR(zombaThinkGoto) +DEF_ANIMATOR(zombaThinkPonder) +DEF_ANIMATOR(zombaThinkSearch) +DEF_ANIMATOR(zombfThinkChase) +DEF_ANIMATOR(zombfThinkGoto) +DEF_ANIMATOR(zombfThinkSearch) +// seq callbacks +DEF_ANIMATOR(FireballSeqCallback) +DEF_ANIMATOR(Fx33Callback) +DEF_ANIMATOR(NapalmSeqCallback) +DEF_ANIMATOR(Fx32Callback) +DEF_ANIMATOR(TreeToGibCallback) +DEF_ANIMATOR(DudeToGibCallback1) +DEF_ANIMATOR(DudeToGibCallback2) +DEF_ANIMATOR(batBiteSeqCallback) +DEF_ANIMATOR(SlashSeqCallback) +DEF_ANIMATOR(StompSeqCallback) +DEF_ANIMATOR(eelBiteSeqCallback) +DEF_ANIMATOR(BurnSeqCallback) +DEF_ANIMATOR(SeqAttackCallback) +DEF_ANIMATOR(cerberusBiteSeqCallback) +DEF_ANIMATOR(cerberusBurnSeqCallback) +DEF_ANIMATOR(cerberusBurnSeqCallback2) +DEF_ANIMATOR(TommySeqCallback) +DEF_ANIMATOR(TeslaSeqCallback) +DEF_ANIMATOR(ShotSeqCallback) +DEF_ANIMATOR(cultThrowSeqCallback) +DEF_ANIMATOR(cultThrowSeqCallback2) +DEF_ANIMATOR(cultThrowSeqCallback3) +DEF_ANIMATOR(SlashFSeqCallback) +DEF_ANIMATOR(ThrowFSeqCallback) +DEF_ANIMATOR(BlastSSeqCallback) +DEF_ANIMATOR(ThrowSSeqCallback) +DEF_ANIMATOR(ghostSlashSeqCallback) +DEF_ANIMATOR(ghostThrowSeqCallback) +DEF_ANIMATOR(ghostBlastSeqCallback) +DEF_ANIMATOR(GillBiteSeqCallback) +DEF_ANIMATOR(HandJumpSeqCallback) +DEF_ANIMATOR(houndBiteSeqCallback) +DEF_ANIMATOR(houndBurnSeqCallback) +DEF_ANIMATOR(podPlaySound1) +DEF_ANIMATOR(podPlaySound2) +DEF_ANIMATOR(podAttack) +DEF_ANIMATOR(podExplode) +DEF_ANIMATOR(ratBiteSeqCallback) +DEF_ANIMATOR(SpidBiteSeqCallback) +DEF_ANIMATOR(SpidJumpSeqCallback) +DEF_ANIMATOR(SpidBirthSeqCallback) +DEF_ANIMATOR(tchernobogFire) +DEF_ANIMATOR(tchernobogBurnSeqCallback) +DEF_ANIMATOR(tchernobogBurnSeqCallback2) +DEF_ANIMATOR(genDudeAttack1) +DEF_ANIMATOR(punchCallback) +DEF_ANIMATOR(ThrowCallback1) +DEF_ANIMATOR(ThrowCallback2) +DEF_ANIMATOR(HackSeqCallback) +DEF_ANIMATOR(StandSeqCallback) +DEF_ANIMATOR(zombfHackSeqCallback) +DEF_ANIMATOR(PukeSeqCallback) +DEF_ANIMATOR(ThrowSeqCallback) +DEF_ANIMATOR(PlayerSurvive) +DEF_ANIMATOR(PlayerKneelsOver) +DEF_ANIMATOR(FireballTrapSeqCallback) +DEF_ANIMATOR(MGunFireSeqCallback) +DEF_ANIMATOR(MGunOpenSeqCallback) +// event callbacks +DEF_ANIMATOR(fxFlameLick) // 0 +DEF_ANIMATOR(Remove) // 1 +DEF_ANIMATOR(FlareBurst) // 2 +DEF_ANIMATOR(fxFlareSpark) // 3 +DEF_ANIMATOR(fxFlareSparkLite) // 4 +DEF_ANIMATOR(fxZombieBloodSpurt) // 5 +DEF_ANIMATOR(fxBloodSpurt) // 6 +DEF_ANIMATOR(fxArcSpark) // 7 +DEF_ANIMATOR(fxDynPuff) // 8 +DEF_ANIMATOR(Respawn) // 9 +DEF_ANIMATOR(PlayerBubble) // 10 +DEF_ANIMATOR(EnemyBubble) // 11 +DEF_ANIMATOR(FinishHim) // 13 +DEF_ANIMATOR(fxBloodBits) // 14 +DEF_ANIMATOR(fxTeslaAlt) // 15 +DEF_ANIMATOR(fxBouncingSleeve) // 16 +DEF_ANIMATOR(returnFlagToBase) // 17 +DEF_ANIMATOR(fxPodBloodSpray) // 18 +DEF_ANIMATOR(fxPodBloodSplat) // 19 +DEF_ANIMATOR(LeechStateTimer) // 20 +DEF_ANIMATOR(DropVoodooCb) // unused + +DEF_ANIMATOR(callbackMakeMissileBlocking) +DEF_ANIMATOR(GenDudeUpdate) +DEF_ANIMATOR(callbackUniMissileBurst) + enum EFeatureFlags { kFeatureCustomAmmoCount = 1, diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index 60364077e..456970f31 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -59,7 +59,7 @@ void fxFlameLick(DBloodActor* actor) // 0 } } if (actor->xspr.burnTime > 0) - evPostActor(actor, 5, kCallbackFXFlameLick); + evPostActor(actor, 5, AF(fxFlameLick)); } //--------------------------------------------------------------------------- @@ -71,7 +71,7 @@ void fxFlameLick(DBloodActor* actor) // 0 void Remove(DBloodActor* actor) // 1 { if (!actor) return; - evKillActor(actor, kCallbackFXFlareSpark); + evKillActor(actor, AF(fxFlareSpark)); if (actor->hasX()) seqKill(actor); sfxKill3DSound(actor, 0, -1); @@ -101,9 +101,9 @@ void FlareBurst(DBloodActor* actor) // 2 auto spAngVec = DAngle::fromBam(i << 29).ToVector().Rotated90CW() * nRadius; if (i & 1) spAngVec *= 0.5; spawnedactor->vel += DVector3(DVector2(0, spAngVec.X).Rotated(nAngVec.X, nAngVec.Y), spAngVec.Y); - evPostActor(spawnedactor, 960, kCallbackRemove); + evPostActor(spawnedactor, 960, AF(Remove)); } - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); } //--------------------------------------------------------------------------- @@ -122,7 +122,7 @@ void fxFlareSpark(DBloodActor* actor) // 3 pFX->vel.Y = actor->vel.Y + Random2F(0x1aaaa); pFX->vel.Z = actor->vel.Z - Random2F(0x1aaaa); } - evPostActor(actor, 4, kCallbackFXFlareSpark); + evPostActor(actor, 4, AF(fxFlareSpark)); } //--------------------------------------------------------------------------- @@ -141,7 +141,7 @@ void fxFlareSparkLite(DBloodActor* actor) // 4 pFX->vel.Y = actor->vel.Y + Random2F(0x1aaaa); pFX->vel.Z = actor->vel.Z - Random2F(0x1aaaa); } - evPostActor(actor, 12, kCallbackFXFlareSparkLite); + evPostActor(actor, 12, AF(fxFlareSparkLite)); } //--------------------------------------------------------------------------- @@ -165,12 +165,12 @@ void fxZombieBloodSpurt(DBloodActor* actor) // 5 } if (actor->xspr.data1 > 0) { - evPostActor(actor, 4, kCallbackFXZombieSpurt); + evPostActor(actor, 4, AF(fxZombieBloodSpurt)); actor->xspr.data1 -= 4; } else if (actor->xspr.data2 > 0) { - evPostActor(actor, 60, kCallbackFXZombieSpurt); + evPostActor(actor, 60, AF(fxZombieBloodSpurt)); actor->xspr.data1 = 40; actor->xspr.data2--; } @@ -191,7 +191,7 @@ void fxBloodSpurt(DBloodActor* actor) // 6 pFX->spr.Angles.Yaw = nullAngle; pFX->vel = actor->vel * (1./256); } - evPostActor(actor, 6, kCallbackFXBloodSpurt); + evPostActor(actor, 6, AF(fxBloodSpurt)); } //--------------------------------------------------------------------------- @@ -210,7 +210,7 @@ void fxArcSpark(DBloodActor* actor) // 7 pFX->vel.Y = actor->vel.Y + Random2F(0x10000); pFX->vel.Z = actor->vel.Z - Random2F(0x1aaaa); } - evPostActor(actor, 3, kCallbackFXArcSpark); + evPostActor(actor, 3, AF(fxArcSpark)); } //--------------------------------------------------------------------------- @@ -233,7 +233,7 @@ void fxDynPuff(DBloodActor* actor) // 8 pFX->vel = actor->vel; } } - evPostActor(actor, 12, kCallbackFXDynPuff); + evPostActor(actor, 12, AF(fxDynPuff)); } //--------------------------------------------------------------------------- @@ -260,13 +260,13 @@ void Respawn(DBloodActor* actor) // 9 case 1: { int nTime = MulScale(actGetRespawnTime(actor), 0x4000, 16); actor->xspr.respawnPending = 2; - evPostActor(actor, nTime, kCallbackRespawn); + evPostActor(actor, nTime, AF(Respawn)); break; } case 2: { int nTime = MulScale(actGetRespawnTime(actor), 0x2000, 16); actor->xspr.respawnPending = 3; - evPostActor(actor, nTime, kCallbackRespawn); + evPostActor(actor, nTime, AF(Respawn)); break; } case 3: { @@ -358,7 +358,7 @@ void PlayerBubble(DBloodActor* actor) // 10 pFX->vel.Z = actor->vel.Z + Random2F(0x1aaaa); } } - evPostActor(actor, 4, kCallbackPlayerBubble); + evPostActor(actor, 4, AF(PlayerBubble)); } } @@ -389,7 +389,7 @@ void EnemyBubble(DBloodActor* actor) // 11 pFX->vel.Z = actor->vel.Z + Random2F(0x1aaaa); } } - evPostActor(actor, 4, kCallbackEnemeyBubble); + evPostActor(actor, 4, AF(EnemyBubble)); } //--------------------------------------------------------------------------- @@ -416,7 +416,7 @@ void CounterCheck(sectortype* pSector) // 12 } if (nCount < nReq) { - evPostSector(pSector, 5, kCallbackCounterCheck); + evPostSector(pSector, 5, kCmdCallback, nullptr); return; } else { @@ -484,7 +484,7 @@ void fxTeslaAlt(DBloodActor* actor) // 15 pFX->vel.Y = actor->vel.Y + Random2F(0x1aaaa); pFX->vel.Z = actor->vel.Z - Random2F(0x1aaaa); } - evPostActor(actor, 3, kCallbackFXTeslaAlt); + evPostActor(actor, 3, AF(fxTeslaAlt)); } @@ -598,7 +598,7 @@ void returnFlagToBase(DBloodActor* actor) // 17 break; } } - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); } //--------------------------------------------------------------------------- @@ -620,7 +620,7 @@ void fxPodBloodSpray(DBloodActor* actor) // 18 pFX->spr.Angles.Yaw = nullAngle; pFX->vel = actor->vel * (1./256); } - evPostActor(actor, 6, kCallbackFXPodBloodSpray); + evPostActor(actor, 6, AF(fxPodBloodSpray)); } //--------------------------------------------------------------------------- @@ -723,7 +723,7 @@ void DropVoodooCb(DBloodActor* actor) // unused auto Owner = actor->GetOwner(); if (Owner == nullptr) { - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); return; } DBloodPlayer* pPlayer; @@ -733,7 +733,7 @@ void DropVoodooCb(DBloodActor* actor) // unused pPlayer = nullptr; if (!pPlayer) { - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); return; } actor->spr.Angles.Yaw = (Owner->spr.pos - actor->spr.pos).Angle(); @@ -741,7 +741,7 @@ void DropVoodooCb(DBloodActor* actor) // unused { if (actor->xspr.data1 == 0) { - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); return; } @@ -775,7 +775,7 @@ void DropVoodooCb(DBloodActor* actor) // unused int nDmg = actDamageSprite(actor, actor2, kDamageSpirit, actor->xspr.data1 << 4); actor->xspr.data1 = ClipLow(actor->xspr.data1 - nDmg, 0); sub_76A08(actor2, actor, pPlayer2); - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); return; } } @@ -816,7 +816,7 @@ void DropVoodooCb(DBloodActor* actor) // unused if (vd && (Chance(vd) || nextactor == nullptr)) { sub_76A08(actor2, actor, NULL); - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); return; } } @@ -824,70 +824,8 @@ void DropVoodooCb(DBloodActor* actor) // unused } } actor->xspr.data1 = ClipLow(actor->xspr.data1 - 1, 0); - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); } } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void callbackCondition(DBloodActor* actor) -{ - if (actor->xspr.isTriggered) return; - - TRCONDITION const* pCond = &gConditions[actor->xspr.sysData1]; - for (auto& obj : pCond->objects) - { - EVENT evn; - evn.target = obj.obj; - evn.cmd = obj.cmd; - evn.funcID = kCallbackCondition; - useCondition(actor, evn); - } - - evPostActor(actor, actor->xspr.busyTime, kCallbackCondition); - return; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void(*gCallback[kCallbackMax])(DBloodActor*) = -{ - fxFlameLick, - Remove, - FlareBurst, - fxFlareSpark, - fxFlareSparkLite, - fxZombieBloodSpurt, - fxBloodSpurt, - fxArcSpark, - fxDynPuff, - Respawn, - PlayerBubble, - EnemyBubble, - nullptr, - FinishHim, - fxBloodBits, - fxTeslaAlt, - fxBouncingSleeve, - returnFlagToBase, - fxPodBloodSpray, - fxPodBloodSplat, - LeechStateTimer, - DropVoodooCb, // unused - #ifdef NOONE_EXTENSIONS - callbackUniMissileBurst, // the code is in nnexts.cpp - callbackMakeMissileBlocking, // the code is in nnexts.cpp - callbackGenDudeUpdate, // the code is in nnexts.cpp - callbackCondition, - #endif -}; - END_BLD_NS diff --git a/source/games/blood/src/callback.h b/source/games/blood/src/callback.h index 0064e384b..ce234f74f 100644 --- a/source/games/blood/src/callback.h +++ b/source/games/blood/src/callback.h @@ -25,39 +25,4 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS void sleeveStopBouncing(DBloodActor* pSprite); -enum CALLBACK_ID { - kCallbackNone = -1, - kCallbackFXFlameLick = 0, - kCallbackRemove = 1, - kCallbackFXFlareBurst = 2, - kCallbackFXFlareSpark = 3, - kCallbackFXFlareSparkLite = 4, - kCallbackFXZombieSpurt = 5, - kCallbackFXBloodSpurt = 6, - kCallbackFXArcSpark = 7, - kCallbackFXDynPuff = 8, - kCallbackRespawn = 9, - kCallbackPlayerBubble = 10, - kCallbackEnemeyBubble = 11, - kCallbackCounterCheck = 12, - kCallbackFinishHim = 13, - kCallbackFXBloodBits = 14, - kCallbackFXTeslaAlt = 15, - kCallbackFXBouncingSleeve = 16, - kCallbackReturnFlag = 17, - kCallbackFXPodBloodSpray = 18, - kCallbackFXPodBloodSplat = 19, - kCallbackLeechStateTimer = 20, - kCallbackDropVoodoo = 21, // unused -#ifdef NOONE_EXTENSIONS - kCallbackMissileBurst = 22, - kCallbackMissileSpriteBlock = 23, - kCallbackGenDudeUpdate = 24, - kCallbackCondition = 25, -#endif - kCallbackMax, -}; - -extern void(*gCallback[kCallbackMax])(DBloodActor*); - END_BLD_NS diff --git a/source/games/blood/src/eventq.cpp b/source/games/blood/src/eventq.cpp index ebff24dd3..d2cdb96f9 100644 --- a/source/games/blood/src/eventq.cpp +++ b/source/games/blood/src/eventq.cpp @@ -400,9 +400,9 @@ void evPost_(EventObject& eob, unsigned int nDelta, COMMAND_ID command, DBloodAc queue.insert(evn); } -void evPost_(const EventObject& eob, unsigned int nDelta, CALLBACK_ID callback) +void evPost_(const EventObject& eob, unsigned int nDelta, VMFunction* callback) { - EVENT evn = { eob, kCmdCallback, (int16_t)callback, PlayClock + (int)nDelta }; + EVENT evn = { eob, kCmdCallback, callback, PlayClock + (int)nDelta }; queue.insert(evn); } @@ -413,7 +413,7 @@ void evPostActor(DBloodActor* actor, unsigned int nDelta, COMMAND_ID command, DB evPost_(ev, nDelta, command, initiator); } -void evPostActor(DBloodActor* actor, unsigned int nDelta, CALLBACK_ID callback) +void evPostActor(DBloodActor* actor, unsigned int nDelta, VMFunction* callback) { evPost_(EventObject(actor), nDelta, callback); } @@ -424,11 +424,6 @@ void evPostSector(sectortype* sect, unsigned int nDelta, COMMAND_ID command, DBl evPost_(ev, nDelta, command, initiator); } -void evPostSector(sectortype* sect, unsigned int nDelta, CALLBACK_ID callback) -{ - evPost_(EventObject(sect), nDelta, callback); -} - void evPostWall(walltype* wal, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator) { auto ev = EventObject(wal); @@ -460,7 +455,7 @@ void evKill_(const EventObject& eob, DBloodActor* initiator) } } -void evKill_(const EventObject& eob, CALLBACK_ID cb) +void evKill_(const EventObject& eob, VMFunction* cb) { for (auto ev = queue.begin(); ev != queue.end();) { @@ -482,7 +477,7 @@ void evKillActor(DBloodActor* actor, DBloodActor* initiator) evKill_(EventObject(actor), initiator); } -void evKillActor(DBloodActor* actor, CALLBACK_ID cb) +void evKillActor(DBloodActor* actor, VMFunction* cb) { evKill_(EventObject(actor)); } @@ -553,9 +548,12 @@ void evProcess(unsigned int time) if (event.cmd == kCmdCallback) { // Except for CounterCheck all other callbacks are for actors only. - assert(event.funcID < kCallbackMax); - if (event.target.isActor()) gCallback[event.funcID](event.target.actor()); - else if (event.target.isSector() && event.funcID == kCallbackCounterCheck) CounterCheck(event.target.sector()); + if (event.target.isActor()) + { + callActorFunction(event.funcID, event.target.actor()); + } + // this is the only one, so no further checks for now. + else if (event.target.isSector()) CounterCheck(event.target.sector()); // no case for walls defined here. } else diff --git a/source/games/blood/src/eventq.h b/source/games/blood/src/eventq.h index 461482928..094be6933 100644 --- a/source/games/blood/src/eventq.h +++ b/source/games/blood/src/eventq.h @@ -192,7 +192,7 @@ struct EVENT { EventObject target; int8_t cmd; - int16_t funcID; + VMFunction* funcID; int priority; TObjPtr initiator; @@ -242,16 +242,16 @@ struct EVENT void evInit(TArray& actors); void evPostActor(DBloodActor*, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator); -void evPostActor(DBloodActor*, unsigned int nDelta, CALLBACK_ID callback); +void evPostActor(DBloodActor*, unsigned int nDelta, VMFunction* callback); void evPostSector(sectortype* index, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator); -void evPostSector(sectortype* index, unsigned int nDelta, CALLBACK_ID callback); +void evPostSector(sectortype* index, unsigned int nDelta, VMFunction* callback); void evPostWall(walltype* index, unsigned int nDelta, COMMAND_ID command, DBloodActor* initiator); void evProcess(unsigned int nTime); void evKillActor(DBloodActor*); void evKillActor(DBloodActor*, DBloodActor* initiator); -void evKillActor(DBloodActor*, CALLBACK_ID a3); +void evKillActor(DBloodActor*, VMFunction* a3); END_BLD_NS diff --git a/source/games/blood/src/fx.cpp b/source/games/blood/src/fx.cpp index 96735965d..e4712f33c 100644 --- a/source/games/blood/src/fx.cpp +++ b/source/games/blood/src/fx.cpp @@ -32,7 +32,7 @@ BEGIN_BLD_NS CFX gFX; struct FXDATA { - CALLBACK_ID funcID; + VMNativeFunction** funcID; uint8_t detail; int16_t seq; int16_t flags; @@ -49,63 +49,63 @@ struct FXDATA { }; FXDATA gFXData[] = { - { kCallbackNone, 0, 49, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 50, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 51, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 52, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 45, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 0, 46, 1, -128, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 42, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 43, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 48, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 60, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBloodBits, 2, 0, 1, 46603, 2048, 480, 2154, 40, 40, 0, -12, 0 }, - { kCallbackNone, 2, 0, 3, 46603, 5120, 480, 2269, 24, 24, 0, -128, 0 }, - { kCallbackNone, 2, 0, 3, 46603, 5120, 480, 1720, 24, 24, 0, -128, 0 }, - { kCallbackNone, 1, 0, 1, 58254, 3072, 480, 2280, 48, 48, 0, -128, 0 }, - { kCallbackNone, 1, 0, 1, 58254, 3072, 480, 3135, 48, 48, 0, -128, 0 }, - { kCallbackNone, 0, 0, 3, 58254, 1024, 480, 3261, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3265, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3269, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3273, 32, 32, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 1024, 480, 3277, 32, 32, 0, 0, 0 }, - { kCallbackNone, 2, 0, 1, -27962, 8192, 600, 1128, 16, 16, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 1 - { kCallbackNone, 2, 0, 1, -18641, 8192, 600, 1128, 12, 12, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 2 - { kCallbackNone, 2, 0, 1, -9320, 8192, 600, 1128, 8, 8, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 3 - { kCallbackNone, 2, 0, 1, -18641, 8192, 600, 1131, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, - { kCallbackFXBloodBits, 2, 0, 3, 27962, 4096, 480, 733, 32, 32, 0, -16, 0 }, - { kCallbackNone, 1, 0, 3, 18641, 4096, 120, 2261, 12, 12, 0, -128, 0 }, - { kCallbackNone, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 58254, 3328, 480, 2185, 48, 48, 0, 0, 0 }, - { kCallbackNone, 0, 0, 3, 58254, 1024, 480, 2620, 48, 48, 0, 0, 0 }, - { kCallbackNone, 1, 55, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 56, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 57, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 58, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 0, 0, 0, 0, 960, 956, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 62, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 63, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 64, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 65, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 66, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackFXBouncingSleeve, 2, 67, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 0, 0, 0, 838, 16, 16, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, - { kCallbackNone, 0, 0, 3, 34952, 8192, 0, 2078, 64, 64, 0, -8, 0 }, - { kCallbackNone, 0, 0, 3, 34952, 8192, 0, 1106, 64, 64, 0, -8, 0 }, - { kCallbackNone, 0, 0, 3, 58254, 3328, 480, 2406, 48, 48, 0, 0, 0 }, - { kCallbackNone, 1, 0, 3, 46603, 4096, 480, 3511, 64, 64, 0, -128, 0 }, - { kCallbackNone, 0, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 11, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 2, 11, 3, 0, 8192, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, - { kCallbackNone, 1, 30, 3, 0, 0, 0, 0, 40, 40, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, - { kCallbackFXPodBloodSplat, 2, 0, 3, 27962, 4096, 480, 4023, 32, 32, 0, -16, 0 }, - { kCallbackFXPodBloodSplat, 2, 0, 3, 27962, 4096, 480, 4028, 32, 32, 0, -16, 0 }, - { kCallbackNone, 2, 0, 0, 0, 0, 480, 926, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, -12, 0 }, - { kCallbackNone, 1, 70, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 } + { nullptr, 0, 49, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 0, 50, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 0, 51, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 0, 52, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 0, 7, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 0, 44, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 0, 45, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 0, 46, 1, -128, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 2, 6, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 2, 42, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 2, 43, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 48, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 60, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { &AF(fxBloodBits), 2, 0, 1, 46603, 2048, 480, 2154, 40, 40, 0, -12, 0 }, + { nullptr, 2, 0, 3, 46603, 5120, 480, 2269, 24, 24, 0, -128, 0 }, + { nullptr, 2, 0, 3, 46603, 5120, 480, 1720, 24, 24, 0, -128, 0 }, + { nullptr, 1, 0, 1, 58254, 3072, 480, 2280, 48, 48, 0, -128, 0 }, + { nullptr, 1, 0, 1, 58254, 3072, 480, 3135, 48, 48, 0, -128, 0 }, + { nullptr, 0, 0, 3, 58254, 1024, 480, 3261, 32, 32, 0, 0, 0 }, + { nullptr, 1, 0, 3, 58254, 1024, 480, 3265, 32, 32, 0, 0, 0 }, + { nullptr, 1, 0, 3, 58254, 1024, 480, 3269, 32, 32, 0, 0, 0 }, + { nullptr, 1, 0, 3, 58254, 1024, 480, 3273, 32, 32, 0, 0, 0 }, + { nullptr, 1, 0, 3, 58254, 1024, 480, 3277, 32, 32, 0, 0, 0 }, + { nullptr, 2, 0, 1, -27962, 8192, 600, 1128, 16, 16, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 1 + { nullptr, 2, 0, 1, -18641, 8192, 600, 1128, 12, 12, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 2 + { nullptr, 2, 0, 1, -9320, 8192, 600, 1128, 8, 8, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, // bubble 3 + { nullptr, 2, 0, 1, -18641, 8192, 600, 1131, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP, -16, 0 }, + { &AF(fxBloodBits), 2, 0, 3, 27962, 4096, 480, 733, 32, 32, 0, -16, 0 }, + { nullptr, 1, 0, 3, 18641, 4096, 120, 2261, 12, 12, 0, -128, 0 }, + { nullptr, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 0, 3, 58254, 3328, 480, 2185, 48, 48, 0, 0, 0 }, + { nullptr, 0, 0, 3, 58254, 1024, 480, 2620, 48, 48, 0, 0, 0 }, + { nullptr, 1, 55, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 56, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 57, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 58, 1, 0, 2048, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 2, 0, 0, 0, 0, 960, 956, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, 0, 0 }, + { &AF(fxBouncingSleeve), 2, 62, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { &AF(fxBouncingSleeve), 2, 63, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { &AF(fxBouncingSleeve), 2, 64, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { &AF(fxBouncingSleeve), 2, 65, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { &AF(fxBouncingSleeve), 2, 66, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { &AF(fxBouncingSleeve), 2, 67, 0, 46603, 1024, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 0, 3, 0, 0, 0, 838, 16, 16, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, + { nullptr, 0, 0, 3, 34952, 8192, 0, 2078, 64, 64, 0, -8, 0 }, + { nullptr, 0, 0, 3, 34952, 8192, 0, 1106, 64, 64, 0, -8, 0 }, + { nullptr, 0, 0, 3, 58254, 3328, 480, 2406, 48, 48, 0, 0, 0 }, + { nullptr, 1, 0, 3, 46603, 4096, 480, 3511, 64, 64, 0, -128, 0 }, + { nullptr, 0, 8, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 2, 11, 3, -256, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 2, 11, 3, 0, 8192, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + { nullptr, 1, 30, 3, 0, 0, 0, 0, 40, 40, CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_WALL, -8, 0 }, + { &AF(fxPodBloodSplat), 2, 0, 3, 27962, 4096, 480, 4023, 32, 32, 0, -16, 0 }, + { &AF(fxPodBloodSplat), 2, 0, 3, 27962, 4096, 480, 4028, 32, 32, 0, -16, 0 }, + { nullptr, 2, 0, 0, 0, 0, 480, 926, 32, 32, CSTAT_SPRITE_TRANSLUCENT | CSTAT_SPRITE_TRANS_FLIP | CSTAT_SPRITE_ONE_SIDE | CSTAT_SPRITE_ALIGNMENT_FLOOR, -12, 0 }, + { nullptr, 1, 70, 1, -13981, 5120, 0, 0, 0, 0, 0, 0, 0 } }; //--------------------------------------------------------------------------- @@ -189,7 +189,7 @@ DBloodActor* CFX::fxSpawnActor(FX_ID nFx, sectortype* pSector, const DVector3& p if (angle == nullAngle) angle = mapangle(pFX->defangle); if (angle != nullAngle) - evPostActor(actor, angle.Buildang() + Random2(angle.Buildang() >> 1), kCallbackRemove); + evPostActor(actor, angle.Buildang() + Random2(angle.Buildang() >> 1), AF(Remove)); return actor; } @@ -222,12 +222,12 @@ void CFX::fxProcess(void) } if (getflorzofslopeptr(actor->sector(), actor->spr.pos) <= actor->spr.pos.Z) { - if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) + if (pFXData->funcID == nullptr) { remove(actor); continue; } - gCallback[pFXData->funcID](actor); + callActorFunction(*pFXData->funcID, actor); continue; } if (pSector != actor->sector()) @@ -247,12 +247,12 @@ void CFX::fxProcess(void) } if (floorZ < actor->spr.pos.Z) { - if (pFXData->funcID < 0 || pFXData->funcID >= kCallbackMax) + if (pFXData->funcID == nullptr) { remove(actor); continue; } - gCallback[pFXData->funcID](actor); + callActorFunction(*pFXData->funcID, actor); continue; } } @@ -282,7 +282,7 @@ void fxSpawnBlood(DBloodActor* actor, int) bloodactor->vel.X = Random2F(0x6aaaa); bloodactor->vel.Y = Random2F(0x6aaaa); bloodactor->vel.Z = -Random2F(0x10aaaa) - FixedToFloat(100); - evPostActor(bloodactor, 8, kCallbackFXBloodSpurt); + evPostActor(bloodactor, 8, AF(fxBloodSpurt)); } } @@ -312,7 +312,7 @@ void fxSpawnPodStuff(DBloodActor* actor, int) spawnactor->vel.X = Random2F(0x6aaaa); spawnactor->vel.Y = Random2F(0x6aaaa); spawnactor->vel.Z = -Random2F(0x10aaaa) - FixedToFloat(100); - evPostActor(spawnactor, 8, kCallbackFXPodBloodSpray); + evPostActor(spawnactor, 8, AF(fxPodBloodSpray)); } } diff --git a/source/games/blood/src/messages.cpp b/source/games/blood/src/messages.cpp index 46dd3fde5..9e03ed2c6 100644 --- a/source/games/blood/src/messages.cpp +++ b/source/games/blood/src/messages.cpp @@ -328,7 +328,7 @@ const char* GameInterface::GenericCheat(int player, int cheat) case kCheatMcGee: { if (!pPlayer->GetActor()->xspr.burnTime) - evPostActor(pPlayer->GetActor(), 0, kCallbackFXFlameLick); + evPostActor(pPlayer->GetActor(), 0, AF(fxFlameLick)); actBurnSprite(pPlayer->GetActor(), pPlayer->GetActor(), 2400); return GStrings("TXTB_FIRED"); } @@ -341,7 +341,7 @@ const char* GameInterface::GenericCheat(int player, int cheat) actHealDude(pPlayer->GetActor(), 200, 200); pPlayer->armor[1] = VanillaMode() ? 200 : 3200; if (!pPlayer->GetActor()->xspr.burnTime) - evPostActor(pPlayer->GetActor(), 0, kCallbackFXFlameLick); + evPostActor(pPlayer->GetActor(), 0, AF(fxFlameLick)); actBurnSprite(pPlayer->GetActor(), pPlayer->GetActor(), 2400); return GStrings("TXTB_RETARD"); } diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 26688fd62..497eb9128 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -44,15 +44,15 @@ CVARD(Bool, nnext_showconditionsprites, false, 0, "makes kModernCondition sprite -short gEffectGenCallbacks[] = { +VMNativeFunction** gEffectGenCallbacks[] = { - kCallbackFXFlameLick, - kCallbackFXFlareSpark, - kCallbackFXFlareSparkLite, - kCallbackFXZombieSpurt, - kCallbackFXBloodSpurt, - kCallbackFXArcSpark, - kCallbackFXTeslaAlt, + &AF(fxFlameLick), + &AF(fxFlareSpark), + &AF(fxFlareSparkLite), + &AF(fxZombieBloodSpurt), + &AF(fxBloodSpurt), + &AF(fxArcSpark), + &AF(fxTeslaAlt), }; @@ -1078,7 +1078,7 @@ void nnExtProcessSuperSprites() EVENT evn; evn.target = pCond->objects[k].obj; evn.cmd = pCond->objects[k].cmd; - evn.funcID = kCallbackMax; + evn.funcID = nullptr; evn.initiator = nullptr; useCondition(pCond->actor, evn); } @@ -1088,7 +1088,7 @@ void nnExtProcessSuperSprites() EVENT evn; evn.target = EventObject(pCond->actor); evn.cmd = (int8_t)aCond->xspr.command; - evn.funcID = kCallbackMax; + evn.funcID = nullptr; evn.initiator = nullptr; useCondition(pCond->actor, evn); } @@ -1330,7 +1330,7 @@ void nnExtProcessSuperSprites() debrisactor->norm_ang(); DAngle ang = debrisactor->spr.Angles.Yaw; - if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, kCallbackEnemeyBubble); + if ((uwater = spriteIsUnderwater(debrisactor)) == false) evKillActor(debrisactor, AF(EnemyBubble)); else if (Chance(0x1000 - mass)) { if (debrisactor->vel.Z > 0x100) debrisBubble(debrisactor); @@ -1611,7 +1611,7 @@ void debrisBubble(DBloodActor* actor) } if (Chance(0x2000)) - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); } //--------------------------------------------------------------------------- @@ -1742,15 +1742,15 @@ void debrisMove(int listIndex) sfxPlay3DSoundVolume(actor, 720, -1, 0, pitch, 75 - Random(40)); if (!spriteIsUnderwater(actor)) { - evKillActor(actor, kCallbackEnemeyBubble); + evKillActor(actor, AF(EnemyBubble)); } else { - evPostActor(actor, 0, kCallbackEnemeyBubble); + evPostActor(actor, 0, AF(EnemyBubble)); for (int ii = 2; ii <= 5; ii++) { if (Chance(0x5000 * ii)) - evPostActor(actor, Random(5), kCallbackEnemeyBubble); + evPostActor(actor, Random(5), AF(EnemyBubble)); } } break; @@ -2462,7 +2462,7 @@ void useObjResizer(DBloodActor* sourceactor, int targType, sectortype* targSect, targetactor->genDudeExtra.updReq[kGenDudePropertyAttack] = true; targetactor->genDudeExtra.updReq[kGenDudePropertyMass] = true; targetactor->genDudeExtra.updReq[kGenDudePropertyDmgScale] = true; - evPostActor(targetactor, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); + evPostActor(targetactor, kGenDudeUpdTimeRate, AF(GenDudeUpdate)); } @@ -3300,9 +3300,9 @@ void useEffectGen(DBloodActor* sourceactor, DBloodActor* actor) int length = sizeof(gEffectGenCallbacks) / sizeof(gEffectGenCallbacks[0]); if (fxId < kEffectGenCallbackBase + length) { - fxId = gEffectGenCallbacks[fxId - kEffectGenCallbackBase]; - evKillActor(actor, (CALLBACK_ID)fxId); - evPostActor(actor, 0, (CALLBACK_ID)fxId); + auto fxfunc = gEffectGenCallbacks[fxId - kEffectGenCallbackBase]; + evKillActor(actor, *fxfunc); + evPostActor(actor, 0, *fxfunc); } } @@ -3628,14 +3628,14 @@ void damageSprites(DBloodActor* sourceactor, DBloodActor* actor) case kDmgBurn: if (actor->xspr.burnTime > 0) break; actBurnSprite(sourceactor, actor, ClipLow(dmg >> 1, 128)); - evKillActor(actor, kCallbackFXFlameLick); - evPostActor(actor, 0, kCallbackFXFlameLick); // show flames + evKillActor(actor, AF(fxFlameLick)); + evPostActor(actor, 0, AF(fxFlameLick)); // show flames break; case kDmgElectric: forceRecoil = true; // show tesla recoil animation break; case kDmgBullet: - evKillActor(actor, kCallbackFXBloodSpurt); + evKillActor(actor, AF(fxBloodSpurt)); for (int i = 1; i < 6; i++) { if (Chance(0x16000 >> i)) @@ -3804,7 +3804,7 @@ void useSeqSpawnerGen(DBloodActor* sourceactor, int objType, sectortype* pSector } // should be: the more is seqs, the shorter is timer - evPostActor(spawned, 1000, kCallbackRemove); + evPostActor(spawned, 1000, AF(Remove)); } } else @@ -5529,7 +5529,7 @@ bool modernTypeOperateSector(sectortype* pSector, const EVENT& event) case kSectorCounter: if (pXSector->locked != 1) break; SetSectorState(pSector, 0, event.initiator.Get()); - evPostSector(pSector, 0, kCallbackCounterCheck); + evPostSector(pSector, 0, kCmdCallback, nullptr); break; } return true; @@ -6350,7 +6350,7 @@ int useCondition(DBloodActor* sourceactor, EVENT& event) srcIsCondition = (pActor->GetType() == kModernCondition || pActor->GetType() == kModernConditionFalse); // if it's a tracking condition, it must ignore all the commands sent from objects - if (sourceactor->xspr.busyTime > 0 && event.funcID != kCallbackMax) return -1; + if (sourceactor->xspr.busyTime > 0 && event.funcID != nullptr) return -1; else if (!srcIsCondition) // save object serials in the stack and make copy of initial object { condPush(sourceactor, event.target); @@ -6553,7 +6553,7 @@ void useUniMissileGen(DBloodActor* sourceactor, DBloodActor* actor) // add bursting for missiles if (missileactor->GetType() != kMissileFlareAlt && sourceactor->xspr.data4 > 0) - evPostActor(missileactor, ClipHigh(sourceactor->xspr.data4, 500), kCallbackMissileBurst); + evPostActor(missileactor, ClipHigh(sourceactor->xspr.data4, 500), AF(callbackUniMissileBurst)); } } @@ -7614,7 +7614,7 @@ bool setDataValueOfObject(int objType, sectortype* sect, walltype* wal, DBloodAc case kDudeModernCustomBurning: objActor->genDudeExtra.updReq[kGenDudePropertyWeapon] = true; objActor->genDudeExtra.updReq[kGenDudePropertyDmgScale] = true; - evPostActor(objActor, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); + evPostActor(objActor, kGenDudeUpdTimeRate, AF(GenDudeUpdate)); break; } return true; @@ -7629,7 +7629,7 @@ bool setDataValueOfObject(int objType, sectortype* sect, walltype* wal, DBloodAc objActor->genDudeExtra.updReq[kGenDudePropertyDmgScale] = true; objActor->genDudeExtra.updReq[kGenDudePropertyStates] = true; objActor->genDudeExtra.updReq[kGenDudePropertyAttack] = true; - evPostActor(objActor, kGenDudeUpdTimeRate, kCallbackGenDudeUpdate); + evPostActor(objActor, kGenDudeUpdTimeRate, AF(GenDudeUpdate)); break; } return true; @@ -9190,7 +9190,7 @@ void callbackUniMissileBurst(DBloodActor* actor) // 22 if ((burstactor->spr.cstat & CSTAT_SPRITE_BLOCK)) { burstactor->spr.cstat &= ~CSTAT_SPRITE_BLOCK; // we don't want missiles impact each other - evPostActor(burstactor, 100, kCallbackMissileSpriteBlock); // so set blocking flag a bit later + evPostActor(burstactor, 100, AF(callbackMakeMissileBlocking)); // so set blocking flag a bit later } burstactor->spr.pal = actor->spr.pal; @@ -9211,9 +9211,9 @@ void callbackUniMissileBurst(DBloodActor* actor) // 22 auto spAngVec = DAngle::fromBam(i << 29).ToVector().Rotated90CW() * nRadius; if (i & 1) spAngVec *= 0.5; burstactor->vel += DVector3(DVector2(0, spAngVec.X).Rotated(nAngVec.X, nAngVec.Y), spAngVec.Y); - evPostActor(burstactor, 960, kCallbackRemove); + evPostActor(burstactor, 960, AF(Remove)); } - evPostActor(actor, 0, kCallbackRemove); + evPostActor(actor, 0, AF(Remove)); } @@ -9317,7 +9317,7 @@ static void dokillEffectGenCallbacks(DBloodActor* actor) { int l = sizeof(gEffectGenCallbacks) / sizeof(gEffectGenCallbacks[0]); while (--l >= 0) - evKillActor(actor, (CALLBACK_ID)gEffectGenCallbacks[l]); + evKillActor(actor, *gEffectGenCallbacks[l]); } void killEffectGenCallbacks(DBloodActor* actor) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 285499ea6..6bfc60af7 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -2159,7 +2159,7 @@ int playerDamageSprite(DBloodActor* source, DBloodPlayer* pPlayer, DAMAGE_TYPE n nKneelingPlayer = nPlayerKneelClient; powerupActivate(pPlayer, kPwUpDeliriumShroom); pActor->SetTarget(source); - evPostActor(pPlayer->GetActor(), 15, kCallbackFinishHim); + evPostActor(pPlayer->GetActor(), 15, AF(FinishHim)); } else { @@ -2191,7 +2191,7 @@ int playerDamageSprite(DBloodActor* source, DBloodPlayer* pPlayer, DAMAGE_TYPE n DBloodActor* pItem = nullptr; if (pPlayer->GetActor()->xspr.dropMsg && (pItem = actDropObject(pActor, pPlayer->GetActor()->xspr.dropMsg)) != NULL) - evPostActor(pItem, 500, kCallbackRemove); + evPostActor(pItem, 500, AF(Remove)); if (pPlayer->GetActor()->xspr.key) { @@ -2202,7 +2202,7 @@ int playerDamageSprite(DBloodActor* source, DBloodPlayer* pPlayer, DAMAGE_TYPE n } if (i == 0 && (pItem = actDropObject(pActor, (pPlayer->GetActor()->xspr.key + kItemKeyBase) - 1)) != NULL) - evPostActor(pItem, 500, kCallbackRemove); + evPostActor(pItem, 500, AF(Remove)); } diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index 29d439335..f1970ae5e 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -723,7 +723,7 @@ void seqProcess(int nTicks) { evKillActor(actor); if ((actor->spr.hitag & kAttrRespawn) != 0 && (actor->spr.inittype >= kDudeBase && actor->spr.inittype < kDudeMax)) - evPostActor(actor, gGameOptions.nMonsterRespawnTime, kCallbackRespawn); + evPostActor(actor, gGameOptions.nMonsterRespawnTime, AF(Respawn)); else DeleteSprite(actor); // safe to not use actPostSprite here } } diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 682c1c36e..0eb99be95 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -71,7 +71,7 @@ bool SetSpriteState(DBloodActor* actor, int nState, DBloodActor* initiator) if ((actor->spr.flags & kHitagRespawn) != 0 && actor->spr.inittype >= kDudeBase && actor->spr.inittype < kDudeMax) { actor->xspr.respawnPending = 3; - evPostActor(actor, gGameOptions.nMonsterRespawnTime, kCallbackRespawn); + evPostActor(actor, gGameOptions.nMonsterRespawnTime, AF(Respawn)); return 1; } if (actor->xspr.restState != nState && actor->xspr.waitTime > 0) @@ -280,7 +280,7 @@ void LifeLeechOperate(DBloodActor* actor, EVENT event) { missile->SetOwner(actor); actor->xspr.stateTimer = 1; - evPostActor(actor, (!actor->xspr.data3 ? 120 : 3 * 120) / 10, kCallbackLeechStateTimer); + evPostActor(actor, (!actor->xspr.data3 ? 120 : 3 * 120) / 10, AF(LeechStateTimer)); actor->xspr.data3 = ClipLow(actor->xspr.data3 - 1, 0); if (!VanillaMode()) // disable collisions so lifeleech doesn't do that weird bobbing missile->spr.cstat &= ~CSTAT_SPRITE_BLOCK_ALL; @@ -2313,7 +2313,7 @@ void trInit(TArray& actors) else #endif pXSector->triggerOnce = 1; - evPostSector(pSector, 0, kCallbackCounterCheck); + evPostSector(pSector, 0, kCmdCallback, nullptr); break; case kSectorZMotion: case kSectorZMotionSprite: diff --git a/source/games/blood/src/vmexports.cpp b/source/games/blood/src/vmexports.cpp index 6358e90dd..48e02b5bb 100644 --- a/source/games/blood/src/vmexports.cpp +++ b/source/games/blood/src/vmexports.cpp @@ -24,214 +24,6 @@ See the GNU General Public License for more details. #include "blood.h" BEGIN_BLD_NS -// ai callbacks -DEF_ANIMATOR(aiGenDudeMoveForward) -DEF_ANIMATOR(aiMoveDodge) -DEF_ANIMATOR(aiMoveForward) -DEF_ANIMATOR(aiMoveTurn) -DEF_ANIMATOR(aiPodChase) -DEF_ANIMATOR(aiPodMove) -DEF_ANIMATOR(aiPodSearch) -DEF_ANIMATOR(aiThinkTarget) -DEF_ANIMATOR(batMoveDodgeDown) -DEF_ANIMATOR(batMoveDodgeUp) -DEF_ANIMATOR(batMoveFly) -DEF_ANIMATOR(batMoveForward) -DEF_ANIMATOR(batMoveSwoop) -DEF_ANIMATOR(batMoveToCeil) -DEF_ANIMATOR(batThinkChase) -DEF_ANIMATOR(batThinkGoto) -DEF_ANIMATOR(batThinkPonder) -DEF_ANIMATOR(batThinkSearch) -DEF_ANIMATOR(batThinkTarget) -DEF_ANIMATOR(beastMoveForward) -DEF_ANIMATOR(beastThinkChase) -DEF_ANIMATOR(beastThinkGoto) -DEF_ANIMATOR(beastThinkSearch) -DEF_ANIMATOR(beastThinkSwimChase) -DEF_ANIMATOR(beastThinkSwimGoto) -DEF_ANIMATOR(burnThinkChase) -DEF_ANIMATOR(burnThinkGoto) -DEF_ANIMATOR(burnThinkSearch) -DEF_ANIMATOR(calebThinkChase) -DEF_ANIMATOR(calebThinkGoto) -DEF_ANIMATOR(calebThinkSearch) -DEF_ANIMATOR(calebThinkSwimChase) -DEF_ANIMATOR(calebThinkSwimGoto) -DEF_ANIMATOR(cerberusThinkChase) -DEF_ANIMATOR(cerberusThinkGoto) -DEF_ANIMATOR(cerberusThinkSearch) -DEF_ANIMATOR(cerberusThinkTarget) -DEF_ANIMATOR(cultThinkChase) -DEF_ANIMATOR(cultThinkGoto) -DEF_ANIMATOR(cultThinkSearch) -DEF_ANIMATOR(eelMoveAscend) -DEF_ANIMATOR(eelMoveDodgeDown) -DEF_ANIMATOR(eelMoveDodgeUp) -DEF_ANIMATOR(eelMoveForward) -DEF_ANIMATOR(eelMoveSwoop) -DEF_ANIMATOR(eelMoveToCeil) -DEF_ANIMATOR(eelThinkChase) -DEF_ANIMATOR(eelThinkGoto) -DEF_ANIMATOR(eelThinkPonder) -DEF_ANIMATOR(eelThinkSearch) -DEF_ANIMATOR(eelThinkTarget) -DEF_ANIMATOR(entryAIdle) -DEF_ANIMATOR(entryEStand) -DEF_ANIMATOR(entryEZombie) -DEF_ANIMATOR(entryFStatue) -DEF_ANIMATOR(entrySStatue) -DEF_ANIMATOR(forcePunch) -DEF_ANIMATOR(gargMoveDodgeDown) -DEF_ANIMATOR(gargMoveDodgeUp) -DEF_ANIMATOR(gargMoveFly) -DEF_ANIMATOR(gargMoveForward) -DEF_ANIMATOR(gargMoveSlow) -DEF_ANIMATOR(gargMoveSwoop) -DEF_ANIMATOR(gargThinkChase) -DEF_ANIMATOR(gargThinkGoto) -DEF_ANIMATOR(gargThinkSearch) -DEF_ANIMATOR(gargThinkTarget) -DEF_ANIMATOR(ghostMoveDodgeDown) -DEF_ANIMATOR(ghostMoveDodgeUp) -DEF_ANIMATOR(ghostMoveFly) -DEF_ANIMATOR(ghostMoveForward) -DEF_ANIMATOR(ghostMoveSlow) -DEF_ANIMATOR(ghostMoveSwoop) -DEF_ANIMATOR(ghostThinkChase) -DEF_ANIMATOR(ghostThinkGoto) -DEF_ANIMATOR(ghostThinkSearch) -DEF_ANIMATOR(ghostThinkTarget) -DEF_ANIMATOR(gillThinkChase) -DEF_ANIMATOR(gillThinkGoto) -DEF_ANIMATOR(gillThinkSearch) -DEF_ANIMATOR(gillThinkSwimChase) -DEF_ANIMATOR(gillThinkSwimGoto) -DEF_ANIMATOR(handThinkChase) -DEF_ANIMATOR(handThinkGoto) -DEF_ANIMATOR(handThinkSearch) -DEF_ANIMATOR(houndThinkChase) -DEF_ANIMATOR(houndThinkGoto) -DEF_ANIMATOR(houndThinkSearch) -DEF_ANIMATOR(innocThinkChase) -DEF_ANIMATOR(innocThinkGoto) -DEF_ANIMATOR(innocThinkSearch) -DEF_ANIMATOR(MorphToBeast) -DEF_ANIMATOR(myThinkSearch) -DEF_ANIMATOR(myThinkTarget) -DEF_ANIMATOR(playStatueBreakSnd) -DEF_ANIMATOR(ratThinkChase) -DEF_ANIMATOR(ratThinkGoto) -DEF_ANIMATOR(ratThinkSearch) -DEF_ANIMATOR(spidThinkChase) -DEF_ANIMATOR(spidThinkGoto) -DEF_ANIMATOR(spidThinkSearch) -DEF_ANIMATOR(sub_628A0) -DEF_ANIMATOR(sub_62AE0) -DEF_ANIMATOR(sub_62D7C) -DEF_ANIMATOR(sub_65D04) -DEF_ANIMATOR(sub_65F44) -DEF_ANIMATOR(sub_661E0) -DEF_ANIMATOR(sub_6CB00) -DEF_ANIMATOR(sub_6CD74) -DEF_ANIMATOR(sub_6D03C) -DEF_ANIMATOR(sub_72580) -DEF_ANIMATOR(sub_725A4) -DEF_ANIMATOR(sub_72850) -DEF_ANIMATOR(tchernobogThinkChase) -DEF_ANIMATOR(unicultThinkChase) -DEF_ANIMATOR(unicultThinkGoto) -DEF_ANIMATOR(unicultThinkSearch) -DEF_ANIMATOR(zombaThinkChase) -DEF_ANIMATOR(zombaThinkGoto) -DEF_ANIMATOR(zombaThinkPonder) -DEF_ANIMATOR(zombaThinkSearch) -DEF_ANIMATOR(zombfThinkChase) -DEF_ANIMATOR(zombfThinkGoto) -DEF_ANIMATOR(zombfThinkSearch) -// seq callbacks -DEF_ANIMATOR(FireballSeqCallback) -DEF_ANIMATOR(Fx33Callback) -DEF_ANIMATOR(NapalmSeqCallback) -DEF_ANIMATOR(Fx32Callback) -DEF_ANIMATOR(TreeToGibCallback) -DEF_ANIMATOR(DudeToGibCallback1) -DEF_ANIMATOR(DudeToGibCallback2) -DEF_ANIMATOR(batBiteSeqCallback) -DEF_ANIMATOR(SlashSeqCallback) -DEF_ANIMATOR(StompSeqCallback) -DEF_ANIMATOR(eelBiteSeqCallback) -DEF_ANIMATOR(BurnSeqCallback) -DEF_ANIMATOR(SeqAttackCallback) -DEF_ANIMATOR(cerberusBiteSeqCallback) -DEF_ANIMATOR(cerberusBurnSeqCallback) -DEF_ANIMATOR(cerberusBurnSeqCallback2) -DEF_ANIMATOR(TommySeqCallback) -DEF_ANIMATOR(TeslaSeqCallback) -DEF_ANIMATOR(ShotSeqCallback) -DEF_ANIMATOR(cultThrowSeqCallback) -DEF_ANIMATOR(cultThrowSeqCallback2) -DEF_ANIMATOR(cultThrowSeqCallback3) -DEF_ANIMATOR(SlashFSeqCallback) -DEF_ANIMATOR(ThrowFSeqCallback) -DEF_ANIMATOR(BlastSSeqCallback) -DEF_ANIMATOR(ThrowSSeqCallback) -DEF_ANIMATOR(ghostSlashSeqCallback) -DEF_ANIMATOR(ghostThrowSeqCallback) -DEF_ANIMATOR(ghostBlastSeqCallback) -DEF_ANIMATOR(GillBiteSeqCallback) -DEF_ANIMATOR(HandJumpSeqCallback) -DEF_ANIMATOR(houndBiteSeqCallback) -DEF_ANIMATOR(houndBurnSeqCallback) -DEF_ANIMATOR(podPlaySound1) -DEF_ANIMATOR(podPlaySound2) -DEF_ANIMATOR(podAttack) -DEF_ANIMATOR(podExplode) -DEF_ANIMATOR(ratBiteSeqCallback) -DEF_ANIMATOR(SpidBiteSeqCallback) -DEF_ANIMATOR(SpidJumpSeqCallback) -DEF_ANIMATOR(SpidBirthSeqCallback) -DEF_ANIMATOR(tchernobogFire) -DEF_ANIMATOR(tchernobogBurnSeqCallback) -DEF_ANIMATOR(tchernobogBurnSeqCallback2) -DEF_ANIMATOR(genDudeAttack1) -DEF_ANIMATOR(punchCallback) -DEF_ANIMATOR(ThrowCallback1) -DEF_ANIMATOR(ThrowCallback2) -DEF_ANIMATOR(HackSeqCallback) -DEF_ANIMATOR(StandSeqCallback) -DEF_ANIMATOR(zombfHackSeqCallback) -DEF_ANIMATOR(PukeSeqCallback) -DEF_ANIMATOR(ThrowSeqCallback) -DEF_ANIMATOR(PlayerSurvive) -DEF_ANIMATOR(PlayerKneelsOver) -DEF_ANIMATOR(FireballTrapSeqCallback) -DEF_ANIMATOR(MGunFireSeqCallback) -DEF_ANIMATOR(MGunOpenSeqCallback) -// event callbacks -DEF_ANIMATOR(fxFlameLick) // 0 -DEF_ANIMATOR(Remove) // 1 -DEF_ANIMATOR(FlareBurst) // 2 -DEF_ANIMATOR(fxFlareSpark) // 3 -DEF_ANIMATOR(fxFlareSparkLite) // 4 -DEF_ANIMATOR(fxZombieBloodSpurt) // 5 -DEF_ANIMATOR(fxBloodSpurt) // 6 -DEF_ANIMATOR(fxArcSpark) // 7 -DEF_ANIMATOR(fxDynPuff) // 8 -DEF_ANIMATOR(Respawn) // 9 -DEF_ANIMATOR(PlayerBubble) // 10 -DEF_ANIMATOR(EnemyBubble) // 11 -DEF_ANIMATOR(FinishHim) // 13 -DEF_ANIMATOR(fxBloodBits) // 14 -DEF_ANIMATOR(fxTeslaAlt) // 15 -DEF_ANIMATOR(fxBouncingSleeve) // 16 -DEF_ANIMATOR(returnFlagToBase) // 17 -DEF_ANIMATOR(fxPodBloodSpray) // 18 -DEF_ANIMATOR(fxPodBloodSplat) // 19 -DEF_ANIMATOR(LeechStateTimer) // 20 -DEF_ANIMATOR(DropVoodooCb) // unused - - DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nGameType) DEFINE_FIELD_X(GAMEOPTIONS, GAMEOPTIONS, nDifficulty) @@ -488,16 +280,16 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBloodActor, addX, bloodactor_addX) return 0; } -static void bloodactor_evPostActorCallback(DBloodActor* act, int delta, int id) +static void bloodactor_evPostActorCallback(DBloodActor* act, int delta, VMFunction* id) { - evPostActor(act, delta, (CALLBACK_ID)id); + evPostActor(act, delta, id); } DEFINE_ACTION_FUNCTION_NATIVE(DBloodActor, evPostActorCallback, bloodactor_evPostActorCallback) { PARAM_SELF_PROLOGUE(DBloodActor); PARAM_INT(d); - PARAM_INT(id); + PARAM_POINTER(id, VMFunction); bloodactor_evPostActorCallback(self, d, id); return 0; } diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index 19548e625..f124a77c7 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -1821,7 +1821,7 @@ void DropVoodoo(int, DBloodPlayer* pPlayer) if (spawned) { spawned->xspr.data1 = pPlayer->ammoCount[9]; - evPostActor(spawned, 90, kCallbackDropVoodoo); + evPostActor(spawned, 90, AF(DropVoodooCb)); UseAmmo(pPlayer, 6, 480/*gAmmoItemData[0].count*/); UseAmmo(pPlayer, 9, pPlayer->ammoCount[9]); pPlayer->hasWeapon[kWeapVoodooDoll] = 0; @@ -1951,7 +1951,7 @@ void AltFireNapalm(int, DBloodPlayer* pPlayer) UseAmmo(pPlayer, 4, missile->xspr.data4); seqSpawn(22, missile, -1); actBurnSprite(pPlayer->GetActor(), missile, 600); - evPostActor(missile, 0, kCallbackFXFlameLick); + evPostActor(missile, 0, AF(fxFlameLick)); sfxPlay3DSound(missile, 480, 2, 0); pPlayer->visibility = 30; pPlayer->flashEffect = 1; @@ -2003,7 +2003,7 @@ void AltFireLifeLeech(int, DBloodPlayer* pPlayer) missile->xspr.Proximity = 1; missile->xspr.DudeLockout = 1; missile->xspr.stateTimer = 1; - evPostActor(missile, 120, kCallbackLeechStateTimer); + evPostActor(missile, 120, AF(LeechStateTimer)); if (gGameOptions.nGameType <= 1) { int nAmmo = pPlayer->ammoCount[8]; diff --git a/wadsrc/static/zscript/games/blood/bloodactor.zs b/wadsrc/static/zscript/games/blood/bloodactor.zs index e85d5b31f..71c74ac2e 100644 --- a/wadsrc/static/zscript/games/blood/bloodactor.zs +++ b/wadsrc/static/zscript/games/blood/bloodactor.zs @@ -117,37 +117,6 @@ class BloodActor : CoreActor native kStatFree = 1024, }; - // the callback ids are only temporary. This should work with direct function references. - enum CALLBACK_ID { - kCallbackNone = -1, - kCallbackFXFlameLick = 0, - kCallbackRemove = 1, - kCallbackFXFlareBurst = 2, - kCallbackFXFlareSpark = 3, - kCallbackFXFlareSparkLite = 4, - kCallbackFXZombieSpurt = 5, - kCallbackFXBloodSpurt = 6, - kCallbackFXArcSpark = 7, - kCallbackFXDynPuff = 8, - kCallbackRespawn = 9, - kCallbackPlayerBubble = 10, - kCallbackEnemeyBubble = 11, - kCallbackCounterCheck = 12, - kCallbackFinishHim = 13, - kCallbackFXBloodBits = 14, - kCallbackFXTeslaAlt = 15, - kCallbackFXBouncingSleeve = 16, - kCallbackReturnFlag = 17, - kCallbackFXPodBloodSpray = 18, - kCallbackFXPodBloodSplat = 19, - kCallbackLeechStateTimer = 20, - kCallbackDropVoodoo = 21, // unused - - kCallbackMissileBurst = 22, - kCallbackMissileSpriteBlock = 23, - kCallbackGenDudeUpdate = 24, - kCallbackCondition = 25, - } enum SEQ_CALLBACK_ID { @@ -503,7 +472,7 @@ native void DropVoodooCb(); // unused } if (itemtype is 'BloodFlagBase' && gGameOptions.nGameType == Blood.kTeamplay) { - spawned.evPostActorCallback(1800, kCallbackReturnFlag); + spawned.evPostActorCallback(1800, AF(returnFlagToBase)); } double top, bottom; @@ -558,7 +527,7 @@ native void DropVoodooCb(); // unused spawned.cstat |= CSTAT_SPRITE_BLOCK; spawned.xspr.target = null; - spawned.evPostActorCallback(600, kCallbackRemove); + spawned.evPostActorCallback(600, AF(Remove)); spawned.initMissile(self); // handle type specific init.