• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[JASS] Request: Could someone make a unit struct thing for me?

Status
Not open for further replies.
Level 2
Joined
Jan 6, 2008
Messages
25
I'm a GUI user and I've had trouble being patient with learning JASS, I'll get around to it one of these days but for the moment, I really need one of those vJass structs or whatever their called. I asked on a different section of this forum how to do it and donut3.5 said a struct.

So, my request is, could anyone make a struct that would save a unit's destination? For my instance, it's a castle-fight style game, only with the whole map as your battlefield on an epic sized map. The units are trained from the buildings, so they automatically go towards the building's rally point. What I need, is to be able to trigger those unit's abilities (for example, make one unit summon another unit when it is attacked, using a GUI trigger).

The trigger part is easy, but after it does the spell, it won't have any orders and it'll stop moving towards the rally point destination. I need to be able to tell him to attack-move to his rally point destination after casting, is there any way to do that?

Request:

A GUI or Jass trigger that stores a unit's destination so that it can be made to attack-move there after casting or taking orders.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Structs aren't necessary for anything, they just make things easier.

JASS:
library SavePosition

struct UnitPos
    real x
    real y
endstruct

function AttachUnitPos takes unit u returns UnitPos
    local UnitPos p = UnitPos.create()
    set p.x = GetUnitX(u)
    set p.y = GetUnitY(u)
    call SetHandleInt(u, "p", p)
    return p
endfunction

endlibrary


This is a simple function you can put in a separate trigger, named SavePosition, for example. It doesn't matter what it's called, you just need to convert that trigger to JASS, remove all text from there and paste this code inside.

Example of usage:

  • Events
    • Unit - A units starts the effect of an ability
  • Conditions
  • Actions
    • Set SomeUnit = (Triggering unit)
    • Custom script: local UnitPos p = AttachUnitPos(udg_SomeUnit)
    • Custom script: set udg_SomeUnitX = p.x
    • Custom script: set udg_SomeUnitY = p.y

This would put the unit position in 2 real variables: SomeUnitX and SomeUnitY. Just remember to put the prefix udg_ each time you use globals in custom script (JASS). This is just a way how to get those coordinates from a struct.

If you want a location version, here it is:

JASS:
struct UnitPos
    location l
endstruct

function AttachUnitPos takes unit u returns UnitPos
    local UnitPos p = UnitPos.create()
    set p.l = GetUnitLoc(u)
    call SetHandleInt(u, "p", p)
    return p
endfunction

endlibrary


The example of usage here would be something like this:

  • Events
    • Unit - A units starts the effect of an ability
  • Conditions
  • Actions
    • Set SomeUnit = (Triggering unit)
    • Custom script: local UnitPos p = AttachUnitPos(udg_SomeUnit)
    • Custom script: set udg_SomeUnitLoc = p.l

Now you have the way of getting the position of the unit (a location). Maybe the location way is easier for GUIers.......

For these functions you need:
  • Jass NewGen Pack - you'll find it on wc3campaigns.net
  • Local Handle Vars - you'll find it on wc3jass.com
I'm not in the mood for linking.....

I hope that helped somehow, though your request still confuses me
 
Last edited:
Level 11
Joined
Aug 25, 2006
Messages
971
Your killing me Silvenon.
JASS:
struct UnitPos
 location l 
endstruct
What the heck is the point of this? A struct is just a global array. This is a waste of vJass.
You could easily declare a global array using GUI. Now local handle vars would require use of jass. But the structs?........
 
Level 2
Joined
Jan 6, 2008
Messages
25
Well thanks everyone for helping, but I've managed to find a way to do it with GUI, using some (imho!) clever use of custom values and point values, but thanks all the same! This thread can die now.
 
Status
Not open for further replies.
Top