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

Replace Worker Units

Status
Not open for further replies.
Level 16
Joined
May 25, 2004
Messages
1,192
I been having issues replacing the Peasants at the start of the game.
(See attached map below)

The objective is to remove the ability to "Build Buildings like humans". I found out that option is only changed by changing the race in the object manager.

So changing the Worker to "Commoner" race allows me to achieve this option. (Orc race also does this along with many others, I just chose commoner as preference)

I tried a simple "Chaos" Ability so I didn't have to use triggers, but I had a problem.

I decided that triggers were needed since the "Build Buildings like humans" problem came up AGAIN! Problem is the trigger is not done correctly, because it is not replacing the units.
  • Peasant Upgrade
    • Events
      • Map initialization
    • Conditions
      • (Unit-type of (Matching unit)) Equal to Peasant
    • Actions
      • Unit - Replace (Matching unit) with a Worker (Commoner) using The old unit's relative life and mana
so once again I have come to the forums for help.

PS - I hate being a newb at triggers!

EDIT: I do know that just changing "Peasant" to race "Commoner" fixes the issue now, but I also would like to have a working trigger for future projects I might need.
 

Attachments

  • ReplaceWorkerTest.w3x
    8.7 KB · Views: 39
Level 16
Joined
May 25, 2004
Messages
1,192
Problem is that there is not matching unit in that trigger.

When clicking matching unit read the script on what it says it is used for.

The above trigger will never work as unit type of triggering unit equal to peasant will never be true with a map init event.
So your saying it does work? That's why I'm posting?)
now when you say it wont ever work, that makes sense, but how do I fix it?
 
Level 5
Joined
Dec 3, 2012
Messages
117
dont have WE here atm, but I think you need something along the lines of this;

  • -Event-
  • Map Init
  • -Actions-
  • Pick every unit in (Units of Type; Peasant) and do actions;
  • Replace with Worker
 
replace starting workers...with Different starting workers.. what else is there to explain? I posted a map so you can see what I want ;)
Which you didn't even download to help fix.

instead of being captain obvious, try to help rather then raise your post count.

I could care less about the post count. I post to help people. Post count means nothing.

Did you ever think I can't download the map.
Next time explain exactly what you want rather than posting something telling people to download a map.

Here is what you need to do.
  • ChangeUnits
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set tempUnit = UnitToReplaceWith
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick all units in playable map area and do actions
        • Loop
          • Unit - Replace Picked unit with tempUnit
 
Level 25
Joined
May 11, 2007
Messages
4,650
  • Untitled Trigger 004
    • Events
      • Time Elapsed is 0.0
    • Conditions
    • Actions
    • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type Peasant) and do (Actions)
        • Loop - Actions
          • Unit - Replace (Picked unit) with a Worker (Commoner) using The new unit's default life and mana
Actually this is what you want to do :)
So you don't create any leaks.
 
Actually you do not want those.

  • Unit Group - Pick all units of type Footman and do...
  • Camera - Pan Camera as needed...

I also forgot the ITE in mine above.

Here is the fixed version.

  • ChangeUnits
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick all units in playable map area and do actions
        • Loop
          • If all conditions are true do actions
            • If conditions
              • unit type of (Picked unit) equal to Peasant
            • Then actions
              • Unit - Replace (Picked unit) with a Worker (Commoner) using The new unit's default life and mana
            • Else actions
 
Level 16
Joined
May 25, 2004
Messages
1,192
Here is the fixed version.


Thank you for the trigger, and my apologies for being rude.

You need to use a different event, "unit enters region (playable map area)".
so then
  • Peasant Upgrade
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Peasant
            • Then - Actions
              • Unit - Replace (Picked unit) with a Worker (Commoner) using The old unit's life and mana
            • Else - Actions
I changed a few things, would this work?
 
Thank you for the trigger, and my apologies for being rude.


so then
  • Peasant Upgrade
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Peasant
            • Then - Actions
              • Unit - Replace (Picked unit) with a Worker (Commoner) using The new unit's default life and mana
            • Else - Actions
?

You need the map initialized trigger event. Or the Time 0.00 seconds trigger event.
The one I posted changes all units at map init into the worker unit. If it does cause any problems at map init change it to Time passed = 0.00 seconds.
 
Status
Not open for further replies.
Top