-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deploy units that are built without a factory.
- Loading branch information
1 parent
b7af912
commit 015f7b8
Showing
1 changed file
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
|
||
function gadget:GetInfo() | ||
return { | ||
name = "Nano Frame Death Handeling", | ||
desc = "Makes nanoframes explode if above X% completion and makes dying nanoframes leave wrecks.", | ||
name = "Nano Frame Death and Factoryless Deployment", | ||
desc = "Makes nanoframes explode if above X% completion and makes dying nanoframes leave wrecks. Causes units built without a factory to deploy properly.", | ||
author = "Google Frog", | ||
date = "Mar 29, 2009", | ||
license = "GNU GPL, v2 or later", | ||
|
@@ -35,6 +35,7 @@ local spCreateFeature = Spring.CreateFeature | |
|
||
local unitFromFactory = {} | ||
local isAFactory = {} | ||
local needDeployUnit = {} | ||
|
||
function gadget:UnitCreated(unitID,unitDefID,_,builderID) | ||
local ud = UnitDefs[unitDefID] | ||
|
@@ -43,6 +44,8 @@ function gadget:UnitCreated(unitID,unitDefID,_,builderID) | |
end | ||
if builderID and isAFactory[builderID] then | ||
unitFromFactory[unitID] = true | ||
elseif (not ud.isImmobile) or ud.customParams.mobilebuilding then | ||
needDeployUnit[unitID] = true | ||
end | ||
end | ||
|
||
|
@@ -86,6 +89,17 @@ local function ScrapUnit(unitID, unitDefID, team, progress, face) | |
end | ||
end | ||
|
||
function gadget:UnitFinished(unitID, unitDefID, teamID, builderID) | ||
if needDeployUnit[unitID] then | ||
local env = Spring.UnitScript.GetScriptEnv(unitID) | ||
if env and env.script.StopMoving then | ||
Spring.UnitScript.CallAsUnit(unitID,env.script.StopMoving) | ||
elseif env and env.StopMoving then | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
GoogleFrog
Author
Contributor
|
||
Spring.UnitScript.CallAsUnit(unitID,env.StopMoving) | ||
end | ||
end | ||
end | ||
|
||
local spawnProjPos = {1, 2, 3} | ||
local spawnProjTable = {ttl = 1, pos = spawnProjPos} | ||
function gadget:UnitDestroyed(unitID, unitDefID, unitTeam) | ||
|
@@ -122,6 +136,7 @@ function gadget:UnitDestroyed(unitID, unitDefID, unitTeam) | |
|
||
isAFactory[unitID] = nil | ||
unitFromFactory[unitID] = nil | ||
needDeployUnit[unitID] = nil | ||
end | ||
|
||
function gadget:Initialize() | ||
|
2 comments
on commit 015f7b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This had to be the least obvious gadget to put this in.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it was the smallest change.
StopMoving
directly within env instead of in thescript
subtable sounds like it would be a bug or at least bad code if any unit had it.