View topic - unbuildable areas?



All times are UTC + 1 hour


Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: unbuildable areas?
PostPosted: 25 Jan 2012, 05:24 
User avatar

Joined: 07 Sep 2010, 17:47
Anyone know if it's possible to make an area of the map unbuildable by means other than inundating it with water or making it too bumpy to build on?


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 06:06 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
lua to block commands in an area.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 06:08 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
example:
Map with a city where you can not build stuff inside the city (such as on the roads) but on some special places inside the city you can build. (such as on the market place)
Code:
function gadget:GetInfo()
  return {
    name      = "do not build on roads",
    desc      = "no you cant have",
    author    = "horse",
    date      = "2011",
    license   = "knorke",
    layer     = -3,
    enabled   = true
   }
end

local forbiddenCity = {x1=521 , z1=523 , x2=4569 , z2=3027}
local allowRects = {}
allowRects[1] = {x1=1028 , z1=1029 , x2=1530 , z2=1534}   -- pimple hill
allowRects[2] = {x1=1978 , z1=1980 , x2=2614 , z2=2606} -- market square
allowRects[3] = {x1=2052 , z1=517 , x2=2560 , z2=1529}    -- | shaped hill at top
allowRects[4] = {x1=514 , z1=2106 , x2=1502 , z2=3028}  -- left down area
allowRects[5] = {x1=3591 , z1=535 , x2=4592 , z2=2042}   -- top right area

function gadget:AllowUnitCreation(unitDefID, builderID, builderTeam, x, y, z)
   if (not x or not y or not z) then return true end --no x,y,z for units from factory
   if (not builderID) then return true end   --no builder -> morph or something like that
   if (not isInRect (x,z, forbiddenCity)) then return true end
   for i = 1, #allowRects do
      if (isInRect (x,z, allowRects[i])) then
         --Spring.Echo ("allowed by " .. i)
         return true
      end
   end
   return false   
end

function isInRect (x,z, rect)
   if (x < rect.x1) then return false end
   if (x > rect.x2) then return false end
   if (z < rect.z1) then return false end
   if (z > rect.z2) then return false end
   return true
end

I hope in my case it will be obvious by the map design but generally you might want something to tell players that they can not build there, before they gave the build order.
AIs will just be confused anyway.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 07:04 
User avatar

Joined: 17 Sep 2010, 14:49
Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 07:06 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
iirc building-blocking features block movement as well.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 07:15 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
Johannes wrote:
Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
sure it is.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 10:25 
Moderator

Joined: 12 Oct 2007, 08:24
This kind of thing should be implemented with an agreed upon interface between maps and games that wish to implement unbuildable areas. knorke's gadget does work but will break many games. I'll provide some examples.

The major and most widely used example is the morph gadget. Many games use morph but if they morph in knorke's unbuildable zone the unit will be destroyed. I'm less familiar with the gadgets of other games but I know a lot of ZK things would break. I'm sure minelayer artillery, carrier drones, terraform, puppies and morph would break.

I like the sound of smoth's solution. A better but more difficult solution would be a gameside version of knorke's gadget which handles game specific exceptions. Maps would then bundle a config that defines unbuildable areas for the game gadget to manage.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 15:46 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
Google_Frog wrote:
The major and most widely used example is the morph gadget. Many games use morph but if they morph in knorke's unbuildable zone the unit will be destroyed.
if (not builderID) then return true end --no builder -> morph or something like that
With that, at least XTA commander upgrading/morphing works.

smoth wrote:
Johannes wrote:
Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
sure it is.
how?

---tl;dr rant---
Quote:
A better but more difficult solution would be a gameside version of knorke's gadget which handles game specific exceptions. Maps would then bundle a config that defines unbuildable areas for the game gadget to manage.
That would be better for many map-gadgets but it is not going to happen.
For example reload bars in zeroK going bogus on the map where you can only attack after a countdown:
Image
All that is needed to fix is the red text:
if (barShader and percent > 0) then
(in mod's hpbars widget)
But instead I was told that using Spring.SetUnitWeaponState to block weapons is not good and instead it is better to return false in AimWeapon of the unitscript. (lol?)
So if adding half a line is too much/not clean/whatever the reason then adding a whole gadget is not going to happen just so that you can make a map where you can not build in the swamp or whatever.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 17:25 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
knorke wrote:
smoth wrote:
Johannes wrote:
Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
sure it is.
how?

unreclaimable - feature tag
indestructable - feature tag or just set gazillion hp, don't remember which
blocking shots/movment - feature tag

block building, build table of features, store the area occupied by the feature as a square based on feature center and footprint. some kind of lua check if commands can be issued in area, had code for it a few years ago for the TD stuff.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 18:00 
Moderator
User avatar

Joined: 22 Feb 2006, 01:02
Location: cheap kitchen
My question was meant to ask what tags you need to make a feature that blocks building but allows unit movement. Because blocking=true blocks both?

Quote:
some kind of lua check if commands can be issued in area
if you do this, you do not need features.
The map Arctic Inferno.sd7 does that btw. (only allow commands in the circular area, would be easy to only block building)


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 18:13 
Content Developer
User avatar

Joined: 13 Jan 2005, 00:46
Location: ModalitÃ
knorke wrote:
My question was meant to ask what tags you need to make a feature that blocks building but allows unit movement. Because blocking=true blocks both?
it does.. but he asked if features could, they can with some lua trickery.

knorke wrote:
Quote:
some kind of lua check if commands can be issued in area
if you do this, you do not need features.
The map Arctic Inferno.sd7 does that btw. (only allow commands in the circular area, would be easy to only block building)
but the point was to have the feature control it unless I misread his question.


Top
 Offline Profile  
 
 Post subject: Re: unbuildable areas?
PostPosted: 25 Jan 2012, 21:40 
User avatar

Joined: 07 Sep 2010, 17:47
Thanks for the gadget and the ideas, but I think I'll just try to make the terrain bumpy enough in the heightmap. Having commands blocked would in this case be pretty confusing for players, I think. Moreover, the area to be blocked is quite irregular. Maybe I could modify the gadget to block build commands based on a typemap. As for blocking features, units definitely need to be able to move over the same terrain on which nothing can be built.


Top
 Offline Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group

Site layout created by Roflcopter et al.