[Solved] Charge Gold and Lumber, techtree requirement

Level 7
Joined
Apr 1, 2019
Messages
156
Trying to have the ability "charge gold and lumber" to have an upgrade requirement but it's not working.


Basically what I'm doing is a unit stores "flux" when it attacks, and I want him to be able upgrade into another unit which costs "50 flux" so I gave him the "charge gold and lumber" ability requiring a dummy upgrade, "50 Flux" then swapping out the ability with another "charge gold and lumber" ability with no requirements once 50 flux is reached. And when that new ability is cast just replacing the unit with the one he upgrades into.


One more thing, is there anyway to change what a unit can build through triggers? I cant seem to find a good workaround. Basically a player chooses what towers they want to be able to build, but once a player chooses more than 11 I run into problems
 
Last edited:

Uncle

Warcraft Moderator
Level 47
Joined
Aug 10, 2018
Messages
4,615
I tested it and it looks like the Charge Gold/Lumber ability can't use upgrades for some reason. Just use the Channel ability instead and trigger the gold/lumber cost (I'm assuming that's why you wanted to use Charge Gold/Lumber).

You'll have to elaborate on the second question about buildings. Is the issue that you can't fit more than 11 buildings on the command card for the Build ability? I read that you can give a unit multiple "Build" abilities like having both the Human Build and Orc Build ability. Or you can use an ability like Bear Form to give your Morphed unit different buildings.

And maybe you can use this?
  • Player - Make Barracks Available for training/construction by Player 1 (Red)
 
Last edited:
Level 7
Joined
Apr 1, 2019
Messages
156
Thx, I found out I can just use a diff ability with a requirement then swap it for "charge gold and lumber" once requirement is met

As for the 11 buildings thing.
I was trying to use the bear form ability to swap builders, but Ideally I want it so once a player picks all 11 buildings and fills the structures built from the first builder, any more buildings pick roll over to the swapped builder.

The trigger you told me of works for the first builder if I just fill structures built with every building. But the swapped builder just builds the same exact stuff
 

Uncle

Warcraft Moderator
Level 47
Joined
Aug 10, 2018
Messages
4,615
No problem. And that makes more sense swapping the ability instead of using Channel.

Also, I think I figured out a pretty decent solution to your limited building issue. I attached a map below with an example of it. It's not perfect but it gets the job done.

How it works:
I start off by giving a Peasant ALL of the possible structures that you can build. Then I make all of these structures unavailable using this action:
  • Player - Make Structure Unavailable for training/construction by Player
Then I create a Hashtable that stores all the structures that the player has "added" so far. Then using this Hashtable and some Integers I create a Page System that breaks up the Structures into Pages aka groups of 11. So Page 1 would show structures 1-11, Page 2 would show structures 12-22, Page 3 would show structures 23-33 and so on and so forth. This is done by making the current page's structures Available while at the same time making the other page's structures Unavailable. And to cycle through these pages I use an ability on the Peasant called Cycle. Casting cycle increases your current Page by 1 and changes your buildable structures accordingly. Cycling past the last page will bring you back to page 1.

One possible issue depending on how your map works:
Structures aren't removed/replaced inside the Hashtable. So once you add a structure to the Hashtable it'll stay there forever. In other words, there's no recycling of unused indices.

Anyway, I tried to make the system as quickly as possible without worrying about performance/versatility, so it's certainly lacking in that department, but I figure the concept is all that's really important.

edit: re-uploaded, fixed a minor bug that impacted performance.
 

Attachments

  • Building Hash 2.w3x
    24.4 KB · Views: 27
Last edited:
Top