Making a Circle of Units (for beginners!)

elmstfreddie

The Finglonger
Reaction score
203
Alright, I'm completely rejigging this tutorial!

Ok, so the triggering given will create a circle of explosives around the caster, then after 2 seconds they explode dealing 250 damage each in a 50 radius (that's definitally overpowered for a map, but just edit "Kaboom! (Barrel O' Explosives)" to edit the stats) Although this effect is intended for a hero ability, you could easily edit it for cinematics.

For this, you will need 5 variables:
Variable1: Real
Variable2: Player
Variable3: Point
Variable4: Unit
Variable5: Unit Group
Variable6: Point (my attempt to remove memory leaks)

Trigger1: Activation Trigger
Code:
Trigger 1
    Events
        Unit - A unit Finishes casting an ability
    Conditions
        (Ability being cast) Equal to Circle of Doom 
    Actions
        Set Variable2 = (Owner of (Casting unit))
        Set Variable3 = (Position of (Casting unit))
        Set Variable4 = (Casting unit)
        Trigger - Turn on Trigger 2 <gen>
        Trigger - Turn on Trigger 3 <gen>

Trigger2: Creation Trigger
Code:
Trigger 2
    Events
        Time - Every __ seconds of game time
    Conditions
    Actions
        Set Variable6 = (position of Variable3 offset by 450 towards Variable1 degrees)
        Unit - Create 1 Peasant for Variable2 at Variable6 facing Variable1 degrees
        Set Variable1 = (Variable1 + 5.00)
        Unit Group - Add (Last created unit) to Variable5

Trigger3: Exploding Trigger
Code:
Trigger 3
    Events
        Time - Every __ seconds of game time (must be equal to or less than the number in Trigger 2)
    Conditions
        Variable1 Greater than or equal to 360.00
    Actions
        Set Variable1 = 0.00
        Trigger - Turn off Trigger 2 <gen>
        Wait 2.00 seconds
        Unit Group - Pick every unit in Variable5 and do (Actions)
            Loop - Actions
                Unit - Order (Picked unit) to Neutral - Kaboom! (Position of (Picked unit))
                Wait 0.20 seconds
                Set tempPosition = (Position of (Picked unit)) 
                Unit Group - Pick every unit in Variable5 and do (Unit - Remove (Picked unit) from the game)
                Custom Script: call RemoveLocation(udg_tempPosition)
        Trigger - Turn off (This trigger)

OK, in order for this to work you need 2 abilities and 2 units:

Ability1: Kaboom! (Barrel O' Explosives) base this off of Kaboom! (Goblin Sappers) and then just change the stats
Ability2: Call it ring of fire or whatever you wish, but this is the "dummy ability". Make it fan of knives, and remove most of the data. Get rid of it's range, damage, and model files.
Unit1: Hero, whatever, the activation unit (caster) give it "Ability2"
Unit2: The exploding unit, give it ability "Kaboom! (Barrel O' Explosives)

That should fix the memory leaks, sorry, i'll get used to this one day...

By the way, you need the wait .2 seconds because if you don't they don't have time to cast kaboom! (even though theres no cast time). Probaly would work with less than .2, but I didn't care because it still removes them from the game :)
 

ayumilove

Youtube account suspended! youtube.com/ayumilove8
Reaction score
110
hi, could you post an attachment of that ability you made above? <3
 

elmstfreddie

The Finglonger
Reaction score
203
as you've seen before, i'm kind of a newb... So, what i'm going to do is just attatch the map with my triggering in it

p.s. it won't work off the start, you have to set variables 2 and 3 :)
 

ayumilove

Youtube account suspended! youtube.com/ayumilove8
Reaction score
110
lol how come it automatically creates those peasants?>

where is my hero >_<

i wan hero cast then only create peasants lol <3


- - - - - - -

anyways, do you have any idea how to move with the hero?
example if the hero moves left, all pesants around it moves together.
all of them move in a synchronize mode.
 

ayumilove

Youtube account suspended! youtube.com/ayumilove8
Reaction score
110
1st Trigger
Code:
Trigger 1
    Events
        Unit - A unit Finishes casting an ability
    Conditions
        (Ability being cast) Equal to Circle of Doom 
    Actions
        Set Variable2 = (Owner of (Casting unit))
        Set Variable3 = (Position of (Casting unit))
        Set Variable4 = (Casting unit)
        Animation - Play (Casting unit)'s spell animation
        Trigger - Turn on Trigger 2 <gen>
        Trigger - Turn on Trigger 3 <gen>
2nd Trigger
Code:
Trigger 2
    Events
        Time - Every 0.01 seconds of game time
    Conditions
    Actions
        Set Variable6 = (Variable3 offset by 450.00 towards Variable1 degrees)
        Unit - Create 1 Peasant for Variable2 at Variable6 facing Variable1 degrees
        Set Variable1 = (Variable1 + 5.00)
        Unit Group - Add (Last created unit) to Variable5
3rd Trigger
Code:
Trigger 3
    Events
        Time - Every 0.01 seconds of game time
    Conditions
        Variable1 Greater than or equal to 360.00
    Actions
        Set Variable1 = 0.00
        [COLOR="Red"]Set tempPosition = (Position of (Picked unit))[/COLOR] 
        Trigger - Turn off Trigger 2 <gen>
        Wait 2.00 seconds
        Unit Group - Pick every unit in Variable5 and do (Actions)
            Loop - Actions
                [COLOR="Red"]Unit - Order (Picked unit) to Neutral - Kaboom! (tempPosition))[/COLOR]
                Wait 0.20 seconds
                Unit Group - Pick every unit in Variable5 and do (Unit - Remove (Picked unit) from the game)
        Trigger - Turn off (This trigger)
        [COLOR="Red"]Custom Script: call RemoveLocation(udg_tempPosition)[/COLOR]
 

Exide

I am amazingly focused right now!
Reaction score
448
What about Unit groups?
They leak too, don't they?
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Code:
Trigger 3
    Events
        Time - Every 0.01 seconds of game time
    Conditions
        Variable1 Greater than or equal to 360.00
    Actions
        Set Variable1 = 0.00
        Trigger - Turn off Trigger 2 <gen>
        Wait 2.00 seconds
        Custom Script: set bj_wantDestroyGroup = true
        Unit Group - Pick every unit in Variable5 and do (Actions)
            Loop - Actions
                Set tempPosition = (Position of (Picked unit)) 
                Unit - Order (Picked unit) to Neutral - Kaboom! (tempPosition))
                Unit Group - Pick every unit in Variable5 and do (Unit - Remove (Picked unit) from the game)
                Custom Script: call RemoveLocation(udg_tempPosition)
        Trigger - Turn off (This trigger)

Would be right and using waits in unit and player group loops messes up. ;)
 

elmstfreddie

The Finglonger
Reaction score
203
Oops, didn't see that one. I knew about those leaks though, in this other map I was doing I fixed that.

Whats the point of Custom Script: set bj_wantDestroyGroup = true?

PS: Exide, using the trigger pick every unit in unit group and do action doesn't leak. Using "picked unit" doesn't either.
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130

Unit Groups


Code:
[COLOR=DarkRed]Unit Group Bad[/COLOR]
    Events
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
            Loop - Actions
                Unit - Kill (Picked unit)

Now this will leak memory for every unit picked, which, depending on how many times this is ran, can add up heavily.

Code:
[COLOR=DarkOrange]Unit Group Good[/COLOR]
    Events
    Conditions
    Actions
        Set Temp_Group = (Units in (Playable map area))
        Unit Group - Pick every unit in Temp_Group and do (Actions)
            Loop - Actions
                Unit - Kill (Picked unit)
        Custom script:   call DestroyGroup (udg_Temp_Group)

This cleans up all of your leaks. We first set our unit group to a unit group variable, pick all the units in this variable, do our actions, and then destroy the unit group variable, using a Custom Script. Remember that when referencing a variable in JASS, you most use underlines for spaces and put ‘udg’ before the Variable name.

Copied directly from that memory leak tutorial up there ^
 

Mr Zero

Junior Regular (Got the T-shirt)
Reaction score
64
Remember that when referencing a variable in JASS, you most use underlines for spaces and put ‘udg’ before the Variable name.
If it is a Global Variable. :D

~Mr. Zero
Tuesday, December 12, 2006
 

Exide

I am amazingly focused right now!
Reaction score
448
Oops, didn't see that one. I knew about those leaks though, in this other map I was doing I fixed that.

Whats the point of Custom Script: set bj_wantDestroyGroup = true?

PS: Exide, using the trigger pick every unit in unit group and do action doesn't leak. Using "picked unit" doesn't either.

I have no idea about the Custom Script.. It's just what we do when we use Unit Groups because they leak? :p
-That's what I've been told, and that's what I do! ^^
 

Mr Zero

Junior Regular (Got the T-shirt)
Reaction score
64
Oops, didn't see that one. I knew about those leaks though, in this other map I was doing I fixed that.

Whats the point of Custom Script: set bj_wantDestroyGroup = true?
Does it not stand there? :rolleyes:
bj_wantDestroyGroup = true
It is like a question, Want Destroy Group ? True/Yes.
Like saying to the map; "When I'm done with this group, destroy it"

:)

~Mr. Zero
Tuesday, December 12, 2006
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
> It's just what we do when we use Unit Groups because they leak?

That's a bit simple maybe... :p


"Pick every unit in" either gets a unit group variable from you, or it will create one if needed.
If it has to create one, that group is never destroyed, hence the leak.

Now, once the group is created, it will loop through its units to do the actions.
To do so, it calls a special "loop over groups" function.
Said function checks if bj_wantDestroyGroup is true, and, if it is, destroys the group once it's done with the loop.

The second trigger in post #13 is generally a better choice.
If nothing else, you see exactly what's going on, without the need to hope that it will work as planned...
 

elmstfreddie

The Finglonger
Reaction score
203
That partially made sense to me. Enough sense though :p I guess i'm not ready for tutorials, need to read on memory leaks more thoroughly (I spent like 1 minute scanning through them, I would say I caught on quickly though, except for small details)
 

c-series

New Member
Reaction score
2
btw in the memory leak tut ... ( forgot which one; it is in here )

it says
set variable for somegroup
and then call DestroyGroup (udg_somegroup)
is more efficient than set bj_wantDestroyGroup

well the tut's did not saying it directly but with examples ....

if that true ... does any1 know why ??...
 
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