• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Solved] Using tables/arrays to seed spawns/drops?

Level 3
Joined
Jun 6, 2024
Messages
13
I'm fairly inexperienced in both programming and the editor so some of this could be obvious and I just need bumped in the right direction. I did some coding back in school and I've dabled in the editor for a decade. Which means I know virtually nothing other than what Ive stumbled across. I'll explain what I'm attempting to do in fairly basic terms and if there's likely issues with it, that's what I'm wanting to know as well as ways I can go about doing it.

Can I create "tables" to pull from? Maybe during initilization? Mostly this would be seeding creep spawns and drops. Something like:

if a unit dies in Y region and the region has no units owned by the hostile player, then wait 30s and create a unit from table X in Y region.

Maybe use rng to create variance in what spawns and it allows me to weight them? Maybe have common, uncommon, and rare variants. But what I need to know is if I can make "table X" and how I could refer to it for this? Maybe something along the lines of assigning units to an array (labor intensive but that's fine with me) and that allows me to perhaps do something like generate a random number between 1 and 1000 and then assign the value of the number generated to a slot on the array. If value is 1-500 use data from Slot 1, if 501-750 use Slot 2, etc. Also I've noticed triggers on death are unreliable sometimes? Maybe a backup trigger at a time of the day cycle thst checks if a unit is there and if not triggers the spawn?

Similar idea for how to use item drops. Something like:

when a unit dies, create an item X at the location of the triggering unit.

Again using rng to weight tables I've created. Not sure whether to tether drops to specific creeps, levels, or regions yet, but that's not the important part and I can figure it out later. These would give me tremendous control over the balance to find the right feel. The map I'm working on is admittedly too ambitious for my skill level, but isn't that everyone on their first real project?

Also worth noting that currently I'm working within the official editor and not using any other systems. I understand that this seems to be inadvisable, but I just kinda want to handle this map using systems within that editor so I understand what's going on. I don't have the time or drive to learn to code in that actual language and then do the map. If this makes my above system impossible/very impractical then I'll find another route. Maybe if I retain the itch after I finish this I'll learn it, but as of now I just want to try some stuff and I think it'll be a 1 off and I'll have scratched it. We'll see I guess. Thanks for the time.

(For those curious about the project because maybe it helps with advice, it's going to be a story driven, but mostly open world rpg. Side quests and boss fights with mechanics. I plan to hand it out once I'm done incase anyoneelse can enjoy it, but mostly it's for me. I've played a lot of rpg games and always wanted to make one and this medium seemed like the right balance of simplicity and freedom. I plan to make a story you can complete in maybe 5 hours if you know what's up, but I want to make it difficult by the end, so some leveling/side questing will definitely help. Then I want some optional and exploratory end game stuff that would require a lot more time to reach. Hidden bosses that are very difficult, etc. As well as replayability with different classes and stuff. As I said, ambitious, but im not in a rush. Just doing what I can when I can. Already have several clases made. Some story developed, and the first boss.)
 
Last edited:
Level 3
Joined
Jun 6, 2024
Messages
13
Itempools does exactly what you are looking for but they dont exist in gui. Itempools Guide
All you need is a trigger that was converted to custom text so that you can write the functions there.
When that is done all you have to do is make a custom script that calls the functions.
Ok, so in summary I just need to convert a trigger to custom and use that to create the item pools the way that link says? From there other triggers can call them in a way similar to what I described? I assume the same type of system works for creeps then as well since an item is essentially a unit at the end of the day? I'd just make a creep pool and spawns would pull from it?
 
Level 24
Joined
Feb 27, 2019
Messages
833
Ok, so in summary I just need to convert a trigger to custom and use that to create the item pools the way that link says? From there other triggers can call them in a way similar to what I described? I assume the same type of system works for creeps then as well since an item is essentially a unit at the end of the day? I'd just make a creep pool and spawns would pull from it?
You know what, I am a total idiot. I didnt read carefully enough and thought you were talking about items. Itempool wont work.
 
Level 3
Joined
Jun 6, 2024
Messages
13
You know what, I am a total idiot. I didnt read carefully enough and thought you were talking about items. Itempool wont work.
I was talking about both. If I had to make specific creep spawns that's fine too. I just figured with some variance it lends to breaking up the monotony of leveling and stuff.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
You know what, I am a total idiot. I didnt read carefully enough and thought you were talking about items. Itempool wont work.
The unitpool type exists as well, and has basically the same API as an itempool. @DrFuzzyGloves, search for those types in common.j and you will see their full API. They are literally just weighed random number generators that can place their associated object instead of just returning a number. Weights are relative. Everything in the itempools tutorial applies to unitpools.
 
Level 3
Joined
Jun 6, 2024
Messages
13
The unitpool type exists as well, and has basically the same API as an itempool. @DrFuzzyGloves, search for those types in common.j and you will see their full API. They are literally just weighed random number generators that can place their associated object instead of just returning a number. Weights are relative. Everything in the itempools tutorial applies to unitpools.
Nice. Thanks. This is what I had hoped for.
 
Top