With Lua, is it feasible for...

With Lua, is it feasible for...

Requests for features in the spring code.

Moderator: Moderators

Post Reply
User avatar
Noruas
XTA Developer
Posts: 1269
Joined: 24 Feb 2005, 02:58

With Lua, is it feasible for...

Post by Noruas »

Well i looked at some old ta stuff, and found the hydration plant, that creates water, and i thought to myself, if you pay a krogoth sum for this, and it creates water as description, it can change a land map into a sea map by 1 terrain lowered or water level by one, and destroys disables all land units as a unique end gamer.
So in otherwords, without causing too much strain on pc, is it feasible for every 30 seconds, the water level raises by 1, till completely submerged (detect max height of map) as a unique end gamer unit style as to *drown them all out* because id love to test that out.
User avatar
Guessmyname
Posts: 3301
Joined: 28 Apr 2005, 21:07

Re: With Lua, is it feasible for...

Post by Guessmyname »

Hmm. Anyone else forseeing issues with pre-existing floating structures?
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: With Lua, is it feasible for...

Post by Argh »

It is perfectly possible to manipulate the heightmap to create the effect desired. However:

1. I may be wrong, but the only method I know of to do this is very computationally expensive. You can't just raise the water level- you'd have to drop the land-level. Not the same thing at all. Now, if the water-level variable was accessible via Lua, it'd be pretty cheap to do it that way. Doing it with the heightmap-adjustment method would be incredibly expensive, and would have to be spaced out over a number of frames to prevent severe problems.

It can be done, but it'd have to be quite slowly done- probably several seconds for a single adjustment over a whole map. Maybe I should write some code to do this, I have just about everything needed to do this kind of work in World Builder already.

2. I don't think that floating stuff would adjust to the method of changing the water level- I think their height is set when created, and doesn't change after that.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: With Lua, is it feasible for...

Post by lurker »

Changing the water level would break a lot of things all over. It's not that bad to change the land height if it's a slow effect.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Re: With Lua, is it feasible for...

Post by trepan »

The original post contained some performance numbers,
and even a suggested method for your request (segmented changes).

viewtopic.php?p=172300#p172300
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: With Lua, is it feasible for...

Post by Argh »

Yeah, a half-second on that chip means probably around 3/4th second on this rig- far too slow to run in one frame. That said, meh, doing it in stages, a few thousand heightmap pixels at a time, is no biggie.
Ships get stuck when they try to go over an area that was formerly land. You can still drive them around in FPS mode, and it looks like they should be able to go through the area using F2 view, but they still get stuck once they stop moving and don't respond to orders.
This testing result indicates that the pathfinder for ships is not seeing changes made to the heightmap (big surprise there, since this was probably never envisioned). Meh, I'll test this, but I strongly suspect this problem still exists, so this may trap land-units, but it may not result in proper functionality overall.
User avatar
SwiftSpear
Classic Community Lead
Posts: 7287
Joined: 12 Aug 2005, 09:29

Re: With Lua, is it feasible for...

Post by SwiftSpear »

I don't see why you think raising the water level would be less expensive than lowering the ground level. The computer doesn't know the difference between the two anyways, and you still need all the code to ratify whatever change is being made physically to the units and structures that will be effected by that change.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: With Lua, is it feasible for...

Post by lurker »

Well, you wouldn't have to update the entire LOS map. The rest of the load would stay the same.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Re: With Lua, is it feasible for...

Post by KDR_11k »

SwiftSpear wrote:I don't see why you think raising the water level would be less expensive than lowering the ground level. The computer doesn't know the difference between the two anyways, and you still need all the code to ratify whatever change is being made physically to the units and structures that will be effected by that change.
Um, changing the water level (if it wasn't hardcoded) would just be changing one value while changing the whole terrain requires changing a value for each terrain spot (128*mapSizeX*128*mapSizeZ spots IIRC, about 4 million on a 16x16 map). The units affected are capped at 10000.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: With Lua, is it feasible for...

Post by lurker »

But changing the water level means recoding every bit of code that checks if something is underwater. And you still have to repath.
User avatar
quantum
Posts: 590
Joined: 19 Sep 2006, 22:48

Re: With Lua, is it feasible for...

Post by quantum »

Slowly adjusting the height map in order to avoid pauses makes the terrain entirely unpassable for some reason.

Here is the unfinished gadget:

Code: Select all

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function gadget:GetInfo()
  return {
    name      = "Random Terrain",
    desc      = "Randomizes the heightmap",
    author    = "quantum",
    date      = "April 28, 2008",
    license   = "GNU GPL, v2 or later",
    layer     = 0,
    enabled   = false  --  loaded by default?
  }
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

if (not gadgetHandler:IsSyncedCode()) then
  return false  --  no unsynced code
end

-- Spring.AdjustHeightMap
-- Game.mapSizeX
-- Game.mapSizeZ

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


local Spring = Spring
local Game = Game
local math = math
local table = table
local coroutine = coroutine

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

local function MakeTerrain()
  local separation = 8*4*4
  local minY = 0
  local maxY = 1000
  local adjustment = 0
  local offset = 0
  for i=0, 0 do
    for x=0, Game.mapSizeX/separation do
      local xs = x*separation+offset
      for z=0, Game.mapSizeZ/separation do 
        local zs = z*separation+offset
        local y = 100
        Spring.AdjustHeightMap(xs, zs, xs+separation+adjustment, zs+separation+adjustment, y)
      end
      coroutine.yield()
    end
  end
end

local co = coroutine.create(MakeTerrain)

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------

function gadget:GameFrame(n)
  coroutine.resume(co)
end

--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: With Lua, is it feasible for...

Post by CarRepairer »

Reminds me of Worms: World Party when the game goes into sudden death mode and the water starts rising, worms near the bottom drown.
User avatar
LordMatt
Posts: 3393
Joined: 15 May 2005, 04:26

Re: With Lua, is it feasible for...

Post by LordMatt »

lol I remember worms.
User avatar
Zoy64
Posts: 454
Joined: 12 Nov 2006, 00:30

Re: With Lua, is it feasible for...

Post by Zoy64 »

the Sega dreamcast version was fun...
Post Reply

Return to “Feature Requests”