Hi,
I have this real annoying problem that is driving me crazy. Hopefully someone here can help me out with it.
My Objective:
I'm trying to reset my map so that it looks exactly as it did when it was first initialized.
The Problem:
Everything works fine when I reset the map for other races. The only race it breaks for is Zerg. It pushes the mineral patches past the creep, and it won't spawn 3 larvae on the hatcheries; even with it being scripted to do so. It's driving me CRAZY! |
I originally tried this with the Data Table, and it worked brilliantly for all races. The only problem was that the Data Table refers to the actual starting units, it doesn't make copies, so when they were killed they couldn't be restored.
I've used debug output to verify that the coordinates are not changing when the items are stored versus restored. I think there is something wrong with the restore function, because with the Data Table I had to explicitly use the create function to make the units and had no problems.
Look at how the creep pushes the mineral patches out of place on Xel'Naga -
My Approach:
Rematch Detected
Melee Initialization
Store Initial Game Units()
Restore Initial Game Units(integer)
I have this real annoying problem that is driving me crazy. Hopefully someone here can help me out with it.
My Objective:
I'm trying to reset my map so that it looks exactly as it did when it was first initialized.
The Problem:
Everything works fine when I reset the map for other races. The only race it breaks for is Zerg. It pushes the mineral patches past the creep, and it won't spawn 3 larvae on the hatcheries; even with it being scripted to do so. It's driving me CRAZY! |
I originally tried this with the Data Table, and it worked brilliantly for all races. The only problem was that the Data Table refers to the actual starting units, it doesn't make copies, so when they were killed they couldn't be restored.
I've used debug output to verify that the coordinates are not changing when the items are stored versus restored. I think there is something wrong with the restore function, because with the Data Table I had to explicitly use the create function to make the units and had no problems.
Look at how the creep pushes the mineral patches out of place on Xel'Naga -
My Approach:
Rematch Detected
Code:
Trigger - Clear the action queue (Clear the active action)
Game - Clear Game Data() - [i]This function will kill and then remove every unit in the game.[/i]
Trigger - Run Melee Initialization (Ignore Conditions, Wait until it finishes)
Melee Initialization
Code:
General - If (Conditions) then do (Actions) else do (Actions)
If
g_NumberOfStartingUnits == 0
Then
Game - Preload Assets()
Variable - Set g_NumberOfStartingUnits = (Store Initial Game Units())
Else
Game - Restore Initial Game Units(g_NumberOfStartingUnits)
Melee - Create melee starting units for all players
Melee - Start the melee AI for all computer players
Melee - Set melee starting resources for all players
Melee - Set default melee options for all players
Store Initial Game Units()
Code:
General - If (Conditions) then do (Actions) else do (Actions)
If
g_StartingUnitsBank == No Bank
Then
Bank - Preload and synchronize bank "StartingUnitsBank" for player 1
Bank - Open bank "StartingUnitsBank" for player 1
Variable - Set g_StartingUnitsBank = (Last opened bank)
Else
Unit Group - For each unit unit_Index in EveryUnitOnMap do (Actions)
Actions
Variable - Set unit_Position = (Position of unit_Index)
Variable - Set unit_owner = (Owner of unit_Index)
Variable - Set unit_Facing = (Facing of unit_Index)
Bank - Store unit unit_Index as (unitKey + (String(numberOfUnits))) of section unitKey in bank g_StartingUnitsBank
Bank - Store point unit_Position as (unitKey + (String(numberOfUnits))) of section positionKey in bank g_StartingUnitsBank
Bank - Store real unit_Facing as (unitKey + (String(numberOfUnits))) of section facingKey in bank g_StartingUnitsBank
Bank - Store integer unit_owner as (unitKey + (String(numberOfUnits))) of section ownerKey in bank g_StartingUnitsBank
Variable - Modify numberOfUnits: + 1
General - Return numberOfUnits
Restore Initial Game Units(integer)
Code:
General - For each integer unitNumber from 0 to (numberOfUnits - 1) with increment 1, do (Actions)
Actions
Variable - Set unit_Position = (Load (unitKey + (String(unitNumber))) of section positionKey from bank g_StartingUnitsBank as point value)
Variable - Set unit_Facing = (Load (unitKey + (String(unitNumber))) of section facingKey from bank g_StartingUnitsBank as real value)
Variable - Set unit_owner = (Load (unitKey + (String(unitNumber))) of section ownerKey from bank g_StartingUnitsBank as integer value)
Bank - Restore (unitKey + (String(unitNumber))) of section unitKey from bank g_StartingUnitsBank for player unit_owner at unit_Position facing unit_Facing
Variable - Set unit_Index = (Last restored unit)
General - If (Conditions) then do (Actions) else do (Actions)
If
(Unit type of unit_Index) == Hatchery
Then
Unit - Add 3 Hatchery - Spawn Mutant Larva to (Last created unit) from player unit_owner
Else