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.
[2024-4-22. : 6:48 pm]
Ultraviolet -- :wob:
[2024-4-21. : 1:32 pm]
Oh_Man -- I will
[2024-4-20. : 11:29 pm]
Zoan -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
You should do my Delirus map too; it's a little cocky to say but I still think it's actually just a good game lol
[2024-4-20. : 8:20 pm]
Ultraviolet -- Goons were functioning like stalkers, I think a valk was made into a banshee, all sorts of cool shit
[2024-4-20. : 8:20 pm]
Ultraviolet -- Oh wait, no I saw something else. It was more melee style, and guys were doing warpgate shit and morphing lings into banelings (Infested terran graphics)
[2024-4-20. : 8:18 pm]
Ultraviolet -- Oh_Man
Oh_Man shouted: lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
oh ya I saw that when Armo posted it on Discord, pretty crazy
[2024-4-20. : 8:09 pm]
Vrael -- thats less than half of what I thought I'd need, better figure out how to open SCMDraft on windows 11
[2024-4-20. : 8:09 pm]
Vrael -- woo baby talk about a time crunch
[2024-4-20. : 8:08 pm]
Vrael -- Oh_Man
Oh_Man shouted: yeah i'm tryin to go through all the greatest hits and get the runs up on youtube so my senile ass can appreciate them more readily
so that gives me approximately 27 more years to finish tenebrous before you get to it?
[2024-4-20. : 7:56 pm]
Oh_Man -- lol SC2 in SC1: https://youtu.be/pChWu_eRQZI
Please log in to shout.


Members Online: MetalGear