How can I make an ability combine two units into one new unit

Level 6
Joined
Jul 10, 2016
Messages
160
I'm trying to make a custom race, where i would use the concept written in the title.

To make things a lot easier to understand, Use the following as examples:
  • Peon
  • War Mill
  • Demolisher
2 Peons enters (or interacts) with a War Mill (or vice versa wherein the War Mill interacts with 2 Peons) and because of that a Demolisher is trained or created.
 
Level 17
Joined
Mar 29, 2020
Messages
1,019
I can help you with this but more details would be good -

do the peons dissappear when you do this? (= they "turned into" the demolisher)

can the demolisher turn back into 2 peons?

Is there an additional cost/cooldown to doing this?

(if you just want to turn 2 units into 1 and you don't need a building to be involved - you could always just alter the hippogryph rider ability...)
 
Level 6
Joined
Jul 10, 2016
Messages
160
do the peons dissappear when you do this? (= they "turned into" the demolisher)
Yes

can the demolisher turn back into 2 peons?
I didn't think about this, but they can simply return to being peons when the demolisher is destroyed.

Is there an additional cost/cooldown to doing this?
I suppose there could be, but if it is not possible, then none would be fine too.

(if you just want to turn 2 units into 1 and you don't need a building to be involved - you could always just alter the hippogryph rider ability...)
I did not think about this. It can be an option, if interacting with the building is too "hard".
 
Level 17
Joined
Mar 29, 2020
Messages
1,019
Hey there, this should in general do what you want. the way it is currently configured -all demolishers that die will turn into 2 peons. If that is a problem, you just need to create an identical copy of demolisher in the OE(give it an "only in editor" suffix so you know which is which) and switch to fields in the triggers to point to that unit type.

besides that, this is slightly abusable as a way to heal peons (it always spawns full health peons). Since healing peons is not such a big deal, If you make this cost anything significant (right now I have it set at 150 wood 150 gold - you just need to change the variables in the setup cost trigger to the price you want) than that won't be worthwhile or problematic. if you change the costs to 0 it is a slight problem. to fix it you need a way to keep track of individual units. I would use bribe's unit indexer - I can add that for you if you want but wasn't worth the trouble if you don't care about that.

note the things that need to be set up in the OE -

the building I used was based on a burrow, but I changed the borrow so attacks available to none. I changed the orc burrow cargo hold ability to only hold 2 units (If you need regular burrows too just create a copy of the ability). and added a custom ability:

the custom ability - I used a channel based spell for the ability that does this - you can just copy from the map I attached and change it to fit your needs.

I think that covers all the bases, if not just check the attached map.




  • setup cost
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet DemoGoldCost = 150
      • Set VariableSet DemoWoodCost = 150
  • merge peons
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to FormMegazord
    • Actions
      • Set VariableSet InBurrow = (Units owned by (Triggering player) matching (((Matching unit) is loaded into (Triggering unit).) Equal to True).)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in InBurrow) Equal to 2
          • ((Triggering player) Current gold) Greater than or equal to DemoGoldCost
          • ((Triggering player) Current lumber) Greater than or equal to DemoWoodCost
        • Then - Actions
          • Unit Group - Pick every unit in InBurrow and do (Actions)
            • Loop - Actions
              • -------- stick unit caching here --------
              • Unit - Remove (Picked unit) from the game
          • Set VariableSet BurrowPoint = (Position of (Triggering unit))
          • Unit - Create 1 Demolisher for Player 1 (Red) at BurrowPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_BurrowPoint)
          • Player - Add (0 - DemoGoldCost) to (Triggering player).Current gold
          • Player - Add (0 - DemoWoodCost) to (Triggering player).Current lumber
        • Else - Actions
      • Custom script: call DestroyGroup(udg_InBurrow)
  • demolisher death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Demolisher
    • Actions
      • Set VariableSet DemoPoint = (Position of (Triggering unit))
      • Unit - Create 2 Peon for (Owner of (Triggering unit)) at DemoPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_DemoPoint)
 

Attachments

  • peonBreeding.w3m
    21.2 KB · Views: 12
Level 6
Joined
Jul 10, 2016
Messages
160
Hey there, this should in general do what you want. the way it is currently configured -all demolishers that die will turn into 2 peons. If that is a problem, you just need to create an identical copy of demolisher in the OE(give it an "only in editor" suffix so you know which is which) and switch to fields in the triggers to point to that unit type.

besides that, this is slightly abusable as a way to heal peons (it always spawns full health peons). Since healing peons is not such a big deal, If you make this cost anything significant (right now I have it set at 150 wood 150 gold - you just need to change the variables in the setup cost trigger to the price you want) than that won't be worthwhile or problematic. if you change the costs to 0 it is a slight problem. to fix it you need a way to keep track of individual units. I would use bribe's unit indexer - I can add that for you if you want but wasn't worth the trouble if you don't care about that.

note the things that need to be set up in the OE -

the building I used was based on a burrow, but I changed the borrow so attacks available to none. I changed the orc burrow cargo hold ability to only hold 2 units (If you need regular burrows too just create a copy of the ability). and added a custom ability:

the custom ability - I used a channel based spell for the ability that does this - you can just copy from the map I attached and change it to fit your needs.

I think that covers all the bases, if not just check the attached map.




  • setup cost
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet DemoGoldCost = 150
      • Set VariableSet DemoWoodCost = 150
  • merge peons
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to FormMegazord
    • Actions
      • Set VariableSet InBurrow = (Units owned by (Triggering player) matching (((Matching unit) is loaded into (Triggering unit).) Equal to True).)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in InBurrow) Equal to 2
          • ((Triggering player) Current gold) Greater than or equal to DemoGoldCost
          • ((Triggering player) Current lumber) Greater than or equal to DemoWoodCost
        • Then - Actions
          • Unit Group - Pick every unit in InBurrow and do (Actions)
            • Loop - Actions
              • -------- stick unit caching here --------
              • Unit - Remove (Picked unit) from the game
          • Set VariableSet BurrowPoint = (Position of (Triggering unit))
          • Unit - Create 1 Demolisher for Player 1 (Red) at BurrowPoint facing Default building facing degrees
          • Custom script: call RemoveLocation(udg_BurrowPoint)
          • Player - Add (0 - DemoGoldCost) to (Triggering player).Current gold
          • Player - Add (0 - DemoWoodCost) to (Triggering player).Current lumber
        • Else - Actions
      • Custom script: call DestroyGroup(udg_InBurrow)
  • demolisher death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Demolisher
    • Actions
      • Set VariableSet DemoPoint = (Position of (Triggering unit))
      • Unit - Create 2 Peon for (Owner of (Triggering unit)) at DemoPoint facing Default building facing degrees
      • Custom script: call RemoveLocation(udg_DemoPoint)

Wow! This is actually amazing. This opens up so many new avenues for my custom race map. I will try this as soon as I can, since I am currently working on a "growth" process for certain units.
 
Top