• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • ✅ The POLL for Hive's Texturing Contest #33 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!

[Spell] Need help with a blocking ability

Status
Not open for further replies.
Level 7
Joined
Jul 21, 2019
Messages
177
Hello, i need help making a "blocking mode" ability, something like the footman's toggleable defend where the unit uses alternate animations, but i need it to block a % of incoming damage, and only when the unit is facing the attacker.

I'm making a hack and slash style map and i already have a key movement and attack system, but i need the units to be able to block attacks too, i do have somewhat decent GUI triggering understanding but pure JASS coding and complex stuff like damage detection systems are beyond me, i don't like working with things i don't understand so i rather avoid these, if possible.

What i need is:

-toggleable ability
-makes unit walk slower and reduce damage coming from the front (can still be damaged from the sides or behind)
-makes unit use defend/alternate animations
-unit must be unable to use other abilities while blocking is toggled, but it can still move

Any advice would be truly appreciated, as i have no idea how to do this.
Something important, i'm making the map in 1.26-1.27 version, and keeping it as simple as possible in order to make it compatible with older and reforged clients, so using any wizardy added after 1.27 is a no-no for me, i've seen old maps with such systmes before so i know it is indeed possible, but i need help.

Thanks in advance :D
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,239
You will need to find one of the legacy damage detection systems to help with this. They can detect and reduce damage in a GUI friendly way. Use cosine of the difference between facing and direction attack came from to resolve if the character was facing the direction or not.
 

Uncle

Warcraft Moderator
Level 68
Joined
Aug 10, 2018
Messages
7,109
I think you could do it like this:

Use Defend as the base ability but remove it's damage reduction effects.

Then create an ability based on Soul Burn, this will act as the Silencing effect. Remove it's damage/slow effects (although you could use it's Slow effects if you so desired) so it acts only as a Silence.

Next you would need to apply this new ability to your Hero using a Dummy unit:
  • Events:
  • Unit - A unit is issued an Order with no target
  • Conditions:
  • Issued Order Equal to defend
  • Actions:
  • Set Variable TempPoint = Position of Triggering unit
  • Unit - Create 1 Dummy for (Owner of Triggering unit) at TempPoint
  • Unit - Add Soul Burn (Your new version) to Last created unit
  • Unit - Add a 0.50 second Expiration Timer to Last created unit
  • Unit - Order Last created unit to Firelord - Soul Burn Triggering unit
  • Custom script: call RemoveLocation (udg_TempPoint)
And remove the Silencing buff when the unit stops Defending:
  • Events:
  • Unit - A unit is issued an Order with no target
  • Conditions:
  • Issued Order Equal to undefend
  • Actions:
  • Unit - Remove Soul Burn (new buff) from Triggering Unit
Then use a Damage Engine as Dr recommended, detecting when a unit with the Defend buff (which you would most likely have changed to a different name) takes damage. In response to this damage taken you find out if the damage dealer is in front of the Defending unit, and if so, you reduce the damage taken. The math for that can be found here -> How detect a unit is in front of you or in your back ?

I'm not sure if Silences prevent the Defend ability from being toggled on/off, so that may be an issue. If that's the case, you may need to find an alternative method for disabling spellcasting. On later versions you can Disable abilities through triggers.
 
Level 7
Joined
Jul 21, 2019
Messages
177
Thanks a lot for that, i will try your method, incase soulburn prevents the defend ability from being used, from the top of my head, maybe i could use a custom metamorphosis and transform the unit to an exact clone without the attack abilities?
 
Last edited:
Status
Not open for further replies.
Top