Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Custom Health Display (https://forums.graalonline.com/forums/showthread.php?t=134264118)

Gunderak 08-06-2011 04:05 AM

Custom Health Display
 
Basically iv scripted a bar background which stays there permanently and a red bar on top of it which on a time out when the players health changes so does the red bars width, i was wondering if there is a more efficant way of achiving this without changing the width and having tons of if statements.
Thanks in advanced im sure some of you pro's will be able to help xD

oo_jazz_oo 08-06-2011 04:28 AM

PHP Code:

width = (player.hearts/player.maxhearts)*maxWidth

If this is what you mean. maxWidth being the full width of your image.

cbk1994 08-06-2011 04:33 AM

In whatever function you use for hitting the player, have it trigger the appropriate script, then redraw it.

Tricxta 08-06-2011 04:59 AM

Quote:

Originally Posted by Gunderak (Post 1662136)
i was wondering if there is a more efficant way of achiving this without changing the width and having tons of if statements.

I dont get why you need tons of if statements o_0

its basically just:
PHP Code:

if (health>0)
{
   
part=(health/maxhealth)*maxwidth;//as jazz stated
   
showimg (300,"someimage.png",posx+maxwidth-part,posy);//where posx and posy are where you want it to sit on the screen
   
changeimgpart (300,maxwidth-part,0,part,imageheight);
   
changeimgvis (300,4);
}
else 
hideimg 300

Or do you have something different? Note this is for a horizontal bar and not a vertical although the same method can be applied

also can who ever neg repped me for this just tell me who you are... im sorry for not knowing gs2! in actual fact since its a person with high rep power im kinda half suspecting who it might be. Sorry for trying to help, I will just refrain for showing an example of what I mean.... YES THATS RIGHT! **** YOU!

Gunderak 08-06-2011 05:57 AM

ahh i see i shall have a play around with that, how does changeimhpart work? what do each int's do?

cbk1994 08-06-2011 06:18 AM

Quote:

Originally Posted by Gunderak (Post 1662150)
ahh i see i shall have a play around with that, how does changeimhpart work? what do each int's do?

http://wiki.graal.net/index.php/Crea.../Changeimgpart

Gunderak 08-06-2011 06:53 AM

thanks for that, but wouldnt it just be as easy to use Guiwhatever.width = whatever;
that wiki seems quite handy. i might use it more instead of posting here.

cbk1994 08-06-2011 07:23 AM

Quote:

Originally Posted by Gunderak (Post 1662162)
thanks for that, but wouldnt it just be as easy to use Guiwhatever.width = whatever;

If you're using GUI controls, yes. changeimgpart only works when you're using showimg.

Gunderak 08-06-2011 07:36 AM

ah ok, so how would i make i if the gui was Health_Text so that it changes the image width to how big player.health is?
also is there a way to check what the players hewlth is ajd make its width accordingly withiut using if(player.health == 3){ do this if player health 2.5 etc etcv
i dont understand how the first method works

Entrok 08-07-2011 09:33 AM

Quote:

Originally Posted by Tricxta (Post 1662144)
I dont get why you need tons of if statements o_0

its basically just:
PHP Code:

if (health>0)
{
   
part=(health/maxhealth)*maxwidth;//as jazz stated
   
showimg (300,"someimage.png",posx+maxwidth-part,posy);//where posx and posy are where you want it to sit on the screen
   
changeimgpart (300,maxwidth-part,0,part,imageheight);
   
changeimgvis (300,4);
}
else 
hideimg 300

Or do you have something different? Note this is for a horizontal bar and not a vertical although the same method can be applied

also can who ever neg repped me for this just tell me who you are... im sorry for not knowing gs2! in actual fact since its a person with high rep power im kinda half suspecting who it might be. Sorry for trying to help, I will just refrain for showing an example of what I mean.... YES THATS RIGHT! **** YOU!

Want to fix some of the things i did see in this script

PHP Code:

if (health>0)
{
  
part=(health/maxhealth)*maxwidth//as jazz stated
  
showimg(300"someimage.png"posx+maxwidth-partposy); // where posx and posy are where you want it to sit on the screen
  
changeimgpart(300maxwidth-part0partimageheight);
  
changeimgvis(3004);
}
else 
hideimg(300); 



All times are GMT +2. The time now is 03:43 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.