[Spell] Draining Life and Mana

Level 5
Joined
Jul 31, 2011
Messages
103
Hi hive, i created this thread because i need help to creating a spell:

The spell summon a tower with expiration time. in the region and every second will drain 1 hp and 1 mana of the units that are in the range of the tower summoned

every hp point and mana point drained will be store in a hp and mp variable

if in the region there is no unit, the hp and mp variable will no increase

the hero have a Drain spell, when he active the tower will destroy and he get the hp and mp stored

if the tower is destroyed be the enemy he only get 50% of the hp and mana stored

if the tower get 0 expiration time hive get 100%

can you help me creating this system?
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
First start of with implementing a unit indexer. (I recommend Bribe's Unit Indexer.)
This is highly recommended to keep MUI data on units.

You need four array variables
1 boolean (to check if the unit is one of those towers)
1 real (for hp)
1 real (for mp)
1 unit (which is the source/caster)

You also need a unit group variable which is all the towers.

When you summon the tower, you set (all using the custom value of the tower)
The boolean to true
The hp and mp to 0.00
The unit to the caster

When a unit dies, you check if the unit is one of those turrets (by checking the boolean with the custom value of the dying unit)
If it is true, you check if the killing unit is owned by an enemy of the source unit (the variable).
If it is an enemy, you give 50% if not, you give 100%.
You also set the boolean to false and the unit variable to No unit. (The reals dont matter.)

If it is not a turret, you loop through all towers (the unit group variable) and check the distance between the dying unit and the tower.
If the dying unit is in range, then you increase the hp and mp values of the custom value of the tower.

Last but not least, you make another trigger that runs when a unit starts the effect of an ability.
You check if the ability is the one that unsummons the towers.
And you give the hp/mp and set the variables back to default.
(Also check if the target is one of the turrets, if not you should order your unit to stop, maybe remove and re-add the ability to avoid the cooldown.)
 
Level 5
Joined
Jul 31, 2011
Messages
103
This is the trigger i created

hi whats up, i created a trigger but is in spanish, can you help me? i will post it

i think there is problem to remove of the PV_group when the unit is not in the range, but i think that every second the trigger check and dont add the units

  • PV Cast
    • Acontecimientos
      • Unidad - A unit Inicia el efecto de una habilidad
    • Condiciones
      • (Ability being cast) Igual a Pilar de Vida
    • Acciones
      • Set PV_Caster = (Casting unit)
      • Set PV_Target = (Target point of ability being cast)
      • Set PV_Distance = (250.00 x 1.00)
      • Set PV_Life = 1.00
      • Set PV_Mana = 1.00
      • Set PV_LifeStore = 0
      • Set PV_ManaStore = 0
      • Set PV_time = 30.00
      • Unidad - Create 1 Torre del EspÃritu for (Owner of PV_Caster) at PV_Target facing Vista edificio predeterminada degrees
      • Unidad - Add a PV_time second Genérico expiration timer to (Last created unit)
      • Set PV_Pos_PV = (Position of (Last created unit))
      • Detonador - Turn on PV Efecto <gen>
      • Detonador - Turn on PV Efecto Destruido <gen>
      • Detonador - Turn on PV Efecto Detonado <gen>
  • PV Effect
    • Acontecimientos
      • Tiempo - Every 1.00 seconds of game time
    • Condiciones
    • Acciones
      • Set PV_Group = (Units within PV_Distance of PV_Pos_PV)
      • Set PV_Cuantity = (Number of units in PV_Group)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si: Condiciones
          • (Number of units in PV_Group) Mayor que 1
        • Entonces: Acciones
          • Grupo de unidad - Pick every unit in PV_Group and do (Actions)
            • Bucle: Acciones
              • Set PV_Picked = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si: Condiciones
                  • (PV_Picked is alive) Igual a True
                  • PV_Picked No igual a PV_Caster
                • Entonces: Acciones
                  • Efecto especial - Create a special effect attached to the origin of PV_Picked using Abilities\Spells\Other\Drain\ManaDrainTarget.mdl
                  • Set PV_Pos_P = (Position of (Picked unit))
                  • Unidad - Set life of PV_Picked to ((Vida of PV_Picked) - PV_Life)
                  • Set PV_LifeStore = (PV_LifeStore + (Integer(PV_Life)))
                  • Partida - Display to (All players) the text: (String(PV_LifeStore))
                  • Unidad - Set mana of PV_Picked to ((Maná of PV_Picked) + (Real(PV_ManaStore)))
                  • Set PV_ManaStore = (PV_ManaStore + (Integer(PV_Mana)))
                  • Partida - Display to (All players) the text: (String(PV_ManaStore))
                • Otros: Acciones
        • Otros: Acciones
  • PV Efecto Destruido
    • Acontecimientos
      • Unidad - A unit Muere
    • Condiciones
      • (Unit-type of (Dying unit)) Igual a Torre del EspÃritu
    • Acciones
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si: Condiciones
          • ((Owner of (Killing unit)) is an enemy of (Owner of PV_Caster)) Igual a True
        • Entonces: Acciones
          • Custom script: call RemoveLocation (udg_PV_Pos_P)
          • Custom script: call DestroyGroup (udg_PV_Group)
          • Set PV_LifeStore = (PV_LifeStore / 2)
          • Set PV_ManaStore = (PV_ManaStore / 2)
          • Unidad - Set life of PV_Caster to ((Vida of PV_Caster) + (Real(PV_LifeStore)))
          • Unidad - Set mana of PV_Caster to ((Maná of PV_Caster) + (Real(PV_ManaStore)))
          • Detonador - Turn off (This trigger)
          • Detonador - Turn off PV Efecto <gen>
          • Detonador - Turn off PV Efecto Detonado <gen>
        • Otros: Acciones
          • Custom script: call RemoveLocation (udg_PV_Pos_P)
          • Custom script: call DestroyGroup (udg_PV_Group)
          • Unidad - Set life of PV_Caster to ((Vida of PV_Caster) + (Real(PV_LifeStore)))
          • Unidad - Set mana of PV_Caster to ((Maná of PV_Caster) + (Real(PV_ManaStore)))
          • Detonador - Turn off (This trigger)
          • Detonador - Turn off PV Efecto <gen>
          • Detonador - Turn off PV Efecto Detonado <gen>
          • Detonador - Turn off PV Efecto Destruido <gen>
  • PV Efecto Detonado
    • Acontecimientos
      • Unidad - A unit Inicia el efecto de una habilidad
    • Condiciones
      • (Ability being cast) Igual a Drenar
    • Acciones
      • Detonador - Turn off PV Efecto Destruido <gen>
      • Custom script: call RemoveLocation (udg_PV_Pos_P)
      • Custom script: call DestroyGroup (udg_PV_Group)
      • Unidad - Set life of PV_Caster to ((Vida of PV_Caster) + (Real(PV_LifeStore)))
      • Unidad - Set mana of PV_Caster to ((Maná of PV_Caster) + (Real(PV_ManaStore)))
      • Detonador - Turn off (This trigger)
      • Detonador - Turn off PV Efecto <gen>
      • Detonador - Turn off PV Efecto Detonado <gen>
      • Set PV_LifeStore = 0
      • Set PV_ManaStore = 0
      • Set PV_Caster = Ninguna unidad
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
You forgot to make them array variables.

Download and import a Unit Indexer and make the variables array variables.
Try to do the variables over ;)

Then do this checklist:
1, Add newly summoned towers to a global unit group.
2, On every second, you loop through all the units in that group (all towers).
3, You pick all units in range of the picked unit (the picked tower).
4, You remove the picked tower from the units in range.
5, You loop through all the units in range. (Be aware that Picked Unit is not from the outer loop, so you have to store it in a temp variable.)
6, Remember to destroy the groups/locations/special effects.
7, Preferably do the check using the boolean instead of the unit type. (For better import/customizaton reasons.)

Rule #1, First do it the correct way, then make it work.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I dont check epic war, i want to see triggers/scripts, not maps.
One of the reasons why THW is better than EW.

It is not hard to do, but you have to do exactly what I said.
You need four array variables
1 boolean (to check if the unit is one of those towers)
1 real (for hp)
1 real (for mp)
1 unit (which is the source/caster)
Going back to what I said before, you need arrays (aka lists of variables).
 
Level 5
Joined
Jul 31, 2011
Messages
103
is a problem the language but see the map in thw
 

Attachments

  • Spell_PV.w3x
    389.4 KB · Views: 50
Top