Page 1 of 1

I hate ACS.

Posted: Mon Oct 24, 2005 21:14
by Nash
To cut a long story short, and to avoid me from throwing an emotional rant...

I want a dynamic light to always be at the player's position, for a flashlight effect.

But no matter how I try, it's not working.

ACS:

Code: Select all

#include "zcommon.acs"

int player_x;
int player_y;
int player_z;

script 1 ENTER // sets player's initial properties
{
Thing_ChangeTID(0, 1000 + PlayerNumber()); //give player a TID
}


script 2 OPEN // main loop script
{

thing_activate(1);

//record player's coords
player_x=GetActorX(1000);
player_y=GetActorY(1000);
player_z=GetActorZ(1000);

//position flashlight
// TID 1 is the dynamic light object
// TID 999 is the teleporter
spawn("TeleportDest3",player_x,player_y,player_z+2*65536,999);
TeleportOther(1,999,0);
delay(1);
Thing_Remove(999);
restart;

}
DECORATE:

Code: Select all

ACTOR Flashlight 20001
{

radius 8
height 8
renderstyle none
+noblockmap
+noclip

States
{
Spawn:
FLIT A 1
Loop
}

}
DOOMDEFS:

Code: Select all

pointlight FLASHLIGHT
{
    color 1.0 1.0 1.0
    size 128
    offset 0 0 0
}

object Flashlight
{
    frame FLIT { light FLASHLIGHT }
}
I really don't want to think about how to get it to work anymore, because I've spent THE LAST FOUR HOURS trying to figure out how.

I haven't even gotten to the trigonometry stuff yet! (I want the dynamic light to always sit in front of the player, oriented to the player's view angle, rather than dead center of the player's position)

Please help me make this work. I've had it up to here with ACS and its illogical oddities!!!

Posted: Mon Oct 24, 2005 22:00
by solarsnowfall
Can you post the WAD?

Posted: Mon Oct 24, 2005 23:27
by solarsnowfall
Nevermind, is this what you're trying to do? The script is modified from on old wad I've had for a while that was used to make a chase cam that follows the player. I merely revised it to spawn an actor that has a light definition in front of the player.

ACS:

Code: Select all

#include "zcommon.acs" 

int degrees = 0; 
int raduis = 64; 
int lightheight = 64;  
int pi = 3.14; 

function int _cos (int angle) 
{ 
   angle %= 1.0; 
   if (angle < 0) 
      angle += 1.0; 
   if (angle > 0.5) 
      angle = -angle + 1.0; 
   return cos (angle); 
} 



function int _sin (int angle) 
{ 
   return _cos (angle + 0.25); 
} 

function int _tan (int a) 
{ 
 int r; 
 r = _sin(a) / _cos(a); 
 return r; 
} 


function int sqrt (int x) 
{ 
   int r; 
   x = (x + 1) >> 1; 
   r = 0; 
   while (x > r) 
   { 
      x -= r++; 
   } 
   return r; 
} 

Script 1 ENTER 
{ 
thing_changeTID(0,1337+playernumber()); 
acs_execute(6,0,0,0,0);  
} 

script 6 (void) 
{ 
int PX = getactorx(activatortid()); 
int PY = getactory(activatortid()); 
int PZ = getactorz(activatortid()); 
int PA = getactorangle(activatortid()) / 256; 
int angle = getactorangle(activatortid()); 
spawn("MapSpot",PX + raduis * _sin(angle + 16383.75),PY + raduis * _cos(angle + 16383.75),PZ + lightheight * 65535,2,PA); 
while (thingcount(t_none, 2) == 0 && raduis > -5 ) 
{ 
raduis = raduis - 5; 
spawn("MapSpot",PX + raduis * _sin(angle + 16383.75),PY + raduis * _cos(angle + 16383.75),PZ + lightheight * 65535,2,PA); 
} 
spawnspot("LightOrb", 2, 3, 0); 
delay(1); 
if (thingcount(t_none, 2) == 1 && raduis < 151)
raduis = raduis + 5; 
thing_remove(2);
thing_remove(3); 
restart; 
}
DECORATE:

Code: Select all

Actor LightOrb
{
	Height 8
	Radius 4
	+IsMonster
	+NoGravity
	+NoBlockmap
	+NoClip
	States
	{
	Spawn:
		NULL A 1 
		Loop
	}
}
DOOMDEFS:

Code: Select all

pointlight FLASHLIGHTGLOW
{
    color 1.0 1.0 1.0
    size 64
}

object LightOrb
{
    frame NULLA { light FLASHLIGHTGLOW    }
}
I didn't make any attemt to have it resemble what you were working on, because there seems to be a problem with the actor you wrote.

There is also this flaslight.WAD floating around you might try and find. I believe it was a weapon in DECORATE, but I haven't seen the code.

Posted: Tue Oct 25, 2005 11:19
by Nash
solars,

You have saved me from a lot of grief. I don't know how to thank you!

:)

Just one thing though, think you can get it to work vertically? Right now, no matter where you mouselook, up or down, it still stays in front of the player.

Another thing, the flashlight disappears when you are really close to walls. Any way to fix this?

Regarding the flashlight wads, I have two of them, one from cutman and the other from ellmo, they are good, but they aren't what I want... I want the player to always have the flashlight, plus also those wads trigger monsters when you turn on the flashlight...

Posted: Tue Oct 25, 2005 16:13
by Enjay
Nash wrote:plus also those wads trigger monsters when you turn on the flashlight...
That can easily be fixed by giving the flashlight/weapon the noalert (or whatever the syntax is) flag.

Posted: Tue Oct 25, 2005 21:31
by Nash
Thanks Enjay, that fixed the problem.

solar, not to pressure you or anything, but can you get it to work vertically?

And if the light disappearing problem can't be fixed, I may have to move to the weapon approach (that means player can't attack while the flashlight is on :/)

Posted: Tue Oct 25, 2005 22:49
by solarsnowfall
Nash wrote:solar, not to pressure you or anything, but can you get it to work vertically?
Unfortunately as far as I am aware, there is now way to do so using this meathod. :(