Just out of curiosity, what do I have to do, if I want to display one single health bar for more than one monster? Let's say, I have two monsters and I want their overall health be displayed in one single bar (that means 1 monster is killed, just 50% of health is left)Enjay wrote:I like Apotherm's hpbar demo. A very neat little script with easily modifyable parameters to suit any monster or situation. I have noticed a couple of minor problems however:
The percentage numbers fading make them hard to read. It works much better if they change instantly.
When you view it at alternative screen resolutions, you can get gaps in the bar. I assume this is due to innacuracies in the sethudsize feature of Zdoom. eg, the script sets it to a hudsize of 800x600. If I view it at 1024x768, I see 4 single pixel gaps in the bar.
Personal choice, but I prefer my health bars to be central rather than hidden by pickup messages.
If anyone is interested, here is my modification (I hope you don't mind Apotherm):
Spoiler:
ACS Prefab Database
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
- Tormentor667
- Posts: 13554
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
If you want to do anything complicated, you'll need to know how they work!Enjay wrote:As for arrays, I simply don't know where to start with them. I don't understand them. It's been explained to me a few times but, so far, I don't get it.
You probably know that there's keys and values in an array. The value is what is stored under its associated key. And if you've had it explained to you like that, of course you're confused.
Let's take one-dimensional arrays first.
Let's say you've got a file cabinet. It's got a label on it: "Enjay" Inside that file cabinet, there are, of course, files. (Imagine, and this may be very difficult, that this is an ideal file cabinet -- the files inside are actually nicely organized and clearly labeled.) The files are various information about you. "Profession." "Last Known Location." "Favorite Donut Flavor."
If we open the "Profession" file, we get a result, say "Biology Teacher."
From that information, we could say: Enjay's Profession is Biology Teacher.
In code, you've got this:
Enjay["Profession"] = "Biology Teacher"
"Enjay" is the array.
"Profession" is the key.
"Biology Teacher" is the value.
Does that make sense? If it doesn't you'd better not read further until it does.
Two dimensional arrays:
So we have our "Enjay" file cabinet. But we want to also keep files for other people as well. Let's add a "Risen" cabinet next to that, and an "Apothem" cabinet as well. Of course, it makes the most sense to have the same files for each person. Now that we have all that stuff, we need a room for it. So we put aside a room and nail a sign to the door: "People."
The biggest container is now the room. That's our array. First, we need to enter the room before choosing a person, then we can get the file we want.
From the people we know, Enjay's Profession is Biology Teacher.
People["Enjay"]["Profession"] = "Biology Teacher"
What is we want information about Risen?
Enter the room, open Risen's information, and find his profession. What is it?
People["Risen"]["Profession"] = "Graphic/Web Designer"
You could lay all that information out in a table. Across the top it would say "XX | Enjay | Risen | Apothem"
and the next line would be
"Profession | Biology Teacher | Graphic/Web Designer | ...."
The horizontal dimension are the cabinets. The vertical dimension are the files.
More dimensions
In the KDIZD Intermap, I use three dimensional arrays.
I keep track of some statistics. That's one dimension.
There could be up to eight players. That's a second dimension.
There are multiple maps in the set. A third dimension.
At then end of the game, I've built a pretty large array. But if I want to know how much healh player 1 lost on map 4, I can do this:
stats[map4][player1][health_lost]
How much ammo did player 2 use on map 2?
stats[map2][player2][ammo_used]
I certainly hope that helps. Let me know if I can clarify anything further.
- TheDarkArchon
- Posts: 7656
- Joined: Sat Aug 07, 2004 5:14 am
- Location: Some cold place
So is thinknig of an array sort of like tables within tables?
Episode - 1
map - 1
player - 1
statistic
Episode - 1
map - 1
player - 2
statistic
and so on...
Each Episode has 9 maps, which each have 8 players, which each have one statistic (or more). If that's a very simple understanding of it, I understand
Episode - 1
map - 1
player - 1
statistic
Episode - 1
map - 1
player - 2
statistic
and so on...
Each Episode has 9 maps, which each have 8 players, which each have one statistic (or more). If that's a very simple understanding of it, I understand

- Bio Hazard
- Posts: 4019
- Joined: Fri Aug 15, 2003 8:15 pm
- Location: ferret ~/C/ZDL $
- Contact:
Um, Risen, you just described the use of a struct or hash-type array. Those are much easier to describe as a file cabinet.
ACS doesn't have structs so I see why you used that description.
As for multidemensional arrays, there really is no limit to how many dimensions there can be. You could go as far as to:
That would be a huge array though I hope you use pointers if you do something like that
.
Code: Select all
files[cabinet][drawer][file].field
As for multidemensional arrays, there really is no limit to how many dimensions there can be. You could go as far as to:
Code: Select all
files[dimension][galaxy][starsystem][planet][continent][country][state][city][building][room][cabinet][drawer][file].field

I just used the first example that came to mind and made some sense.Bio Hazard wrote:Um, Risen, you just described the use of a struct or hash-type array. Those are much easier to describe as a file cabinet.
I'd rather not confuse anybody with things they cannot do.Bio Hazard wrote:ACS doesn't have structs so I see why you used that description.
Again, not something you can do with ACS though.Bio Hazard wrote:As for multidemensional arrays... You could go as far as to... That would be a huge array though I hope you use pointers if you do something like that.
It's hard enough just getting a multidimensional array to move across maps!
- Apothem
- Posts: 2070
- Joined: Sat Nov 29, 2003 7:13 pm
- Location: Performing open heart surgery on an ACS compiler.
That would take a whole new bar. You'd take the percentage of remaining hp for both monsters and divide by 2 (for 2 monsters) and you could also make the bar have two seperate colors for both the monsters within the same bar too, and all that would only take a little extra if statement and a little modification to the for loop.Tormentor667 wrote: Just out of curiosity, what do I have to do, if I want to display one single health bar for more than one monster? Let's say, I have two monsters and I want their overall health be displayed in one single bar (that means 1 monster is killed, just 50% of health is left)
- Tormentor667
- Posts: 13554
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
Well, I am a total scripting noob concerning this... and I'd need such a script for 4 or more monsters, could someone write such a script?Apothem wrote:That would take a whole new bar. You'd take the percentage of remaining hp for both monsters and divide by 2 (for 2 monsters) and you could also make the bar have two seperate colors for both the monsters within the same bar too, and all that would only take a little extra if statement and a little modification to the for loop.Tormentor667 wrote: Just out of curiosity, what do I have to do, if I want to display one single health bar for more than one monster? Let's say, I have two monsters and I want their overall health be displayed in one single bar (that means 1 monster is killed, just 50% of health is left)
I suppose it is more of a demonstration of how this could be achieved than a full prefab. I really don't want to trawl through the source for all the frames of the monsters. But if do, I could compile it into a library and the sequence could be triggered by using Do_Hexen_Ending(); or Do_Doom2_Ending(); (or something)Sir_Alien wrote:Also, it doesn't really appear flexible enough to be included in the database.
The sounds could be in another dimension of the array with the sprites, but thats about the only way to do it because there would be too many 'placeholder' variables.Sir_Alien wrote:Not enough of the attributes are predefined as strings or variables (i.e. sounds) at the beginning of the script to make importing this into another script easy (if you simply used another string array or two for the sounds you could compress script 1 down quite a bit).
Or use changecamera();Apothem wrote:Didn't think of the skybox, but yeah, that's definently on the right track. Lets see where he takes it, and we'll go from there.
Also, the script could be modified allow the monsters to be rotated and killed at a certain time, but it would require keybindings (might do this eventually)
- Apothem
- Posts: 2070
- Joined: Sat Nov 29, 2003 7:13 pm
- Location: Performing open heart surgery on an ACS compiler.
That's the purpose to taking away all the weapons and adding a line hit special to the wall the player is facing. The player punches the wall, and the monster dies. The multi-dimensional array would define the monster sprite used and the max animation and firing frames and such.justin024 wrote:Apothem wrote:Didn't think of the skybox, but yeah, that's definently on the right track. Lets see where he takes it, and we'll go from there.
Or use changecamera();
Also, the script could be modified allow the monsters to be rotated and killed at a certain time, but it would require keybindings (might do this eventually)
Here is a demo of what I was talking about, done with just keybindings and no line specials. Press Z/X to rotate and C to kill. But only monsters that aren't mirrored can be set up to be rotated. Load .zip w/ gzdoom
- Attachments
-
ending.zip
- Ending Demo 2
- (1.98 KiB) Downloaded 55 times
@Double Post (:P)
Something I noticed about Jalla's RPG script is that it is a one map script which makes it basically useless for mods with more than one map.
Solution: Make these map-level variables into global variables and place the scripts inside a library
Something I noticed about Jalla's RPG script is that it is a one map script which makes it basically useless for mods with more than one map.
Solution: Make these map-level variables into global variables and place the scripts inside a library
Code: Select all
int xp = 0; // player experience
int lv = 1; // player level
int nextlv = 2; // next level
int hp = 100; // player health
int ar = 0; // player armour
str gained = "";
I will look into it, shouldn't be too hard. I could put an HP bar in each corner of the screen.Tormenter667 wrote:Well, I am a total scripting noob concerning this... and I'd need such a script for 4 or more monsters, could someone write such a script?