• 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.

Third Resource System?

Status
Not open for further replies.
Hello. I need help making a third resource in my map.

The third resource are based on the lumber (and Tiberium in C&C series) resources. It is harvested by targeting certain crystal doodads (let's call it Alphanites), and special indestructible trees will regenerate the Alphanites harvested nearby.

Also, the Alphanites will emit special red auras, healing certain units.

Any help is appreciated. Thanks.
 

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,239
Actually it's not that hard to create.

Create a destrucable based on any tree, change the model / texture and name it Alphanite. Then place it out as you wish.

Every 1 second check if the current order of all workers is harvest. Then check if the target is an Alphanite. Then remove 10 lumber and add 10 Alphanite to an integer array to keep track on it.
 

Chaosy

Tutorial Reviewer
Level 41
Joined
Jun 9, 2011
Messages
13,239
Right. Then I'd do the following.

every second check if the current animation of unit is equal to any of those where he carry lumber on the back. Save that into a boolean. If the unit was playing such an animation one second ago but isn't anymore you know that he has returned it to a building. Remove 20 lumber and add 20 X. Don't do the last part unless the boolean mentioned below is equal to true.

The problem is that we don't want the player to somehow mix lumber and X together so we'll need to work around that. Every second check for the HP of each X. If the HP is lower than last time you checked, someone has harvested. Pick every unit within 25 (play around with the number) whom current order is harvest and is currently targeting picked tree and do something like set boolean[unit id] = true
Lastly when a unit is ordered to harvest a tree but boolean[unit id] is true, order him to stop.

Don't forget to reset the boolean variable once he has returned X.
 
You can not check the current animation of a unit.

The best way to do this would be to code the harvesting process manually.

Make the harvest ability based on the warclub ability (it allows to target trees), then, when a player casts it, trigger all behaviour of the unit (attacking the node, returning to a nearby base, returning to the node).

If a player gives any other order inbetween, cancel the behaviour. Store the amount of resources currently carried by the unit as a integer (use a unit indexer) so that it doesn't get lost when the unit is manually moved by the player.
 
You can not check the current animation of a unit.

The best way to do this would be to code the harvesting process manually.

Make the harvest ability based on the warclub ability (it allows to target trees), then, when a player casts it, trigger all behaviour of the unit (attacking the node, returning to a nearby base, returning to the node).

If a player gives any other order inbetween, cancel the behaviour. Store the amount of resources currently carried by the unit as a integer (use a unit indexer) so that it doesn't get lost when the unit is manually moved by the player.

Okay, thanks. I'll try your method.

EDIT: However, there are still harvestable trees in the map. If a worker carrying lumber harvest the third resource, will the previously carried lumbers be counted as the integer too?
 
Okay, thanks. I'll try your method.

EDIT: However, there are still harvestable trees in the map. If a worker carrying lumber harvest the third resource, will the previously carried lumbers be counted as the integer too?
No, lumber will work as usual, but I think it would be confusing as hell to have the same worker carry both lumber and your other resource.
 
Status
Not open for further replies.
Top