Tutorial Creating Triggered Passive Spells

D.V.D

Make a wish
Reaction score
73
Hey guys, I'm going to tell you how to create triggered passive spells. A triggered passive spell is made because the ability editor doesn't let you create the actions. Also, in the trigger editor events, there aren't any events like: A unit's passive spell is activated so your going to have to trigger it through actions. This tutorial requires some knowledge in the trigger editor.

1. First off i'm going to show you what basic actions you need to know:
If all conditions are true then else do actions: This action lets you create conditions when ever you want after actions. Usually this action is used to check what level of the casting ability is, or used to create a condition that lets you create a percent (Conditions are going to be explained later).

Create (interger) (unit) at (point) facing (Point): This action is used to create a unit for many reasons like dummies to cast abilities for you. One thing needed to know is that the illusions also have the spell so it can stack really quickly.

Pause (unit): This action is used to stop a unit in all ways. The unit can't cast abilities, move, or attack. The unit however is still target able by other units or abilities.

Add (ability): This action is used to add any ability to any unit. This means that units can be given hero abilities and still be able to cast them.

Order (unit) to (attack or cast spell) (unit): This action is mainly used to order a unit to cast a spell. The only catch is that you have to order the unit to cast the spell based off of your ability you want to cast. For example: I make a triggered Chain lightning that creates explosions in random areas around the map. I want the unit to cast the spell at a cinematic so the way to do it is to: Order Caster to Orc Farseer - Chain Lightning TargetUnit. The catch in this action is that if the unit has 2 spells based off of Chain Lightning and you order the unit to chain lightning, the game will start to glitch.

Add a (interger) (Expiration Type) to (unit); This action is normally used to kill dummy units or give a unit a amount of seconds to live.

There are many more actions but too many to explain. Now on to the abilitys!

Passive Mirror Image

First off we start with making the dummy unit.
Unit:Copy the footman and paste him in the object editor. Then set his model file under custom to .mdl. Next off, set his shadow image (unit) to none. Next off set all of his attacks to 0 and then go to targets allowed. Set everything in targets allowed to null( Take away the check mark by clicking on it). Then set his food cost to 0 and name to Dummy. Last but not least, give him the ability locust. Now that the unit is done go to the evasion ability and set everything to null but the icon. Make the Icon anything you want. Now of to the trigger editor:
Make the instilization trigger have nothing in it but the event instilization and use melee time of the day. Now create a trigger called passive mirror image.
Create a event called A unit is attacked.
Code:
Passive Mirror Image
    Events
        Unit - A unit is attacked
    Conditions
    Actions

Next off, create a action, if all conditions are true then else do actions.
Code:
Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
        Then - Actions
        Else - Actions

Go to the conditions and go to interger. And click ok. You should get something like this:
Code:
Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Number of units in (Units in (Playable map area))) Equal to 0
        Then - Actions
        Else - Actions

Change the number of units in playable map area to level of ability for unit. Set the ability to evasion and the unit to Triggering Unit. Next, change the 0 to 1. You should get something like this:
Code:
Passive Mirror Image
    Events
        Unit - A unit is attacked
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Evasion for (Triggering unit)) Equal to 1
            Then - Actions
            Else - Actions

Next off, got create another if all conditons are true then else do acitions but on Then - Actions. You will have this:
Code:
Actions
    If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        If - Conditions
            (Level of Evasion for (Triggering unit)) Equal to 1
        Then - Actions
            If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                If - Conditions
                Then - Actions
                Else - Actions
        Else - Actions

Now go to the conditions again and put integer condition again:
Code:
(Number of units in (Units in (Playable map area))) Equal to 0

Go to the condition and scroll down until you hit math and use random number. It will give you this:
Code:
(Random integer number between 1 and 10) Equal to 0

Change the second number to 100 and the third number to your percent. Im going to use 15. Next change equal to to less that or equal to.
Code:
(Random integer number between 1 and 100) Less than or equal to 15


Doing this, your percent is now 15. Now, go to then - actions and put Create 1 Dummy for owner of triggering unit at position of triggering unit facing position of triggering unit. This is what you'll get:
Code:
Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Position of (Triggering unit))

Next off go to unit and put in add ability to unit. Make the ability, inventory hero and the unit to lastcreatedunit. After that, go to hero's and put in create item for hero. Make the item wand of illusions and the unit lastcreatedunit. You're trigger should look like this:
Code:
Passive Mirror Image
    Events
        Unit - A is attacked
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Evasion for (Triggering unit)) Equal to 1
            Then - 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 15
                    Then - Actions
                        Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Position of (Triggering unit))
                        Unit - Add Inventory (Hero) to (Last created unit)
                        Hero - Create Wand of Illusion and give it to (Last created unit)
                    Else - Actions
            Else - Actions

Now go to hero and use the action order hero to use item on unit. Make the hero lastcreatedunit and the unit, triggering unit. Next off get the action Expiration timer under units. Make it to Add a 1 second generic expiration timer to lastcreatedunit. Your trigger should be looking like this:
Code:
Passive Mirror Image
    Events
        Unit - A unit Is attacked
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Evasion for (Triggering unit)) Equal to 1
            Then - 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 15
                    Then - Actions
                        Unit - Create 1 Dummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing (Position of (Triggering unit))
                        Unit - Add Inventory (Hero) to (Last created unit)
                        Hero - Create Wand of Illusion and give it to (Last created unit)
                        Hero - Order (Last created unit) to use (Last created item) on (Triggering unit)
                        Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                    Else - Actions
            Else - Actions

Now create units around you and give your hero max strength. Go and test your map and see if it works. Just remember the spell doesn't work if the level is above 1. To make it go above one to any number, you are going to have to
Copy the first action the amount of times you want and change the level integer to 1 higher than before. To change the percent you will need to change the Integer at random number. The original one we used is (Random integer number between 1 and 100) Less than or equal to 15. Change the 15 to any percent you want. The 1 indicates starting from 1 percent and the 100 is to 100%.Now were going to make it so that the clones can't get duplicated and mass up. First off your going to need another trigger. Name the trigger Anti Duplicate. Now put into the events, A unit begins casting an ability.
Code:
Unit - A unit Starts the effect of an ability

Under conditions go to boolean and unit is a illusion:
Code:
((Target unit of ability being cast) is an illusion) Equal to True

Next off, go to actions and get the action Order Unit with no target. Change Unit to Triggering Unit and for no target, change that to Stop. You should now have a trigger like this:
Code:
Anti Duplicate
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        ((Target unit of ability being cast) is an illusion) Equal to True
    Actions
        Unit - Order (Triggering unit) to Stop

Now the only unit that can be duplicated is the hero. Now we'll make a passive critical strike. Now your probably wondering why make a passive critical strike when there already is one? The reason were making it is because its more editable when you trigger it. So start of with a trigger called Critical Strike. Give it the action a unit is attacked.
Code:
Critical Strike
    Events
        Unit - A unit Is attacked
    Conditions
    Actions

Next of, in conditions, go to boolean and get the condition attacked unit is alive equal to true. Next off, in conditions put If all conditions are true then else do actions. Your trigger should look like this:
Code:
Critical Strike
    Events
        Unit - A unit Is attacked
    Conditions
        ((Attacked unit) is alive) Equal to True
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
            Then - Actions
            Else - Actions

In conditions put Level of Critical Strike equal to 1.
Code:
(Level of Critical Strike for (Triggering unit)) Equal to 1

Then put If all conditions are true then else do actions and under the new conditions, put Random number between 1 and 100 Less than or equal to 10.
Code:
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 10
    Then - Actions
    Else - Actions

Now you create a variable. We can create a global variable or convert this to Jass and create a local variable. Im going to make local variables so convert this to trigger to Jass under edit:convert to custom text. You'll get something like this:
JASS:

function Trig_Critical_Strike_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(GetAttackedUnitBJ()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001Func001C takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= 10 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('AOcr', GetTriggerUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Actions takes nothing returns nothing
    if ( Trig_Critical_Strike_Func001C() ) then
        if ( Trig_Critical_Strike_Func001Func001C() ) then
        else
        endif
    else
    endif
endfunction

//===========================================================================
function InitTrig_Critical_Strike takes nothing returns nothing
    set gg_trg_Critical_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Critical_Strike, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Critical_Strike, Condition( function Trig_Critical_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Critical_Strike, function Trig_Critical_Strike_Actions )
endfunction


This may seem pretty wierd but if you read it, its very similar to GUI and atleast for me, its easy to tell what the actions do. Now were going to need to make local variables so type:
JASS:

The interger means the variable type. The variable type can alaways be changed. GetHeroStatBJ(bj_HEROSTAT_STR means strength and lastly, GetTriggeringUnit means Triggering Unit. Pretty simple? Seems to be so. Now in this critical strike, its not going to multiply the damage of the unit but the strength of the unit. Its a bit different from the original. Now we have to damage the attacked unit but there's one problem, we can't make the interger go to the damage amount because the damage amount has to be a real. So what do we do? We convert it in the damage function/action:

UnitDamageTargetBJ means damage target. Get Attacker and get attackedunitBJ is attacking unit and attacked unit. I2R is probably the wierd part of the function. I means interger, 2 means to and r Means real. I2R is a conversion of interger to real. Strength means our local interger. The rest is pretty obvious. Now you probably typed the local variable at the wrong section (Just incase) so here is the way the code is supposed to be:
JASS:

function Trig_Critical_Strike_Conditions takes nothing returns boolean
    if ( not ( IsUnitAliveBJ(GetAttackedUnitBJ()) == true ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001Func001C takes nothing returns boolean
    if ( not ( GetRandomInt(1, 100) <= 10 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('AOcr', GetTriggerUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Critical_Strike_Actions takes nothing returns nothing
    local integer Strength = GetHeroStatBJ(bj_HEROSTAT_STR, GetTriggerUnit(), true)
    if ( Trig_Critical_Strike_Func001C() ) then
        if ( Trig_Critical_Strike_Func001Func001C() ) then
        else
        endif
             call UnitDamageTargetBJ( GetAttacker(), GetAttackedUnitBJ(), I2R(Strength), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Critical_Strike takes nothing returns nothing
    set gg_trg_Critical_Strike = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Critical_Strike, EVENT_PLAYER_UNIT_ATTACKED )
    call TriggerAddCondition( gg_trg_Critical_Strike, Condition( function Trig_Critical_Strike_Conditions ) )
    call TriggerAddAction( gg_trg_Critical_Strike, function Trig_Critical_Strike_Actions )
endfunction

Local variables should be written at the top of the trigger so I changed the position to the highest point were needed. This by the way, is the long version of the code. This code can be decreased to smaller sizes by changing a few things. Well the is my tutorial and hope it helps:). [This tutorial has been edited. Special thanks to: Larcenist, Dryvnt, Flare, Nina,Kazuga and Vestras.]
 

Naga'sShadow

Ultra Cool Member
Reaction score
49
Nice. But you shouldn't need a second trigger, if you simply include a second if then or just place a condition unit is an illusion equal to false in the trigger condition. That way the trigger will simply not even fire when an illusion is attacked in the first place.

Also I'm not 100% sure about this but position of triggering unit leaks. As in the game remembers that location after its been used and will eat up memory space. To fix that you can set a variable (call it temp_point) to the units position and then order the unit to appear at temp_point. Afterward you can erase temp_points location with the custom script (call RemoveLocation udg_temp_point).

If I'm wrong about this could someone correct me?

Anyway great spell +1.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Was Bored. :D

Code:
Passive Mirror Image
    Events
        Unit - A unit Is attacked
    Conditions
    Actions
        Set TempPoint = Position of (Triggering unit)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Level of Evasion for (Triggering unit)) Equal to 1
                (Attacked unit) Is an Illusion Equal to False
            Then - 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 15
                    Then - Actions
                        Unit - Create 1 Dummy for (Owner of (Triggering unit)) at TempPoint facing TempPoint
                        Unit - Add Inventory (Hero) to (Last created unit)
                        Hero - Create Wand of Illusion and give it to (Last created unit)
                        Hero - Order (Last created unit) to use (Last created item) on (Triggering unit)
                        Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                    Else - Actions
            Else - Actions 
        Custom Script: call RemoveLocation (udg_TempPoint)
 

D.V.D

Make a wish
Reaction score
73
I'll add new parts and I'll make it leak less. But that will be done probably on Friday when Im not at school. Who reduced my rep by like 15?

EDIT: Never mind, I got it.
 

Romek

Super Moderator
Reaction score
964
..Wtf? o_O
This is basically the same as my tutorial. Just in GUI. And not as explanatory.
 

LightChaosma

New Member
Reaction score
60
Add a (interger) (Expiration Type) to (unit); This action is normally used to kill dummy units or give a unit a amount of seconds to live.

eh... what exactly do you understand with the term integer??:p
 

Flare

Stops copies me!
Reaction score
662
Integer is a number and romek why did you reduce my rep? I replied 3 times not bumped and im almost done adding a new part to this tutorial.

1) It's actually a real value that Add Expiration Timer uses (doesn't really make much of a difference, unless it's a short expiration timer)
2) He thinks you're pretty much stealing his tutorial's material(?), even though there is the difference in (a) the ability's effect and (b) the use of GUI. And it's only rep, it's not the end of the world
 

Romek

Super Moderator
Reaction score
964
Wtf? I didn't give you -Rep. Are you paranoid or something?

But yeah, I do think that you basically copied my tutorial but made it GUI. (And made it worse overall)
 

D.V.D

Make a wish
Reaction score
73
I don't even know what you did in your tutorial romek. Why do I get blamed for making my first tutorial? And yes you did minus my rep. Says so on my userCP.
 

Flare

Stops copies me!
Reaction score
662
By the way, have you actually tested this?
Code:
Anti Duplicate
    Events
        Unit - A unit Starts the effect of an ability
    Conditions
        ((Target unit of ability being cast) is an illusion) Equal to True
    Actions
        Unit - Order (Triggering unit) to Stop

Once the effect of an ability starts, I don't think you can stop it like that. And, that'd prevent all abilities from affecting illusions (so if you tried to Dispel an illusion, it wouldn't work, assuming your trigger was right)

And it's not really copied, other than the event (not much choice there) and the % chance (again, not much choice there)
 

Romek

Super Moderator
Reaction score
964
Maybe I gave you -Rep for something else. Not for this though (I haven't given rep to the first post).

And the concept is extremely similar. It's basically re-written.
 

D.V.D

Make a wish
Reaction score
73
Well, sorry but I don't even know what you wrote in your tutorial. And you apparently minused my rep for bumping 3 times in 24h but it doesn't matter so I won't bring the topic up again.

EDIT: Added a new part to this tutorial :).
 

quraji

zap
Reaction score
144
What's the point of writing the tutorial and GUI and then converting it to JASS at the end?
 

D.V.D

Make a wish
Reaction score
73
Because its easier to use locals and the people that read this learn some Jass.
 

quraji

zap
Reaction score
144
the people that read this learn some Jass.

Maybe.. probably not as much as if it were created step by step in JASS and not GUI :p

I would stick either to JASS or GUI, unless you're writing a GUI -> JASS tutorial ;)
 

D.V.D

Make a wish
Reaction score
73
I`ll probably write more parts to this tutorial but probably stick to GUI.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top