Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Lycaon

Problem making enemies shoot inaccurately in the dark

Recommended Posts

I'm making a map where enemies shoot less accurately at you when you are in dark sectors (below 80 brightness value). I use CallACS and Getactorlightlevel to achieve this, but i'm unable to make it work. Here's what I've done so far

This is the decorate line. the idea is that if the result is lower than 80, it jumps to an alternate missile state that has a more random shooting spread, as well as other behavior alterations

Missile:
REEL E 0 A_jumpif (CallACS("TargetLight", 0, 0, 0) < 80, "missile1dark")
REEL E 0 A_JumpIfCloser (325, "Missile2")
And this is the map script

script "TargetLight" (void)
{
SetActivatorToTarget(0);
int z = GetActorLightLevel(0);
SetResultValue (z);
}
What actually happens is that the actor always skips to "missile1dark" state, nomatter what light value the sector i'm standing has. For some reason, the result value doesn't seem to be set right.

Thanks a lot in advance!

EDIT: It seems to have been solved by replacing the "< 80" expression with a "<= 80" expressino for some reason, I have no idea why.

Share this post


Link to post

If your sector had brightness exactly 80, it's understandable: 80 is not lesser (<) than 80, but 80 is lesser or equal (<=) than 80.

If that wasn't the case, try to move the comparison part into the script itself:

script "TargetLight" (void)
{
SetActivatorToTarget(0);
if(GetActorLightLevel(0)<80) { SetResultValue (1); }
else { SetResultValue (0); }
}
And omit it in DECORATE:
Missile:
REEL E 0 A_jumpif (CallACS("TargetLight", 0, 0, 0), "missile1dark")
REEL E 0 A_JumpIfCloser (325, "Missile2")

Share this post


Link to post

For the record, the sector in which I was testing the script had 64 bright, so the </<= thing shouldn't have mattered. All I can think is that somehow the GetActorLightLevel special was returning an innaccurate light level.

Share this post


Link to post
Lycaon said:

REEL E 0 A_jumpif (CallACS("TargetLight", 0, 0, 0) < 80, "missile1dark")
[...]
What actually happens is that the actor always skips to "missile1dark" state,
[...]
the sector in which I was testing the script had 64 bright,

Sounds like it worked alright as it should had. Unless you had also tried it in a sector with brightness greater than 80 and the jump to "missile1dark" was not performed.

Check if my suggested code works any better / differently than yours with the "<".

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×