• 🏆 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!

[JASS] Different passive ability effects

Status
Not open for further replies.
Level 1
Joined
Oct 29, 2010
Messages
1
Hi,

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?

Practical answers are welcome :)

Thank you for your attention!
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

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

Greetings and Peace
Dr. Boom
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
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.
 
Status
Not open for further replies.
Top