Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-10-2010, 11:37 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Circular HUD Bar

Made this for fun. It was intended to be a health bar like Kingdom Hearts, but I got a bit stumped when it came to branching the bar off from the angle. Either way, I figured I'd fix this up and post it as a script for others to use or even better, learn.

Right now the bar itself extends per your health(it's based on player.hearts and player.fullhearts, if you're using custom, replace all instances of player.fullhearts with your custom maxHP, and player.hearts with your custom HP), so make sure you define the maximum amount of possible life(for example, 20 is set for mines since default hearts max out at 20).

Click image for larger version

Name:	graal_1276162528.png
Views:	1194
Size:	165.8 KB
ID:	51169

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
this.HUDimage   "dusty_guibartest1.png"// Define the image of the bar;
  
showstats(1024);        // Hide all but the player
  
this.HUDx       50;   // Center 'X' position of the HUD
  
this.HUDy       50;   // Center 'Y' position of the HUD
  
this.radius     23;   // Distance the bar extends out to from center
  
this.thickness  15;   // Thickness of bar in pixels
  
this.margin     2;    // Thickness of outline in pixels
  
this.startangle pi/2// Starting angle of bar
  
this.direction  1;    // Direction the bar goes. -1 = left, 1 = right
  
this.maxlife    20;   // Define the max amount of life possible

  
onTimeout();
}

function 
onTimeout() {
  
// RECORD CUSTOMIZATIONS INTO TEMPORARY VARIABLES
  // THIS IS SIMPLY FOR THE EASE OF SHORTER VARIABLE NAMES
  
temp.sa this.startangle;
  
temp.ox this.HUDx;
  
temp.oy this.HUDy;
  
temp.this.radius;
  
temp.this.thickness;
  
temp.this.margin;

  
// DISPLAY THE HEART IMAGE
  // THIS CAN BE CHANGED TO SOMETHING LIKE THE PLAYER'S HEAD
  
with (findimg(1000)) {
    
image "state.png";
    
ox 20;
    
oy 22;
    
partw 40;
    
parth 44;
    
layer 6;
  }

  
// ALTER THE 'FILL'. THIS IS A VARIABLE THAT COUNTS UP
  // OR DOWN TO THE PLAYER'S HEARTS, SO WE CAN USE IT AS
  // AN ALTERNATIVE, THUS ANIMATING THE BAR FILLING
  
if (this.fill != player.heartsthis.fill += (this.fill player.hearts) ? .5 : -.5;
  else 
this.fill player.hearts;

  
// IF NEW IMAGE COUNT IS LESS THAN THE OLD, HIDE EXCESSIVE IMAGES
  
if (this.oldi player.fullhearts*2hideimgs(200,300+this.oldi);

  for (
temp.i=0;i<player.fullhearts*2;i++) {
    
temp.seg pi/this.maxlife;
    
temp.= (sa + (i*seg)*this.direction);
    
temp.padding = {(== 0)*pi/40,(((i+1)/2) == player.fullhearts)*pi/40};
    
with (findimg(200+i)) {
      
polygon = {
        
ox cos(padding[0])*(r+t)      ,oy sin(padding[0])*(r+t)      ,
        
ox cos(seg padding[1])*(r+t),oy sin(seg padding[1])*(r+t),
        
ox cos(seg padding[1])*r    ,oy sin(seg padding[1])*r    ,
        
ox cos(padding[0])*r          ,oy sin(padding[0])*r          ,
      };
      
red blue green 0;
      
alpha 1;
      
layer 4;
    } 

    if (
this.fill*2) {
      
with (findimg(300+i)) {
        
polygon = {
          
ox cos(a)*(r+t-m)      ,oy sin(a)*(r+t-m)      ,
          
ox cos(seg)*(r+t-m),oy sin(seg)*(r+t-m),
          
ox cos(seg)*(r+m)  ,oy sin(seg)*(r+m)  ,
          
ox cos(a)*(r+m)        ,oy sin(a)*(r+m)        ,
        };
        
image thiso.HUDimage;
        
layer 5;
      }
    } else 
hideimg(300+i);
  }
  
this.oldi i// RECORD THIS IMAGE COUNT AS OLD

  // IF BAR IS FILLED, SET A LONGER TIMEOUT FOR EFFICIENCY, OTHERWISE
  // SET IT AS LOW AS POSSIBLE FOR SMOOTHER FILL ANIMATION
  
setTimer(this.fill == player.hearts 0.25 0.05);

If I figure out how, I may eventually also add the Kingdom Hearts version. Also, the image for the bar is attached. Make sure you download and save this appropriately.
Attached Images
 
Reply With Quote
  #2  
Old 06-10-2010, 12:51 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
That's really cool, nice work. I would have had no idea how to do this without a ton of images .
__________________
Reply With Quote
  #3  
Old 06-10-2010, 01:51 PM
maximus_asinus maximus_asinus is offline
RIP DarkCloud_PK
Join Date: Oct 2001
Location: Canada
Posts: 3,746
maximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond reputemaximus_asinus has a reputation beyond repute
amazing Dusty, great work.
__________________
Save Classic!
Reply With Quote
  #4  
Old 06-10-2010, 04:04 PM
Cloven Cloven is offline
Delteria
Cloven's Avatar
Join Date: Dec 2006
Location: Florida, United States
Posts: 542
Cloven has a spectacular aura about
Send a message via AIM to Cloven
Yeah that's definitely very nice work Dusty.
Reply With Quote
  #5  
Old 06-10-2010, 04:03 PM
Fulg0reSama Fulg0reSama is offline
Extrinsical Anomaly
Fulg0reSama's Avatar
Join Date: Sep 2009
Location: Ohio
Posts: 3,049
Fulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant futureFulg0reSama has a brilliant future
Extremely good work man
__________________

Careful, thoughts and opinions here scare people.
Reply With Quote
  #6  
Old 06-10-2010, 05:20 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
Good work Dusty.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
  #7  
Old 06-10-2010, 06:10 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Amazing work, Dusty
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #8  
Old 06-10-2010, 07:41 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Haha, so this is what you were talking about earlier!!! good job tuff guy
__________________
Reply With Quote
  #9  
Old 06-10-2010, 08:22 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by xAndrewx View Post
Haha, so this is what you were talking about earlier!!! good job tuff guy
Something a little different, but ya I was hoping to do something like this:

But so far I've had no luck figuring it out.
Reply With Quote
  #10  
Old 06-10-2010, 11:03 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by DustyPorViva View Post
Something a little different, but ya I was hoping to do something like this:

But so far I've had no luck figuring it out.
I would rep you for that image alone.

I really like this code of yours. It's always been kinda "weird" always either having to do vertical or horizontal lines when displaying some kinds of values, but this is really cool.

I'll have to play around with this, thanks!
__________________
Reply With Quote
  #11  
Old 06-10-2010, 08:20 PM
Tigairius Tigairius is offline
The Cat
Tigairius's Avatar
Join Date: Jan 2007
Location: Missouri, USA
Posts: 4,240
Tigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant futureTigairius has a brilliant future
Good stuff.
__________________


“Shoot for the moon. Even if you miss, you'll land among the stars.”
Reply With Quote
  #12  
Old 06-10-2010, 08:55 PM
Cubical Cubical is offline
Banned
Join Date: Feb 2007
Posts: 1,348
Cubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant futureCubical has a brilliant future
Why not use multiple images and check the players hp each time they are hit to figure out which image to change. I could see it done with like4 or 5 images
Reply With Quote
  #13  
Old 06-15-2010, 04:02 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Cubical View Post
Why not use multiple images and check the players hp each time they are hit to figure out which image to change. I could see it done with like4 or 5 images
Hmm, I've only just seen this. Do you mean a predefined set of images to account for every amount of health? Ya, sure, it could be done... but at what cost? 4 or 5 images would only account for 4 or 5 possible status of health(it would only work for someone with 2-3 hearts). After that, you start to lose accuracy as you don't have an image for all the possible increments. Someone with 20 hearts would need 40 images to account for every instance(.5 hp, 1 hp, 1.5hp... so on and so forth).

The method I used is much more dynamic, and can be used with custom systems to display even higher values of HP(up to the 100-200's and really... no limit).

edit: I guess it's not optimized for larger numbers, but I guess that'll be my next goal!
Reply With Quote
  #14  
Old 06-15-2010, 04:23 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
you should probably lose the timeout for custom systems though
__________________
Reply With Quote
  #15  
Old 06-10-2010, 09:07 PM
adam adam is offline
http://wiki.graal.us/
adam's Avatar
Join Date: Nov 2001
Posts: 2,247
adam has a spectacular aura aboutadam has a spectacular aura about
Send a message via AIM to adam
That's not nearly as cool though.
__________________
Rogue Shadow (TCN)(NAT)(Global Development Team)

For development help, contact the patrons of the #graaldt irc channel below, I am usually there.
Click Here to Join IRC Chat Now! -- irc.freenode.net Channel: #graaldt
Quote:
<Dustyshouri> no, RogueShadow is always talking about scripts lol
<Dustyshouri> in fact, he pretty much brought Graal back as a topic single-handedly
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:10 PM.


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