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

Some questions about vJass

Status
Not open for further replies.
Level 17
Joined
Mar 21, 2011
Messages
1,611
Hi :)

Question No.1:

I think it is ok to use the following functions, but i dont know if there is a better way:
UnitInventoryCount
UnitAddItemByIdSwapped


Question No.2:

can you read the length of an array?


Question No.3:

How can i get an offset point in vJass?
i did it like this, but i'm not sure if this is the best solution
JASS:
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real x2 = GetLocationX(Location(x, y)) + 600.00 * Cos(f * bj_DEGTORAD)
    local real y2 = GetLocationY(Location(x, y)) + 600.00 * Sin(f * bj_DEGTORAD)



thats it, thank you!
 
Level 14
Joined
Jun 27, 2008
Messages
1,325
I think it is ok to use the following functions, but i dont know if there is a better way:
UnitInventoryCount
UnitAddItemByIdSwapped
Both are non-native functions (BJs), which means you can replace them by their implementation.
List of BJs: https://warcraft.ingame.de/maps/mappedia/Blizzard.j

The implementation of BJs are compositions of jass language elements and native functions.
List of natives: http://warcraft.ingame.de/maps/mappedia/Common.j

Just do a fulltext search for your functions.


can you read the length of an array?
No, arrays always have length 8192.
You can search the array for the last entry by looping through it...

How can i get an offset point in vJass?
i did it like this, but i'm not sure if this is the best solution
JASS:
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local real x2 = GetLocationX(Location(x, y)) + 600.00 * Cos(f * bj_DEGTORAD)
    local real y2 = GetLocationY(Location(x, y)) + 600.00 * Sin(f * bj_DEGTORAD)

Replace GetLocationX(Location(x, y)) with x. Same with y..
Apart from that its fine.
 
Level 17
Joined
Mar 21, 2011
Messages
1,611
Thanks for your answers,

If i take a look at the "UnitInventoryCount", it does what i would actually do to check. It loops through every inventory slot and checks if item != null. If so --> counter++
so is it really necessary to make it myself?
 
Status
Not open for further replies.
Top