'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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top