PDA

View Full Version : Proper Use Of SetScreenState For Nearby Rooms



HeroOfFire
08-05-2010, 01:40 PM
Back in build 1076, I used the following in a custom door script to change the screen state of nearby rooms to simulate the normal NES door mechanics.


Game->SetScreenState(Game->GetCurMap() + 1, Game->GetCurScreen() + 16 - (8 * Game->GetCurMap()), ST_DOORDOWN, true);

Although it looks complex, this code worked perfectly, which meant a few bugs were worked around (as the GetCurMap() + 1 and the 8 screen offset per map show). Since that build, changes were made to the functions that completely broke the script.

What I want to know is, what would be an updated version of the code above that works (it changes the state of the screen directly below the current one to mark the top door opened). Or has a bug been introduced that needs to be fixed/worked around?

Wolfman2000
08-06-2010, 04:30 PM
I gave it a shot myself, but I don't think I did it right either. My unencrypted test quest is here: use 1286 (http://drop.io/wolfman2000/asset/setscreentest-qst). It's possible I set up the door or FFC wrong, but I need someone else to verify.

Gleeok
08-06-2010, 07:06 PM
Yes, there was a bug in Game->GetCurMap() returning the wrong map / crashing. _L_ I believe fixed this around 11**. Remove the "+ 1" and I think it should work.

[edit] Nope I was wrong:


ZScript: now, Game->GetScreenState() and Game->SetScreenState() now correctly count maps from 1 upward (as indicated in zscript.txt) rather than 0 upward.

Same fix though.

HeroOfFire
08-25-2010, 01:15 AM
Now I think there is a bug with SetScreenState. The following works in Mac Build 1304.


Game->SetScreenState(Game->GetCurMap(), Game->GetCurScreen() + 16, ST_DOORDOWN, true);
Game->SetScreenState(Game->GetCurMap(), Game->GetCurScreen() - 16, ST_DOORUP, true);
Game->SetScreenState(Game->GetCurMap(), Game->GetCurScreen() + 1, ST_DOORRIGHT, true);
Game->SetScreenState(Game->GetCurMap(), Game->GetCurScreen() - 1, ST_DOORLEFT, true);

...at least for a while. At some point, these statements no longer function correctly. Experiementing a little, I noticed that this would work when the normal statements did not.


Game->SetScreenState(Game->GetCurMap(), Game->GetCurScreen(), ST_DOORUP, true);

The bug occurs with screens on higher Map Numbers, or possibly higher DMap Numbers (one or the other). The bug looks like SetScreenState gets offset by 16 at some point. Is this supposed to happen?