Page 1 of 1

Deathcam

PostPosted: Sat Nov 06, 2021 3:04 am
by Hey Doomer
My take on https://forum.zdoom.org/viewtopic.php?f=3&t=29235&p=555792&hilit=killcam#p555792. It shows a flash of a viewpoint from whatever killed the player before switching back. I'm not sure how satisfying this is.

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 allExpand view
    #library "deathcam"
    #include "zcommon.acs"

    script "deathcam" (int tid)
    {
        ChangeCamera(tid, 0, 0);
        Delay(35 * 6);
        ChangeCamera(0, 0, 0);
    }


ZScript:

Code: Select allExpand view
    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);
          }
       }
    }


I haven't tested this extensively, so I'm not sure what happens with flying critters, and the height of 50 will give an interesting perspective from a Cyberdemon that may or may not make sense depending. It is interesting how little code can do so much. Nice engine!

Re: Deathcam

PostPosted: Sat Nov 06, 2021 7:16 am
by Enjay
That's pretty neat. Personally, I tend to use the built-in death camera so, for me, it would perhaps be better if there was a delay so that I could see my death from the GZDoom deathcam, then it switch to the perspective of my killer (then back again). Definitely a fun effect though.

Re: Deathcam

PostPosted: Sat Nov 06, 2021 12:04 pm
by Hey Doomer
Good suggestion!