• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

question about points

Status
Not open for further replies.
Level 13
Joined
May 11, 2008
Messages
1,198
when i was first making a custom spell i was making a unit cast a spell at a point, and well, so...i found out i should use a point variable and set it to where i need it to be and after i'm done with it i should remove it.

but now i'm thinking instead of bothering with the variable i can just do convert coordinates to point for the command in casting the spell, and use the x and y of the unit...and this will be leakless, right?

conversion functions seem to be really nice to use...i've been looking for using them wherever possible lately.

i think this is a good alternative, so let me know for sure.

  • pandaren flames
    • Events
    • Conditions
      • (Ability being cast) Equal to (==) |cff20b2aaPandaren Flames|r (frenzy)
    • Actions
      • Set points = (Position of (Casting unit))
      • Unit - Create 1 Archer for (Owner of (Casting unit)) at points facing Default building facing (270.0) degrees
      • Unit - Order (Last created unit) to Human Blood Mage - Flame Strike points
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • Point - Remove points
so what i'm saying is, i think i can change the above trigger into this one below, and it will be nice saving a bit of map space and clutter because it doesn't bother with a variable, eh?

  • pandaren flames
    • Events
    • Conditions
      • (Ability being cast) Equal to (==) |cff20b2aaPandaren Flames|r (frenzy)
    • Actions
      • Unit - Create 1 Archer for (Owner of (Casting unit)) at (Point((X of (Casting unit)), (Y of (Casting unit)))) facing Default building facing (270.0) degrees
      • Unit - Order (Last created unit) to Human Blood Mage - Flame Strike (Point((X of (Casting unit)), (Y of (Casting unit))))
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
 
Last edited:
Level 16
Joined
Oct 12, 2008
Messages
1,570
Well, i think it still leaks, check this:
'Convert coördinates to point'
What this does is:
Take 2 reals, and make it a point, so you still make a point (location)
  • Unit - Create 1 Footman for Player 1 (Red) at (Point(0.00, 0.00)) facing Default building facing degrees
is in Jass:
JASS:
call CreateNUnitsAtLoc( 1, 'hfoo', Player(0), Location(0, 0), bj_UNIT_FACING )
When we get Jasscraft it says this is the function we just used:
JASS:
function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
    call GroupClear(bj_lastCreatedGroup)
    loop
        set count = count - 1
        exitwhen count < 0
        call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
        call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
    endloop
    return bj_lastCreatedGroup
endfunction
See what it does? It takes a location, which means it leaks

Well, i at least think it does, even though you use reals, it makes a location out of it, which will leak (i think),,
If you want to non leak without creating and removing a point you should use this:
JASS:
native          CreateUnit              takes player id, integer unitid, real x, real y, real face returns unit
It uses 2 reals, but you cant say how many so use it in a loop when you want more ;)

BTW: If i am talking total crap here, please correct me!!!!
(by this i mean: I am not totaly sure!)

-Yixx,,-
 
Level 13
Joined
May 11, 2008
Messages
1,198
slaydon, you're silly i have another trigger which adds the event when the hero unit is chosen, that will allow the spell to be casted by more than one unit.

Yixx, that's what i thought...i don't know much about making custom text for gui though and i want the spell to stay gui because i'm attaching the event to it from another trigger. i'm not sure that you can add events to triggers when they're converted to jass. i might try putting in the
call CreateUnit( as a custom text action in the gui trigger, but i'm not sure if that'll be ok...

i'll probably be testing the map soon for this, as soon as i'm done with a new loading screen i should be ready to start finalizing the newest version.
 
a) Yixx is right, that function creates a location, which means it leaks if you don't destroy the location.

b) Don't bother trying to use coordinates in GUI. Just stick to what you know and use points. That way you need no custom script.

c) Of course it's possible to add events to JASS triggers - you can do anything you can do in GUI in JASS.
 
Status
Not open for further replies.
Top