Deathcam

Post your example zscripts/ACS scripts/etc here.
Forum rules
The Projects forums are only for projects. If you are asking questions about a project, either find that project's thread, or start a thread in the General section instead.

Got a cool project idea but nothing else? Put it in the project ideas thread instead!

Projects for any Doom-based engine (especially 3DGE) are perfectly acceptable here too.

Please read the full rules for more details.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Deathcam

Post by Hey Doomer »

My take on viewtopic.php?f=3&t=29235&p=555792&hili ... am#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 all

    #library "deathcam"
    #include "zcommon.acs"

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

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);
          }
       }
    }
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!
User avatar
Enjay
 
 
Posts: 26494
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Deathcam

Post 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.
Hey Doomer
Posts: 283
Joined: Sat Sep 25, 2021 3:38 am

Re: Deathcam

Post by Hey Doomer »

Good suggestion!

Return to “Script Library”