Staredit Network > Forums > SC1 Mapping Tools > Topic: [SOLVED] Accessing unit data
[SOLVED] Accessing unit data
This topic is locked. You can no longer write replies here.
Jul 28 2010, 1:59 am
By: jhuni  

Jul 28 2010, 1:59 am jhuni Post #1



I need some way to access the data on all the units on the map and dump it into a text file, that way I can recreate those units with triggers. For example, the text file might be like:

Quote
(50, 94, "Player 1", "Zerg Zergling")
(170, 1110, "Player 2", "Terran Civilian")
(219, 1081, "Player 2", "Terran Civilian")
(689, 1084, "Player 7", "Terran Supply Depot")
(1025, 1687, "Player 7", "Terran Supply Depot")
(1792, 1856, "Player 8", "Terran Marine")

Then I could use that data to generate triggers to create those units...

Is there some sort of editor/tool that does this?

Post has been edited 1 time(s), last time on Jul 29 2010, 3:57 am by jhuni.



None.

Jul 28 2010, 2:13 am Cinolt Post #2



Are these units preplaced or ones currently in the game? I doubt a program exists for either that exports into a text file, but for the former you can see a similar list by selecting any unit and pressing enter in SCMDraft 2.



None.

Jul 28 2010, 2:45 am rockz Post #3

ᴄʜᴇᴇsᴇ ɪᴛ!

Open map in winMPQ.
Extract scenario.chk.
Open Scenario.chk in a hex editor (like HxD)
Search for string "UNIT".
Quote from oldwiki
"UNIT" Section
Required for all game types (vanilla, hybrid, broodwar)
This section contains all the pre-placed units on the map and their properties. Each unit on the map gets the following structure:

* 4 byte long: The unit's class instance (sort of a "serial number")
* 2 byte integer: X coordinate of unit
* 2 byte integer: Y coordinate of unit
* 2 byte integer: Unit ID
* 2 byte integer: Type of relation to another building (i.e. add-on, nydus link, etc.)
* 2 bytes: Flags of special properties which can be applied to the unit and are valid:
o Bit 0 - Cloak is valid
o Bit 1 - Burrow is valid
o Bit 2 - In transit is valid
o Bit 3 - Hallucinated is valid
o Bit 4 - Invincible is valid
o Bit 5-15 - Unused

* 2 bytes: Out of the elements of the unit data, the properties which can be changed by the map maker:
o Bit 0 - Owner player is valid (the unit is not a critter, start location, etc.; not a neutral unit)
o Bit 1 - HP is valid
o Bit 2 - SP is valid
o Bit 3 - Energy is valid (unit is a wraith, etc.)
o Bit 4 - Resource amount is valid (unit is a mineral patch, vespene geyser, etc.)
o Bit 5 - Amount in hangar is valid (unit is a reaver, carrier, etc.)
o Bit 6-15 - Unused

* 1 byte: Player number of owner (0-based)
* 1 byte: Hit points % (1-100)
* 1 byte: Shield points % (1-100)
* 1 byte: Energy points % (1-100)
* 4 byte long: Resource amount
* 2 byte integer: Number of units in hangar
* 2 bytes: Unit state flags
o Bit 0 - Unit is cloaked
o Bit 1 - Unit is burrowed
o Bit 2 - Building is in transit
o Bit 3 - Unit is hallucinated
o Bit 4 - Unit is invincible
o Bit 5-15 - Unused

* 4 bytes: Unused
* 4 byte long: Class instance of the unit to which this unit is related to (i.e. via an add-on, nydus link, etc.). It is "0" if the unit is not linked to any other unit.
As you can see, each unit is 36 bytes long, so set the lenth to 36, then copy/paste into excel or something. Delete the insignificant bytes (only ones you need are X, Y, UnitID, Player ID, possibly unit properties).

If that's too much, and difficult to translate UnitIDs into units, then I suggest you use SCMDraft and make a long image of all the units on the map, as yoonkwun suggested.

You'll still have to place locations at each of these areas, which makes it kind of difficult. Why do you want to create them with triggers?



"Parliamentary inquiry, Mr. Chairman - do we have to call the Gentleman a gentleman if he's not one?"

Jul 29 2010, 4:07 am jhuni Post #4



Quote
If that's too much, and difficult to translate UnitIDs into units

Thank you, that will save me a lot of work because manually copying the unit data would be a pain. I will write a function to convert the Unit IDs into Unit Names so that shouldn't be a problem.

Quote
You'll still have to place locations at each of these areas, which makes it kind of difficult. Why do you want to create them with triggers?

I have an 8px resolution hybrid location grid so I can place the units relatively easily/accurately. However, since these type of grids can't extend very far I don't have very much room to pre-place units in the map editor so I will create them with triggers when they are needed.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[01:05 am]
Vrael -- I won't stand for people going around saying things like im not a total madman
[01:05 am]
Vrael -- that's better
[12:39 am]
NudeRaider -- can confirm, Vrael is a total madman
[10:18 pm]
Vrael -- who says I'm not a total madman?
[02:26 pm]
UndeadStar -- Vrael, since the ad messages get removed, you look like a total madman for someone that come late
[2024-5-02. : 1:19 pm]
Vrael -- IM GONNA MANUFACTURE SOME SPORTBALL EQUIPMENT WHERE THE SUN DONT SHINE BOY
[2024-5-02. : 1:35 am]
Ultraviolet -- Vrael
Vrael shouted: NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
Gonna put deez sportballs in your mouth
[2024-5-01. : 1:24 pm]
Vrael -- NEED SOME SPORTBALL> WE GOT YOUR SPORTBALL EQUIPMENT MANUFACTURING
[2024-4-30. : 5:08 pm]
Oh_Man -- https://youtu.be/lGxUOgfmUCQ
[2024-4-30. : 7:43 am]
NudeRaider -- Vrael
Vrael shouted: if you're gonna link that shit at least link some quality shit: https://www.youtube.com/watch?v=uUV3KvnvT-w
Yeah I'm not a big fan of Westernhagen either, Fanta vier much better! But they didn't drop the lyrics that fit the situation. Farty: Ich bin wieder hier; nobody: in meinem Revier; Me: war nie wirklich weg
Please log in to shout.


Members Online: NudeRaider, Roy