Problem with Dynamic Spotlight in ACS

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
-- Alexei --
Posts: 12
Joined: Sun Mar 24, 2024 11:04 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Home
Graphics Processor: ATI/AMD (Modern GZDoom)

Problem with Dynamic Spotlight in ACS

Post by -- Alexei -- »

Obviously this is about GZDoom, specifically 4.11.3a. (also, this is my first time in these forums so I'm sorry if I mess up somewhere)

I wanted to learn ACS apart from just scripted events in maps so I challenged myself to make a flashlight of sorts without basing it on any existing ones, my plan was to use the dynamic spotlight that comes with gzdoom.pk3 (thing 9840).

The problem is that since I can't specify any arguments inside the Spawn function I just used SetThingSpecial. Every argument seems to work fine but defining the color is really, really bad, I even copied the default white that UDB puts in and not even that works, I ended up looking into another thread somewhere that used a custom function and a bytecode value but none of them work either for me.

Here is the file:
flashlight-in-acs-by-alexei-v1.pk3
(1.82 KiB) Downloaded 23 times
Here is the source code (I hope I got the formatting right):

Code: Select all

 bool IsFlashlightOn; //I shouldn't need to explain what this does
bool IsFlashlightOff; //used to end the while loop
function int MakeColor(int r, int g, int b) //nash is the messiah
{
    return (b << 16) | (g << 8) | r;
} //unused for now, not the solution to the color problem

Script "FlashlightActivate" (void)
{
	int pangle = GetActorAngle(0) >> 8; //GetActor returns fixed point, SpawnForced uses
	int ppitch = GetActorPitch(0) >> 8; //byte, shifts bits to the right 8 times (10 >> 1 = 01)
	IsFlashlightOn = true; //pangle & ppitch unused, SetActor uses fixed point too, no need to convert
	IsFlashlightOff = false;
	//Log(s:"enabled flashlight"); //debugging
	while (isFlashlightOff == false) //spawns spotlight with the player's coords, angle & pitch
	{ //make sure not to use 1888 as a TID in your maps
		SpawnForced("Spotlight",GetActorX(0), GetActorY(0), GetActorZ(0)+48.0, 1888);
		SpawnForced("Spotlight",GetActorX(0), GetActorY(0), GetActorZ(0)+48.0, 1888);
		SpawnForced("Spotlight",GetActorX(0), GetActorY(0), GetActorZ(0)+48.0, 1888);
		SetThingSpecial(1888, 0, 255, 14, 30, 216, 0); //16777215 is white... SUPPOSEDLY >:(
		SetActorAngle(1888, GetActorAngle(0)); 		// nice bug gzdoom ↑ >:(
		SetActorPitch(1888, GetActorPitch(0));
		Delay(2);
		Thing_Remove(1888);
	}
}
If it helps, I'm using OpenGL rendering with software lighting, shadowmapping is PCF low and my GPU is an integrated AMD Radeon Graphics, I also excluded the script for toggling it on and off and a couple of comments for readability
User avatar
-- Alexei --
Posts: 12
Joined: Sun Mar 24, 2024 11:04 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Home
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Problem with Dynamic Spotlight in ACS

Post by -- Alexei -- »

25 views and 0 replies... odd

I'm probably dealing with a bug at this point but I thought I was smart, I read on the wiki that strings are actually indexes on a table, so I made like 10 string variables and multiplied them together inside the function to get to 16777215 and it had the same result. I also read on a thread that it got solved using ZScript but I want to learn ZScript properly and calmly, not forcefully for a dumb bug thing, specially since it seems much closer to actual programming, which I last did in highschool on some computer classes with extremely basic C++ knowledge that wouldn't get me any farther than making questionnaires and the stdio.h library.

I think this is a lost cause until the bug gets fixed, this just can't be an intended feature. Too bad, I was really excited about making a flashlight that didn't require ZScript.

This is how it looks if anyone is curious, no idea how it didn't occur to me to put screenshots on the original post https://imgur.com/a/ykqh6Ww

Edit: maybe it's me but imgur is acting weird today, refresh the page if it doesn't load for you
User avatar
phantombeta
Posts: 2175
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Problem with Dynamic Spotlight in ACS

Post by phantombeta »

It's not a bug. Spotlights only hold their color as a single integer in the map data. In-game, the args work the same as point lights, and the spotlight-specific data gets stored in variables called SpotInnerAngle and SpotOuterAngle instead.
Unfortunately, I don't believe there's any way to set those two variables in ACS without calling a ZScript function with ScriptCall.
User avatar
-- Alexei --
Posts: 12
Joined: Sun Mar 24, 2024 11:04 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11 Home
Graphics Processor: ATI/AMD (Modern GZDoom)

Re: Problem with Dynamic Spotlight in ACS

Post by -- Alexei -- »

I'm no expert, but I find it weird that changing the arguments through ACS having such effects wouldn't be unintended, specially if it ends up requiring using other methods for it to work. Either way, bug or not, it's such a shame I'll end up finishing this in the far future.

Thanks for your help!
User avatar
phantombeta
Posts: 2175
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Problem with Dynamic Spotlight in ACS

Post by phantombeta »

-- Alexei -- wrote: Tue Mar 26, 2024 8:48 am I'm no expert, but I find it weird that changing the arguments through ACS having such effects wouldn't be unintended, specially if it ends up requiring using other methods for it to work.
Like I said, the args work the same as a point light in-game. This is intentional, they both use the same code internally, so the args have to control the same things for both in-game.
Post Reply

Return to “Scripting”