Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

FPSC Classic Scripts / Health Bar Problem

Author
Message
Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 24th Mar 2009 21:49
Heck, I know some scripting but when I look at this script, I explode with nonsensicatility (?)



Now, this is a hud that I desperately want to work, unfortunately it doesnt. Plystire told me for it to work to simply take out the Armor aspects of the script.
Since the script is loaded with statements I dont understand, im sure I could remove what I think is the Armor part and still have a non-working script in my explorer, idly waiting for me to make the next disastrous move. So I call upon the community, whose combined intellect would easily be able to share the knowledge of the meaning of life (Yes I know its 42)
Help?


Making the challenge? More like kicking teh nass!
Seen Endangered City yet? It wont last long!
Crusader2
16
Years of Service
User Offline
Joined: 8th Aug 2008
Location: Somewhere...
Posted: 24th Mar 2009 23:36 Edited at: 24th Mar 2009 23:36


That should do it.

Some people say that I'm crazy... And I agree.
USE PLY'S MOD!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 25th Mar 2009 02:51
Please take note of this line:
Quote: "Find out how much to scale by using (Current/Max)"


The way the script works is you set the CalcVar to your current health (setvar=CalcVar $PH) and then divide it by the player's MAX HEALTH (divvar=CalcVar 500). This will give us the correct percentage we need to scale the HUD. However, the scale command wants the percentage as a non-decimal number (While in mathematics a value of 1.0 is 100%, this script wants a value of 100 for 100%) We would then need to multiply the value we get by 100. In the script I gave you, I skipped this part and combined it with the division step, producing the "divvar=CalcVar 5".

So let's say the player has 250 health. This script takes 250/5 and gets 50. That's 50 percent of the player's maximum health, and the scalehudx command then changes the hud's size to half of what it was originally.


If 500 is NOT the maximum health your player can have, you'll need to edit the division part of the script to suit it.


Now, I am going to ask you what I ask EVERYONE who says "it doesn't work". You ready?

...

What doesn't work about it? You have to tell me EXACTLY what it's doing that it shouldn't be doing or what it's NOT doing that it SHOULD be doing. Simply saying "It doesn't work" doesn't give me a clue as to what's going wrong.


That said, make sure you are applying the script to a dynamic entity that will always be active. Dynamic Lights work well for this, as do trigger zones. You may also have not put the HUD image in the right location.



There, that is my comprehensive outlook on this script. I hope you followed along closely.


The one and only,


Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 25th Mar 2009 19:09
Sorry Plystire, ill be more descriptive this time...

Before hand, The armor section of the script kept my health at a steady 100, and not even the armor variable went down while I was being shot. Crusader2 changed the script to take out all armor elements, and now it works!
Now to make one for an enemy...


Making the challenge? More like kicking teh nass!
Seen Endangered City yet? It wont last long!
Mugen Wizardry
User Banned
Posted: 29th Mar 2009 02:51
How do u use this?
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 29th Mar 2009 04:18
It requires Ply's Mod to function. After that, just create a "bar" image to use as the health bar and stick it on a dynamic light (or triggerzone, which is my favorite )


The one and only,


Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 29th Mar 2009 13:20
Good old trigger zones! One effective way to open into a game would be a blank hud and then upon entering the trigger zone, the health hud would appear.
Hey Plystire? You know how I was asking you about a middle shrinking in health hud e.g >---< >--< >-< >< What would the scalehud be set to?


Making the challenge? More like kicking teh nass!
Seen Endangered City yet? It wont last long!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Mar 2009 03:17
For the HUD to shrink towards the middle, you would need to reposition it since the scale will only scale it down towards the left.

The trick is to scale it how you are scaling it now, but ALSO reposition it so that it will remain centered even with the new scale. This would require you to hardcode some values into the script based upon the dimensions of your health bar image.

Here's some math for you to mull over if you want to do it:

Reposition distance = Image Width / Scale

The scale should be in decimal form. (That is... Current Health / Maximum Health)


The one and only,


Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 30th Mar 2009 10:02 Edited at: 30th Mar 2009 10:04
Width of Image = 512 pixels
Scale = Current/Max Health?

So Repo Distance = 512/1
= 512?


Making the challenge? More like kicking teh nass!
Seen Endangered City yet? It wont last long!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Mar 2009 14:08
Whoops, that formula wouldn't do at all.

Repostion Distance = Image Width * ( 1 - Scale )


The one and only,


Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 30th Mar 2009 18:41 Edited at: 30th Mar 2009 18:53
Hrm...

Repostion Distance = Image Width * ( 1 - Scale )
= 512 * (1 - 1.0) (1.0 being Current/Max 100/100)
= 512 x 0
= 0
Scale hud 0?

EDIT: Will this hud work on the newest version on FPS Creator? Because im really getting bad frame rate, 20 fps at most on 1.5gb on RAM on a simple 6 square level...


Making the challenge? More like kicking teh nass!
Seen Endangered City yet? It wont last long!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 30th Mar 2009 23:48
Dude your RAM doesn't play a HUGE role in why you get low framerates. That would be your CPU and your GPU.

And, yes, if the HUD is scaled up to 100%, then the "Reposition Distance" should be 0. If it's at 25%, then it should be repositioned by 75% of the Image's width.

Now, since you need to learn some more scripting, I'll let you implement it. Call it good practice


The one and only,


Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 31st Mar 2009 00:19
Oh I give up... I guess i'll have to stick back to just a normal bar. I can't learn scripting, its like a dyslexia problem with me, I look at a script and I just can't learn it or even understand how it works...


Making the challenge? More like kicking teh nass!
Seen Endangered City yet? It wont last long!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 31st Mar 2009 07:14
That's okay. I think a normal accurate health bar is a break-thru enough for FPSC.


The one and only,


Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 31st Mar 2009 10:01 Edited at: 31st Mar 2009 10:02
Yeah, I should save the shrinking bar for the sequel, if I can hurl my co-workers towards the scripting tutorial...
Now to make a hud going around the bar. Also, how do you remove the black areas around the bar? It seems running dds. textures inside the engine don't run with the whole "transparent black" thing anymore...


Making the challenge? More like kicking teh nass!
Seen Endangered City yet? It wont last long!
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 1st Apr 2009 01:54
dds files have an embedded alpha channel, so using black for transparency would be a little redundant.

Open the file in Paint.NET and change the black parts to be transparent.


The one and only,


mAcpo
16
Years of Service
User Offline
Joined: 3rd Dec 2007
Location: USA
Posted: 27th Jul 2009 04:27
Hey Plystire, I am attempting to use either code snippets in this thread by YFPSD and Crusader2. I have created a healthbar.dds which I have attached to this post. I have put it in the right folder and checked the HUD coordinates. I have tried attaching the scripts to a trigger zone and dynamic light. I am unable to get a health bar onscreen with either method. It does not show up at all. I have tested my trigger zone with a fog off/on script which is working so my trigger zone appears to be ok. I am using Project Blue and my version is the latest full purchased edition from s4real. Can you give me some suggestions?

Here is the contents of my script

Attachments

Login to view attachments
Thistle Studios
17
Years of Service
User Offline
Joined: 1st Mar 2007
Location: Kirkcaldy
Posted: 27th Jul 2009 11:21
Dont ask Plystire for help anymore, he has quit FPS Creator. I myself have done so too as it is just holding me back.


Pentium 4 2.61ghz 1.5gb DDR 333Mhz RAM NVIDIA GeForce 7600GS AGP 8X
Endangered City. An Endangered Species
mAcpo
16
Years of Service
User Offline
Joined: 3rd Dec 2007
Location: USA
Posted: 27th Jul 2009 16:33
ummm ok, last i checked he posted yesterday and I purchased project blue which he is a part of. I know they said they were taking some time from PB but I am sure he will be back to finalize the 1.7 version.

Login to post a reply

Server time is: 2024-11-25 05:12:37
Your offset time is: 2024-11-25 05:12:37