HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Custom Resources (Besides Gold and Wood)

01-19-2003, 11:30 PM#1
Guest
Ok, time for a tricky question... Basically I'm trying to add several types of resources to the game, mainly Stone and Iron (Possibly another one)... Basically different types of materials are used to make different types of units and buildings...

Now, I know I can use a leaderboard to display how much of each resource the player has (This is single-player only)... That's easy.

There are two tricky parts...

---

First, there has to be a way to obtain these resources... I was thinking of a custom unit based on the gold mine... A special type of worker unit (Miner or something) could mine for stone and iron the same way a standard peasant mines for gold, and return it to a certain building. This would require some sort of modified version of the Harvest and Return Gold abilities, though I'm not sure how to do that.

On the other hand, to simplify that part, there could be a building that's placed on or near the stone mine that continuously generates the resources, though I'm not sure how to restrict the placement to keep it in range of the mine. I thought of making regions around every stone mine/quarry/whatever, but the player wouldn't know whether they'd made the mining post in range until the resources failed to come in...

---

Second, once the resources are collected, how can I require them when building certain units? I was thinking of a trigger for the Start Training action (Or whatever it's called), but I checked and there doesn't seem to be a way to see what type of unit the building is trying to create. If I could check that, it would be as easy as "If trying to make unit type A (Which requires 40 stone, and the player doesn't have 40 stone, cancel and display a message"...

So, anyone have any ideas?
01-19-2003, 11:41 PM#2
AlexBS
if (variable amount of stone) is less than (amount unit costs) then cancel unit training

if greater than or equal, subtract amount it costs

hope this helps also theres a thread somewhere here ill post again after i go find it some1 explained how to get oil
01-19-2003, 11:42 PM#3
AlexBS
http://www.wc3campaigns.com/forums/s...&threadid=9764 scroll down a bit its in there
01-20-2003, 12:27 AM#4
Extrarius
And interesting way to handle extra resources (that I saw done in a missile command-style map) is to spawn units in a radius of another unit, and make them on a team hostile to the players. Then a peon-type unit attacks and kills the unit, and you make a trigger give X whatever to the owner of the killing unit. In the map I'm talking about the units used the model of the sentry ward and they were positioned around a gold mine. They also respawned so you could never run out, but you might want to use a variable to count how many have spawned in a certain region and if the variable is a certain number, don't spawn any more and that spot will have no resources anymore.

The only 'problem' is that the peons don't have to return to the base each time they kill one like they do for wood or gold.
01-20-2003, 12:50 AM#5
Guest
Hmm, that oil method (That Alex posted the link for) will work great for collection... Never thought of using a double unit like that...

But for building, there's a problem...

The event is easy... "A unit owned by Player 1 (Red) Begins training a unit"...

But then---

Oh blah, I just figured it out... I was trying to find the variable for "Unit being trained", but then I remember it's not a Unit yet, just a Unit Type.... And there's a "Event Response - Trained-Unit Type"...

Thanks guys... This'll work perfectly :)
01-20-2003, 02:06 AM#6
AlexBS
im glad to be of assistance :)
01-20-2003, 05:26 AM#7
Dinadan87
Quote:
Originally posted by AlexBS
im glad to be of assistance :)


Glad I could too! (The oil idea was me). If you have problems making it work ask me and I'll see what I can do.
01-20-2003, 06:41 AM#8
Guest
Actually, the oil idea turned out not to work... That would work fine if the pickup and drop-off points are both preset, but in this case the drop-off point is a structure that the player builds, and there can be more than one of them...

I'm using a modified version of Extrarius's idea right now... The "Mine" (Not GOLD mine) is now a neutral-passive vulnerable structure (WIth 10k life and 1k/sec regeneration)... Whenever it's attacked, a trigger checks the Unit Type of the attacker... If it's a Stone Miner, it adds 1 stone... If it's an Iron Miner, it adds 1 iron... I can regulate the mining speed by changing the cooldown period of the miners' attacks... To make it more user-friendly, I have another trigger that makes miners automatically attack the mine instead of just moving to it on a right-click, and telling any other potential attackers to automatically stop :)

Of course, I'm not quite done...

The simple part turned out to be the real problem... I might be missing something obvious here, but how can a trigger tell a building to cancel the most recent "Train" action? I have it all set up to decrement the stone/iron when they're used, but I have no way of stopping the player when the stone/iron runs out...

---

Oh, on a side note... I have a rather original system in this story-driven campaign... The main character has the power to animate golems (Build a humanoid shape out of wood/stone/iron, and touch it to make it come to life)... So the units, upon leaving the production buildings, are frozen until the hero touches (attacks) them... That part works perfectly :)
01-20-2003, 07:23 AM#9
Dinadan87
Well it would take some complicated triggering to decide which locations to return the custom resource to, but it COULD be done. Each time a new dropoff point is built, the trigger calculates the distance from a certain mining point to every dropoff on the map. Then it picks the shortest distance one, stores that dropoff as a variable and whenever peasants mine form that source, they will head towards the variable dropoff point. Just run a trigger to check for the nearest dropoff point each time one is built, and make sure to run it for each custom resource mine you have and it should go fine. The only complication is that it will ignore impassible terrain for distance so it won't ALWAYS choose the very best path but it usually will. This may be a little too complicated if it's not a big deal to you, but it WOULD work go give it a try if you feel like it.
01-20-2003, 07:29 AM#10
Guest
Heh... It's a LOT more complicated, and I want to keep this as optimized as possible... Let's just say the food limit isn't going to mean much, regardless of the size of the army.... With that many units running around, I can't have it running through variable arrays every time a miner reaches either end of his destination...

Don't get me wrong, that's a great way to do it, but simplicity is going to pay off in the end...

Though I don't suppose ya have any ideas on how to automatically cancel a training order :)
01-20-2003, 04:52 PM#11
AlexBS
just variables, you cant auto do it. check if enough continue training else cnacel training thats as simple as it gets
01-20-2003, 11:05 PM#12
Guest
Yeah, I got that part... I'm sure I'm just missing something completely obvious, but I can't find an action to "cancel training"... The closest I've found is telling the building to stop, but that doesn't work...