I'm trying to set the hp of Unit Index 1465 to 1 using Extended Unit ID 3900
The address for hp for this unit is
address = 6456296-336*index + offset = 6456296 - 336*1465 + 8 = 5964064
solving the equation (from a by placing formula)
5964064 = 48*3900 + 4*x + 5776160
we find x = 176 (this is the player number)
So I go ahead and place a dt for unit index 1465 and 2 UnitID 3900 for Player 176 but nothing is happening, whats up?
Attachments:
Post has been edited 1 time(s), last time on Oct 3 2014, 5:05 pm by sigsaucy.
I think i just realized whats up, the DT starts out with max hp, so by placing the Extended units im just adding HP to a already maxed out HP unit, so I won't see any difference.
I've tried to get around this by setting the HP of the dt to 5% = 4 HP at start, this means that the address for HP for the DT should be value 256*4
by adding the 2 extended units the value should now be 256*4 + 2 so that ceil( (256*4 + 2)/256 ) = 5 but this isn't working
I'm just trying to find some basic things to fool around with, but all the interesting properties seem out of reach sadly
Post has been edited 1 time(s), last time on Oct 3 2014, 7:11 pm by sigsaucy.
An artist's depiction of an Extended Unit Death
I don't have the time at the moment to check your math, but this could be the actual problem: Unit HP starts on the second byte. You'll need 256 of your extended unit to add one HP.
Starting with max HP isn't an issue: the current HP will still go up.
On the offsets page
https://code.google.com/p/bwapi/source/browse/trunk/bwapi/BWAPI/Source/BW/CUnit.hit says
/*0x008*/ s32 hitPoints; // Hit points of unit, note that the displayed value in broodwar is ceil(healthPoints/256)
// Officially called "xLife"
so you're saying that in ceil(healthPoints/256) healthPoints refers to the 2nd byte?
I just tried placing 256 of them and it still didnt work
Attachments:
Post has been edited 2 time(s), last time on Oct 3 2014, 5:33 pm by sigsaucy.
An artist's depiction of an Extended Unit Death
Yes: the reason you divide by 256 is because it starts on the second byte. (The first byte is a fractional value used for Zerg regeneration, I believe.)
If it's still not working, it means the math is off somewhere. Open a memory editor and verify that you're changing the correct value. Alternatively, you can use EUDGen to calculate the EUD, use EUDTrig to convert it to an address, and use EUPCalc to verify the extended unit you're using is in that list. (I'll update EUPCalc to accept a MemoryID so it isn't this huge a pain... Someday...)
If you still can't figure it out, I can verify the math later today.
using a memory editor ive found the address for unit index 1465's hp to be
0x5B03C0 = 5964736
this is off from my calculation of 5964064 calculated from the formula
address = 6456296-336*index + offset
by 672
ive checked my calculation and it seems the only explanation is that the formula is wrong.
The address for unit Index 1466's hp is 336 off from 1465's so the 336*index part of the formula is right.
so it seems the value 6456296 and/or offsets listed at
https://code.google.com/p/bwapi/source/browse/trunk/bwapi/BWAPI/Source/BW/CUnit.h are wrong
also when here is a list of the dt's hp and the value at 0x5B03C0 for different values
0x5B03C0 = 3024, hp = 12 with 3024/256 = 11.8125
0x5B03C0 = 4024, hp = 16 with 4024/256 = 15.71875
0x5B03C0 = 5425, hp = 22 with 5425/256 = 21.1914
0x5B03C0 = 9224, hp = 37 with 9224/256 = 36.03125
so it appears that the way HP is stored at the address is [a,b,c,d] where hp = (b + c*256 + d*256^2) + ceil(a), so that the first byte representing fractional hp isn't just used for zerg regen, but for everyone
Post has been edited 7 time(s), last time on Oct 3 2014, 9:30 pm by sigsaucy.
An artist's depiction of an Extended Unit Death
Oh true: units with armor take fractional damage, so it would make sense that the first byte is used for this.
Post has been edited 2 time(s), last time on Oct 3 2014, 9:31 pm by Roy.
I assumed the offset list was correct and have come up with the formula
for index = 0
address = 5885096 + offset
for index > 0
address = 6456968 + offset - 336*index
the only thing different is the large numbers, maybe someone else can check to see if this is correct.
Just confirmed that these are correct:
If index > 0 Address = 6456296-336*index + offset
Else Address = 5885096 + offsetWill look at the rest shortly
Edit: Your start locations are at early indexes, start locations don't use indexes once loaded into starcraft (so your dark templar isn't at 1465), a good rule of thumb is to always have start locations at the last indexes when you use EUDs/EUPs.
Post has been edited 2 time(s), last time on Oct 3 2014, 9:33 pm by jjf28.
TheNitesWhoSay - Clan Aura -
githubReached the top of StarCraft theory crafting 2:12 AM CST, August 2nd, 2014.
ahhhhhhh i see, so if you have
index 0 start locatoin
index 1 marine
in the map editor in starcraft it loads it ha
index 0 marine,
thanks!
An artist's depiction of an Extended Unit Death
(I guess I should make this its own post, rather than an edit. Also, I use
this list for the unit node structure, because I find it easier to read. But that's not the issue here.)
I'm not sure where you got your formula (it's not wrong, just simplified), but from
this topic, it is described as follows:
Unit index pointer:
u = 0: 5885096
u > 0: 6455960 - 336*(u-1)
So for index 1465, it would be:
6455960 - 336*(1465-1)
6455960 - 336*1464
6455960 - 491904
5964056
Which, in hex, is 0x5B0118. Add 0x8 for the location of health for that unit index, and you have 0x5B0120.
By the way, there's two reasons your map doesn't work. One is (as jjf mentions above) because Start Locations don't use index IDs. Your Dark Templar is actually Unit Index #1463. The other reason is because your extended units are placed before the Dark Templar, which means they'll write to the address where the Dark Templar's HP will be located, but then the Dark Templar gets initialized and sets the HP to its default.
hurrah success!!!!!!!!!!!!!!!!!!!!!!!!! the dt has 5 hp!!!! thanks for all the help dudez
Attachments:
Post has been edited 1 time(s), last time on Oct 3 2014, 10:05 pm by sigsaucy.