Cast Shadows

Post your example zscripts/ACS scripts/etc here.

Cast Shadows

Postby Hey Doomer » Wed Nov 03, 2021 3:50 am

CASTSPRITESHADOW offers control over what casts a shadow, so here's my take on implementing this with inclusion and exclusion arrays:

Code: Select allExpand view
// caster_events.zs

class caster_EventHandler : EventHandler
{
   Array<string> shadows;
   Array<string> noshadows;

   bool noshadow(string s)
   {
      if (noshadows.Size()==0)
      {
         noshadows.Push("Column");
         noshadows.Push("BurningBarrel");
         noshadows.Push("ExplosiveBarrel");
         noshadows.Push("TechLamp");
         noshadows.Push("TechLamp2");
         noshadows.Push("TechPillar");
      }
      return (noshadows.Find(s) != noshadows.Size());
   }

   bool shadow(string s)
   {
      if (shadows.Size()==0)
      {
         shadows.Push("NonsolidMeat2");
         shadows.Push("NonsolidMeat3");
         shadows.Push("NonsolidMeat4");
         shadows.Push("NonsolidMeat5");
         shadows.Push("NonsolidTwitch");
         shadows.Push("DoomPlayer");
      }
      return (shadows.Find(s) != shadows.Size());
   }

   override
   void WorldThingSpawned(WorldEvent e)
   {
      string cn = e.thing.GetReplacee(e.thing.GetClassName()).GetClassName();
      e.thing.bCastSpriteShadow = (e.thing.bSolid && CVar.GetCVar("cast_solid"))
         || (e.thing.bMissile && CVar.GetCVar("cast_missile"))
         || (e.thing.bCorpse && CVar.GetCVar("cast_corpse")) || shadow(cn) || !noshadow(cn);
   }
}


This presents a few more options if the GZDoom menu option is "Default," controlled by CVars:

Code: Select allExpand view
user bool cast_solid = true;
user bool cast_corpse = true;
user bool cast_missile = true;


Rather than select all monsters I have chosen SOLID actors, and what doesn't cast can be excluded. Still playing around with this, but that's the idea.
You do not have the required permissions to view the files attached to this post.
Hey Doomer
 
Joined: 25 Sep 2021
Operating System: Windows 11
OS Test Version: No (Using Stable Public Version)
Graphics Processor: ATI/AMD with Vulkan Support

Return to Script Library

Who is online

Users browsing this forum: No registered users and 0 guests