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

Percent chance for Cleaving Attack

Status
Not open for further replies.
Level 3
Joined
Aug 16, 2011
Messages
26
I'm trying to make a Cleaving Attack ability that is similer to the ability of the same name but has a percent chance to activate. Example:
level 1: 20% chance to hit with 40% dmg
level 2: 30% chance to hit with 60% dmg
level 3: 40% chance to hit with 80% dmg
level 4: 50% chance to hit with 100% dmg

The problem is I have no idea how to do it. How do I know when the hero attacks? I have no knowledge in JASS and am trying to do it with trigers. Is it possible?
 
Level 17
Joined
Feb 11, 2011
Messages
1,860
This is how you would calculate the percent chance:

  • Trigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to [your hero]
      • (Level of Cleave for (Attacking unit)) Greater than or equal to 1
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to (((Level of Cleave for (Attacking unit)) x 10) + 10)
        • Then - Actions
        • Else - Actions
I unfortunately don't know how to deal the extra damage.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
1. You use a damage detection system. There are two quite good in GUI. One made by Weep and the other by Bribe, search them up in the spells section.

2. Yes you use the template of Bean above to calculate the randomness.

3. You pick units around the damaged unit (with the use of your damage detection system) and orders the damage dealer to deal damage to the picked units (Unit - Damage Target (PickedUnit)).
 
Level 3
Joined
May 21, 2011
Messages
31
Here's a simple trigger using it, but it doesn't use a damage detection system. I always thought base damage was... bleh, I like attribute basing. It bases it off of your strength for damage, (2 * Level of cleaving attack for attacking unit) * (level of cleaving attack for attacking unit * 0.20).

Here is the trigger

Cleaving Attack
  • Cleaving Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Mountain King
      • (Level of Cleaving Attack for (Attacking unit)) Greater than or equal to 1
    • Actions
      • Set Cleave_Math = (10 x (Level of Cleaving Attack for (Attacking unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Random integer number between 1 and 100) Less than or equal to Cleave_Math
        • Then - Actions
          • Set Cleave_Point = (Position of (Attacking unit))
          • Set Cleave_UG = (Units within 150.00 of Cleave_Point matching ((((Matching unit) is Sleeping) Not equal to True) and ((((Matching unit) is Magic Immune) Not equal to True) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of
          • Unit Group - Pick every unit in Cleave_UG and do (Actions)
            • Loop - Actions
              • Special Effect - Create a special effect attached to the chest of (Picked unit) using Objects\Spawnmodels\Orc\Orcblood\BattrollBlood.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Cause (Attacking unit) to damage (Picked unit), dealing ((2.00 x ((Real((Strength of (Attacking unit) (Include bonuses)))) x (Real((Level of Cleaving Attack for (Attacking unit)))))) x ((Real((Level of Cleaving Attack for (Attacking unit)))) x 0.20)) damage of attack type Hero and damage type Normal
          • Custom script: call RemoveLocation(udg_Cleave_Point)
          • Custom script: call DestroyGroup(udg_Cleave_UG)
        • Else - Actions

It bases it off of bash ability, and plays the slam animation when it goes through. The bash ability is only an information holder, no stats on it.


Here is the map for you.


http://www.hiveworkshop.com/forums/pastebin.php?id=ycslye



Very simple trigger, but if you put in the damage detection system, it would get really advanced :p. It's up to you, I tend to like the attribute system better.
 
Level 4
Joined
Aug 8, 2011
Messages
84
There is a very good reason that people say to use a damage detection system for abilities like this rather that using triggers that fire off of when a unit is attacked / when a unit attacks.

The reason is that you can cheat triggers that fire when a unit attacks by simply clicking to attack, and hitting the stop key briefly after. If you do this correctly and fast enough, you can cause such triggers to activate when they shouldn't, or just much more frequently than they should.

This was the case in DotA with some abilities too, it was highly exploitable.

Damage detection on the other hand is 100% accurate, since it is executed when the damage actually occurs.
 
Level 3
Joined
Aug 16, 2011
Messages
26
I'm having trouble finding the |(Level of Cleave for (Attacking unit)) Greater than or equal to 1" Condition. I'm using vanilla World Editor. Is this in some other editor? I can't seem to find the right conditon or something.

Edit: Nevermind. I found it in Black-apples' demo map for the ability. Thanks for that :)

Re Edit: Why does the Arithmetic action not work with integer values? Or am I wrong? I have an int value and it doesnt appear in the Arithmetic action until I make it real.
 
Last edited:
Level 3
Joined
Aug 16, 2011
Messages
26
The thing that makes the map crash is the calculation of the damage done to the cleaved units. It's supposed to be a percentage of the damage done to the initial target and I calculate it like so (I'm using Weep's damage detection system):
Unit - Cause GDD_DamageSource to damage (Picked unit), dealing (GDD_Damage x ((0.20 x (Real(lvlofcleave))) + 0.20)) damage of attack type Hero and damage type Normal

Something in here crashes the map. When I make the damage static like 100 it doesn't crash, but sometimes kills the units outright even when they have something like 250hp.

edit: lvlofcleave is a variable holding the level of cleaving atacks the hero has
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
The thing you mention about "sometimes kills a unit" is because the spell triggers again because Unit-DamageTarget will be detected as well as a damage and as your cleaving unit is the damage dealer it is possible to strike again. Easiest way to counter this is just using Trigger - Turn off this trigger at the start of the trigger and then Trigger - Turn on this trigger at the end.
 
Status
Not open for further replies.
Top