Scripts / Help with Health Bar

Author
Message
Crazy Programmer
19
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 6th Feb 2016 23:00
I am just playing around with my first attempt at a script to setup a health bar.

Here is what iv come up with, but I am having trouble figuring out how to call the max health set by the FPE file I think it is.



I understand g_PlayerHealth calls the players current health. Is there not a global which tells me the max health?
If so how can I change the max health in the script with out having to set it in the Editor.

There is SetPlayerHealth() which only adds to its current health which will exceed the max health set in the editor.
I'm looking for a command maybe along the lines of. SetPlayerMaxHealth() and a global variable. g_PlayerMaxHealth.

In other words I'm looking for ways to call/change the Variables set in the Editor using Lua script. (I'm assuming defined in the FPE file if I read the guide right.)

Sorry if I'm not making any since, this style of doing things is all too new to me.
Download My Games for Android. Made with AGK.
Jellyfish Dive- https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Brick Destroyer - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_BrickDestroyer
Ping Bong - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_Pong_Ping_Bong

perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 7th Feb 2016 00:18 Edited at: 7th Feb 2016 00:20
Hi, Crazy Programmer

Create a starting health variable for e and fill it on the first run of the script.

extract from ai_soldier.lua
Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 8.1 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
Crazy Programmer
19
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 7th Feb 2016 02:27
Your script is asking if the startinghealth = no value then assign it the value of g_Entity[e]['health']

My question is.
Where is the value of g_Entity[e]['health'] stored. Also I'm assuming that it would pull the health of the Entity that the script is assigned too.

Iv looked and looked for the script that is controlling my player but have yet to find it.

I have been using the Fantasy Evil Wizard for testing and his health starts off at 100. I assign a script to a barrel that is controlling the health bar and setting the players health to 1000. When I throw out a mob that kills me I respawn with 100 health. after i have set the health to 1000 when the script first runs.

I'm just a little confused with what all is going on behind the scenes with the player and how to grasp this much wanted power.

Download My Games for Android. Made with AGK.
Jellyfish Dive- https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Brick Destroyer - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_BrickDestroyer
Ping Bong - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_Pong_Ping_Bong

perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 7th Feb 2016 04:53 Edited at: 7th Feb 2016 05:31
[updated]
My mistake, my first reply is for an entity's health, not the player. sorry.

Most of the Players settings are still hardcoded, so we don't have them in lua yet.

So on the stock players health hud image its has

100 | 100

which is represented by...
g_PlayerHealth | Players health value, as set in the players start marker.

Hopefully I have not mislead you again..

I haven't made a player health hud yet, so It looks like ill do it now as well.

Quote: "When I throw out a mob that kills me I respawn with 100 health"


when you respawn the health is set as per the Players health value, as set in the players start marker.

Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 8.1 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 7th Feb 2016 07:33 Edited at: 7th Feb 2016 10:06
This might help to get started.
As you collect health and it increases past the players start marker value, then Players_maxHealth is increased as well to get you the correct scale percentage, and when the player dies the player restarts with the new higher Players_maxHealth.
I think this is what you are trying to achieve.

Cheers



UPDATED
Desktop: Intel(R) Core(TM) i7-4790 CPU @ 3.60GHz (8 CPUs), ~3.6GHz, Windows 8.1 64-bit, 16 GB Ram, NVIDIA GeForce GTX 750 Ti, Display Memory: 4018 MB. Resolution 1360x768, Passmark 3528.
Laptop: Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2336 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)
Crazy Programmer
19
Years of Service
User Offline
Joined: 6th Sep 2004
Location: Lost in AGK
Posted: 7th Feb 2016 20:50 Edited at: 7th Feb 2016 20:56
That's a very nice example working quite well. I am just a little upset it is not possible to have control over the health set by the editor.

Just as an example. When you die you respawn with the Max Health set by the editor which is 100. Is there not a script controlling how the character respawns with (X) amount of health...Where he would respawn...Did he lose his gear when he died? How much Xp did he lose? Is he going to have a cooldown?

And the original healthbar still shows 40/100 when the actual health is 40/410.

How could I track if the player has died in a script then have a script execute.

If PlayerDied()
SetPlayerHealth(maxHealth)
SetPlayerSpawnPoint(100,0,2345)
PlayerXP = PlayerXP *.9 --Xp loss is 10%
--etc etc etc
end


Also the game I am trying to create is Medieval Fantasy. Where you would like any other RPG run around slaying monsters completing quests and gaining xp.

Its not just a quick shoot em up game which would be made and completed after a few short minutes / hours. There is no way to write and read from a file to save game progress or a save mode?
From my knowledge there is no way to save progress.

Is life with GameGuru even worth pursuing at the moment with lack of key features?
I may have to decide to stick with AGK. The only reason I chose to buy GameGuru was to support TGC and check out the product. Also having so much media at your disposal is quite nice.
Download My Games for Android. Made with AGK.
Jellyfish Dive- https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_JellyFishSwim
Brick Destroyer - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_BrickDestroyer
Ping Bong - https://play.google.com/store/apps/details?id=com.CrazyProgrammerProductions.my_Pong_Ping_Bong

smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 8th Feb 2016 00:36
you need to do (pretty much) all the work yourself, that's just how GG is right now, even though it's being sold as a full product it is still very much a beta.

for checking it the player dies is simple, just check 'if g_PlayerHealth < 1 then'
you can create your own save if you like by writing to files using the lua file commands (not GG specific), check the lua manual for the code http://www.lua.org/pil/21.1.html and also moshroom has a script for saving or you can just wait for the save/load feature which is being worked on now.... i doubt waiting a month or 2 for saving would be the biggest issue you'll have when trying to make a game with GG
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, AMD R9 200 series , directx 11
Teabone
Forum Support
17
Years of Service
User Offline
Joined: 8th Jun 2006
Location: Earth
Posted: 8th Feb 2016 00:50
Quote: "There is no way to write and read from a file to save game progress or a save mode?
From my knowledge there is no way to save progress."


I believe the next release should have what your looking for. My understand is the saving and loading in GG will be done in LUA, pre-made for us in the next build by Lee.
Twitter - Teabone3 | Youtube - Teabone3 | Twitch - Teabone3

i7 -2600 CPU @ 3.40GHz - Windows 7 - 8GB RAM - Nivida GeForce GT 740

Login to post a reply

Server time is: 2024-05-03 11:47:57
Your offset time is: 2024-05-03 11:47:57