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!
I'm new to jass and have been wondering how to do custom passive abilities.
For example, how can "15% chance to poison target for x seconds dealing x damage" be done?
Well, logically dummy passive ability should be used (bash with 0 sec) plus cast poison. The alternative question is - how to materialize this - casting poison when "bash spell" passed?
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:
Perfect help but I want edit a little thing about the creation of dummy. Also you should make the following:
- Set the collision size of the dummy to 0
- Set Movement Type to: fly
- Set Movement Fly High (Both: High and Minimum high) to: 1
- Set Movement Speed to: 1
Why fly?
- I use it because with fly the dummy can be created on cliffs or other unpathable terrain.
- Can avoid bugs
There are a few things I left out, actually, like the cast-range and cool-down and stuff; also I would use the movement type foot and then use the fly-height bug to modify the unit's height so that you can control the exact positioning of the dummy.
I thought it would be more beneficial if I gave him some tips and then let him figure out the rest; so if he has any more questions we'll know where to look.
flying units have bugged flying height on cliff edges (and pitch angles might look weird, too)
storm crow form and SetUnitX/Y are better
edit: if your dummy has locust ability given in object editor you can place them on cliffs directly
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.