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

Linking Units

Status
Not open for further replies.
Level 33
Joined
Mar 27, 2008
Messages
8,035
I have 2 situation right now (currently, don't know what's future to come).

Situation 1
My Hero casts Mirror Image. Now I want those illusions to share damage with the Caster. How would I link it ? If you're suggesting me to use Spirit Link, just forget it. The target is random and has (even if it has 1% chance) it will still probably would target any other units in the area. Same goes for Pick Every Unit action around the Caster, that won't work, what if there are more than 1 Hero casting the spell at the same time, nearby each other ? The "share" is fked up. For instance, Unit A would share with illusions with A-1,2,3,4 but instead, the Pick Every Unit messed it up by linking all nearby illusions.

Situation 2
My Hero casts Locust Swarm. Now I want to detect an event that the Locust being "spawned" or "released" from the caster so I can do something to it. I already tried the event "A unit spawns a summon unit" but to no avail, it didn't detect. I also tried "A unit starts the effect of an ability", it did catches the event, but right now... how can I link/refer to the Locust when I successfully casts Locust Swarm ? Again, same with Situation 1, don't suggest me the old-fashion "Pick Every Unit..." action, like I said, it would mess up the calculation if 2 or more instance is casting nearby to each other.

I believe there is a solution, somehow, somewhere...
Thank you for your time.

EDIT:
And yes, I want the triggers (or the solutions) to be in a MUI state, no MPI is allowed.
 
Last edited:
Level 11
Joined
Jun 15, 2011
Messages
447
For question 1, you may want to use a damage detection system, which you can find many tutorials in the net, and maybe here, in the hive. So when the caster takes damage, then make all illusions owned by owner of caster to also take damage.

For question 2, try using "A unit enters Playable Map Area" then add condition "Unit-type of entering unit equal to locust unit"
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You just don't get it, do you ?
It's easy to "detect" them, now how would I "link" them to one another ?

Detailed Example (special, for you, karassu)
I have 3 Blademaster.
Blademaster A casts Mirror Image and it spawns 3 illusions.
Blademaster B casts Mirror Image and it spawns 3 illusions.
Blademaster C casts Mirror Image and it spawns 3 illusions.

How can I link each of its illusion to each of its caster ?


So when the caster takes damage, then make all illusions owned by owner of caster to also take damage.
If you can't show how to do the text in red, you would probably don't know what you're talking.

Detailed Example for Situation 2
Same as above, how would I link each Locust instance for each Caster.
 
Level 11
Joined
Jun 15, 2011
Messages
447
You don't understand what I said? What I'm telling is like this:

[Trigger 1]
Events: A unit enters playable map area
Conditions: Unit-type of entering unit equal to (Caster)
Entering unit is a hero equal to true
Actions: Trigger add (trigger 2) the event (triggering unit takes damage)

[Trigger 2]
Events:
Conditions:
Actions:
Pick every units owned by owner of caster and do Unit set the life of (illusion) to (life of illusion - whatever value)
or
Pick every units owned by owner of caster and do Unit cause (damage source) to damage (illusion) dealing (damage taken by caster)

[As easy as that, specially for you Defskull.]
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Haha you just don't get it !!!
Can you create a test map for me ?
And if it's wrong, I'll show where it's wrong in your understanding.
+rep will be given for your hard work, indeed (even though it's wrong).

The situation would follow the situation in the post #3.
3 Blademaster, all cast Mirror Image and each of the illusion would be assigned to each of the Caster individually, not share all of them for one player.

Example:
Blademaster A produces 3 illusions - A-1 / A-2 / A-3
Blademaster B produces 3 illusions - B-1 / B-2 / B-3
Blademaster C produces 3 illusions - C-1 / C-2 / C-3

Now when Blademater B takes damage, I want to modify B-1 / B-2 / B-3, how can I do that ?
If Blademaster C takes damage, bla bla bla
If Blademaster A takes damage, bla bla bla

EDIT:
All Blademaster is from the same player (Player 1).
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
You see........................................................
I want Blademaster A to produce 3 illusions, AND ONLY WHEN BLADEMASTER A TAKES DAMAGE, HIS ILLUSIONS TAKES DAMAGE, NOT ALL ILLUSIONS OWNED BY PLAYER TAKES DAMAGE.
 
Level 9
Joined
Dec 12, 2007
Messages
489
Situation 1

I would like to clear some points:
1. the hero casts a spell
2. it creates few images of the hero
3. those images are linked to the hero and share damage taken between them.

assuming you already familiar with Damage Detection System,
a possible solution will be:

1. a custom spell ( not Mirror Image ) -> refered as ability A
and a dummy unit spell (Wand of Illusion) -> refered as ability B.

2. when ability A is cast, save the caster in a hashtable/struct and order dummy to cast ability B on caster several times (as much as you like).

3. check if the ability B is cast with event unit summon, and link the summoned unit to the caster (retrieved from hashtable/struct) either with unit group or array.

the only drawback of this workaround is loss of invulnerability period and buff removal.
and no mirror image splitting effect of course.

I assume you can do the rest with Damage Detection System and few more triggers.

Situation 2

what do you want to do when you already able to enum those locusts?
if you want to trigger something when those locust attack, I can only think of 2 possible solutions:

Alternative 1
Fully trigger the Locust Swarm, that way you gain freedom and total control of the locusts.
but this is probably most unfavorable.

Alternative 2
Save the caster's owning player upon ability cast, and check if the caster's owning player == the owner of locust when the locust attack, and check if the unit type of Locust is match, then trigger the rest.
However this is limited to be MPI as MUI is impossible to achieve when dealing with unit spawned by Locust Swarm.
good luck on finding ways to make this one MUI.
 
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
I have 2 situation right now (currently, don't know what's future to come).

Situation 1
My Hero casts Mirror Image. Now I want those illusions to share damage with the Caster. How would I link it ? If you're suggesting me to use Spirit Link, just forget it. The target is random and has (even if it has 1% chance) it will still probably would target any other units in the area. Same goes for Pick Every Unit action around the Caster, that won't work, what if there are more than 1 Hero casting the spell at the same time, nearby each other ? The "share" is fked up. For instance, Unit A would share with illusions with A-1,2,3,4 but instead, the Pick Every Unit messed it up by linking all nearby illusions.
EDIT:
And yes, I want the triggers (or the solutions) to be in a MUI state, no MPI is allowed.

1. u tryed hashtable where 1st key is the caster unit index/or handle id and 2nd key is a increment variable (when u cast the 2nd key allways get +1 compared with previous) saved value is the casted illusion unit
something like
JASS:
u = GetTriggerUnit()
cv = GetUnitUserData(u)
clone[cv] = clone[cv] + 1
//u can also use GetUnitTypeId(u) and add expiration timer to clone if u want
cloneUnit =  CreateUnit(GetTriggerPlayer(),'unitrawcode',x,y,ang)
// we save the cloned unit
call SaveUnitHandle(clone_table, GetHandleId(u),clone[cv], cloneUnit)
//we assign to original unit to clone because later we want get the original unit
call SaveUnitHandle(owner_table, GetHandleId(cloneUnit), 0,u)
set u = null

ofc arrange if a clone die, i guess that u know

if a unit reicive damage then
JASS:
local integer i = 1
set illusion1 = GetTriggerUnit()
local unit u = LoadUnitHandle(owner_table, GetHandleId(illusion1), 0) 
local unit illusion1
local unit illusion2
local integer c
if u != null then
set cv =  GetUnitUserData(u)
loop
exitwhen i > clone[cv] 
      set illusion2 = LoadUnitHandle(clone_table, GetHandleId(u),i)
      if illusion1 != illusion2 then
         calculate distance  between illusion1 and illusion2 
      endif
set i = i + 1
endif
endif
set u = null
set illusion1 = null
set illusion2 = null

maybe this can give a ideea to u
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
I haven't tested it, but I hope it works. Trying to help blindly.

1. Detect illusions or use Action - Create instead to do so. When hero takes damage, you detect that amount, then set hero life to current life + damage amount taken, this will heal up. Then divide detected damage by number of illusions + hero and cause that divided damage to hero as well as to illusions.

2. Trigger a new spell. When cast, create the amount of locust at position of caster, set it all into variables, pick random point with offset for each locust separately around hero and order locust to move there to create that moving immitation. Add adjusted Phoenix Fire to make it attack. Since you have units in variables, you can link to it.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
#1
Well, you just gave me formula/calculation (which I already know @@"). I just need to know how to link unit to caster by using Mirror Image as base spell.

#2
Yeah well I thought about triggering the whole spell completely from the start, but I think I want to to use Locust in any way :/
 
Level 31
Joined
Jun 27, 2008
Messages
2,557
You go a harder way. Fully triggering spell would be easier as it would work out as well as the basis of mirrors or swarm, except that you could link units with caster and these spells are complicated.

Why Pick every unit is not an option? You can pick it and check unit's owner, then you can add picked units into unit group, and so then in the condition: if picked unit belongs to that unit group, do nothing, else add picked unit to unit group 2. I mean that you can experiment with the conditions.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Perhaps something like this might work?
JASS:
constant native IsUnitInRange       takes unit whichUnit, unit otherUnit, real distance returns boolean
constant native IsUnitInRangeXY     takes unit whichUnit, real x, real y, real distance returns boolean

EDIT: nvm this will simply return a boolean... And thus is checking instead of linking.
I couldn't really think of anything usefull so far, I see your frustration :/

Went through the entire function list for get but couldn't think of anything. You have already tried trained unit (would be weird), summoned unit and spell target unit right?
I guess there is no way of linking through handle ID's?
 
Status
Not open for further replies.
Top