Yeap Mount Hippogryph is what you are looking for(if you want to combine selected unit type A with a random unit type B in some range of the caster).
Make an ability based on it and edit the fields:
data Partner unit type
the unit that is combined with the unit having the ability)
data resulting unit type: (what will become after combining)
This will not do any good if you want to combine towers or specific units(like player picks a random unit and targets another random unit with "combine" ability) where you want to have multiple combination based on the combined units.
If you want to do the second thing, then make a dummy ability. When something target another thing with it then with a trigger check what the units are(done with 2 loops and one global array unit(integer) containing every unit type that can be combined, another global array unit(integer) that contains the results; data in the second array should be organized by using some simple mathematical function to be called when you get the types of units combined see below for an example) and replace the casting unit with some combination(removing the targeted unit in the process ).
Like you have 3 unit types
A, B and C.
Put the raw codes of those in and array(in some trigger ran at some initialization(like 1 sec after game start or what ever)).
You want to have the combinations:
AB
AC
AA
BC
BB
CC
(AA, BB, CC optional)
You have 2 ways of putting them in an array.
first one is:
array[0]=AA
array[1]=AB
array[2]=AC
array[3]=BA
array[4]=BB
array[5]=BC
array[6]=CA
array[7]=CB
array[8]=CC
Or:
array[0]=AA
array[1]=AB
array[2]=AC
array[3]=BB
array[4]=BC
array[5]=CC
Choosing a way is important because the way you check what unit should be created is different. Also way 2 is more economical and less work to do but also is a little bit more complex.
Now for the actual combination I will post a trigger a few minutes from now.
Edit:
-
combination
-
Events
-
Unit - A unit Starts the effect of an ability
-
Conditions
-
(Ability being cast) Equal to Combination
-
Actions
-
For each (Integer A) from 0 to 2, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Unit-type of (Casting unit)) Equal to unitarray[integer A]
-
Then - Actions
-
For each (Integer B) from 0 to 2, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Unit-type of (Target unit of ability being cast)) Equal to unitarray[integer B]
-
Then - Actions
-
Unit - Replace (Casting unit) with a ComboArray[(Integer A)*3 + Integer B] using The new unit's default life and mana
-
Unit - Remove (Target unit of ability being cast) from the game
-
Else - Actions
-
Else - Actions
This will do for the first method of unit type storage.
Will post the other situations some time later(have stuff to do).
Edit2:
For the second the unit for the replacement should be like this:
ComboArray[Min(Integer A, Integer B)+Min(integer A,1) + Max(Integer A, Integer B)]
The situation where you have no AA,BB,CC is comming
Here it is:
the ComboArray should look like this:
array[0]=AB
array[1]=AC
array[2]=BA
array[3]=BC
array[4]=CA
array[5]=CB
And the call should be:
ComboArray[Integer A * 2 + Min(1, Integer B)]
OR like this:
array[0]=AB
array[1]=AC
array[2]=BC
and the call should be:
ComboArray[Min(integer A, integer B) + Max(integer A, integer B) - 1]
Those call are universal. All you need to do is adjust the loop ends to the number of unit types that can be combined. And set the arrays according to what you want and choose the appropriate call.
The actual replacement can be changed but still you need to check what unit to create.
P.s. the speed this works at is ( A+B ) max ( 2*n ) ^^
so it is not slow