• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Create auto-cast cleave spell mechanic?

Status
Not open for further replies.
Level 2
Joined
Nov 20, 2019
Messages
24
Here is an imgur of how the ability is currently working wc3 test cleave

Heya all. Hope everyone is doing well.

I am attempting to make a cleave-type attack that will cost mana to activate. I have a rough-idea of a way to achieve this however I am running into some issues. Please forgive the shonky triggering.

***removed image see updated below***

In essence - I want my MELEE hero to be able to auto-cast this attack (based on searing arrows) where he will only cleave at the cost of mana/casting the ability - it is NOT passive - I currently doing this by using Searing Arrows as a dummy ability to trigger a dummy unit spawning.

The dummy unit has a passive cleave attack tuned how I want and will only attack once and then be removed.

I̶s̶s̶u̶e̶s̶ ̶I̶ ̶a̶m̶ ̶r̶u̶n̶n̶i̶n̶g̶ ̶i̶n̶t̶o̶ ̶a̶r̶e̶ ̶t̶o̶ ̶d̶o̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶d̶i̶r̶e̶c̶t̶i̶o̶n̶ ̶t̶h̶e̶ ̶d̶u̶m̶m̶y̶ ̶i̶s̶ ̶f̶a̶c̶i̶n̶g̶.̶ ̶H̶o̶w̶ ̶c̶a̶n̶ ̶I̶ ̶t̶r̶i̶g̶g̶e̶r̶ ̶t̶h̶i̶s̶ ̶s̶o̶ ̶t̶h̶e̶ ̶d̶u̶m̶m̶y̶ ̶i̶s̶ ̶f̶a̶c̶i̶n̶g̶ ̶t̶h̶e̶ ̶e̶x̶a̶c̶t̶ ̶s̶a̶m̶e̶ ̶d̶i̶r̶e̶c̶t̶i̶o̶n̶ ̶a̶s̶ ̶m̶y̶ ̶h̶e̶r̶o̶ ̶a̶t̶ ̶t̶h̶e̶ ̶t̶i̶m̶e̶ ̶o̶f̶ ̶c̶a̶s̶t̶i̶n̶g̶?̶ ̶A̶d̶d̶i̶t̶i̶o̶n̶a̶l̶l̶y̶,̶ ̶I̶ ̶m̶i̶g̶h̶t̶ ̶m̶a̶k̶e̶ ̶t̶h̶e̶ ̶d̶u̶m̶m̶y̶ ̶u̶n̶i̶t̶ ̶s̶p̶a̶w̶n̶ ̶o̶n̶ ̶m̶y̶ ̶h̶e̶r̶o̶ ̶r̶a̶t̶h̶e̶r̶ ̶t̶h̶a̶n̶ ̶t̶h̶e̶ ̶t̶a̶r̶g̶e̶t̶ ̶a̶s̶ ̶t̶h̶i̶s̶ ̶w̶i̶l̶l̶ ̶w̶o̶r̶k̶ ̶b̶e̶t̶t̶e̶r̶ ̶w̶i̶t̶h̶ ̶t̶h̶e̶ ̶'̶c̶o̶n̶e̶'̶ ̶e̶f̶f̶e̶c̶t̶ ̶o̶f̶ ̶t̶h̶e̶ ̶c̶l̶e̶a̶v̶e̶.̶

~Lastly~ because this ability has an 'auto-cast' feature - It seems to not trigger from 'A unit starts the effect of an ability' when auto-casted. It only works when you manually click and cast the spell. How can I make this trigger from an auto-cast?

I am trying to achieve all this from stock editor - no DD systems, etc.

Thanks for reading - any advice is greatly appreciated.

*EDIT: I am also attempting to make the dummy have identical damage to the casting hero - It doesn't seem to be working, I'm not surprised though.

*EDIT 2: Ok - I have largely worked out the positioning issues. The dummy unit now spawns on my hero facing the correct direction and attacks once (working perfectly). Is there a way I can remove the small delay before the dummy unit attacks for the first time, just to make the entire mechanic feel more crisp/instant? Still needing help with getting the dummy units damage to mirror the casting hero's.

upload_2020-8-26_17-21-20.png
 

Attachments

  • upload_2020-8-26_16-48-40.png
    upload_2020-8-26_16-48-40.png
    25 KB · Views: 48
Last edited:
Level 24
Joined
Feb 9, 2009
Messages
1,787
Try this, although do note your trigger and this will "Instantly" apply before the projectile hits
  • Cleave Attack Example
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Cleave Attack
    • Actions
      • Set Cl_Unit[1] = (Triggering unit)
      • Set Cl_Point[1] = (Position of Cl_Unit[1])
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 225.00 of Cl_Point[1]) and do (Actions)
        • Loop - Actions
          • Set Cl_Unit[2] = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Cl_Unit[2] is alive) Equal to True
              • (Cl_Unit[2] belongs to an enemy of (Owner of Cl_Unit[1])) Equal to True
            • Then - Actions
              • Unit - Cause Cl_Unit[1] to damage Cl_Unit[2], dealing (Real((Base Damage of Cl_Unit[1] for weapon index 0))) damage of attack type Spells and damage type Universal
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Cl_Point[1])
Alternatively, you could base the ability on something toggleable like mana shield or immolation and use DDS (I recommend bribe's) and detect when the toggled ability buff is on the caster and a projectile hits to deal aoe and negate mana.

To apply this to the above trigger would look like this:

  • Untitled Trigger 003
    • Events
      • Game - DamageEvent becomes Equal to 1.00
    • Conditions
      • (DamageEventSource has buff Acid Bomb) Equal to True
      • IsDamageSpell Equal to False
    • Actions
      • Set Cl_Unit[1] = DamageEventSource
      • Set Cl_Unit[2] = DamageEventTarget
      • Set Cl_Point[1] = (Position of Cl_Unit[2])
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 225.00 of Cl_Point[1]) and do (Actions)
        • Loop - Actions
          • Set Cl_Unit[2] = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Cl_Unit[3] is alive) Equal to True
              • (Cl_Unit[3] belongs to an enemy of (Owner of Cl_Unit[1])) Equal to True
              • Cl_Unit[3] Not equal to Cl_Unit[2]
            • Then - Actions
              • Unit - Cause Cl_Unit[1] to damage Cl_Unit[3], dealing (Real((Base Damage of Cl_Unit[1] for weapon index 0))) damage of attack type Spells and damage type Universal
            • Else - Actions
      • Custom script: call RemoveLocation(udg_Cl_Point[1])
 
Level 8
Joined
Mar 19, 2017
Messages
248
To make the spell "feel more instant", since it is an actual attack of a dummy unit, you should give the dummy 0.00 attack time and instant attack type. If you use dummies, instead of pooling a wait and removing it, you could simply give it timed life. If you give it 0.0 attack time, i think that you can even remove it right away, but you should test this.

The damage is not correctly updated and handled because the unit weapon field functions don´t work right now (some related get functions work), but you can easily solve this by using the BlzGetUnitBaseDamage (of the hero) function instead.

To imitate the autocast functions you should do lots of things:
1. An attack event or damage event trigger. Damage event is superior because it avoids the cancel animation issue. There is a vanilla function that detects and retrieves Wc3 attack damage in 1.32 so you don't need a system or tricks for this.
2. You will need a mana cost condition (easy to manage) and a cooldown condition also (easy to do with the new natives). Basically you need to know if the cleave ability is not in cooldown (BlzGetUnitAbilityCooldownRemaining, you can easily search it in the GUI as real data) and that the hero has the actual mana (real GetUnitState v/s BlzGetUnitAbilityManaCost, you can easily search these functions in the GUI as real and integer data respectively) to cast it.
3. If the conditions are met, then you perform the cleave actions and use the new native that starts the cooldown of abilities (BlzStartUnitAbilityCooldown, i think you can search it in the GUI easily on the unit actions maybe). That should work.
 
Level 2
Joined
Nov 20, 2019
Messages
24
Thank you to @Devalut and @disruptive_ for lightning fast replies. Both your responses actually helped me greatly in different ways.

@disruptive_ I ended up changing the attack speed to 0.00 and changed the weapon damage field as suggested which did the trick (there is still a slight delay but it's tolerable). I haven't attempted to resolve the autocast yet, but I think I'm going to leave this as a stronger, castable ability (not being lazy, just prefer it). I will still try your suggestion however.

@Devalut if you have a reason to think your system would be more 'responsive' than the way I've done it, I'd definitely be down to try it that way, but otherwise it seems to be working as is (see below). I do think your system however is way better with the variables as I'll probably encounter errors with 'Last created unit'. Any idea how to tweak below to potentially solve that?

upload_2020-8-26_20-58-10.png


The 'move' is due to a small graphical bug I was encountering, this fixed it.

*** imgur of working ability Brutal Slash Test (imgur) ***
Thanks again guys, both repped.

:)
 
Last edited:
Level 19
Joined
Feb 27, 2019
Messages
590
Try changing these and see if it reduces the delay.

Art - Propulsion Window
(degrees) (Real)
Maximum angle that a unit/hero can launch a projectile before it needs to physically turn itself towards a target.

Set to 360

Combat - Attack x - Animation Backswing Point (Real)
The amount of time it takes a unit/building/hero to go through half the physical movement necessary to attack something. If the unit/building/hero has no animations for attacking, the time set in this field still applies, but there will be no viewed physical movement. This field combines additively with "Combat - Attack x - Animation Damage Point" to form the total time taken to physically attack a target.

Sete to 0.00

Combat - Attack x - Animation Damage Point (Real)
The amount of time it takes a unit/building/hero to go through half the physical movement necessary to attack something. If the unit/building/hero has no animations for attacking, the time set in this field still applies, but there will be no viewed physical movement. This field combines additively with "Combat - Attack x - Animation Backswing Point" to form the total time taken to physically attack a target.

Set to 0.00

Combat - Attack x - Range (Integer)
For ranged attackers, defines how far they can fire at targets.

Set to 9999 (Not sure if this makes it a ranged unit but I can only guess no since it has normal attack type)

Movement - Turn Rate (Real)
Defines the speed at which the unit/building/hero is allowed to turn. Turn speed can only be affected by certain spells, and by the trigger action "Animation - Change Unit Turn Speed". Turn speed values range between 0 and 1, with 1 being the fastest turn speed possible.

Set to 3.00
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
So does it have to be a Dummy unit that's doing the attacking?

This seems like a very simple spell:
Toggle on Searing Arrows -> Add a hidden Cleave ability
Toggle off Searing Arrows -> Remove the Cleave ability

You'll only ever Cleave if the ability is toggled on.

To remove the Cleave ability when out of mana:
A unit is attacked -> Attacking unit has Cleave and mana less than X -> Remove Cleave + Toggle off Searing Arrows (Optional)

If the Dummy is indeed needed then I highly recommend using a Damage Engine as everything else will most likely be buggy/exploitable. "A unit is attacked" is not meant to be used for detecting when a unit takes damage, it's meant to detect when an attack starts. The attack doesn't have to finish or even hit for the Event to go off.
 
Last edited:
Level 2
Joined
Nov 20, 2019
Messages
24
Try changing these and see if it reduces the delay.

Art - Propulsion Window
(degrees) (Real)
Maximum angle that a unit/hero can launch a projectile before it needs to physically turn itself towards a target.

Set to 360

Combat - Attack x - Animation Backswing Point (Real)
The amount of time it takes a unit/building/hero to go through half the physical movement necessary to attack something. If the unit/building/hero has no animations for attacking, the time set in this field still applies, but there will be no viewed physical movement. This field combines additively with "Combat - Attack x - Animation Damage Point" to form the total time taken to physically attack a target.

Sete to 0.00

Combat - Attack x - Animation Damage Point (Real)
The amount of time it takes a unit/building/hero to go through half the physical movement necessary to attack something. If the unit/building/hero has no animations for attacking, the time set in this field still applies, but there will be no viewed physical movement. This field combines additively with "Combat - Attack x - Animation Backswing Point" to form the total time taken to physically attack a target.

Set to 0.00

Combat - Attack x - Range (Integer)
For ranged attackers, defines how far they can fire at targets.

Set to 9999 (Not sure if this makes it a ranged unit but I can only guess no since it has normal attack type)

Movement - Turn Rate (Real)
Defines the speed at which the unit/building/hero is allowed to turn. Turn speed can only be affected by certain spells, and by the trigger action "Animation - Change Unit Turn Speed". Turn speed values range between 0 and 1, with 1 being the fastest turn speed possible.

Set to 3.00

@[db]east Thank you so much for this! I played around with some of these settings as you suggested and the spell is much more response now (virtually instantaneous). A++ repped!

So does it have to be a Dummy unit that's doing the attacking?

This seems like a very simple spell:
Toggle on Searing Arrows -> Add a hidden Cleave ability
Toggle off Searing Arrows -> Remove the Cleave ability

You'll only ever Cleave if the ability is toggled on.

To remove the Cleave ability when out of mana:
A unit is attacked -> Attacking unit has Cleave and mana less than X -> Remove Cleave + Toggle off Searing Arrows (Optional)

If the Dummy is indeed needed then I highly recommend using a Damage Engine as everything else will most likely be buggy/exploitable. "A unit is attacked" is not meant to be used for detecting when a unit takes damage, it's meant to detect when an attack starts. The attack doesn't have to finish or even hit for the Event to go off.

@Uncle I didn't think about that way. It's looking more and more like i'll need to implement a Damage Engine in the long run. I will try your method for a similar spell i'm making and see if it fares any better. Much obliged - repped :)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
@[db]east Thank you so much for this! I played around with some of these settings as you suggested and the spell is much more response now (virtually instantaneous). A++ repped!



@Uncle I didn't think about that way. It's looking more and more like i'll need to implement a Damage Engine in the long run. I will try your method for a similar spell i'm making and see if it fares any better. Much obliged - repped :)
Damage Engine opens up A LOT of possibilities, I wouldn't make a map without it :p

But yeah, it's not actually needed if you design it the way I described.
 
Status
Not open for further replies.
Top