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.

Newcomers DBPro Corner / global "health" variable

Author
Message
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 28th May 2009 19:12
Hi, I was hoping to get some help on a simple health variable...thing.

I want to have a variable, say "health" and now how do I make it so when you come into combat any monsters health is loaded, although each monster has it's own health, and then how would I have it decrease and such, having only one variable, or would I need more...?

Any good ideas?

My site: www.skyknight.co.uk
Dream And Death
18
Years of Service
User Offline
Joined: 21st Feb 2006
Location: The circus! Juggling job, kids and DBPro
Posted: 28th May 2009 20:19
You need to look into arrays!

Dim EnemyHealth(100)

would give you the ability to handle 100 enemy's health seperately in 'one' variable.

"You get what everyone gets, you get a lifetime!" - Death, The Sandman Library

First you Dream, then you ... - Neil Gaiman, 2001
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 28th May 2009 20:36
...alright, is there a good turoial or guide on this or am I going solo for this one?

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 28th May 2009 20:47
ok, read these 2 tutorials:
http://forum.thegamecreators.com/?m=forum_view&t=84908&b=7
http://forum.thegamecreators.com/?m=forum_view&t=110324&b=7

and combine them. then you'll have a good base for an enemy system!

*ding ding*
Grog Grueslayer
Valued Member
19
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 28th May 2009 21:00
It's not as hard as you think Jasonorc. Just dimensionalize it like Dream And Death said and use DEC to lower the health.



Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 29th May 2009 10:19
Or better yet (although maybe slightly more complicated if you haven't tried it before), just have your array enemies declared as a custom type; that way you could get its position, strength, etc. from that same array and avoid eventually messing up because you type the name of the wrong one of your 50 or so arrays somewhere. Such a problem can also be hard to discover afterwards.

Something like this for instance


Hope that helps; I find it a very nice way of keeping track of such things. Took me a while to get used to though.

Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 29th May 2009 15:07
Cool, thanks rudolpho, but how would I then connect enemy23 or whatever to a specific enemy within the game, so when your in combat, it calls up the correct set of data and can then alter or use it?

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 29th May 2009 17:22
if this game is in 3D, you could give the UDT a extra value, the Object Number. Then, when you shoot or something, you just have to loop through the array and check for the object number you just shoot at. then you can alter the values

*ding ding*
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 29th May 2009 17:56
... well, that sounds like it should work, it would probably be more effective if understood that...

Do you mean have object number in the array, and then have it search when I have a creature appear?

How would that look in code?

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 29th May 2009 21:33
a little bit of code in pseudo code



hope you understand it, if you don;t know what pseudo code is, look it up at wikipedia sinci i suck at explaining ^^

*ding ding*
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 29th May 2009 23:57
I...don't think I understood that, but I'll look over it and try implementing it and see if I can start to understand it (and bobell, it feels like your a 24 hou dbp noob helper, I will be honestly surprised if your not a mod one day)

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 30th May 2009 10:22 Edited at: 30th May 2009 12:45
ok, have a look at this:

i suppose you are making it in 3d? then i'll gues that you use the command intersect object for shooting, or something similliar. if you do, it'll look a little bit like this:

firs we define a type. this type contains 2 values: the Zombie object number, the zombie is i think just a person, but then green. and the type also contains the object number of the hitbox. the hitbox is placed at the heads position every loop, so we can check for headshots every loop. How? well, lets say we now what the Y position is. and we now that the psotition of the head limb always the objects y position + 10 is. then we just place the hitbox at y position(objectnum)+10

we also make an array, to store the hitbox object number for every enemy and the main zombie object number for every enemy.

we now have this code:



Now that we have updated the hitboxes, it's time for checking if the player shooted (or shot) at some of the zombies. first, we loop through the array to get the Object numbers of the main zombie object and the Hitbox. then, we first check for collision with the hitbox, and then we check for collision with the body of teh zombie. Why in this order? because, if we would check for the zombie main object first, and we were aiming at the head, we would always get hit, and if we are aiming at the zombie's torso, and we check for the hitbox first, we'll know that we aren;t aiming at the head cause we'll get a negative for head collision then. so, all in all, it would look like this:



i hope you can understand the loads of infirmation at once, since i'm not a too good explanator read through it a few times, and try to run through in your head, that sometimes makes me understand it better. oh, and you can also copy this whole code in your DBP ide, that makes it more understandable.

EDIT: omg sorry, i think i posted in the wrong topic i think this would be most helpful in this topic: http://forum.thegamecreators.com/?m=forum_view&t=151506&b=7

ohhh i feel so emberrased D:

*ding ding*
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 30th May 2009 13:13 Edited at: 30th May 2009 13:14
Brilliant, I think can modify that to suit my purpose, thanks.

I'm just going to ask one more question (jeez the amount of questions I need to ask this game isn't gonna have any of my code in it)

How do I set a specific position on a map for x amount of zombies to spawn over t amount of time? I want to have a horde of x zombies (x most likely being a calculation about the level previous to this one)
enter the map from one position, in t amount of time.

This is so I can have maybe 2 to 300 zombies pour realisticly from one area without them spawning inside eachother, but also spawning the moment they can (meaning I make room for maybe 20, and 20 spawn, and once they've moved, another will take it's place in the box until x zombies has been met)

EDIT: Oh and bobbel, that post allows me to udnerstand the problem with both my topics, thanks

My site: www.skyknight.co.uk
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 30th May 2009 16:46
Not complaining or anything, but your code would look a lot more readable if you intendented your lines, bobbel. Just a suggestion when posting to the newcomers board

bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 30th May 2009 17:05
yeah, well, i'm still learning, and my tab key isn;t working great lately. but i'll keep it in mind, thanks

*ding ding*
Jasonorc
16
Years of Service
User Offline
Joined: 29th Apr 2008
Location: Turn around...
Posted: 30th May 2009 17:38
bobbel, what do you think of my latest question then (in this post, just above yours)

My site: www.skyknight.co.uk
bobbel
15
Years of Service
User Offline
Joined: 5th Jan 2009
Location: In my DBPro case xD
Posted: 31st May 2009 00:03 Edited at: 31st May 2009 00:05
well if you wanted to spawn 40 zombies in 10 seconds, you can divide the amount of time by the amount of zombies, which makes 0.25 per zombie for the spawn time. which is pretty short i think, unless the zombies move fast. what you could do is have four locations, and each time you spawn a zombie, you chose another random spawn point. that way you can let them in pretty fast and get attacked from multiple ditances, or make waves of four each () how this would look in code? first i would make a variable, which contains the status of zombie spawning. if there still are less zombies then the level needs, it is 1. if there is enough, you just set it to 0 which means OMG NO MORE ZOMBIEZ.



i think this is pretty much it, tell me if i forgot something

*ding ding*

Login to post a reply

Server time is: 2024-11-24 06:32:34
Your offset time is: 2024-11-24 06:32:34