I wondered this also, as the dithered-in black can be a bit boring.
Perhaps the flashlight plugin has a suitable function?
Of course, if you're in 256 color mode you can make your own custom fade out/in by using the SetPalRGB function.
Here's a simple fade in/out thing I wrote up. You can modify it to suit your needs (highlights fade slower, etc.):
//store palette for fades
int palr[256];
int palg[256];
int palb[256];
function Fade(string direction) {
if (StrComp (direction, "in") == 0) { //fade in
//erase palette
int speed = 0;
int i = 17;
while (i <= 255) {
palette[i].r = 15;
palette[i].g = 5;
palette[i].b = 5;
i += 1;
}
UpdatePalette ();
int j = 0;
int musicfade = 0;
while (j < 63) {
i = 17;
while (i <= 255) {
if (palette[i].r < palr[i]) palette[i].r += 1;
if (palette[i].g < palg[i]) palette[i].g += 1;
if (palette[i].b < palb[i]) palette[i].b += 1;
i += 1;
}
speed += 1;
if (speed == 3) {
Wait (1);
UpdatePalette ();
speed = 0;
}
if (musicfade < 100) musicfade += 2;
SetMusicMasterVolume (musicfade);
j += 1;
}
palette[18].r = palr[18];
palette[18].g = palg[18];
palette[18].b = palb[18];
UpdatePalette ();
}
else if (StrComp (direction, "out") == 0) { //fade out
int speed = 0;
int j = 0;
int musicfade = 100;
while (j < 63) {
int i = 17;
while (i <= 255) {
if (palette[i].r > 15) palette[i].r -= 1;
if (palette[i].g > 5) palette[i].g -= 1;
if (palette[i].b > 5) palette[i].b -= 1;
i += 1;
}
speed += 1;
if (speed == 3) {
Wait (1);
UpdatePalette ();
speed = 0;
}
if (musicfade > 0) musicfade -= 2;
SetMusicMasterVolume (musicfade);
if ((musicfade == 0) && (IsMusicPlaying() == 1)) StopMusic();
j += 1;
}
}
else if (StrComp (direction, "reset") == 0) { //reset palette
//erase palette
int speed = 0;
int i = 17;
while (i <= 255) {
palette[i].r = 15;
palette[i].g = 5;
palette[i].b = 5;
i += 1;
}
UpdatePalette ();
int j = 0;
int musicfade = 0;
while (j < 63) {
i = 17;
while (i <= 255) {
if (palette[i].r < palr[i]) palette[i].r += 1;
if (palette[i].g < palg[i]) palette[i].g += 1;
if (palette[i].b < palb[i]) palette[i].b += 1;
i += 1;
}
j += 1;
}
palette[18].r = palr[18];
palette[18].g = palg[18];
palette[18].b = palb[18];
UpdatePalette ();
}
}
Then put this in your game_start:
//store gui palette
int j = 17;
while (j <= 27) {
palr[j] = palette[j].r;
palg[j] = palette[j].g;
palb[j] = palette[j].b;
j += 1;
}
Then in the on_event:
if (event == eEventLeaveRoom) {
Fade("out");
}
if (event == eEventEnterRoomBeforeFadein) {
//store room palette
int j = 28;
while (j <= 255) {
palr[j] = palette[j].r;
palg[j] = palette[j].g;
palb[j] = palette[j].b;
j += 1;
}
//erase palette
int i = 17;
while (i <= 255) {
palette[i].r = 15;
palette[i].g = 5;
palette[i].b = 5;
i += 1;
}
UpdatePalette ();
}
Then all you have to do is make sure to put this in the "Player Enters Screen (after fadein)" in each room:
Fade("in");
Sorry for the late reply but I cannot get the script to work. I am very thankful for your reply and I wonder if it would be possible for you to send a test-game just to show the function?
Thanks again :D
I didn't read the codes thoroughly, but it quite possibly won't work as expected, since the room palette is probably darkened in the event eEventEnterRoomBeforeFadein.
But since there's no "afterfadein" event for on_event(), so it seems there're no easy fix for the code (I can muck up completely different codes easily, just don't have the time to do so). One possible fix is to remove the "if (event == eEventEnterRoomBeforeFadein){ }" part from on_event() and put it into a new function:
function StorePal(){
//store room palette
Ã, Ã, int j = 28;
Ã, Ã, while (j <= 255) {
Ã, Ã, Ã, palr[j] = palette[j].r;
Ã, Ã, Ã, palg[j] = palette[j].g;
Ã, Ã, Ã, palb[j] = palette[j].b;
Ã, Ã, Ã, j += 1;
Ã, Ã, Ã, }
Ã, Ã, //erase palette
Ã, Ã, int i = 17;
Ã, Ã, while (i <= 255) {
Ã, Ã, Ã, palette[ i ].r = 15;
Ã, Ã, Ã, palette[ i ].g = 5;
Ã, Ã, Ã, palette[ i ].b = 5;
Ã, Ã, Ã, i += 1;
Ã, Ã, Ã, }
Ã, Ã, UpdatePalette ();
}
Then put in script header:
import function StorePal();
Then in
every room which you need the effect, in "player enters room after fade in" event add the code:
StorePal();
I'll expect some other glitches as well, but I'm not in a position to investigate them.