ACS Prefab Database

Archive of the old editing forum
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.
Locked
User avatar
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:

Post by Tormentor667 »

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:
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)
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

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.
If you want to do anything complicated, you'll need to know how they work!

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.
User avatar
TheDarkArchon
Posts: 7656
Joined: Sat Aug 07, 2004 5:14 am
Location: Some cold place

Post by TheDarkArchon »

How would you define a 3D array without making the items "go into the screen"?
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

An array is just a data construct, it doesn't have to represent a 2 or 3 dimensional space. I could easily have a 4-dimensional array for the intermap if we were to add more episodes after KDIZD...

[episode (1-4)] [map number(1-9)] [player number (1-8)] [statistic]
User avatar
Phobus
Posts: 5984
Joined: Thu May 05, 2005 10:56 am
Location: London
Contact:

Post by Phobus »

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 :)
User avatar
DoomRater
Posts: 8270
Joined: Wed Jul 28, 2004 8:21 am
Preferred Pronouns: He/Him
Location: WATR HQ
Contact:

Post by DoomRater »

Yeah, you're on the right track.
User avatar
Bio Hazard
Posts: 4019
Joined: Fri Aug 15, 2003 8:15 pm
Location: ferret ~/C/ZDL $
Contact:

Post by Bio Hazard »

Um, Risen, you just described the use of a struct or hash-type array. Those are much easier to describe as a file cabinet.

Code: Select all

files[cabinet][drawer][file].field
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:

Code: Select all

files[dimension][galaxy][starsystem][planet][continent][country][state][city][building][room][cabinet][drawer][file].field
That would be a huge array though I hope you use pointers if you do something like that :?.
User avatar
Risen
Posts: 5263
Joined: Thu Jan 08, 2004 1:02 pm
Location: N44°30' W073°05'

Post by Risen »

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 just used the first example that came to mind and made some sense.
Bio Hazard wrote:ACS doesn't have structs so I see why you used that description.
I'd rather not confuse anybody with things they cannot do.
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.
Again, not something you can do with ACS though.

It's hard enough just getting a multidimensional array to move across maps!
User avatar
Apothem
Posts: 2070
Joined: Sat Nov 29, 2003 7:13 pm
Location: Performing open heart surgery on an ACS compiler.

Post by Apothem »

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)
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.
User avatar
Enjay
 
 
Posts: 26991
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

Thanks for the info Risen (and others). I'll be copying this thread to a text file and trying to use the contents at some point. :)
User avatar
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:

Post by Tormentor667 »

Apothem wrote:
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)
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.
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?
User avatar
justin024
Posts: 379
Joined: Sun Nov 14, 2004 1:29 am
Location: Illinois
Contact:

Post by justin024 »

Sir_Alien wrote:Also, it doesn't really appear flexible enough to be included in the database.
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: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).
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.
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)
User avatar
Apothem
Posts: 2070
Joined: Sat Nov 29, 2003 7:13 pm
Location: Performing open heart surgery on an ACS compiler.

Post by Apothem »

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. :wink:

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)
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.
User avatar
justin024
Posts: 379
Joined: Sun Nov 14, 2004 1:29 am
Location: Illinois
Contact:

Post by justin024 »

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
User avatar
justin024
Posts: 379
Joined: Sun Nov 14, 2004 1:29 am
Location: Illinois
Contact:

Post by justin024 »

@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

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 = "";
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?
I will look into it, shouldn't be too hard. I could put an HP bar in each corner of the screen.
Locked

Return to “Editing (Archive)”