Okay well let's think of this problem. What you want to do I'm assuming is have a
15% chance on attack to inflict a poisonous effect - so let's think this through.
The first thing we have is "
15% chance on attack" so let's break this down. We're going to need a damage-detection system in order to detect when a unit follows through with a successful attack. It is a little more complicated than I'm making it sound because you'll probably need to learn how to use a damage-detection system first (though it's not rocket science). Once you've successfully started detecting attacks then you can randomize when your main effect occurs by comparing a randomly generated number to a certain constant. Here's an example:
JASS:
local boolean pushEffect = false
if GetRandomInt(0, 100) < 15 then
set pushEffect = true
endif
Assuming that
GetRandomInt
is truly random, it can be said that
pushEffect is only going to be
true
15% of the time, as a random number between 1-100 only has 15% chance to be less than
15.
Once you've set this up, you can then proceed to executing the effects of the poison. The easiest way to go about this would be to make a "dummy" ability based on
Shadow Strike which will poison/damage the target. You're also going to need a "dummy" unit that will be used to cast this spell. It is important that you set up your dummy caster properly, so here's a few things to look for:
- Cast Backswing/Point must be 0.00.
- Set the Food cost to 0.
- Set the model to "None".
- Give the unit the Locust ability (shift+enter, 'Aloc').
You need to make sure your dummy caster doesn't affect game-play, the strict purpose of it is to cast a spell and then disappear. In order to make a dummy caster simply create a unit with the raw-code of the dummy unit, let's say it is
'h000'.
JASS:
local unit dummy = CreateUnit(GetOwningPlayer(yourAttacker), 'h000', GetUnitX(theAttackedUnit), GetUnitY(theAttackedUnit), 0)
It is also useful to remove this unit's
Move ability so it doesn't have to rotate to cast spells.
JASS:
call UnitRemoveAbility(dummy, 'Amov')
Now you want to add the ability you created to this unit so that he can cast it.
JASS:
call UnitAddAbility(dummy, yourShadowStrikeID)
Now all that is left to do would be to order the dummy to cast the spell on the target (which I labeled as
theAttackedUnit) and then remove the dummy. Since the dummy casts instantly (cast backswing = 0.00, no move ability) we can remove him
immediately after issuing an order:
JASS:
call IssueTargetOrder(dummy, theAttackedUnit, "shadowstrike")
call RemoveUnit(dummy)
This is the bare minimum, try these tips out first and then see if you have any further questions.