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

[Spell] Help executing an interesting spell idea

Status
Not open for further replies.
Level 8
Joined
Mar 15, 2007
Messages
230
Hey all, so I recently posted a thread about getting ideas for spells in my map and someone came up with this idea (just so you know, the Lich in my map is a basic unit type, not a hero):
* Phylactery: Creates a Phylactery with timed life. If the Lich is killed while the Phylactery is still alive, respawns with half health at the Phylactery's location, destroying it. Destroying the Phylactery while the Lich is still alive causes it to lose all its mana.
The thing is, I have no idea how to actually execute something like that. I have only a basic understanding of triggers and no knowledge or skill with JASS. I know local variables and arrays are involved, but that's it. Any help is much appreciated. Thanks!
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,682
So the first question, how many Lich units will be in the map? Can a player control more than 1 Lich, or is it 1 Lich per player, or 1 Lich in total?

The design will depend upon this. If it's only 1 Lich than it'll be a very simple trigger to throw together.
 
Level 8
Joined
Mar 15, 2007
Messages
230
Players will be able to train as may liches as they want. The population limit is 100 and each unit only takes up 1 population. It's also a ten player map, so in theory, there could be 1,000 liches on the map.
 
Level 8
Joined
Mar 15, 2007
Messages
230
The spell is based on Healing Ward, so it will be targeted. The phylactery will also be on a timer, so the effect would need to be deactivated after the timer runs out.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,682
Here you go. I used a Unit Indexer (GUI Unit Indexer 1.4.0.0) in order to make it MUI (work for multiple units).

How the Unit Indexer works:
Each unit is given a unique "Index" when it is first created. This is done by setting the Custom Value of the unit to a unique value. From that point on, as long as you have access to the unit, you also have access to it's custom value.

This is useful because we can then plug any unit's custom value into the Index [] of a Variable Array, and since no two units share the same custom value than this Index is basically reserved for that specific unit.

For example, using an Integer Array called UnitKills, we could keep track of how many kills EACH unit has. So when a unit gets a kill you would increase UnitKills[custom value of killing unit] by 1, and since each unit has it's own unique custom value than you avoid any issues of replacing/overwriting an Index. This results in each unit having it's own kill count. And then whenever you want to reference this value you would simply plug the desired unit's custom value into the UnitKill's Index. Like: Pick every unit in playable map area -> Display text message "UnitKills[custom value of picked unit]".


And here are the triggers. Using the Unit Indexer I am able to link the Phylactery to it's Lich. This is done by using two Unit variables with Arrays, and using the Lich's custom value as the [Index] in these Arrays.
  • Summon Phylactery
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • (Unit-type of (Summoned unit)) Equal to Phylactery
    • Actions
      • Set VariableSet UDex = (Custom value of (Summoning unit))
      • -------- --------
      • -------- Remove any existing Phylactery (it's replaced with the new one) --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Phylactery_Ward[UDex] is alive) Equal to True
        • Then - Actions
          • Unit - Kill Phylactery_Ward[UDex]
        • Else - Actions
      • -------- --------
      • -------- Set the Phylactery Variables (This links the Phylactery to the Lich) --------
      • Set VariableSet Phylactery_Lich[UDex] = (Summoning unit)
      • Set VariableSet Phylactery_Ward[UDex] = (Summoned unit)
      • -------- --------
      • -------- Create special effect at position of Phylactery --------
      • Set VariableSet TempPoint = (Position of Phylactery_Ward[UDex])
      • Special Effect - Create a special effect at TempPoint using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • -------- Clean up leaks --------
      • Custom script: call RemoveLocation (udg_TempPoint)
  • Lich Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Lich
    • Actions
      • Set VariableSet UDex = (Custom value of (Triggering unit))
      • -------- --------
      • -------- Check if it has a Phylactery --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Phylactery_Ward[UDex] is alive) Equal to True
        • Then - Actions
          • -------- Kill the Phylactery --------
          • Unit - Kill Phylactery_Ward[UDex]
          • -------- --------
          • -------- "Revive" the Lich --------
          • Set VariableSet TempPoint = (Position of Phylactery_Ward[UDex])
          • Unit - Create 1 Lich for (Triggering player) at TempPoint facing Default building facing degrees
          • Unit - Set life of (Last created unit) to 50.00%
          • Unit - Set mana of (Last created unit) to 0.00%
          • -------- --------
          • -------- Create special effect at position of Phylactery --------
          • Special Effect - Create a special effect at TempPoint using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
          • Special Effect - Destroy (Last created special effect)
          • -------- --------
          • -------- Clean up leaks --------
          • Custom script: call RemoveLocation (udg_TempPoint)
        • Else - Actions

Edit: Updated and uploaded v2. I forgot to give the Lich mana. Not really important but I figured I'd post it anyway.
 

Attachments

  • Phylactery Lich Spell 2.w3m
    23.3 KB · Views: 24
Last edited:
This should also be doable with a simple hashtable
  • Lich
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to Lich
          • ((Load (Key LichPhylactery.) of (Key (Dying unit).) in Hash.) is alive) Equal to True
        • Then - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Triggering unit)) Equal to Phylactery
            • Then - Actions
              • Unit - Set mana of (Load (Key LichPhylacteryOwner.) of (Key (Dying unit).) in Hash.) to 0.00
            • Else - Actions

Very roughly and leaving out a lot but shows the idea.
 
Last edited:
Status
Not open for further replies.
Top