unbuildable areas?
Moderator: Moderators
unbuildable areas?
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?
Re: unbuildable areas?
lua to block commands in an area.
Re: unbuildable areas?
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)
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.
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
AIs will just be confused anyway.
Re: unbuildable areas?
Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
Re: unbuildable areas?
iirc building-blocking features block movement as well.
Re: unbuildable areas?
sure it is.Johannes wrote:Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
-
- Moderator
- Posts: 2464
- Joined: 12 Oct 2007, 09:24
Re: unbuildable areas?
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.
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.
Re: unbuildable areas?
if (not builderID) then return true end --no builder -> morph or something like thatGoogle_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.
With that, at least XTA commander upgrading/morphing works.
how?smoth wrote:sure it is.Johannes wrote:Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
---tl;dr rant---
That would be better for many map-gadgets but it is not going to happen.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.
For example reload bars in zeroK going bogus on the map where you can only attack after a countdown:

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.
Re: unbuildable areas?
knorke wrote:how?smoth wrote:sure it is.Johannes wrote:Is it easily possible to have unreclaimable, indestructible features that don't block shots or movement, but block buildings?
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.
Re: unbuildable areas?
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?
The map Arctic Inferno.sd7 does that btw. (only allow commands in the circular area, would be easy to only block building)
if you do this, you do not need features.some kind of lua check if commands can be issued in area
The map Arctic Inferno.sd7 does that btw. (only allow commands in the circular area, would be easy to only block building)
Re: unbuildable areas?
it does.. but he asked if features could, they can with some lua trickery.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?
but the point was to have the feature control it unless I misread his question.knorke wrote:if you do this, you do not need features.some kind of lua check if commands can be issued in area
The map Arctic Inferno.sd7 does that btw. (only allow commands in the circular area, would be easy to only block building)
Re: unbuildable areas?
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.