'Meat Shield' Spell - Need help

Meowier

New Member
Reaction score
6
Okay, basically this spell is called Meat Shield. Basically when the buff is placed on an ally, a % of damage they take is taken by the caster of Meat Shield instead. Basically a damage mitigator.

The spell works, it just doesn't work, and I know why, I just need help figuring a way around it. There's three triggers.

Meat Shield
Code:
Events
- Unit - A unit enters (Playable map area)

Conditions

Actions
- Trigger - Add to Meat Shield Damage <gen> the event (Unit - (Triggering unit) Takes damage)

Obviously the first trigger is necessary for any takes damage event.


Meat Shield Cast
Code:
Events
- Unit - A unit Starts the effect of an ability

Conditions
- (Ability being cast) Equal to Meat Shield 

Actions
- Set MeatShieldCaster[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
- Set MeatShieldInteger[(Player number of (Owner of (Triggering unit)))] = (Level of Meat Shield  for (Triggering unit))

This spell sets the spell's level so that the % needed is clear, and if the caster levels up the spell while it's in effect, the already in effect spell won't change. It also sets the caster.


Meat Shield Damage
Code:
Events

Conditions
- ((Triggering unit) has buff Meat Shield ) Equal to True

Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    If - Conditions
        MeatShieldInteger[(Player number of (Owner of (Triggering unit)))] Equal to 1
    Then - Actions
        Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (((Real(MeatShieldInteger[(Player number of (Owner of (Triggering unit)))])) x 0.50) x (Damage taken)))
        Unit - Set life of MeatShieldCaster[(Player number of (Owner of (Triggering unit)))] to ((Life of MeatShieldCaster[(Player number of (Owner of (Triggering unit)))]) - (((Real(MeatShieldInteger[(Player number of (Owner of (Triggering unit)))])) x 0.50) x (Damage taken)))
    Else - Actions


And the last trigger is the one that actually does stuff. Now i'm well aware of why the spell won't work like it should in certain circumstances. Basically after each variable there's [Player number of (Owner of Triggering unit)))], and in the Meat Shield Damage trigger, that stuffs it up because the triggering unit is the unit getting hurt.

So basically, if player 2 casts this on a player 1 unit, it won't work. If Player 1 casts this on a player 2 unit, it won't work. However, if player 1 casts it on a player 1 unit, it does work.

I need to find another way to do the Index on the variables that will allow it to be usable for multiple players.

Any suggestions?
 

Uszi

New Member
Reaction score
5
Getting ready for class... so haven't had an oppotunity to read through...

Doesn't the spirit link ability in WC3 already do this? Could you use that ability and fewer triggers?
 

Meowier

New Member
Reaction score
6
Spirit link, however, can only split damage evenly. I also want to be capable of doing stuff like preventing damage fully from a unit, or different numbers than 50%.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
I need to find another way to do the Index on the variables that will allow it to be usable for multiple players.
This is exactly what unit indexing systems such as J4L's AIDS (has a GUI version) are made to do. It automatically assigns every unit a unique integer as its custom value, and you can use this value to index your spell targets (though bear in mind that a number will be recycled and reused if a unit is removed from the game, so you should check that the unit with that index equals the originally-targeted unit). :)

It makes things like this so much easier.

P.S. Nice username. :3
 

Meowier

New Member
Reaction score
6
Alright, i'll take a look at it, thanks.

So even though that system is JASS, it can work with my Gui?
 

Ayanami

칼리
Reaction score
288
Well, here's a trigger that I've just came up with. Not 100% sure if it works, but it should.

Trigger:
  • Damage Register
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Meat Shield Damage &lt;gen&gt; the event (Unit - (Triggering unit) Takes damage)


Trigger:
  • Meat Shield
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Meat Shield
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CustomValue Less than 100
        • Then - Actions
          • Set CustomValue = (CustomValue + 1)
        • Else - Actions
          • Set CustomValue = 1
      • Set Caster[CustomValue] = (Triggering unit)
      • Set Target[CustomValue] = (Target unit of ability being cast)
      • Set TempPoint = (Center of (Playable map area))
      • Unit - Create 1 Hidden Dummy for (Owner of Caster[CustomValue]) at TempPoint facing Default building facing degrees
      • Unit - Set the custom value of (Last created unit) to CustomValue
      • Unit Group - Add (Last created unit) to DummyGroup
      • Custom script: call RemoveLocation(udg_TempPoint)


Trigger:
  • Meat Shield Periodic
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
      • (DummyGroup is empty) Equal to False
    • Actions
      • Unit Group - Pick every unit in DummyGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Target[TempInt] has buff Meat Shield) Equal to False
            • Then - Actions
              • Unit - Remove (Picked unit) from the game
            • Else - Actions


Trigger:
  • Meat Shield Damage
    • Events
    • Conditions
      • (DummyGroup is empty) Equal to False
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit Group - Pick every unit in DummyGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to Target[TempInt]
            • Then - Actions
              • Set RealDamage = ((0.10 x (Real((Level of Meat Shield for Caster[TempInt])))) x (Damage taken))
              • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + RealDamage)
              • Set RealDamage2 = ((Damage taken) - RealDamage)
              • Unit - Cause (Damage source) to damage Caster[TempInt], dealing RealDamage2 damage of attack type Chaos and damage type Universal
            • Else - Actions
      • Trigger - Turn on (This trigger)


Hope this helps.

Glenphir
 

Nexor

...
Reaction score
74
Woa Woa WOA, there will be an infinite loop I think.
Turn off the last trigger and turn on, the damage action should be between those switches.
 

crazyfanatic

New Member
Reaction score
20
mb the very first event should be like unit is issued targeting a point/unit/no point so that each time when a spell is cast or unit is attacked it checks if its buff carrier?
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
So even though that system is JASS, it can work with my Gui?
Yes, the code version will work if you can compile vJASS (ie. are using NewGen). All you need to do is get the unit's custom value and use it as your index.

Additionally, at the bottom of his post, he has also posted a GUI version. :p
 

Meowier

New Member
Reaction score
6
Looks like it works Glenphir, thanks for helping!

And thanks for suggesting AIDS, Weep, but I really can't wrap my head around it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top