• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Mui spells: Rotten drain, Help me with it!

Status
Not open for further replies.
Level 1
Joined
Jun 13, 2008
Messages
132
Hi again, I am making one of my spells for my map using one tutorial from hive and, guess what, another trouble making it.
Before starting I will tell you that the tutorial is about Dinamic indexing, my spell is launched, the caster gains health, the target loses health and armor, and wenever the caster stops casting the spell it automatically stops gaining health, and the target stops losing health and armor.
The problem is, I really don't understand too well what I am doing, I need your help with my triggers, when I launch the spell everything mentioned works well, then when target stops channeling by ending the channel time o manually everything works, but when two units cast the same spell over the target unit, when one ends, the armor debuff is gone. Could you check my map and tell me what I can improve or suggestions? I need you, help me please!
View attachment Tutorial 3 (Rotten life Mui).w3x
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
First off, generally questions related to fixing/help with specific existing coding problems should be in Triggers&Scripts.

Second off, there are two options:

#1: Given you have a relatively quick period, you could add the following code to "Drenacion vital 2:" right after the start of the loop

  • If (All Conditions are true) Then do (Then Actions) Else do (Else Actions)
    • If - Conditions
      • (Level of Armor (-1) for Target[Integer]) Equal to 0
    • Then - Actions
      • Unit - Add Armor (-1) to Target[Integer]
    • Else - Actions
The user might notice this though, and it will allow their armour to be changed briefly, so it might not be desirable.

#2: The better solution is a bit more complicated.

First off, we'll need a hashtable, let's call it RottenLifeHash. You'll need to initialize it at map initialization:

  • Actions
    • Hashtable - Create a hashtable
    • Set RottenLifeHash = (Last created hashtable)
We're also going to need a Handle variable, which I'll call TempHandle, because GUI has some problems with the way handles are handled.

Next off, whenever we add the spell to the unit, let's increase the 0th index of that hashtable at the location of the unit by 1. We'll need some Custom Script to do so. So, instead of just adding the ability, now we have this:

  • Unit - Add Armor (-1) to Target[Index]
  • Custom script: set udg_TempHandle = udg_Target[udg_Index]
  • Hashtable - Save ((Load 0 of (Key TempHandle) from RottenLifeHash) + 1) as 0 of (Key TempHandle) in RottenLifeHash
Basically, we're noting every time we apply (or try to apply) the ability to the unit.

Now, in any case where you want to remove the ability from the unit, instead decrease the index in the hashtable by 1. If it's 0, then remove the unit. So, replace any lines which remove armor (-1) with the following code:

  • Custom script: set udg_TempHandle = udg_Target[udg_Integer]
  • Hashtable - Save ((Load 0 of (Key TempHandle) from RottenLifeHash) - 1) as 0 of (Key TempHandle) in RottenLifeHash
  • If (All Conditions are True) Then do (Then Actions) Else do (Else Actions)
    • If - Conditions
      • (Load 0 of (Key TempHandle) from RottenLifeHash) Equal to 0
    • Then - Actions
      • Unit - Remove Armor (-1) from Target[Integer]
And that's it!

Edit: Apparently the Custom Script stuff is only necessary if you're using JNGP, otherwise you can just use Target[Index] in (Key x) directly.
 
Status
Not open for further replies.
Top