• 🏆 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!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

hiring random units at mercenary camp

Status
Not open for further replies.
Level 2
Joined
Mar 23, 2018
Messages
8
i want to edit a melee map (echo isles for example) so that in mercanary camps you can only purchase random units. i want to have 10 buttons in a merc camp.

- "recruit a random level 1 unit" - so for 100 gold you get a random level 1 unit from a collection of all level 1 unit type creeps (e.g. gnoll warrior level 1, or spider level 1 etc.)

- "recruit a random level 2 unit" - so for 200 gold you get a random level 2 unit from a collection of all level 2 unit type creeps (e.g. troll level 2, or turtle level 2 etc.)

... etc. until level 10 units.

does anyone have an idea how to do it? i couldnt manage it on my own. thanks
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
does anyone have an idea how to do it? i couldnt manage it on my own. thanks
What have you tried? Show us?


You'll need to trigger it.

You make 10 dummy items. Each with the tooltip for a level of units.
When an item is bought, you'll remove the item and spawn a random unit depending on what item was bought.

Ideally you'd do this with a double array unit group variable, but I don't think that it is supported by the editor?
So, a Hashtable maybe... Although, for simplicity, rather do it with just multiple variables and if-then-else.

What you need:
10 Unit-Array variables.
10 dummy items
Some configurable variables
Some triggers

Although, I'd rather do it with a Hashtable...
 
There is a built in function to gain the unit-type of a Random Creep (level based), did you try it. It does only random creeps, which would normaly appear on the map.

I would recomment fake units over items, to allow non-heroes hire units.
Give the fakes the same level as the result level, easy as possible.
then when an unit is sold simply replace it with a random creep of the same level, done.
 
Level 2
Joined
Mar 23, 2018
Messages
8
thank you for the answers. fake units seems to be a better option, since like in normal games normal units should be also able to make a purchase at the merc camp.

i guess i have to do all this in the trigger editor? a more detailed instruction would be helpful, since im a beginner to world editor.

where im stuck currently:

upload_2018-3-24_9-58-55.png


for testing reasons i want just to concetrate on a single random level 1 unit from a total pool of three level 1 units. what would be the correct actions for this? which action should i choose at the position where i have "... with a spider"?
 
Last edited:
Hirelings are sold not trained.
Your fake unit will never pass that condition, cause it should not be part of the random pool.
the random creep type should be the replace result.

How To Post Your Trigger


Event: unit sells Unit.

Condition: Unit-Type of Sold Unit equal to fake unit level 1.
i would create a new ability which all your fakes have.
So you can use it for all Fakes.
Level of fake identy greater 0.​
Action: replace sold unit with random Creep (Level of Sold Unit).
 
Level 2
Joined
Mar 23, 2018
Messages
8
  • TrainUnit1
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to (Random level 1 creep unit-type)
    • Actions
      • Set x = (Random integer number between 1 and 3)
      • Unit - Replace (Sold unit) with a (Random level 1 creep unit-type) using The new unit's default life and mana
i dont understand the part with creating new ability for fakes. do you mean create custom abilities in the object editor?
 
Well wrote that really bad, but yes.
The idea is to have something special which is shared by all fake units:
might be unneeded in you map now that i think about it again, you wana altered melee, in melee one can only buy heroes (taverns) and creeps, therefore the condition should be is sold Unit hero = false.
If in your map there is another way to buy units, well then you might need it.​
You could use the level of the fake unit to spawn a creep of the same level then you only need 1 Trigger.

1. Fake Units have a special custom ability doing nothing to easily identify them.
  • Buy RandomCreep
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Level of Fake Creep Option for (Sold unit)) Equal to 1
    • Actions
      • Unit - Replace (Sold unit) with a (Random level (Level of (Sold unit)) creep unit-type) using The new unit's default life and mana
2. Or list all possible buy options inside an or any in conditions
  • Buy RandomCreep
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Sold unit)) Equal to Fake: Buy Creep LVL 1
          • (Unit-type of (Sold unit)) Equal to Fake: Buy Creep LVL 2
          • (Unit-type of (Sold unit)) Equal to Fake: Buy Creep LVL 3
          • and so on
    • Actions
      • Unit - Replace (Sold unit) with a (Random level (Level of (Sold unit)) creep unit-type) using The new unit's default life and mana
3.Is non hero
  • Buy RandomCreep
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • ((Sold unit) is A Hero) Equal to False
    • Actions
      • Unit - Replace (Sold unit) with a (Random level (Level of (Sold unit)) creep unit-type) using The new unit's default life and mana
 
Level 2
Joined
Mar 23, 2018
Messages
8
its not enough to work as it seems, but i wrote it too bad i think.

i have an existing melee map echo isles, where you can already train a random hero at an altar (instead of picking one of the 4 available options for each race).

now i want to edit the map, so that the already existing mercenary camps dont sell anymore the 4 standard units (mud golem, troll priest etc.) instead , the merc camp should have 10 buttons. "buy creep lvl 1" , "buy creep lvl 2" etc.

but i think i really need some sort of hashtable where i can fill in all various lvl 1 creeps which exist across all available tilesets (lordaron summer, barrens etc.). but i really dont know how to do it exactly.

lets say, for example there are five different neutral level 1 creeps across all tilesets.

spiderling lvl 1
troll lvl 1
gnoll lvl 1
wolf lvl 1
ogre lvl 1

so when pressing the "buy creep lvl 1" button at the merc camp one of this unit should be randomly bought. so every creep listed above needs a value and when pressing the "buy lvl 1 creep"-button the dice should be rolled 1-5 and then the according unit gets bought


attached is the map im working so far
 

Attachments

  • 2EchoIslesRH.w3x
    120.5 KB · Views: 25
Nah hashtable & GUI & Unit-Types is bad, you will end up using only custom script.
Edit: and in this case your are better off with using UnitPools directly, which too needs only custom script but atleast does the random and the indexing for you.​


I see so you wana spawn Random creeps from all Terrain Types.
Well now you either need to add all Creeps to all Terrain-Types so they are valid randomCreeps (would alter preplaced Random Creeps too)

In this case alter the Field "Editor - Tilesets" for all Creeps inser "All".
Make Creeps aviable 2.jpg


or, list up the creeps in an Array and then do the random access.

The Listing could be done by 2 ways.
  1. More simple one has not to stick around with 2D, when buying such a fake unit load in all Possible Types of that level into an Unit-Type Array and pick a random index. This requiers 10 Triggers or 10 big If elses better 10 triggers.
      • Buy Level 1
        • Events
          • Unit - A unit Sells a unit
        • Conditions
          • (Unit-type of (Sold unit)) Equal to Fake Level 1
        • Actions
          • Set RandomCreep[1] = Spinne
          • Set RandomCreep[2] = Murloc-Läufer
          • Set RandomCreep[3] = Satyr
          • Set RandomCreep[4] = Satyr-Schwindler
          • there are alot more.
          • Unit - Replace (Sold unit) with a RandomCreep[(Random integer number between 1 and 4)] using The new unit's default life and mana
  2. Splitup the Array in sections each level takes upto 100 slots. Level 1 starts at 100 and goes to 199, Level 2 200 to 299 ... Kind of 2D.
      • Init
        • Events
          • Map initialization
        • Conditions
        • Actions
          • -------- List up all Creeps. --------
          • -------- Level 1 --------
          • Set RandomCreep[100] = Spinne
          • Set RandomCreep[101] = Murloc-Läufer
          • Set RandomCreep[102] = Satyr
          • Set RandomCreep[103] = Satyr-Schwindler
          • Set RandomCreepLast[1] = 103
          • -------- Level 2 --------
          • Set RandomCreep[200] = Dunkel-Troll
          • Set RandomCreep[201] = Dunkel-Troll-|nSchattenpriester
          • Set RandomCreepLast[2] = 201
          • -------- Level 3 --------
          • Set RandomCreep[300] = Bronzener Großdrachen-Welpe
          • Set RandomCreepLast[3] = 300
      • Buy
        • Events
          • Unit - A unit Sells a unit
        • Conditions
          • ((Sold unit) is A Hero) Equal to False
        • Actions
          • Unit - Replace (Sold unit) with a RandomCreep[(Random integer number between (100 x (Level of (Sold unit))) and RandomCreepLast[(Level of (Sold unit))])] using The new unit's default life and mana
  3. You could also use jass's UnitPools, which are a collection of Unit-Types with buildin placerandom unitType but for some wierd reason the GUI-Access was never written by blizzard.
 
Last edited:
Level 2
Joined
Mar 23, 2018
Messages
8
1. screenshots: this seems for me like the easiest option, but what shall i do afterwards? after i have changed all creeps tileset to "all"? there are about~250 creeps which i would have to change to "all". What shall i do after i did this?

2. screenshot: i tried this solution, but i i couldnt manage to get this work. i have problem with this unit-type array and i didnt manage to Create an action like you have made e.g. "Set RandomCreep[102] = satyr"
i assume i have to begin with: action - set variable - edit varibles - create new variable "unit-index" integer... and then how to continue? this is where im stuck


so far i created a new custom unit "random unit level 1" which is currently the only option available for purchase at merc camp. i managed to get it work, that the fake replcaes an actual creep (in this example, barbed arachnatid) but i dont get it to work that the fake unit replaces a random creep

  • TrainUnit1
    • Events
      • Unit - A unit Sells a unit
    • Conditions
      • (Unit-type of (Sold unit)) Equal to Random Unit Level 1
    • Actions
      • Unit - Replace (Sold unit) with a Barbed Arachnathid using The new unit's default life and mana
thanks for the help, much appreciated.
 
1. screenshots: this seems for me like the easiest option, but what shall i do afterwards? after i have changed all creeps tileset to "all"? there are about~250 creeps which i would have to change to "all". What shall i do after i did this?

Add all your "Buy options" (the fake units) to the shop.
Then you need to setup the "buy options", an easy way to redirect fake unit to random Creep Level is by giving the fake unit the same level as the creep you wana spawn, In such a setting you can just use Get Level of Sold Unit and you have the creep Level.
Make sure that the Buy options are not counted as neutral hostile, else they might morph to themself (no Creep for you :(. )
(there is a field in Object Edtior under categoriy "Editor")​

After setting up the Units the trigger below should do the morphing.
2. Or list all possible buy options inside an or any in conditions
  • base.gif
    Buy RandomCreep
    • joinminus.gif
      events.gif
      Events
      • line.gif
        joinbottom.gif
        unit.gif
        Unit - A unit Sells a unit
    • joinminus.gif
      cond.gif
      Conditions
      • line.gif
        joinbottomminus.gif
        if.gif
        Or - Any (Conditions) are true
        • line.gif
          empty.gif
          joinbottomminus.gif
          cond.gif
          Conditions
          • line.gif
            empty.gif
            empty.gif
            join.gif
            if.gif
            (Unit-type of (Sold unit)) Equal to Fake: Buy Creep LVL 1
          • line.gif
            empty.gif
            empty.gif
            join.gif
            if.gif
            (Unit-type of (Sold unit)) Equal to Fake: Buy Creep LVL 2
          • line.gif
            empty.gif
            empty.gif
            join.gif
            if.gif
            (Unit-type of (Sold unit)) Equal to Fake: Buy Creep LVL 3
          • line.gif
            empty.gif
            empty.gif
            joinbottom.gif
            if.gif
            and so on
    • joinbottomminus.gif
      actions.gif
      Actions
      • empty.gif
        joinbottom.gif
        unit.gif
        Unit - Replace (Sold unit) with a (Random level (Level of (Sold unit)) creep unit-type) using The new unit's default life and mana
 
Level 2
Joined
Mar 23, 2018
Messages
8
unfortunately its still not working with moprhing the fake units into random ones. i have followed your instructions, i dont know why its still not working.

can you please have a look at the map?


at the moment i have tested it with random creeps level 1-5
 

Attachments

  • 2EchoIslesRH.w3x
    121.9 KB · Views: 19
Status
Not open for further replies.
Top