• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[JASS] Fourth Resource

Status
Not open for further replies.
Level 4
Joined
Jun 18, 2008
Messages
119
I'm having some difficulty figuring out how to set up a fourth resource.

Event - a unit (requiring the resource) begins training
Condition -
Action - If: Real (?): ??? (Something to the effect of, amount of variable x equal to x)
Then: Subtract x amount of variable x
Else: Stop training, display message: "you do not have enough resource to do that"

I also need the multiboard coding that would display this in a live update without causing lag.

If someone could get this in vJass with no leaks, I'd prefer it.

Please thanks!
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
First you need a global integer that contains your resource, I'll name it "Resource".

Events: a unit begins training
Conditions: type of (trained unit) equal to Unitthatrequiresresource
Actions: if (Resource >= theresourcecostofyourunit, for instance 250) Then: set Resource = Resource - 250
Else: Stop training and display message to owning player?

That GUI trigger should work and should be leakless
 
Level 4
Joined
Jun 18, 2008
Messages
119
Would that lag at all?

Conditions: type of (trained unit) equal to Unitthatrequiresresource

How do I set up the variable Unitthatrequiresresource?

(Like, what category of variable is it, and how do I add units to it? Do I have to do it for each gold-costing unit individually?)
 
Level 4
Joined
Jun 18, 2008
Messages
119
Of course I did?

Talk down to me some moar, pls. It really encourages me to get involved with the Hive community.



Uploaded screenshot.

Should that work?
 

Attachments

  • gold.jpg
    gold.jpg
    20 KB · Views: 87
Last edited:
Level 21
Joined
Aug 21, 2005
Messages
3,699
That condition probably works too, but just change it to
Unit type - Unit type of (Trained unit) equal to (footman)

Oh and please,
make the trigger
then test it
then if it doesn't work, ask why it doesn't work

instead of asking if it "would" work...

Anyway, a small remark: that trigger will only work for 1 player, not for multiple players. Just remarking it... You'll have to use arrays to make it work for more players.
 
Level 4
Joined
Jun 18, 2008
Messages
119
Ahhhh, I see what you mean now.

Thanks. :]

How might I set the array up within the trigger?

i.e.
Gold [1,2,3,4,5,6,7,8,9,10,11,12] = Gold [1,2,3,4,5,6,7,8,9,10,11,12] - 50

Is it possible to include all 12 arrays like that?
 
Status
Not open for further replies.
Top