Copy of hero

Level 16
Joined
Dec 12, 2021
Messages
206
Hello, I'm trying to create a spell in which you select one of your units regardless of the distance and a copy of the hero who used the spell is generated, the copy has to be at the same level as the hero, or consequently, if the copy is not a hero it would have to have the same characteristics as the hero who summoned it at the time, for example, the same life, damage and mana of the hero who generated it being at level 7 for example. Another thing is that it has to have the same skills that the hero learned at the time, that is, if he only learned holy light and divine shield but not the aura of devotion, the copy would have to have only 2 skills and not the aura (I do not plan to add the ultimate ability for the copy), and well I also made a configuration so that the copy is more transparent to differentiate it from the real one. In conclusion, I want to summon a copy of my hero at the position of my selected unit no matter where it is, and the copy has to have 100% of my hero's maximum life and maximum mana, and also the same attack damage, and also the same skills that it learned at the time and at the same level. And another thing I noticed is that the name of my hero's copy is different from the original hero. And finally, when the 60 seconds of summoning pass or the copy dies, it disappears from the game and cannot be revived, since in my spell that I made I get the option to revive it and that is not something that should happen with the spell. And one additional thing is that I don't care if the copy is a hero or a dummy unit, but it has to have the same characteristics as the original (attack damage, armor, maximum mana, maximum life, etc.)
 

Attachments

  • PROYECTIONEHRO.w3x
    17.9 KB · Views: 2
Level 45
Joined
Feb 27, 2007
Messages
5,578
I didn’t open the map because I’m not near an editor. You've described your objective very well, but nothing in your post describes what you’ve tried or what issues you are having. That’s the most important thing to include when you post here needing help.

The answer to this is to use the Gamecache. Normally it’s for saving a hero or some other units between maps of a campaign, but you can store and then immediately place a copy of that stored unit directly onto the map.

This retains all abilities, ability ranks, items, and max HP/MP values. It does not retain current hp %, buffs, or cooldowns; obviously anything triggered that was tracking the original unit will also not know about the duplicate. You can set active cooldowns to match the source unit as well as manipulate its current health and mana to match. Other effects from buffs cannot easily be transferred but with some fuckery and enough planning you could do it.
 
Last edited:
Level 16
Joined
Dec 12, 2021
Messages
206
Okay, you're right, I described my objective very well, as for my spell that I made in this trigger, I did it well but I saw some things that didn't fit, for example, I made a copy of my paladin, at its current level, that's fine, but there's no way for it to learn the skills that my paladin learned at the time, another thing is that when the copy dies, I have the option to revive it and have it as an additional hero, that would ruin the game mechanics, another thing that I didn't like is that when I summoned a copy it took another name, for example, my original hero is uther (paladin), and the copy was called arthas (paladin), not exactly those names but I'm sure you understand what I mean. Well, those 2 problems I had mainly with my detonator. I don't know where to activate the game cache that you mentioned or how, maybe you're referring to the damage engine? In any case, could you teach me or make a map with the appropriate triggers?
 
Hero name can be renamed with one of the newer natives provided around 1.29-1.31 patch (not sure which one drops it).

  • Hero - Set Name of (Triggering unit) to Original Hero Name
Your copy is creating an actual unit, hence the game treat it as such and will apply everything related to the unit including hero limits, food cost, and hero tier. It is also treated as an actual hero. Depending on your map, there might be strategies to circumvent some of the issues with some nifty hack, but without knowing what kind of map exactly it is hard to propose solutions.

Learning abilities can be tricky. I would recommend mapping all heroes to one hashtable and then when a copy is executed, insert the data to the actual hashtable and have the copied hero read from that data. Given that this ability is theorically instant, I don't think collisions will occur.
 
Level 16
Joined
Dec 12, 2021
Messages
206
It's a very good idea, however, how about my proposal: Instead of creating a copy of the hero, which is a copy of a normal unit, that is, a unit but with the same attributes, so we won't have to worry about the name (it could simply be called Paladin), nor worry about whether it can be resurrected at the altar of kings and its food consumption, in this case the only concern is how to assign the powers that the original hero learned at the time to the copy of the hero, which would be a unit but with the same model.
Example: I create a copy of the human soldier, but I name it "Paladin", I choose the same HP and MP as the original hero, and the same damage, with the same powers at the original hero's current level.
 
I would map the hero abilities first to a Hashtable or an array for all heroes, then depending on the copied hero, find the matching hero data in said Hashtable/Array and then give those abilities to the copy. Afterward, set the ability level to match the original's level like this:
  • Unit - Set level of YOUR_ABILITY for COPY_UNIT to (Level of YOUR_ABILITY for ORIGINAL_UNIT)
 
I didn’t open the map because I’m not near an editor. You've described your objective very well, but nothing in your post describes what you’ve tried or what issues you are having. That’s the most important thing to include when you post here needing help.

The answer to this is to use the Gamecache. Normally it’s for saving a hero or some other units between maps of a campaign, but you can store and then immediately place a copy of that stored unit directly onto the map.

This retains all abilities, ability ranks, items, and max HP/MP values. It does not retain current hp %, buffs, or cooldowns; obviously anything triggered that was tracking the original unit will also not know about the duplicate. You can set active cooldowns to match the source unit as well as manipulate its current health and mana to match. Other effects from buffs cannot easily be transferred but with some fuckery and enough planning you could do it.
It doesn't retain the hero name though. This is not visible in campaign because it is the only name that unit can have :D

Could you send me the map with the triggers or show me some screenshots? The problem is, I'm not very good at handling hash tables. I'm using version 1.27, and maps created in higher versions don't open my Word editor.
Doesn't have to be a Hashtable. You can also use an array. Something like this for an array:
  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set AstralIndex = (AstralIndex + 1)
      • Set HeroType[AstralIndex] = Paladin
      • Set UnitType[AstralIndex] = Footman
      • Set Skill1[AstralIndex] = Holy Light
      • Set Skill2[AstralIndex] = Divine Shield
As for Hashtables, it is not intuitive to work with in GUI since you need to cast Ability to Integer and vice versa to save it as an integer and return it back.

For Reforged user, newer natives can help lower the burden in scanning the abilities with the BlzGetUnitAbilityByIndex native
 
Last edited:

Rheiko

Spell Reviewer
Level 26
Joined
Aug 27, 2013
Messages
4,214
You can give this a try.

First, I create the copies of available heroes and remove their default abilities.
Then I stored all the possible copy of the heroes into array. When casting the spell, the trigger searches through the array and proceed if it finds a match. Then I match the copy's information to caster's information (Life, Mana, Ability Levels, Hero Levels). When time is up, remove the copy from the game.

in object editor, make sure these values are set to true:
Stats - Hero - Hide Hero Death Message
Stats - Hero - Hide Hero Interface Icon
Stats - Hero - Hide Hero Minimap Display

I think the labels are quite straightforward. They hide your copy's death message, interface icon (the top left thingy), hero minimap display. It will still show up in minimap as normal unit so no need to worry.

  • AstralProjection Config
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- - --------
      • -------- Your Ability ID from Object Editor here --------
      • -------- - --------
      • Set AP_AbilityID = Astral Projection
      • -------- - --------
      • -------- Store all the heroes and skills into arrays --------
      • -------- - --------
      • Set AP_HeroType[1] = Paladin
      • Set AP_CopyType[1] = Paladin (Copy)
      • Set AP_Skill1[1] = Holy Light
      • Set AP_Skill2[1] = Divine Shield
      • Set AP_Skill3[1] = Devotion Aura
      • -------- - --------
      • Set AP_HeroType[2] = Archmage
      • Set AP_CopyType[2] = Archmage (Copy)
      • Set AP_Skill1[2] = Blizzard
      • Set AP_Skill2[2] = Summon Water Elemental
      • Set AP_Skill3[2] = Brilliance Aura
      • -------- - --------
      • Set AP_HeroType[3] = Mountain King
      • Set AP_CopyType[3] = Mountain King (Copy)
      • Set AP_Skill1[3] = Storm Bolt
      • Set AP_Skill2[3] = Thunder Clap
      • Set AP_Skill3[3] = Bash
      • -------- - --------
      • Set AP_HeroType[4] = Blood Mage
      • Set AP_CopyType[4] = Blood Mage (Copy)
      • Set AP_Skill1[4] = Flame Strike
      • Set AP_Skill2[4] = Banish
      • Set AP_Skill3[4] = Siphon Mana
      • -------- - --------
      • -------- Make sure the slot matches the number of heroes you have --------
      • -------- - --------
      • Set AP_MaxSlot = 4
      • -------- - --------
      • -------- The Duration of your copy --------
      • -------- - --------
      • Set AP_Duration = 60.00
      • -------- - --------
      • -------- Transparency and coloring to differentiate hero and copy --------
      • -------- - --------
      • Set AP_ColorRed = 80.00
      • Set AP_ColorGreen = 80.00
      • Set AP_ColorBlue = 80.00
      • Set AP_Transparency = 50.00
      • -------- - --------
      • -------- Special effect when copy appears --------
      • -------- - --------
      • Set AP_SpawnEffect = Abilities\Spells\Items\AIil\AIilTarget.mdl
      • -------- - --------
      • -------- Special effect when copy disappears --------
      • -------- - --------
      • Set AP_DespawnEffect = Abilities\Spells\Orc\FeralSpirit\feralspirittarget.mdl
  • AstralProjection
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to AP_AbilityID
    • Actions
      • -------- Store necessary information --------
      • Set AP_Owner = (Triggering player)
      • Set AP_Caster = (Triggering unit)
      • Set AP_Target = (Target unit of ability being cast)
      • Set AP_Life = (Life of AP_Caster)
      • Set AP_Mana = (Mana of AP_Caster)
      • Set AP_Point = (Position of AP_Target)
      • -------- Loop through all the slot to check --------
      • For each (Integer AP_TempInt) from 1 to AP_MaxSlot, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of AP_Caster) Equal to AP_HeroType[AP_TempInt]
            • Then - Actions
              • -------- Store skill level info --------
              • Set AP_Skill1Level = (Level of AP_Skill1[AP_TempInt] for AP_Caster)
              • Set AP_Skill2Level = (Level of AP_Skill2[AP_TempInt] for AP_Caster)
              • Set AP_Skill3Level = (Level of AP_Skill3[AP_TempInt] for AP_Caster)
              • -------- Create the copy --------
              • Unit - Create 1 AP_CopyType[AP_TempInt] for AP_Owner at AP_Point facing Default building facing degrees
              • Set AP_Copy = (Last created unit)
              • -------- Add the copy to group so we can filter them when they die --------
              • Unit Group - Add AP_Copy to AP_CopyGroup
              • -------- Add expiration time to the copy --------
              • Unit - Add a AP_Duration second Generic expiration timer to AP_Copy
              • -------- Change its look --------
              • Animation - Change AP_Copy's vertex coloring to (AP_ColorRed%, AP_ColorGreen%, AP_ColorBlue%) with AP_Transparency% transparency
              • -------- Create spawn effect --------
              • Set AP_Point2 = (Position of AP_Copy)
              • Special Effect - Create a special effect at AP_Point2 using AP_SpawnEffect
              • Special Effect - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_AP_Point2)
              • -------- Match their level to the original --------
              • Hero - Set AP_Copy Hero-level to (Hero level of AP_Caster), Hide level-up graphics
              • -------- Match their ability to the original --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AP_Skill1Level Greater than 0
                • Then - Actions
                  • Unit - Add AP_Skill1[AP_TempInt] to AP_Copy
                  • Unit - Set level of AP_Skill1[AP_TempInt] for AP_Copy to (Level of AP_Skill1[AP_TempInt] for AP_Caster)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AP_Skill2Level Greater than 0
                • Then - Actions
                  • Unit - Add AP_Skill2[AP_TempInt] to AP_Copy
                  • Unit - Set level of AP_Skill2[AP_TempInt] for AP_Copy to (Level of AP_Skill2[AP_TempInt] for AP_Caster)
                • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AP_Skill3Level Greater than 0
                • Then - Actions
                  • Unit - Add AP_Skill3[AP_TempInt] to AP_Copy
                  • Unit - Set level of AP_Skill3[AP_TempInt] for AP_Copy to (Level of AP_Skill3[AP_TempInt] for AP_Caster)
                • Else - Actions
              • -------- Match their HP to the original --------
              • Unit - Set life of AP_Copy to AP_Life
              • -------- Match their Mana to the original --------
              • Unit - Set mana of AP_Copy to AP_Mana
              • -------- Immediately break the loop when a match is found --------
              • Set AP_TempInt = AP_MaxSlot
            • Else - Actions
      • -------- Clean up leak --------
      • Custom script: call RemoveLocation(udg_AP_Point)
  • AstralProjectionRemoval
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in AP_CopyGroup) Equal to True
    • Actions
      • -------- Create despawn effect --------
      • Set AP_Point = (Position of (Triggering unit))
      • Special Effect - Create a special effect at AP_Point using AP_DespawnEffect
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_AP_Point)
      • -------- Remove the copy from the group --------
      • Unit Group - Remove (Triggering unit) from AP_CopyGroup
      • -------- Remove the copy from the game --------
      • Unit - Remove (Triggering unit) from the game
This will be much more efficient in hashtable but I'm lazy and as Daffa said, it is not very intuitive to work with in GUI.
Unfortunately, there's nothing I can do with Hero's Proper Name. A possible workaround is to allow your Hero and your Copy to have only one Proper Name. Also this does not account for bonus stats acquired from tomes, should be easy to add, though. Simply match the copy's stats to your caster's.
Attack damage and armor are rather difficult to manipulate pre 1.31. So I won't even bother with them.
 

Attachments

  • Astral Projection.w3x
    21.7 KB · Views: 2
Also, a side note:
Assuming your map is single-player, Game Cache is a valid solution to this matter. It still has the name issue but every thing else will be matched 1:1. Otherwise, Game Cache is not possible since it is not functional in multiplayer (this is why Save Load systems exist)
Attack damage and armor are rather difficult to manipulate pre 1.31. So I won't even bother with them.
I don't think there's much with attack and armor stats since they're usually tied to hero stats. There's BonusMod for manipulation of those stats pre-1.31 (just need to deal with the Lua Object Merger or 198 abilities...)
 
I’m sorry why are we ignoring my Gamecache comment? It’s exactly what you want to do. Food used, hero name, remove from game upon death, current hp/mp/cooldowns are all things you can easily set to match the original once it’s cloned with the Gamecache.
I think I have given comment on it over several posts, though I don't know if OP had tried that option in his map. On the other hand, Hero Name is a big pickle for this particular case because he's using 1.27 version which doesn't come with the necessary native. I checked UjAPI if it does have this particular native, but didn't find it so far... JNGP doesn't have it either.
It doesn't retain the hero name though. This is not visible in campaign because it is the only name that unit can have :D
Also, a side note:
Assuming your map is single-player, Game Cache is a valid solution to this matter. It still has the name issue but every thing else will be matched 1:1. Otherwise, Game Cache is not possible since it is not functional in multiplayer (this is why Save Load systems exist)
I attached a map with the Game Cache approach and the name doesn't match if there's more than 1 name.
 

Attachments

  • PROYECTIONEHRO.w3x
    19.1 KB · Views: 1
Level 16
Joined
Dec 12, 2021
Messages
206
Hey guys, sorry for the delay, I was able to open Rheiko's map correctly and the ability seems very successful, except for the name, but I think I could overlook that detail. And another thing, Daffa's map won't let me open it. As I said before, I'm using version 1.27. Maybe that's why. It would be nice if you could just post a screenshot of the triggers and I could imitate them.
Something else, I got this ability idea from a Maxwell map. I don't know if you could verify how he proposed it. He uses the Naga High Arcanist, and his ultimate ability is the same as the one I'm telling you. Could you verify how he designed his triggers for this ability?
MAxwell map
 

  • Arcane Projection
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Unit - Add Item Armor Bonus (+1) to (Triggering unit)
      • Set Variable Set Point = (Position of (Target unit of ability being cast))
      • Unit - Create 1 . Priest for (Owner of (Triggering unit)) at Point facing 270.00 degrees
      • Unit - Add a 180.00 second Generic expiration timer to (Last created unit)
      • Selection - Select (Last created unit) for (Owner of (Triggering unit))
      • Custom script: RemoveLocation(udg_Point)
      • Set Variable Set Point = (Position of (Last created unit))
      • Special Effect - Create a special effect at Point using Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using Abilities\Spells\Items\AIil\AIilTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using war3mapImported\MassTeleportTo.mdx
      • Special Effect - Destroy (Last created special effect)
      • Hashtable - Save Handle Of (Last created unit) as 0 of (Key (Triggering unit).) in Brainwash .
      • Hashtable - Save Handle Of (Triggering unit) as 0 of (Key (Last created unit).) in Brainwash .
      • Animation - Play (Last created unit) 's spell animation
      • Animation - Queue (Last created unit) 's stand animation
      • Unit - Add Channel to (Last created unit)
      • Unit - Missing string for 'BlzStartUnitAbilityCooldown'
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Parasite for (Triggering unit)) Not equal to 0
        • Then - Actions
          • Unit - Add Parasite to (Last created unit)
          • Unit - Set level of Parasite for (Last created unit) to (Level of Parasite for (Triggering unit))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Channel for (Triggering unit)) Not equal to 0
        • Then - Actions
          • Unit - Add Channel to (Last created unit)
          • Unit - Set level of Channel for (Last created unit) to (Level of Channel for (Triggering unit))
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Brilliance Aura for (Triggering unit)) Not equal to 0
        • Then - Actions
          • Unit - Add Brilliance Aura to (Last created unit)
          • Unit - Set level of Brilliance Aura for (Last created unit) to (Level of Brilliance Aura for (Triggering unit))
        • Else - Actions
      • Custom script: RemoveLocation(udg_Point)

  • Arcane Projection Copy
    • Events
      • Unit - A unit Finishes casting an ability
      • Unit - A unit Stops casting an ability
    • Conditions
      • (Ability being cast) Equal to Channel
    • Actions
      • Unit - Remove Item Armor Bonus (+1) from (Triggering unit)
      • Set Variable Set Point = (Position of (Load 0 of (Key (Triggering unit).) in Brainwash.))
      • Trigger - Turn off Arcane_Projection_Death <gen>
      • Hashtable - Clear all child hashtables of child (Key (Load 0 of (Key (Triggering unit).) in Brainwash.).) in Brainwash .
      • Unit - Kill (Load 0 of (Key (Triggering unit).) in Brainwash.)
      • Unit - Remove (Load 0 of (Key (Triggering unit).) in Brainwash.) from the game
      • Trigger - Turn on Arcane_Projection_Death <gen>
      • Special Effect - Create a special effect at Point using Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using Abilities\Spells\Items\AIil\AIilTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using war3mapImported\MassTeleportTarget2.mdx
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using war3mapImported\MassTeleportTo.mdx
      • Special Effect - Destroy (Last created special effect)
      • Custom script: RemoveLocation(udg_Point)
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit).) in Brainwash .

  • Arcane Projection Death
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Priest
    • Actions
      • Unit - Remove Item Armor Bonus (+1) from (Load 0 of (Key (Triggering unit).) in Brainwash.)
      • Set Variable Set Point = (Position of (Triggering unit))
      • Trigger - Turn off Arcane_Projection_Copy <gen>
      • Unit - Order (Load 0 of (Key (Triggering unit).) in Brainwash.) to Stop .
      • Trigger - Turn on Arcane_Projection_Copy <gen>
      • Special Effect - Create a special effect at Point using Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using Abilities\Spells\Items\AIil\AIilTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using war3mapImported\MassTeleportTarget2.mdx
      • Special Effect - Destroy (Last created special effect)
      • Special Effect - Create a special effect at Point using war3mapImported\MassTeleportTo.mdx
      • Special Effect - Destroy (Last created special effect)
      • Hashtable - Clear all child hashtables of child (Key (Load 0 of (Key (Triggering unit).) in Brainwash.).) in Brainwash .
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit).) in Brainwash .
      • Custom script: RemoveLocation(udg_Point)
      • Unit - Remove (Triggering unit) from the game
You need to make sense of some data being inaccurate due to how Trigger Viewer works
 
Level 16
Joined
Dec 12, 2021
Messages
206
Thanks bro, I tried to transfer the triggers you gave me to my map and it works very well, the only problem is that the copy of the hero can level up, I don't like that, and also that the copy collects items but when it dies the items go with it, it should be more feasible to be able to throw the items on the ground when it dies, and it shouldn't level up because this is a "copy".
 
Level 16
Joined
Dec 12, 2021
Messages
206
1742537918469.png

I used these commands to drop the items the copy was carrying when it died, but isn't there a way to combine them all? Since I used six different commands to drop items for each corresponding slot, is there a way to make a single command for all six slots in the hero's inventory?
 
Level 16
Joined
Dec 12, 2021
Messages
206
Sorry for the bother bro, I've been wanting to see what system this map uses for custom race selection for a while now but my editor won't let me open the map, I don't know if you could open it for me and see what triggers it uses for configuring the race selection system, since I've seen other systems within the hive but they work with a lot of lag, or have some problems and in my experience only this map is the only good system that doesn't present lag at the time of its gameplay, but it's a shame I can't copy its triggers and import them to mine :(
 

Attachments

  • El despertar de los Naga.w3x
    9.7 MB · Views: 2
Sorry for the bother bro, I've been wanting to see what system this map uses for custom race selection for a while now but my editor won't let me open the map, I don't know if you could open it for me and see what triggers it uses for configuring the race selection system, since I've seen other systems within the hive but they work with a lot of lag, or have some problems and in my experience only this map is the only good system that doesn't present lag at the time of its gameplay, but it's a shame I can't copy its triggers and import them to mine :(
Create a new thread for this topic
 
Top