WARCHILD_89 wrote:Does anyone know how to scale the cockpit sprite according to the screen resolution???
I think you could use an ACS script like this one
Code: Select all
#library "any_name_here.txt" //note that the name is irrelevant but if you have lots of scripts you should use a name that will help you remember what it does
#include "zcommon.acs"
#define Image_name_here 1
str image_string = "Image_name_here";
Script "any_name_here" (VOID)
{
SetHudSize(640,480,0); // your resolution here - preferably with the same size as the image you want to use as HUD
SetFont(CHUD); // this line set the image_string(can be any name BTW) to be used as font
// The next line is to display the image as HUD by the mean of HUDMESSAGE, the 'A' is replaced by the image you have defined earlier
HudMessage(c:'A'; HUDMSG_PLAIN | HUDMSG_ALPHA, 128, CR_UNTRANSLATED, 320.0, 240.0, 0, 0.4);
// The delay line is to prevent the script runaway error
delay(1);
}
Here is the HUD animation i'm using in one of my mod. This script is a modified version of Cybermind's radar script and it's show another way to define multiple images and use one defined word for all images.
Code: Select all
#define F_RADAR_SIZE 12 // this means F_RADAR_SIZE is composed of 12 elements that should be all in the string(str F_RADAR)
str F_RADAR[F_RADAR_SIZE] =
{"RADAR1", "RSAFEZ", "RSAFEZ1", "RSAFEZ2", "RSAFEZ3", "RSAFEZ4",
"RSAFEZ5", "RSAFEZ6", "RSAFEZ7", "RSAFEZ8", "RSAFEZ9", "RSAFEZA"};
Script 868 (VOID)
{
int atic = 0;
int MRadarC = CheckInventory("MRadarOn");
while(MRadarC == 1) // Escape if gone!
{
SetHudSize(640,480,0);
SetFont(F_RADAR[atic]);
HudMessage(c:'A'; HUDMSG_PLAIN | HUDMSG_ALPHA, 128, CR_UNTRANSLATED, 320.0, 360.0, 0, 0.2);
if(atic == 0) // Special case for first/last frames
delay(8);
else if(atic == F_RADAR_SIZE - 1)
delay(10);
else
delay(1);
atic++;
atic %= F_RADAR_SIZE;
}
}
So if your HUD image is called MyHUD.png and you want the string to be named "HUD2" here is how the script would look like. Note that the script name doesn't matter and you can even use a number as long as the script has no error it should work fine
Code: Select all
#library "MyNewHUD.txt"
#include "zcommon.acs"
#define MyHUD 1
str HUD2 = " MyHUD";
Script "MyNewHUD" (VOID)
{
SetHudSize(640,480,0);
SetFont(HUD2);
HudMessage(c:'A'; HUDMSG_PLAIN | HUDMSG_ALPHA, 128, CR_UNTRANSLATED, 320.0, 240.0, 0, 0.4);
delay(1);
}
Also note that the location of the image is at 320.0, 240.0 with an 0.4 alpha(transparency), Those can be changed to fit your needs
it should work since it's working well on one of the mods i'm working on
Ho and the image i used in my mod is a 4:3 ratio (resolution of 640x480) and i had to adjust the location at 320.0(x), 240.0(y) to make it display properly so my guess is you will probably have to do the same .
EDIT : I forgot to say something REALLY important. (VOID) script needs to be called by an actor so if you have a script for the player you can call the ACS there or you can just replace the (VOID) by ENTER and the script will execute at the beginning of all maps. Also add a loadacs.txt with the name of your script inside so zdoom will load it instead of ignoring it. One more thing, the ACS script needs to be compiled with Slade 3 (or any other programs capable of compiling ACS) I know it might sounds complicated but it's not. If you need help let me know. I'll do whatever i can to help you.