• 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.

[Trigger] Spell Shield That Takes Damage - Triggers Not Working Right

Status
Not open for further replies.
Level 1
Joined
May 28, 2009
Messages
5
Hi btw (first ever post)

I'm trying to make a spell that works like Power Word: Shield from World of Warcraft using GUI. The spell creates a barrier on the target, protecting it from X amount of damage, and then disperses once X damage has been dealt to the target. I couldn't find a spell that works the way I want (Anti-Magic Shell is exactly what I want but only effects spell damage T_T) so I started messing around with triggers and came up with these two triggers:
untitled2.PNG

Once the spell Light Shield is cast on a target, this trigger checks for an open slot on an array called LightShield. It checks to see if LightShield [X] is in use (has a value higher than 0) and then if it is not, the target of the spell is recorded in the corresponding LightShieldTarget [X] array. Also, LightShield [X] is set to an amount based on the caster's Intellect and the level of the spell at the time it is being used. It also adds the Event "If LightShieldTarget [X] takes damage" to my second trigger. LightShield [X] measures the amount of damage LightShieldTarget [X] can take before losing the shield.
untitled1.PNG

This trigger activates when any unit that has ever had Light Shield cast upon it takes damage and still has the buff "Light Shield". It searches through all 100 slots in the LightShieldTarget array, searching for the slot that the unit is in. Then, it subtracts the damage taken from the LightShield [X] that corresponds to that unit. It is also supposed to nullify the damage taken by adding it back to the unit's HP. This is where I run into problems.

For whatever reason, strange things keep happening to the target when he takes damage. Sometimes he'll lose 3 hit points. Sometimes he'll heal 10 hit points, but rarely is damage ever negated like I want. Also, I've seen a unit that does 12ish damage take out a shield in two hits. It's really buggy and I don't know why. The problem seems to stem from "damage taken". Any suggestions.

(P.S. I discovered what Arrays and Integer A Loops do as I was making this spell, so it's possible that I screwed up on the Array trigger somehow.)
 
Level 1
Joined
May 28, 2009
Messages
5
El bumpadora

Oh, and I'd like to add (encase it matters) that the dummy spell called "Light Shield" in my game is actually a modified version of "Lightning Shield" which does no damage and gives a custom buff to the target called "Light Shield" which has an almost infinite duration.
 
Level 4
Joined
Feb 25, 2008
Messages
58
The event "Unit takes damage" is only usable for a pre-defined unit (so before the map even starts) which means that sadly, what you're trying to do just wont work with GUI (because Blizzard sucks). You're going to have to use JASS to create this ability since GUI isn't capable of detecting a) when a generic unit takes damage or b) how much damage a generic unit takes.

I suggest reading some JASS tutorials (can be found in the tutorials section) and also search the spells section because I'm sure someone has done something similar before. Good luck!
 
Status
Not open for further replies.
Top