Page 1 of 1

ACS: Changing sectors light level

Posted: Tue Aug 07, 2018 10:01 am
by Ahpiox

Code: Select all

#include "zcommon.acs"

script "LightRide" ENTER // addr = 8, flags=0000
{
    int local0;
    int goto_block;
    switch (goto_block) {
    case 0:
        if ((PlayerNumber() == 0)) {
            local0 = 0;
            goto_block = 2; restart;
        } else {
            goto_block = 3; restart;
        }

    case 2:
        if ((local0 < 9999)) {
			if(GetSectorLightLevel(local0) > 148) {Light_LowerByValue(local0, GetSectorLightLevel(local0) / 1.4);}
            Light_LowerByValue(local0, 24);
			SetFogDensity(local0,56);
            local0++;
            goto_block = 2; restart;
        } else {
            goto_block = 3; restart;
        }

    case 3:
        Terminate;

    }
}
It's modified code from DarkDoom. I tried to make this script seriously lowing light level if sector has light level higher than 148 units. But as i can see, this is not work at all. Any help pls?

Re: ACS: Changing sectors light level

Posted: Tue Aug 07, 2018 10:53 am
by KeksDose
At a glance, this bit here doesn't look good:

Code: Select all

Light_LowerByValue(local0, GetSectorLightLevel(local0) / 1.4); 
In acs, '.' is special notation for fixed point. The gist lies in interpretation, as 1.0 fixed = 65536 whole. Here, 1.4 is around 100k, so the division results in 0, as it's done whole.

You can divide fixed by a whole number, and you can also multiply fixed with a whole number, and get the expected fixed result. [wiki]FixedMul[/wiki] and [wiki]FixedDiv[/wiki] will handle anything involving two fixed numbers.

I'd do this:

Code: Select all

(GetSectorLightLevel(local0) * 10) / 14

Re: ACS: Changing sectors light level

Posted: Tue Aug 07, 2018 10:58 am
by Ahpiox
Nope, still nothing. Idk why, but still thanks for reply

Re: ACS: Changing sectors light level

Posted: Tue Aug 07, 2018 11:32 am
by KeksDose
Scratch everything. This script will not work as expected, because you are cycling through sector tags, not every sector by itself, so GetSectorLightLevel will, for same tagged sectors, return one light value for all of them, even if they're different. Think of a map with only tag 0 and light level 255, except for one sector, which happens to be the one picked by GetSectorLightLevel.

This should definitely be done in zscript, since you can then actually cycle through each sector individually.

Re: ACS: Changing sectors light level

Posted: Tue Aug 07, 2018 9:49 pm
by Ahpiox
Okay, will try to make this thing in zscript. Will learn from wiki and DarkDoomZ script. Thanks