In my new work in progress I'm customizing the HUDS using a script smallg wrote, and it looks good so far:
However, I have encountered a small issue with switching levels and the custom HUD. When you are injured and enter a winzone it resets your max health to your current health, for example if you entered the winzone with 55/100 health, when you load into the new level you wil have 55/55 health.
Here's a video showing what's happening, note how before entering the HUD says 53/100, after loading into level 2 it says 53/53, and if I turn on the normal HUD it says 53/100:
I've been speaking with smallg over private messages about this and even he doesn't know how to fix it, and I was wondering if anybody else had come across this and knows how to fix it.
Here's the script:
--set the path to find the image to use to display behind the health text
health_i = LoadImage("scriptbank\\images\\hud\\health_bg.png")
--set the path to the image to use behind the gun & ammo count
ammo_i = LoadImage("scriptbank\\images\\hud\\ammo_bg.png")
--set the path to the image to use behind the lives counter
lives_i = LoadImage("scriptbank\\images\\hud\\lives_bg.png")
--note values are % of screen so 50 is middle of the screen
health_posx = 81 --x position of the health hud
health_posy = 1 --y position of the health hud
health_sizex = 10 --x size of health hud
health_sizey = 5 --y size of the health hud
--set values again for the lives count
lives_posx = 90
lives_posy = 1
lives_sizex = 10
lives_sizey = 5
--set values again for the ammo counter
ammo_posx = 70
ammo_posy = 1
ammo_sizex = 10
ammo_sizey = 5
--colour of the text in RGB format (0,0,0 = black and 255,255,255 = white)
health_red = 255
health_blue = 255
health_green = 255
--colour for ammo text
ammo_red = 255
ammo_green = 255
ammo_blue = 255
--colour for lives text
lives_red = 255
lives_green = 255
lives_blue = 255
--the size of the text (1 = small, 5 = big)
text_size = 3
--note the text position is currently automatically placed in the center of the image
--set to 1 if you want the max_PlayerHealth to increase when players current health goes above it (not a good idea if you are using a temporary health increase effect in your level)
dynamic_max_health = 1
max_PlayerHealth = nil
health_sprite = nil
ammo_sprite = nil
lives_sprite = nil
player_dead = 0
function custom_hud_init(e)
HideHuds()
Hide(e)
CollisionOff(e)
end
function custom_hud_main(e)
--create and size sprites
if health_sprite == nil and health_i ~= nil then
health_sprite = CreateSprite(health_i)
SetSpriteSize(health_sprite,health_sizex,health_sizey)
else
if ammo_sprite == nil and ammo_i ~= nil then
ammo_sprite = CreateSprite(ammo_i)
SetSpriteSize(ammo_sprite,ammo_sizex,ammo_sizey)
else
if lives_sprite == nil and lives_i ~= nil then
lives_sprite = CreateSprite(lives_i)
SetSpriteSize(lives_sprite,lives_sizex,lives_sizey)
else
--handles player max health
if max_PlayerHealth == nil then
max_PlayerHealth = g_PlayerHealth
else
--checks if we want to increase the players max health
if dynamic_max_health == 1 then
if g_PlayerHealth > max_PlayerHealth then
max_PlayerHealth = g_PlayerHealth
end
end
--check if player died and restore his health to max health
if g_PlayerHealth < 1 then
player_dead = 1
elseif player_dead == 1 then
SetPlayerHealth(max_PlayerHealth)
player_dead = 0
end
--show the health hud
SetSpritePosition ( health_sprite, health_posx , health_posy )
PasteSprite ( health_sprite )
TextCenterOnXColor(health_posx+(health_sizex/2),health_posy+(health_sizey/(text_size-1)),text_size,g_PlayerHealth.." / "..max_PlayerHealth,health_red,health_green,health_blue)
SetSpritePosition ( health_sprite, -9999, -9999 )
--show the ammo hud
SetSpritePosition ( ammo_sprite, ammo_posx , ammo_posy )
PasteSprite ( ammo_sprite )
TextCenterOnXColor(ammo_posx+(ammo_sizex/2),ammo_posy+(ammo_sizey/(text_size-1)),text_size,g_PlayerGunAmmoCount.." / "..g_PlayerGunClipCount,ammo_red,ammo_green,ammo_blue)
SetSpritePosition ( ammo_sprite, -9999, -9999 )
--show the lives hud
SetSpritePosition ( lives_sprite, lives_posx , lives_posy )
PasteSprite ( lives_sprite )
TextCenterOnXColor(lives_posx+(lives_sizex/2),lives_posy+(lives_sizey/(text_size-1)),text_size,g_PlayerLives,lives_red,lives_green,lives_blue)
SetSpritePosition ( lives_sprite, -9999, -9999 )
end --max_PlayerHealth set
end --lives_sprite created
end --ammo_sprite created
end --health_sprite created
end --main
function custom_hud_exit(e)
end
i5, NV960 2GB, 16GB memory, 2x 2TB Hybrid, Win10.
i3 , Intel integrated graphics, 6GB memory, 512GB Generic SATAIII Win8.1.
Intel Celeron (duel Core), Radeon integrated graphics, 4GB memory, 180gB Generic SATAII, WinVista.
Q6600, Intel integrated graphics, 8GB memory, 512GB Generic SATAII, Win7.