unbuildable areas?

unbuildable areas?

Discuss maps & map creation - from concept to execution to the ever elusive release.

Moderator: Moderators

Post Reply
User avatar
zoggop
Posts: 289
Joined: 07 Sep 2010, 18:47

unbuildable areas?

Post by zoggop »

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?
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: unbuildable areas?

Post by smoth »

lua to block commands in an area.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: unbuildable areas?

Post by knorke »

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: Select all

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.
User avatar
Johannes
Posts: 1265
Joined: 17 Sep 2010, 15:49

Re: unbuildable areas?

Post by Johannes »

Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: unbuildable areas?

Post by knorke »

iirc building-blocking features block movement as well.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: unbuildable areas?

Post by smoth »

Johannes wrote:Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
sure it is.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: unbuildable areas?

Post by Google_Frog »

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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: unbuildable areas?

Post by knorke »

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---
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.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: unbuildable areas?

Post by smoth »

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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: unbuildable areas?

Post by knorke »

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?
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)
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: unbuildable areas?

Post by smoth »

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:
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.
User avatar
zoggop
Posts: 289
Joined: 07 Sep 2010, 18:47

Re: unbuildable areas?

Post by zoggop »

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.
Post Reply

Return to “Map Creation”