• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

How to properly replace a unit?

Status
Not open for further replies.
Level 4
Joined
Jul 19, 2010
Messages
99
Okay I am faced with a (probably) very simple but yet complicating system. I need to replace a unit (a hero) with another one but yet the abilities, experience and everything need to carry over to the new unit. (Gun replacement system?)
I don't know how to do this. Please help? :)
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
Another quite similar possibility.

Modify Metamorphosis, make it like in that tutorial. The original unit should be the alternate form. Give both forms the ability.

You can toggle between the forms.

Disable the ability at map initialization:
  • Player - Disable Metamorphosis xx for Player 1 (Red)
When you want to transform, works back and forth, displays no icon.
  • Untitled Trigger 125
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
      • Player - Enable Metamorphosis xx for Player 1 (Red)
      • Unit - Order Blood Mage 0009 <gen> to Night Elf Demon Hunter - Metamorphosis
      • Player - Disable Metamorphosis xx for Player 1 (Red)
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
It should work. Remember
Fill out the data fields correctly: the "Normal Form" field is the unit you morph TO, the "Alternate Form" field is the unit you morph FROM.
and
The original unit should be the alternate form.
I attached a test map. Press Esc to switch between the Archmage and Antonidas. Note that ability levels and items are kept intact.

In my test map I had to use two abilities. I think if you use Maker's method, you only need one.
 

Attachments

  • TransformTest.w3x
    12.5 KB · Views: 155
Level 4
Joined
Jul 19, 2010
Messages
99
Lmao i think i figured a system out but i do have a problem, every time the unit is morphed, when you move the "new" unit, a death animation is played at a random spot near the unit (it shows blood and the sound of a unit dying), but this does not affect the new unit? Like wtf? Lol
 
Level 9
Joined
Apr 23, 2010
Messages
312
Forgive me if this isn't what your looking for, but I think this might help...
  • Replace Unit
    • Events
    • Conditions
    • Actions
      • Set ReplacedUnit_u = (Triggering unit)
      • Set UnitExperience_int = (Hero experience of ReplacedUnit_u)
      • Set Strength_int = (Strength of ReplacedUnit_u (Exclude bonuses))
      • Set Agility_int = (Agility of ReplacedUnit_u (Exclude bonuses))
      • Set Intellignece_int = (Intelligence of ReplacedUnit_u (Exclude bonuses))
      • Set Strength_int = (Strength of ReplacedUnit_u (Exclude bonuses))
      • Set Abilities_a[0] = Holy Light
      • Set Abilities_a[1] = Devotion Aura
      • Set Abilities_a[2] = Divine Shield
      • Set Abilities_a[3] = Resurrection
      • Set AbilityLevel_int[0] = (Level of Abilities_a[0] for NewUnit_u)
      • Set AbilityLevel_int[1] = (Level of Abilities_a[1] for NewUnit_u)
      • Set AbilityLevel_int[2] = (Level of Abilities_a[2] for NewUnit_u)
      • Set AbilityLevel_int[3] = (Level of Abilities_a[3] for NewUnit_u)
      • Set Item_i[0] = (Item-type of (Item carried by ReplacedUnit_u in slot 1))
      • Set Item_i[1] = (Item-type of (Item carried by ReplacedUnit_u in slot 2))
      • Set Item_i[2] = (Item-type of (Item carried by ReplacedUnit_u in slot 3))
      • Set Item_i[3] = (Item-type of (Item carried by ReplacedUnit_u in slot 4))
      • Set Item_i[4] = (Item-type of (Item carried by ReplacedUnit_u in slot 5))
      • Set Item_i[5] = (Item-type of (Item carried by ReplacedUnit_u in slot 6))
      • Set ItemCharges_int[0] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 1))
      • Set ItemCharges_int[1] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 2))
      • Set ItemCharges_int[2] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 3))
      • Set ItemCharges_int[3] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 4))
      • Set ItemCharges_int[4] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 5))
      • Set ItemCharges_int[5] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 6))
      • Unit - Replace ReplacedUnit_u with a Footman using The old unit's relative life and mana
      • Set NewUnit_u = (Last replaced unit)
      • Hero - Set NewUnit_u experience to UnitExperience_int, Hide level-up graphics
      • Hero - Modify Strength of NewUnit_u: Set to Strength_int
      • Hero - Modify Agility of NewUnit_u: Set to Agility_int
      • Hero - Modify Intelligence of NewUnit_u: Set to Intellignece_int
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Unit - Add Abilities_a[(Integer A)] to NewUnit_u
          • Unit - Set level of Abilities_a[(Integer A)] for NewUnit_u to AbilityLevel_int[(Integer A)]
      • For each (Integer A) from 0 to 5, do (Actions)
        • Loop - Actions
          • Hero - Create Item_i[(Integer A)] and give it to NewUnit_u
          • Item - Set charges remaining in (Last created item) to ItemCharges_int[(Integer A)]
This should work for any unit you want just change the abilities to the abilities of the unit you are replacing. You don't need to set the level of the unit, the experience does that automatically. I didn't know what event your using so I left it blank, you might want to change the "triggering unit" in "set - replacedunit_u = (triggering unit)" to something more appropriate according to your event. Again, if this isn't what you need i'm sorry.
 
Level 4
Joined
Jul 19, 2010
Messages
99
Forgive me if this isn't what your looking for, but I think this might help...
  • Replace Unit
    • Events
    • Conditions
    • Actions
      • Set ReplacedUnit_u = (Triggering unit)
      • Set UnitExperience_int = (Hero experience of ReplacedUnit_u)
      • Set Strength_int = (Strength of ReplacedUnit_u (Exclude bonuses))
      • Set Agility_int = (Agility of ReplacedUnit_u (Exclude bonuses))
      • Set Intellignece_int = (Intelligence of ReplacedUnit_u (Exclude bonuses))
      • Set Strength_int = (Strength of ReplacedUnit_u (Exclude bonuses))
      • Set Abilities_a[0] = Holy Light
      • Set Abilities_a[1] = Devotion Aura
      • Set Abilities_a[2] = Divine Shield
      • Set Abilities_a[3] = Resurrection
      • Set AbilityLevel_int[0] = (Level of Abilities_a[0] for NewUnit_u)
      • Set AbilityLevel_int[1] = (Level of Abilities_a[1] for NewUnit_u)
      • Set AbilityLevel_int[2] = (Level of Abilities_a[2] for NewUnit_u)
      • Set AbilityLevel_int[3] = (Level of Abilities_a[3] for NewUnit_u)
      • Set Item_i[0] = (Item-type of (Item carried by ReplacedUnit_u in slot 1))
      • Set Item_i[1] = (Item-type of (Item carried by ReplacedUnit_u in slot 2))
      • Set Item_i[2] = (Item-type of (Item carried by ReplacedUnit_u in slot 3))
      • Set Item_i[3] = (Item-type of (Item carried by ReplacedUnit_u in slot 4))
      • Set Item_i[4] = (Item-type of (Item carried by ReplacedUnit_u in slot 5))
      • Set Item_i[5] = (Item-type of (Item carried by ReplacedUnit_u in slot 6))
      • Set ItemCharges_int[0] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 1))
      • Set ItemCharges_int[1] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 2))
      • Set ItemCharges_int[2] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 3))
      • Set ItemCharges_int[3] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 4))
      • Set ItemCharges_int[4] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 5))
      • Set ItemCharges_int[5] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 6))
      • Unit - Replace ReplacedUnit_u with a Footman using The old unit's relative life and mana
      • Set NewUnit_u = (Last replaced unit)
      • Hero - Set NewUnit_u experience to UnitExperience_int, Hide level-up graphics
      • Hero - Modify Strength of NewUnit_u: Set to Strength_int
      • Hero - Modify Agility of NewUnit_u: Set to Agility_int
      • Hero - Modify Intelligence of NewUnit_u: Set to Intellignece_int
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Unit - Add Abilities_a[(Integer A)] to NewUnit_u
          • Unit - Set level of Abilities_a[(Integer A)] for NewUnit_u to AbilityLevel_int[(Integer A)]
      • For each (Integer A) from 0 to 5, do (Actions)
        • Loop - Actions
          • Hero - Create Item_i[(Integer A)] and give it to NewUnit_u
          • Item - Set charges remaining in (Last created item) to ItemCharges_int[(Integer A)]
This should work for any unit you want just change the abilities to the abilities of the unit you are replacing. You don't need to set the level of the unit, the experience does that automatically. I didn't know what event your using so I left it blank, you might want to change the "triggering unit" in "set - replacedunit_u = (triggering unit)" to something more appropriate according to your event. Again, if this isn't what you need i'm sorry.
hmm it may be but its a little complex for me, haha. It might take me all day to figure that one out. But the system that Maker offered works well, but there are two problems to it,
1. When the unit changes, it automatically does a death animation (it doesn't kill the unit)
2. It only works for one unit. I had gotten it so that it worked for two units but then all of a sudden it stopped working, the abilities are exactly the same, as well as the triggers.
 
Level 9
Joined
Apr 23, 2010
Messages
312
What event are you using? The only thing's you need change in the trigger i made for you is the "abilities_a" array and what unit you are changing the replaced unit with, the trigger does the rest for you.

These are the basic abilites for the paladin that should be changed to the abilities of your hero.
  • Set Abilities_a[0] = Holy Light
  • Set Abilities_a[1] = Devotion Aura
  • Set Abilities_a[2] = Divine Shield
You can always add more abilities by adding another "set Abilities_a[#] = Your new ability" and just change the # to the very next number, in this case it would be 3 but sinse I have already used 3 for the ultimate, it would become 4.

This is the ultimate (level 6 ability) which can b e changed just the same as the above abilities.
  • Set Abilities_a[3] = Ressurection
You will need to change where it says "Footman" to what unit you want to change "ReplacedUnit_u" with.
  • Unit - Replace ReplacedUnit_u with a Footman using The old unit's relative life and mana
If you want it to work for multiple units you will want to place a ITE (If/Then/Else) that checks the unit type of "ReplacedUnit_u" and replace the unit accordingly. If the unit is the wrong type, move to the next ITE check and so on.
  • If ((Unit-type of (ReplacedUnit_u)) Equal to "YourUnit") then do (Unit - Replace (ReplacedUnit_u) with a "YourNewUnit" using The old unit's relative life and mana) else do (Do nothing)
If you need more help feel free to ask :)
 
Level 9
Joined
Apr 23, 2010
Messages
312
Yes, it should look something like this when your finished.
  • Replace Unit
    • Events
      • Player - Player 1 (Red) skips a cinematic sequence
    • Conditions
    • Actions
    • Set ReplacedUnitGroup = (Random unit from (Units owned by (Triggering player) of type "YourUnit"))
    • Set ReplacedUnit_u = (Random unit from ReplacedUnitGroup)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Item-type of (Item carried by (ReplacedUnit_u) of type "YourItem")) Equal to "YourItem"
    • Then - Actions
      • Set UnitExperience_int = (Hero experience of ReplacedUnit_u)
      • Set Strength_int = (Strength of ReplacedUnit_u (Exclude bonuses))
      • Set Agility_int = (Agility of ReplacedUnit_u (Exclude bonuses))
      • Set Intellignece_int = (Intelligence of ReplacedUnit_u (Exclude bonuses))
      • Set Strength_int = (Strength of ReplacedUnit_u (Exclude bonuses))
      • Set Abilities_a[0] = Holy Light
      • Set Abilities_a[1] = Devotion Aura
      • Set Abilities_a[2] = Divine Shield
      • Set Abilities_a[3] = Resurrection
      • Set AbilityLevel_int[0] = (Level of Abilities_a[0] for NewUnit_u)
      • Set AbilityLevel_int[1] = (Level of Abilities_a[1] for NewUnit_u)
      • Set AbilityLevel_int[2] = (Level of Abilities_a[2] for NewUnit_u)
      • Set AbilityLevel_int[3] = (Level of Abilities_a[3] for NewUnit_u)
      • Set Item_i[0] = (Item-type of (Item carried by ReplacedUnit_u in slot 1))
      • Set Item_i[1] = (Item-type of (Item carried by ReplacedUnit_u in slot 2))
      • Set Item_i[2] = (Item-type of (Item carried by ReplacedUnit_u in slot 3))
      • Set Item_i[3] = (Item-type of (Item carried by ReplacedUnit_u in slot 4))
      • Set Item_i[4] = (Item-type of (Item carried by ReplacedUnit_u in slot 5))
      • Set Item_i[5] = (Item-type of (Item carried by ReplacedUnit_u in slot 6))
      • Set ItemCharges_int[0] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 1))
      • Set ItemCharges_int[1] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 2))
      • Set ItemCharges_int[2] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 3))
      • Set ItemCharges_int[3] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 4))
      • Set ItemCharges_int[4] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 5))
      • Set ItemCharges_int[5] = (Charges remaining in (Item carried by ReplacedUnit_u in slot 6))
      • If ((Unit-type of (ReplacedUnit_u)) Equal to "YourUnit") then do (Unit - Replace (ReplacedUnit_u) with a "YourNewUnit" using The old unit's relative life and mana) else do (Do nothing)
      • Set NewUnit_u = (Last replaced unit)
      • Hero - Set NewUnit_u experience to UnitExperience_int, Hide level-up graphics
      • Hero - Modify Strength of NewUnit_u: Set to Strength_int
      • Hero - Modify Agility of NewUnit_u: Set to Agility_int
      • Hero - Modify Intelligence of NewUnit_u: Set to Intellignece_int
      • For each (Integer A) from 0 to 3, do (Actions)
        • Loop - Actions
          • Unit - Add Abilities_a[(Integer A)] to NewUnit_u
          • Unit - Set level of Abilities_a[(Integer A)] for NewUnit_u to AbilityLevel_int[(Integer A)]
      • For each (Integer A) from 0 to 5, do (Actions)
        • Loop - Actions
          • Hero - Create Item_i[(Integer A)] and give it to NewUnit_u
          • Item - Set charges remaining in (Last created item) to ItemCharges_int[(Integer A)]
    • Else - Actions
  • Unit Group - Pick every unit in ReplacedUnitGroup and do (Unit - Hide (Picked unit))
  • Custom script: call DestroyGroup(udg_ReplacedUnitGroup)
 
Status
Not open for further replies.
Top