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: 328
  • Uncomplete list of BirthAnimations.txt
    3.6 KB · Views: 345

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.
  • 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

      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