Exide
I am amazingly focused right now!
- Reaction score
- 448
CreateEffect
By Exide
Version 1.0
By Exide
Version 1.0
Table of Content:
- Pre-words
- Description
- The Functions
- Detailed Information for New Users
- Examples
Pre-words:
Hello.
I wanted to create a simple function for new mappers to use when creating their maps. Specifically when creating Special Effects. -So I did!
I hope these functions will be useful for many new users out there.
Description:
These functions uses the call DestroyEffect(AddSpecialEffect()) -trick.
Pros: Instantly creates and removes a special effect, cleaning up the leak automatically.
Cons: Only works on special effects that have the 'Birth' animation.
So how do I know what Special Effects have the Birth animation, then? -You might be wondering. Well, I made an Uncomplete List of Birth Animations that can be found, attached, at the bottom of this Post.
The Functions:
Here's the complete list of the functions:
JASS:
function CreateEffect takes string whateffect, real x, real y returns nothing
call DestroyEffect(AddSpecialEffect(whateffect, x, y))
endfunction
function CreateEffectOnUnit takes string whateffect, unit target, string attpoint returns nothing
call DestroyEffect(AddSpecialEffectTarget(whateffect, target, attpoint))
endfunction
function CreateEffectAtLoc takes string whateffect, location where returns nothing
call DestroyEffect(AddSpecialEffectLoc(whateffect, where))
endfunction
function CreateEffectAtLocCheck takes string whateffect, location where, boolean check returns nothing
call DestroyEffect(AddSpecialEffectLoc(whateffect, where))
if check == true then
call RemoveLocation(where)
endif
endfunction
function CreateEffectLP takes string whateffect, real x, real y, player p returns nothing
if GetLocalPlayer() != p then
set whateffect = ""
endif
call DestroyEffect(AddSpecialEffect(whateffect, x, y))
endfunction
function CreateEffectOnUnitLP takes string whateffect, unit target, string attpoint, player p returns nothing
if GetLocalPlayer() != p then
set whateffect = ""
endif
call DestroyEffect(AddSpecialEffectTarget(whateffect, target, attpoint))
endfunction
function CreateEffectAtLocCheckLP takes string whateffect, location where, boolean check, player p returns nothing
if GetLocalPlayer() != p then
set whateffect = ""
endif
call DestroyEffect(AddSpecialEffectLoc(whateffect, where))
if check == true then
call RemoveLocation(where)
endif
endfunction
Detailed Information for New Users:
First of all you need to know where the Map Header is. The Map Header is found in the Trigger Editor (F4), at the very top of the list on your left. It has the same name as your map.
Once you have found the Map Header, paste the functions that you want to use in it. The picture below explains better.
Examples:
Once you have successfully pasted the functions that you want to use into the Map Header, you can begin calling the functions.
We do this with the help of Custom scripts.
Example #1 - CreateEffect:
JASS:
function CreateEffect takes string whateffect, real x, real y returns nothing
call DestroyEffect(AddSpecialEffect(whateffect, x, y))
endfunction
In this example we are using a unit and it's coordinates (X, Y). We get the unit through a global variable called TargetUnit (udg_TargetUnit). The event is irrelevant.
Trigger:
- Example 1
- Events
- Conditions
- Actions
- Custom script: set udg_X = GetUnitX(udg_TargetUnit)
- Custom script: set udg_Y = GetUnitY(udg_TargetUnit)
- Custom script: call CreateEffect("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_X, udg_Y)
This simple trigger will create a special effect where udg_TargetUnit is, using the Thunder Clap model. (This can, obviously use local variables, as well.)
Example #2 - CreateEffectOnUnit:
If you rather create the effect on a certain unit, you can use this function:
JASS:
function CreateEffectOnUnit takes string whateffect, unit target, string attpoint returns nothing
call DestroyEffect(AddSpecialEffectTarget(whateffect, target, attpoint))
endfunction
We will once again use udg_TargetUnit as our Test Pilot. The event doesn't matter, so I'll just skip it.
Trigger:
- Example 2
- Events
- Conditions
- Actions
- Custom script: call CreateEffectOnUnit("Abilities\\Spells\\Human\\Invisibility\\InvisibilityTarget.mdl", udg_TargetUnit, "chest")
This trigger will create a special effect attached to TargetUnit's chest, using the Invisibility Target model.
Example #3 - CreateEffectAtLoc & CreateEffectAtLocCheck:
If you rather use a Point (location) instead of Coordinates (X, Y), you can use these two functions.
JASS:
function CreateEffectAtLoc takes string whateffect, location where returns nothing
call DestroyEffect(AddSpecialEffectLoc(whateffect, where))
endfunction
function CreateEffectAtLocCheck takes string whateffect, location where, boolean check returns nothing
call DestroyEffect(AddSpecialEffectLoc(whateffect, where))
if check == true then
call RemoveLocation(where)
endif
endfunction
Trigger:
- Example 3
- Events
- Conditions
- Actions
- Set temppoint = (Position of TargetUnit)
- Custom script: call CreateEffectAtLoc("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_temppoint)
- Custom script: call RemoveLocation(udg_temppoint)
This trigger does the exact same thing as Example 1, using a Point (location).
If you are too lazy to clean up the point leak by yourself, you can use CreateEffectAtLocCheck:
Trigger:
- Example 4
- Events
- Conditions
- Actions
- Set temppoint = (Position of TargetUnit)
- Custom script: call CreateEffectAtLocCheck("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_temppoint, true)
Notice the 'true' value at the end of this function. -If you set it to true, the Point will automatically be cleaned. If you set it to false, it will not be cleaned.
-Why is this useful? Take a look:
Trigger:
- Example 5
- Events
- Conditions
- Actions
- Set temppoint = (Position of TargetUnit)
- Custom script: call CreateEffectAtLocCheck("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_temppoint, false)
- Custom script: call CreateEffectAtLocCheck("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_temppoint, true)
-This will create two effects at the same time (without a wait between the functions I doubt you will be able to see them.)
-If you put 'true' in the first, the second won't show at all - because there won't be a Point to create the effect at.
Example #6 - CreateEffect*LP:
LP in this cause stands for Local Player.
If you want to display the effect to only one player, you can use this function.
* means there are the several different ways (see examples above) to use this function. IE: CreateEffectLP, CreateEffectOnUnitLP, CreateEffectAtLocCheckLP.
In this final example I wll show CreateEffectAtLocCheckLP:
JASS:
function CreateEffectAtLocCheckLP takes string whateffect, location where, boolean check, player p returns nothing
if GetLocalPlayer() != p then
set whateffect = ""
endif
call DestroyEffect(AddSpecialEffectLoc(whateffect, where))
if check == true then
call RemoveLocation(where)
endif
endfunction
Trigger:
- Example 6
- Events
- Conditions
- Actions
- Set temppoint = (Position of TargetUnit)
- Custom script: call CreateEffectAtLocCheck("Abilities\\Spells\\Human\\ThunderClap\\ThunderClapCaster.mdl", udg_temppoint, true, GetOwningPlayer(udg_TargetUnit))
This trigger works mainly like the one in Example 4, with a small difference: GetOwningPlayer(udg_TargetUnit) - meaning this function will show the effect only to the owner of 'TargetUnit'.
I hope I haven't forgotten anything, and that someone has learned something new.