Adding and substracting from IDs

A

Anvilsmith

Guest
I based my entire map, along with a lineup of roughly 180 units, on the idea that you could add an integer to the unitId of the first to get another unit's Id. Well, apparently, this doesn't work - or, at least, it does up to 'h009'. Once it needs to switch from that to 'h00A', no unit is created. The game just doesn't recognize the new Id. Apparently, however, I can add numbers to 'h00A' and obtain, say 'h00D'. So I can go past the apparent rift between '*009' and '*00A' by using an if statement to check whether an integer is about to cross from '*009' to a higher value, and switching to the higher value manually instead. In other words...

Code:
    set uid = 'h006' + m
    if m >= 4 then
    set uid = 'h00A' + m - 4
    endif
call CreateUnit(Player(p), uid, bla bla bla)

Problem is, I'm not sure if other such rifts exist. Presumably, some would show up between '*00Z' and '*010', '*019' and '*01A' and so on. Since I'm using a lot of unit types, and it's fairly difficult to check them all at once, I thought I'd ask about the matter here.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Sounds rather weird... :p


> set uid = 'h006' + m

set uid = 'h006'
set uid = uid + m

Would this be doing anything better / different?
(Assuming you have the IDs as part of the calculation)
 

Luth

Lex Luthor!
Reaction score
41
Since the ids arent actually sequential, as you've suggested they arent, then using sequential math on them wont work. You'll have to test the cases manually.

That isnt to say there isnt some algorithm you could devise that could do most of the work for you, but nothing popped into my head. ... Well, I suppose you could easily find a limit on the "good" boundaries, h000-h009, h00A-h00Z, etc etc, and equation that would define them, and using that, you can do a boundary check. If it falls in outside the "good" boundary, then simply bump it up to the next known "good" boundary.
 
A

Anvilsmith

Guest
The algorithm I'm going to use is simple, since '**n0' - '**mZ' always counts as 214 (m being n-1), while '***A' - '***9' always counts as 8. The difference between '***Z' and '***A' is 25, while that between '***9' and '***0' is obviously 9. I already posted it on Wc3Jass, though I'm almost embarassed to toss something so simple among its fabulous scripts. Sadly, 214 and 8 aren't prime to each other, or I could've used a more fancy algorithm.

By the way, phyrexian, the link doesn't seem to work. I did find plenty of other Ascii tables, though.
 

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,495
Indeed.

'0009', for example, isn't 9, it's ((48 * 256 + 48) * 256 + 48) * 256 + 57...

It's not a number in hex notation, it's a 4 characters string.

Interesting.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top