Uncle
Warcraft Moderator
- Joined
- Aug 10, 2018
- Messages
- 7,866
This is a rather simple and possibly unnecessary idea but I figured it might be of use to someone.
I've created a small system that allows GUI users to save all of their preplaced units in the World Editor, and by that I mean save each unit's player-owner, unit-type id, x position, y position, and facing angle, inside of a text file so that the user can safely delete these preplaced units from their map and instead create them via triggers in-game. I've also added a Unit Group variable which can be used to add specific units to an ignore group which tells the system not to save them-useful for units that you don't want to delete.
You would really only want to do this once you're done placing units in your map, although it could come in handy during the development process if your loading times are a pain. I've seen a lot of maps that have 1000's of preplaced units and I imagine this could help.
The pros:
HOW TO USE:
Step 1: Open your map and copy and paste the above Jass code into a new script. Then call the StorePreplacedUnits() function in one of your triggers. This function will save all of your preplaced units once it runs.
Step 2: Launch your map and allow the function to run and then quit the game. The units will have been saved in a .txt file located at: C:\Users\Profile\Documents\Warcraft III\CustomMapData. Then open this newly created StorePreplacedUnits.txt file and copy it's entire contents.
Step 3: Run the Preplaced Units Formatter.app and follow the instructions. You may have to hit Enter twice despite what the instructions say.
This app formats the save file into a usable Jass function.
Step 4: Copy the now properly formatted code and paste it into a new script. You now have access to a function that will create all of your preplaced units.
Step 5: Now you can delete any preplaced units from your map and instead create them in-game by calling the CreatePreplacedUnits() function.
---
So this is my first time "making an app" and I have no idea if you can use the attached Preplaced Units Formatter app without extra file(s) or the correct .Net framework installed. It was created as a C# Console App in Visual Studio and published using .Net Core 3.1.
I've created a small system that allows GUI users to save all of their preplaced units in the World Editor, and by that I mean save each unit's player-owner, unit-type id, x position, y position, and facing angle, inside of a text file so that the user can safely delete these preplaced units from their map and instead create them via triggers in-game. I've also added a Unit Group variable which can be used to add specific units to an ignore group which tells the system not to save them-useful for units that you don't want to delete.
You would really only want to do this once you're done placing units in your map, although it could come in handy during the development process if your loading times are a pain. I've seen a lot of maps that have 1000's of preplaced units and I imagine this could help.
The pros:
- Improved World Editor performance.
- Improved load times.
- Any other preset data like Dropped Items, % Life, % Mana, Level, Abilities, etc. won't be saved. I suppose some of these things could be added in the future if people actually wanted it.
- Triggers that reference preplaced units won't work anymore BUT you could use the ignore unit group to get around this.
- You'll want to have backup versions of your map with all of the units still preplaced. Don't misunderstand how this works, it can't paste the units back into the editor after saving/closing the map.
vJASS:
function StorePreplacedUnitsCallback takes nothing returns nothing
local unit u = GetEnumUnit()
local integer unitid = GetUnitTypeId(u)
local integer id = GetPlayerId(GetOwningPlayer(u))
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real face = GetUnitFacing(u)
if IsUnitInGroup(u, udg_SPU_Ignore) == false then
call Preload("call CreateUnit(Player(" + I2S(id) + "), " + I2S(unitid) + ", " + R2S(x) + ", " + R2S(y) + ", " + R2S(face) + ")")
endif
set u = null
endfunction
function StorePreplacedUnits takes nothing returns nothing
local group g = GetUnitsInRectAll(GetEntireMapRect())
call PreloadGenClear()
call PreloadGenStart()
call ForGroup(g, function StorePreplacedUnitsCallback)
call PreloadGenEnd("StorePreplacedUnits.txt")
call DestroyGroup(g)
call DestroyGroup(udg_SPU_Ignore)
set g = null
endfunction
HOW TO USE:
Step 1: Open your map and copy and paste the above Jass code into a new script. Then call the StorePreplacedUnits() function in one of your triggers. This function will save all of your preplaced units once it runs.
Step 2: Launch your map and allow the function to run and then quit the game. The units will have been saved in a .txt file located at: C:\Users\Profile\Documents\Warcraft III\CustomMapData. Then open this newly created StorePreplacedUnits.txt file and copy it's entire contents.
Step 3: Run the Preplaced Units Formatter.app and follow the instructions. You may have to hit Enter twice despite what the instructions say.
This app formats the save file into a usable Jass function.
Step 4: Copy the now properly formatted code and paste it into a new script. You now have access to a function that will create all of your preplaced units.
Step 5: Now you can delete any preplaced units from your map and instead create them in-game by calling the CreatePreplacedUnits() function.
---
So this is my first time "making an app" and I have no idea if you can use the attached Preplaced Units Formatter app without extra file(s) or the correct .Net framework installed. It was created as a C# Console App in Visual Studio and published using .Net Core 3.1.
Attachments
Last edited: