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

Combining Units or Structures With an Ability?

Status
Not open for further replies.
Level 4
Joined
Apr 15, 2008
Messages
82
I need a way that I could combine two structures with an ability. Eg.
You build a Guard Tower.
You build an Arcane Tower.
You cast the combining spell in some way to combine the units into a Cannon Tower.
 
Level 19
Joined
Aug 24, 2007
Messages
2,888
yes that name is taken already

What will it be liek.. liek towers need to be together or ???
more details
 
Level 4
Joined
Aug 13, 2006
Messages
47
Why don't you use the normal upgrade way ? o_O
Because what he wants to do is more fun. I think he wants to know how the sacrifice ability connects the Sacrificial Pit to the acolyte... and well, i want to know that too, i want to connect other units to each other in the same fashion as Sacrifice

Edit: wait a minute, what HE wants is connect them like the night elf archer and the hippogryph combining them into the hippogryph rider
 
Last edited:
Level 5
Joined
Aug 27, 2007
Messages
138
I'm trying to make an ability similar to sacrifice, but this makes Goblin Schredders "sacrifice" themselves to become a Gobin Heavy Bot

Make a spell that does nothing and replace the caster with a "Gobin Heavy Bot?"
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
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
 
Last edited:
Status
Not open for further replies.
Top