# Percent chance for Cleaving Attack

Status
Not open for further replies.

#### woodknight

Level 3
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?

#### Mr_Bean

Level 17
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.

#### baassee

Level 22
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)).

#### Black-apples

Level 3
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 . It's up to you, I tend to like the attribute system better.

#### Ameranth

Level 4
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.

#### Ameranth

Level 4
... Because he said he wants his to be proc-based?

#### woodknight

Level 3
Thanks so much for the feedback. Its very late here so I will try to implement your ideas tomorow. Thanks again for the great help.

#### Black-apples

Level 3
I thought he meant for damage detection, for the damage of the attack to be based on the damage of the unit.

#### defskull

Level 33
@Black-apples
You've got a fail condition for the picking units in range condition

• ((((Matching unit) is Magic Immune) Not equal to True)
FYI, cleaving affects Magic Immune units.

#### Mr_Bean

Level 17
@Black-apples
Your trigger is good but it gives the wrong proc chance: 10/20/30/40% while it should be 20/30/40/50%. You should do this:
• Set Cleave_Math = ((10 x (Level of Cleaving Attack for (Attacking unit))) + 10)

#### baassee

Level 22
There are other damage sources apart from attributes (such as damage items, damage buffs etc).

If you learn how to deal with a DD system you will learn a lot along the way and thus become a better coder so I'd go for a DD system. Those I mentioned are both easy to use and explained for your safety.

#### woodknight

Level 3
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:

#### woodknight

Level 3
I think I almost got it but now it crashes sometimes. Black-apples uses some custom scripts. How can I use them? Do I download them from somewhere?

#### Mr_Bean

Level 17
They are under actions in the trigger editor. Press new action, they search and type "custom" (without quotations).

#### woodknight

Level 3
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

#### baassee

Level 22
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.

#### woodknight

Level 3
Thanks so much for the great help! The ability is working perfectly now. I will make a demo map and upload it soon so it can be reviewed. Once more thank you for the great advice, examples and help. You are great

Status
Not open for further replies.

Replies
2
Views
741
Replies
6
Views
883
Replies
10
Views
958
Replies
3
Views
412
Replies
48
Views
2K