Re: Journeywar
Posted: 02 Jul 2012, 17:24
But what is its purpose?
It does not give a number, not give you a unit? What is it?Error: why are you using CNullUnitScript anyway?
[f=0008200] Error: Invalid piecenumber
Code: Select all
function gadget:GetInfo()
return {
name = "WaterLevelManager",
desc = "Recives the terraFormInformation. applies the actuall terraforming, informs Units about the currentWaterLevelOffset",
author = "PicassoCT",
date = "7 b.Creation",
license = "GNU GPL, v2 its goes in all fields",
layer = 0,
enabled = true -- loaded by default?
}
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- synced only
if (gadgetHandler:IsSyncedCode()) then
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
--various Tools
--function validates Unit Table
function validateUnitTable(tableToValidate)
x=table.getn(tableToValidate)
for i=1,x,1 do
if Spring.ValidUnitID((tableToValidate[i][1]))~= true then
table.remove(tableToValidate,i)
x=x-1
i=i-1
end
end
return tableToValidate
end
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
local boolGameIsNotOver=true
local gWaterOffSet=0 --global WaterOffset
local UPDATE_FREQUNECY=4200
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
boolFirst=true
--Table contains all the WaterLevelChanging Units
local WaterLevelChangingUnitsTable={}
--Table contains all Units who perform Terraforming - and thus need to be informed of rising waterLevels
local LandLordTable={}
local TerrainMapWorkingCopy={}
local orgTerrainMap={}
GG.addWaterLevel = 0
GG.subWaterLevel = 0
--function collects the stored changedate from the WaterLevelingUnits
function getGlobalOffset()
returnVal=GG.addWaterLevel-GG.subWaterLevel
GG.addWaterLevel=0
GG.subWaterLevel=0
return returnVal
end
--Every unit signs up, is checked for its UnitdefId beeing that of a WaterAdder or a WaterSubstractor
function gadget:UnitCreated(unitID, unitDefID, unitTeam)
if unitDefID==UnitDefNames["cwaterextractor"].id or unitDefID == UnitDefNames["jwatergate"].id then
Spring.Echo("Registrated WaterUnit")
subTable={}
subTable[1]=unitID
subTable[2]=unitDefID
subTable[3]=unitTeam
index=(table.getn(WaterLevelChangingUnitsTable))+1
WaterLevelChangingUnitsTable[index]={}
WaterLevelChangingUnitsTable[index]=subTable
end
if unitDefID==UnitDefNames["mdiggmex"].id or unitDefID == UnitDefNames["jdrilltree"].id then
Spring.Echo("Registrated DigUnit")
subTable={}
subTable[1]=unitID
subTable[2]=unitDefID
subTable[3]=unitTeam
index=(table.getn(LandLordTable))+1
LandLordTable[index]={}
LandLordTable[index]=subTable
end
end
--Creates the original TerrainTable
function forgeFirstTerrainMap()
for out=1,Game.mapSizeX,1 do
SubTable={}
Spring.Echo("Adding to the Max")
for i=1,Game.mapSizeZ,1 do
SubTable[i]=Spring.GetGroundHeight(out,i)
end
orgTerrainMap[out]={}
orgTerrainMap[out]=SubTable
end
assert(orgTerrainMap)
end
--adds the WaterLvl to the heightmap
function computateWaterHeightmap()
TerrainMapWorkingCopy= orgTerrainMap
local WaterOffset= getGlobalOffset()
--assert(TerrainMapWorkingCopy)
--Spring.Echo("Here we go again")
--assert(WaterOffset)
outerLimit=Game.mapSizeX
innerLimit=Game.mapSizeZ
-- Spring.Echo(outerLimit)
--Spring.Echo("the table getn", table.getn(TerrainMapWorkingCopy))
--Spring.Echo(innerLimit)
for out= 1, outerLimit, 1 do
for i= 1, innerLimit, 1 do
TerrainMapWorkingCopy[out][i]=(TerrainMapWorkingCopy[out][i])+ WaterOffset
end
end
end
function applyTerraInform()
if boolFirst == true then
boolFirst=false
orgTerrainMap= forgeFirstTerrainMap()
else
computateWaterHeightmap()
end
if getGlobalOffset ~= 0 then
Spring.SetHeightMapFunc(function()
for z=1,Game.mapSizeZ-1, 1 do
for x=1,Game.mapSizeX-1, 1 do
Spring.SetHeightMap( x, z, TerrainMapWorkingCopy[x][z] )
end
end
end)
end
end
function gadget:GameFrame(f)
if f%UPDATE_FREQUNECY == 0 then
--applyChanges to Map
applyTerraInform(gheightMap)
end
end
end
Code: Select all
for z=1,Game.mapSizeZ-1, 1 do
for x=1,Game.mapSizeX-1, 1 do
Spring.SetHeightMap( x, z,
Code: Select all
for x=0,Game.mapSizeX,8 do
for z=0,Game.mapSizeZ,8 do
Spring.SetHeightMap(x,z,
Code: Select all
--Creates the original TerrainTable
Code: Select all
TerrainMapWorkingCopy= orgTerrainMap
Good call, did that...zwzsg wrote:No, but I know that:
You could save time and memory by using steps of 8 in loops dealing with heighmap:Code: Select all
for z=1,Game.mapSizeZ-1, 1 do for x=1,Game.mapSizeX-1, 1 do Spring.SetHeightMap( x, z,
Code: Select all
for x=0,Game.mapSizeX,8 do for z=0,Game.mapSizeZ,8 do Spring.SetHeightMap(x,z,
Problem is that i dont want to flood the engine with calls every half minute (i allready do once i start terraformin), so i just get the heightmap once, and then add to a copy of the org (+ waterheightmap)+calced in heightmapchanges by the miningunits) and that should be expensive enoughzwzsg wrote:What's wrong with using Spring.GetGroundOrigHeight ?Code: Select all
--Creates the original TerrainTable
Code: Select all
TerrainMapWorkingCopy= orgTerrainMap
Code: Select all
function table.copy(t)
local t2 = {}
for k,v in pairs(t) do
t2[k] = v
end
return t2
end
Snowmobiles run on tracks and the Old, Homebrew or specialty ones tend to look pretty frail.PicassoCT wrote:Im searching for something paradox.. im searching for maschinery on tracks, which looks frail, and im searching for a unique setup for this tracked maschinery. If you have something inspiring and want to share.. post it. Even just unique shapes watched from above..
frankly i tried everything for a weekend now, and im all out of ammo.