'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?
 
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?
 
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%.
 
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
 
Alright, i'll take a look at it, thanks.

So even though that system is JASS, it can work with my Gui?
 
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
 
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.
 
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?
 
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
 
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 The Helper:
    It is weird seeing a way more realistic users online number
  • The Helper The Helper:
    Happy Tuesday Night!
    +1
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top