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

Transformed units cannot construct buildings

Status
Not open for further replies.
Level 3
Joined
Aug 14, 2018
Messages
8
I am trying to implement an "advanced structure" feature, and my method is:

Two peons with everything identical except Structures Built.
Ability based on "Berserk" called "Build Advanced Structure"
Two abilities based on "Bear Form", which will transform the one peon into to the other

Triggers look like the following:

Convert to advanced builder:
  • Events
    • Unit - A Unit is issued an order with no target
  • Conditions
    • Unit-type of (Ordered unit) Equal to Peon (Basic)
    • Issued order Equal to Order(berserk)
  • Actions
    • Trigger - Turn off <Convert to Basic Peon>
    • Unit - Add "Convert to Advanced Peon" to (Ordered unit)
    • Unit - Remove "Convert to Advanced Peon" from (Ordered unit)
    • Unit - Order (Ordered Unit) to Build
    • Trigger - Turn on <Convert to Basic Peon>
Convert to basic builder:
  • Events
    • Game - The 'Build Structure' button is clicked
  • Conditions
  • Actions
    • Set VariableSet IntPlayer = (Player number of (Triggering player))
    • Unit Group - Pick every unit in (Units owned by (Player(IntPlayer)) of type Peon (Advanced)) and do (Actions)
      • Loop - Actions
        • Unit - Add "Convert to Basic Peon" to (Picked unit)
        • Unit - Remove "Convert to Basic Peon" from (Picked unit)
Now, the conversion works flawlessly. In fact everything does, except that when I try to build a structure with a transformed unit (e.g. a basic peon that started as an advanced peon or vice versa) they will walk to the location to build the building, but will not proceed to build it.

The reason I am using this method for advanced structures is because if a unit is holding resources, I do not want those resources to be lost if they are ordered to build a building that is not of their tech level. Simply replacing a unit results in this loss of resources.

I would also like to mention that if I transform the unit back to its base form, it will be able to construct buildings again.


Edit: Just tried with Chaos - same result
 
Last edited by a moderator:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
I think it's losing the Repair ability when transforming. That seems like the only thing that would prevent it from building. Otherwise, it's a weird bug.
Looking at other threads it sounds like you can just enable/disable buildings for the player as you see fit.

Also, this leaks a Unit Group:
  • Unit Group - Pick every unit in (Units owned by (Player(IntPlayer)) of type Peon (Advanced)) and do (Actions)
 
Level 3
Joined
Aug 14, 2018
Messages
8
I think it's losing the Repair ability when transforming. That seems like the only thing that would prevent it from building. Otherwise, it's a weird bug.
Looking at other threads it sounds like you can just enable/disable buildings for the player as you see fit.

Also, this leaks a Unit Group:
  • Unit Group - Pick every unit in (Units owned by (Player(IntPlayer)) of type Peon (Advanced)) and do (Actions)
Well, it does not lose the repair ability, and the enable/disabling of buildings is not a good solution either because if a unit is ordered to build an advanced structure, and a different unit is ordered to build a basic structure while the first unit is on its way to build, it will no longer have the ability to build that structure and just sit there.

Also, I am fairly sure the repair ability bug is only applicable to human buildings, which the buildings I'm building are not, they are orc buildings.

..and thanks for pointing out the leak.. I guess ill make it a variable

Based on the testing I've done, it seems like the actual structures which can be built are not updated to reflect what the newly transformed unit can build, only the interface is. Basically, any structures which both units can build, the new unit will be able to build, but if its a structure that only the new unit "can build", it cannot be built -- even though it can be selected and placed to be built.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,565
What if you mimicked the behavior of the Orc building mechanics using triggers?

When a Peon is issued an order to build and reaches it's build destination (which fails), you detect this failure, create a Dummy unit and order it to immediately begin construction on that Point, and hide your Peon.

You could have two types of Dummy units, one for basic and one for advanced buildings. The one you create would depend on which order the Peon was initially given before failing to build.

Then you can link the Peon/Building together using a Unit Indexer or Hashtable. This way when the building dies/cancels/finishes construction you can get access to the Peon and Unhide it in response.

The Dummy could have an expiration timer or you could also link it to the Building as well and Remove it once the building dies/cancels/finishes construction.

Note: If the Basic building stuff works as intended then you would only need a single Advanced Dummy unit and only need to check for Advanced build orders since those are the ones that cause problems.
 
Last edited:
Level 3
Joined
Aug 14, 2018
Messages
8
What if you mimicked the behavior of the Orc building mechanics using triggers?

When a Peon is issued an order to build and reaches it's build destination (which fails), you detect this failure, create a Dummy unit and order it to immediately begin construction on that Point, and hide your Peon.

You could have two types of Dummy units, one for basic and one for advanced buildings. The one you create would depend on which order the Peon was initially given before failing to build.

Then you can link the Peon/Building together using a Unit Indexer or Hashtable. This way when the building dies/cancels/finishes construction you can get access to the Peon and Unhide it in response.

The Dummy could have an expiration timer or you could also link it to the Building as well and Remove it once the building dies/cancels/finishes construction.

Note: If the Basic building stuff works as intended then you would only need a single Advanced Dummy unit and only need to check for Advanced build orders since those are the ones that cause problems.
I think I've solved it using a third type of peon:

One peon with only Advanced structures
One peon with only Basic structures
One peon with all structures

  • Every peon starts out as the All variety
  • When the Build button is clicked, Chaos(Advanced) will attempt to be removed and Chaos(Basic) will be added to the unit
  • When the Advanced Structure button is clicked, the previous trigger will be temporarily disabled;
Chaos(Basic) will attempt to be removed;
Chaos(Advanced) will be applied to the unit;
and the Build menu will be opened.

I just tried this out with 3 structures and it appears to be working, but I have not tried it with 12+ structures yet so there's a possibility this will not work like I'd hoped. Here's praying. I'll update with the result once I test it, in case anyone is having a similar issue. (it works with more)
 
Last edited:
Status
Not open for further replies.
Top