• 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] Uncle are you there?

Level 5
Joined
Jun 24, 2024
Messages
59
Hi all and hi @Uncle,

i recently started creating my own Warcraft 3 Map and i struggle immensely with Triggers and Hashtables, i read alot of your answers in the thread:
- but i can't get my own idea to work:

I'm (re-)creating a classic Tower Defense game and i basically want a builder to build a Basic tower (with a question mark as model) which then rolls 3 random towers out of a pool of towers. Those are all the Level one variant, i also kinda like the idea of merging them (Two of the same kind to the next level), the triggering being the one that gets upgraded.

I tried your solutions for the difficulties in named thread but for some reason i can't my build tower to show 3 random upgrade options...

If you are active still and willing to help, i'd be very thankful :))

Best Regards
SMOrc
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,876
There's a good amount of people that help in these forums, I wouldn't lower your odds of getting help by singling one out :p

Anyway, I don't think there's such a thing as truly random upgrades. This is because you can only set a Units upgrades in the Object Editor and there are no Actions to modify this data at runtime.

However, there's almost always a workaround solution. One method would be to rely on abilities since you can Add/Remove these on the fly. In this case all of your abilities can be based on the Charge Gold and Lumber ability which gives you access to a Gold Cost, Lumber Cost, and customizable Order Id.

It's not too difficult to get a basic setup running:
  • Events
    • Time - Elapsed game time is 0.00 seconds
  • Conditions
  • Actions
    • Set Variable Tower_Ability_Type[1] = Arrow Tower (Ability 1)
    • Set Variable Tower_Ability_Type[2] = Fire Tower (Ability 1)
    • Set Variable Tower_Ability_Type[3] = Cannon Tower (Ability 1)
    • Set Variable Tower_Unit_Type[1] = Arrow Tower (Unit 1)
    • Set Variable Tower_Unit_Type[2] = Fire Tower (Unit 1)
    • Set Variable Tower_Unit_Type[3] = Cannon Tower (Unit 1)
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Tower_Ability_Type[1]
  • Actions
    • Unit - Replace (Triggering unit) with a Tower_Unit_Type[1] ...
Of course the above trigger can be modified to work for all of the Towers by taking advantage of the Array data we stored beforehand. Taking it a step further, you can use a Hashtable to act as one big database for all of your "upgrades", giving you greater control, less triggers, and a more systematic approach.

I would practice using these techniques until they start to make sense. There's plenty of tutorials and examples on Hive that go into great detail on how to use Arrays, For Loops, Hashtables, etc. Also, I recommend adding Text Messages to your triggers to give yourself a visual aid of what's happening at all times (or what's not happening) which can help you debug things.
 
Last edited:
Top