HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Replace Worker Units

05-08-2014, 06:32 PM#1
JCarrill0
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.
Trigger:
Peasant Upgrade
Collapse Events
Map initialization
Collapse Conditions
(Unit-type of (Matching unit)) Equal to Peasant
Collapse 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.
Attached Files
File type: w3xReplaceWorkerTest.w3x (8.7 KB)
05-09-2014, 07:30 AM#2
Anitarf
You need to use a different event, "unit enters region (playable map area)". Then, use "triggering unit" instead of "matching unit" in the rest of your trigger. "Matching unit" is supposed to be used only when you are doing a "pick every unit * matching condition" action.
05-09-2014, 12:14 PM#3
JCarrill0
Quote:
Originally Posted by Anitarf
You need to use a different event, "unit enters region (playable map area)". Then, use "triggering unit" instead of "matching unit" in the rest of your trigger. "Matching unit" is supposed to be used only when you are doing a "pick every unit * matching condition" action.
Ah ok. How about:
Trigger:
Peasant Upgrade
Collapse Events
Unit - A unit enters (Playable map area)
Conditions
Collapse Actions
Custom script: set bj_wantDestroyGroup = true
Collapse Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Unit-type of (Picked unit)) Equal to Peasant
Collapse Then - Actions
Unit - Replace (Picked unit) with a Worker (Commoner) using The old unit's life and mana
Else - Actions
I also want to make sure I am not creating any memory leaks.
05-09-2014, 02:33 PM#4
Anitarf
I was thinking of something more like this:
Trigger:
Peasant Upgrade
Collapse Events
Unit - A unit enters (Playable map area)
Collapse Conditions
(Unit-type of (Triggering unit)) Equal to Peasant
Collapse Actions
Unit - Replace (Triggering unit) with a Worker (Commoner) using The old unit's life and mana

Quote:
Originally Posted by JCarrill0
I also want to make sure I am not creating any memory leaks.
You're using GUI triggers, there's no way to not create memory leaks. :)
05-09-2014, 05:13 PM#5
JCarrill0
Quote:
Originally Posted by Anitarf
You're using GUI triggers, there's no way to not create memory leaks. :)
How does one FIX this? Convert to Jass correct? (still don't even know were to begin with Jass)
05-09-2014, 08:06 PM#6
Anitarf
Quote:
Originally Posted by JCarrill0
How does one FIX this? Convert to Jass correct? (still don't even know were to begin with Jass)
Well, first of all, you don't really have to fix it. If you are more comfortable with GUI triggers, there's nothing wrong with continuing to use them. As long as you're not using them intensively, the memory leaks shouldn't even matter, especially not on modern hardware.

However, if you aren't intimidated by JASS, I'd certainly recommend switching to it. You can just try converting triggers to JASS on your own or you can follow the excellent Introduction to JASS tutorial.

When working with JASS, it is highly recommended to use the NewGen editor for the vJass language extension that comes with it, as well as other nice features such as a compiler that doesn't crash as often, function lists and auto-completion.
05-10-2014, 02:16 PM#7
JCarrill0
Quote:
Originally Posted by Anitarf
Well, first of all, you don't really have to fix it. If you are more comfortable with GUI triggers, there's nothing wrong with continuing to use them. As long as you're not using them intensively, the memory leaks shouldn't even matter, especially not on modern hardware.

However, if you aren't intimidated by JASS, I'd certainly recommend switching to it. You can just try converting triggers to JASS on your own or you can follow the excellent Introduction to JASS tutorial.

When working with JASS, it is highly recommended to use the NewGen editor for the vJass language extension that comes with it, as well as other nice features such as a compiler that doesn't crash as often, function lists and auto-completion.
awesome, I will consider it, I just want to become well knowledged in "GUI Triggers" first
05-10-2014, 05:40 PM#8
Kyrbi0
Good Guy Anitarf...

Click image for larger version

Name:	Wc3C - GoodGuyGreg Meme - Anitarf and Gui.jpg
Views:	17
Size:	57.1 KB
ID:	50948