Shadow length

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

Shadow length

Post by Hey Doomer »

In reviewing Nash's Sprite Shadow code I started to wonder if shadows could be lengthened in darker sectors. The idea is that in very bright light coming from all sides the shadow would be smaller; darkness generates longer shadows. This only works against sector lighting.

I added an incremental tid to monsters on spawn starting at 22000. Then I wrote an ACS script to return the value of GetActorLightLevel based on that tid. Finally I added this to Nash's code:

Code: Select all

				// lengthen shadows when it is darker
				int tid = caster.tid;
				float length = 0.1;
				if (tid > 21999)
				{
					int light = ACS_NamedExecuteWithResult("GetSectorLight",tid,0,0,0);

					if (light > 200) length = 0.1;
					if (light > 150 && light <= 200) length = 0.2;
					if (light > 100 && light <= 150) length = 0.3;
					if (light > 50 && light <= 100) length = 0.4;
					if (light < 50) length = 0.5;
				}
That all seems correct to me. The length factor affects the Scale.Y number, which defaults to 0.1 (a small shadow).

https://i.postimg.cc/xdzh5Bpd/Screensho ... 172208.png
https://i.postimg.cc/Dwbx3Lrj/Screensho ... 172339.png
https://i.postimg.cc/KvC5fj6n/Screensho ... 172533.png

In these example screenshots I tried to capture zombies in lighter and darker sectors.

Return to “Script Library”