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.
Next off, create a action, if all conditions are true then else do actions.
Go to the conditions and go to interger. And click ok. You should get something like this:
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:
Next off, got create another if all conditons are true then else do acitions but on Then - Actions. You will have this:
Now go to the conditions again and put integer condition again:
Go to the condition and scroll down until you hit math and use random number. It will give you this:
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.
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:
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:
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:
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.
Under conditions go to boolean and unit is a illusion:
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:
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.
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:
In conditions put Level of Critical Strike 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.
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:
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:
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:
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.]
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(039;AOcr039;, 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:
local integer Strength = GetHeroStatBJ(bj_HEROSTAT_STR, GetTriggerUnit(), true)
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:
JASS:
call UnitDamageTargetBJ( GetAttacker(), GetAttackedUnitBJ(), I2R(Strength), ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL )
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(039;AOcr039;, 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.]