• 🏆 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!

Replace Worker Units

Status
Not open for further replies.
Level 16
Joined
May 25, 2004
Messages
1,170
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: 37
Level 16
Joined
May 25, 2004
Messages
1,170
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
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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 12
Joined
May 20, 2009
Messages
822
  • Untitled Trigger 004
    • Events
      • Map initialization
    • Conditions
    • Actions
      • 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
 
Level 25
Joined
May 11, 2007
Messages
4,651
  • 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.
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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,170
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?
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
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