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: 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);
}
}