It assigns a tid to all monsters as needed. When the player is killed it executes an ACS ChangeCamera to the viewpoint of the killer, waits a bit, and switches back. This works but breaks immersion (then again, this ain't Skyrim). I chose an arbitrary camera height of 50.
ACS:
Code: Select all
#library "deathcam"
#include "zcommon.acs"
script "deathcam" (int tid)
{
ChangeCamera(tid, 0, 0);
Delay(35 * 6);
ChangeCamera(0, 0, 0);
}
Code: Select all
class deathcam_EventHandler : EventHandler
{
int tidCounter;
override
void WorldThingSpawned(WorldEvent e)
{
// give the monster a unique tid
if (tidCounter == 0)
{
tidCounter = 22000;
}
if (e.thing && e.thing.bIsMonster && !e.thing.tid)
{
e.thing.ChangeTid(tidCounter);
tidCounter++;
}
}
override
void WorldThingDied(WorldEvent e)
{
if (e.thing && e.thing is "PlayerPawn" && e.inflictor && e.thing.target.tid)
{
e.thing.target.CameraHeight = 50;
e.thing.ACS_NamedExecute("deathcam", 0, e.thing.target.tid, 0, 0);
}
}
}