Snippet CreateEffect Functions

Exide

I am amazingly focused right now!
Reaction score
448
CreateEffect
By Exide
Version 1.0

Table of Content:
  1. Pre-words
  2. Description
  3. The Functions
  4. Detailed Information for New Users
  5. 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.

attachment.php




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. :)
 

Attachments

  • MapHeader.jpg
    MapHeader.jpg
    204.6 KB · Views: 330
  • Uncomplete list of BirthAnimations.txt
    3.6 KB · Views: 346

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
I think those "create special effect for player" funcs are useful, the orthers aren't for GUI-ers, they rather hard to use :rolleyes:
p.s: never mind if I'm wrong :p
 

wraithseeker

Tired.
Reaction score
122
I would rather you make a whole effect library that allows timed effect (although it has been done) etc (think of some!) with struct syntax rather then making this.

I think this might be useful for GUIers only.
 

Jesus4Lyf

Good Idea™
Reaction score
397
Ew, struct syntax! What the hell? *Shrugs*

I can vouch that off memory all the one-liners were inline friendly, and none of the get local player stuff desynched.

But I can also bet that in the time any mapper who needs this stuff could find it, they could write it. Problem. o.o

Except, yes, the local player stuff. You've written it correctly - I finally tested and "" (empty string) is always string #1 I believe, so setting to it locally shouldn't desynch ever, basically. :) (Just nod and smile.)
 

Exide

I am amazingly focused right now!
Reaction score
448
I think those "create special effect for player" funcs are useful, the others aren't for GUI-ers, they rather hard to use

I thought they were very easy to use.. I need new mappers to test and see what they think. ^^

I think this might be useful for GUIers only.

That's the point, and also the reason behind my wall of text.


But I can also bet that in the time any mapper who needs this stuff could find it, they could write it.


Nah, nearly every single map uses special effects. Many features leaks. :p
I also believe that the GetLocalPlayer function might be useful to many.
 

Romek

Super Moderator
Reaction score
964
Most of this is overkill.

The XY stuff is completely useless.

The GetLocalPlayer stuff is somewhat useful. :p
 

Exide

I am amazingly focused right now!
Reaction score
448

Romek

Super Moderator
Reaction score
964
> What do you use? Points?
No.

Your script:
- Set X variable
- Set Y variable
- Custom Script Function

Setting the variables could be inlined, though it would require even more JASS. GUI users + Jass = Ouch.

Default GUI:
- Create Effect at X/Y
- Destroy Last Created Effect

... :p
The Create Effect action also has a nice drop-down list of all the models and effects.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
I think every mapper has done one of these special effect libraries at some point...

It's really better to code these things yourself and use them directly to avoid function calls, therefore I'll just graveyard this.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top