AddSpecialEffectTarget() and Invisibility

Status
Not open for further replies.
Level 21
Joined
May 16, 2012
Messages
644
It will leak. They have their own functions for destroying them. I think it's negligible, but it's a bad practice.
You must store the effect and destroy after use.

Ok, and one last thing, promise. We know that unit Id's are represented by 4 chars strings like 'e003' but they are integers resulted from a string hash, i presume, from that string. So lets say that 'e003' = 10000, if i do a loop from 'e003' to lets say 'e007', incrementing by 1 each step, the results will be 'e003', 'e004', 'e005', 'e006' and 'e007'?
 
Level 19
Joined
Oct 17, 2012
Messages
859
For looping through object ids, BJObjectId or NextPrevObjectId will come in handy. Do note that going from 'e003' to 'e007' will not necessarily be the same as incrementing 10000 by 1 to 10004. Gaps may appear in between, where an integer id is not equal to any 4 char code within the range provided. How increment for object ids actually works is explained in Easiest way to preload objects.
 
Last edited:
Level 21
Joined
May 16, 2012
Messages
644
For looping through object ids, BJObjectId or NextPrevObjectId will come in handy. Do note that going from 'e003' to 'e007' will not necessarily be the same as incrementing 10000 by 1 to 10004. Gaps may appear in between, where an integer id is not equal to any 4 char code within the range provided. How increment for object ids actually works is explained in Easiest way to preload objects.

I did a loop that is incremented by 1 and it actually works like i described.

JASS:
set i = 'e003'
loop
    exitwhen i > 'e007'
        call UnitApplyTimedLife(CreateUnit(neutral, i, x + GetRandomInt(0, 75), y + GetRandomInt(0, 75), 0), 'BTLF', 20)
    set i = i + 1
endloop

'e003' to 'e007' are units in my editor and it correctly creates them.
 
Level 19
Joined
Oct 17, 2012
Messages
859
Yeah, from 0 to 9 works perfectly by incrementing by 1 because it follows the system Warcraft 3 uses. From 9 to 10 however may turn out to be more than an increment of 1. This is just something to watch out for in case you need more object ids and use the same pattern for the ids.
 
Level 19
Joined
Jan 1, 2018
Messages
739
We know that unit Id's are represented by 4 chars strings like 'e003' but they are integers resulted from a string hash, i presume, from that string.
Just wanted to point out that fourcc IDs are not hashed. A hash function maps arbitrary-sized data to fixed-size, but the fourcc ID is already fixed-size, since it needs to be exactly 4 characters long. Instead, the ID is converted to an integer by taking the numerical value of each character with a radix of 256, so it's similar to hexadecimal numbers.
 
Status
Not open for further replies.
Top