ID:144593
 
Code:
client/New()
new/obj/Main/a(src)
new/obj/Main/b(src)
new/obj/Main/c(src)
new/obj/Main/d(src)
new/obj/Main/e(src)
new/obj/Main/f(src)
new/obj/Main/g(src)
new/obj/Main/h(src)
new/obj/Main/i(src)
new/obj/Main/j(src)
// new/obj/Hearts/h1(src)
// new/obj/Hearts/h2(src)
// new/obj/Hearts/h3(src)
..()
mob
var
curheart=3
maxheart=3
maxhearthp=4
obj/he1
obj/he2
obj/he3
h1d=4
h2d=4
h3d=4
obj/maxheartse
health=12
maxhealth=12
hearts=3
maxhearts=3
verb
define()
usr.he1=new/obj/Hearts/h1(client)
usr.he2=new/obj/Hearts/h2(client)
usr.he3=new/obj/Hearts/h3(client)
usr.maxheartse=usr.he3
usr.maxhearthp=usr.h3d
testverb(n as num)
usr.health-=n
healthcheck()
recover(n as num)
usr.health+=n
healthcheck()
proc
healthcheck()
if(usr.hearts>=usr.maxhearts)usr.hearts=usr.maxhearts
var/a=(usr.h1d*usr.maxheart)-4+usr.maxhearthp
var/b=usr.health
if(a!=b)
a-=usr.h1d
a-=usr.h2d
b-=usr.h1d
b-=usr.h2d
a=b
if(usr.maxhearthp<=0)
usr.curheart-=1
if(usr.maxheartse==usr.he3)
usr.maxheartse=usr.he2
usr.maxhearthp=usr.h2d
if(usr.maxheartse==usr.he2)
usr.maxheartse=usr.he1
usr.maxhearthp=usr.h1d
if(usr.maxhearthp>=5)
usr.curheart+=1
if(usr.maxheartse==usr.he1)
usr.maxheartse=usr.he2
usr.maxhearthp=usr.h2d
if(usr.maxheartse==usr.he2)
usr.maxheartse=usr.he3
usr.maxhearthp=usr.h3d
usr.maxhearthp=(usr.health-12)+4
if(usr.maxhearthp>=4)usr.maxhearthp=4
if(usr.maxheartse==usr.he3)usr.he3.icon_state="[usr.maxhearthp]"
if(usr.maxheartse==usr.he2)usr.he2.icon_state="[usr.maxhearthp]"
if(usr.maxheartse==usr.he1)usr.he1.icon_state="[usr.maxhearthp]"
if(usr.maxheartse==usr.he3)usr.maxhearthp=h3d
if(usr.maxheartse==usr.he2)usr.maxhearthp=h2d
if(usr.maxheartse==usr.he1)usr.maxhearthp=h1d
obj/Hearts
icon = 'Hearts.dmi'
icon_state = "4"
screen_loc = "10,10"
New(client/C)
C.screen+=src
h1
screen_loc = "9:15,10"
h2
screen_loc = "9:23,10"
h3
screen_loc = "9:31,10"


Problem description:
I'm trying to make a heart system similar to that seen in the Zelda game series. Each heart is divided into quarters (hence the health variable being 12 (3 heart containers * 4 health per heart). I want to make it so you can gain more heart containers throughout the game and have your health go up when recovered and down when injured.
However, so far all I've been capable of doing is making the first of three hearts (I haven't tried it with more than 3 hearts) can gain and lose fractions, but the remaining two hearts do not change, even if health goes below 8.
Does anyone know how to do this? I'd assume that lists would be of help, and those are pretty much my weak point when it comes to programming.
Thanks in advance.
no usr in proc, no use boonlean variables(change number variables from == to =< or =>, or if you just want to know if its true(1 or more) then...
if(whatever)
just put a variable in the if.If you want to know if it isnt true:
if(!whatever)
)

Sorry I cant really help you though.But what I just said, could possibly fix it.change what needs to be changed, and see.
In response to Dragon_fire6653
People always tell me to use src instead of usr, but having coded for 5 years I have never really seen any problems with it...
It's been 23 hours...so..bump.
In response to FireEmblem
FireEmblem wrote:
People always tell me to use src instead of usr, but having coded for 5 years I have never really seen any problems with it...

You can use usr in proc if you want its a matter of choice. Unless your releasing a library or demo or something like that then usr is probably a good forum bashing deterrent.

As for you code above I can't really solve it. All those variables confuse me. How ever I will post this, http://developer.byond.com/hub/Shadowdarke/HUDmeter. HUDmeter. It might help you.

Sorry I can not be of more help.
I didn't inspect your code, but from what you said, it's probably a math error.

Could you show me what are you doing to determine what each heart will display?
In response to Green Lime
Thanks much, Green Lime. I'll see if I can fit that into my code.

EDIT: The Heart system works fine, but my money HUD..not so much.
Money = new(src, "Money", "7, 10:17", "mon", "mmon", \
list('Numbers.dmi', 'Numbers.dmi', 'Numbers.dmi','Numbers.dmi'), 9)

mon and mmon are set to 9999. Numbers.dmi has numbers 0 through 9, 0 not having an icon_state name. Just like the heart system and everything else in Shadowdarke's library.

However, whenever I change the digits, it messes up. I entered in 5667, HUD shows 9920. 1234 gives 4000. 1 gives 0000.

I want it to be so when you have 1, the HUD reads 0001, and when I enter in 5667, it shows 5667. Anyone know what's wrong with this?

Also, it won't let me do something like:
list('Numbers.dmi', 'Numbers.dmi' = "8:21,10:17", 'Numbers.dmi' = "8:29,10:17",'Numbers.dmi' = "9:5,10:17"), 9)
In response to FireEmblem
FireEmblem wrote:
Thanks much, Green Lime. I'll see if I can fit that into my code.

EDIT: The Heart system works fine, but my money HUD..not so much.
Money = new(src, "Money", "7, 10:17", "mon", "mmon", \
> list('Numbers.dmi', 'Numbers.dmi', 'Numbers.dmi','Numbers.dmi'), 9)

mon and mmon are set to 9999. Numbers.dmi has numbers 0 through 9, 0 not having an icon_state name. Just like the heart system and everything else in Shadowdarke's library.

However, whenever I change the digits, it messes up. I entered in 5667, HUD shows 9920. 1234 gives 4000. 1 gives 0000.

HUDmeter is made for meters, not numeric displays. The meter you just defined has 40 units in it, 4 sections of 10 values each. With 5667/9999, it is filling the first two meters completely and setting them at the full state (9). The third section of the meter is about 2/10ths full, so it displays state 2. You can illustrate exactly why this happens if you decrease mmon to 40 and put in the slide() code from teh HUDmeter demo.

For a numeric display, take a look at sd_Text of DMIfonts.


Also, it won't let me do something like:
list('Numbers.dmi', 'Numbers.dmi' = "8:21,10:17", 'Numbers.dmi' = "8:29,10:17",'Numbers.dmi' = "9:5,10:17"), 9)


This is because of how BYOND handles lists. You can have an unassociated value in the list many times with no problem, but if you associate a value with it, it will only appear once in the list with the last defined associated value.
In response to Shadowdarke
Wait, sd_Text of DMIfonts, or sd_Text or DMIfonts?
In response to FireEmblem
or :p