Re: Checking when a unit is near or in a feature.
Posted: 15 May 2011, 23:54
Oh ok, yeah that works 

Open Source Realtime Strategy Game Engine
https://springrts.com/phpbb/
Code: Select all
for name, fd in pairs(FeatureDefs) do
if (string.find(name, "ad0_bushes")) then
if (not fd.customParams) then fd.customParams = {} end
fd.blocking = false
if (not fd.customParams.provide_cover) then
fd.customParams.provide_cover = 1
end
end
end
Well, it was not meant to be used by players at all.Only request I have left is that the visuals of the cells be sped up.
Code: Select all
for name, fd in pairs(FeatureDefs) do
if(tonumber(fd["footprintz"]) <= 2 or tonumber(fd["footprintx"]) <= 2
or string.lower(fd["category"]) == "vegitation" or string.lower(fd["category"]) == "vegetation") then
fd["blocking"] = false
if (not fd.customparams) then
fd.customparams = {}
end
if (not fd.customparams.provide_cover) then
fd.customparams.provide_cover = 1
Spring.Echo("Feature["..name.."] is providing cover!")
end
end
end
Code: Select all
for name, fd in pairs(FeatureDefs) do
if(
(
tonumber(fd["footprintz"]) <= 2
or tonumber(fd["footprintx"]) <= 2
or string.lower(fd["category"]) == "vegitation"
or string.lower(fd["category"]) == "vegetation"
)
and (not fd["name"] or string.lower(fd["name"]) ~= "ammobox")
) then
fd["blocking"] = false
if (not fd.customparams) then
fd.customparams = {}
end
if (not fd.customparams.provide_cover) then
fd.customparams.provide_cover = 1
-- Spring.Echo("Feature["..name.."] is providing cover!")
end
end
end
possible but cant see how it would cause an error.I believe it was caused by my ammobox feature that is spawned when a unit dies, and is destroyed when an engineer gets near it (destroyed and turned into resource income or a drone depending on what gets near it).
Code: Select all
function getcover (x,z)
local tx, tz = tcoord (x,z)
return cover[tx][tz] or 0
end
Also, wrt:[09:32:21] <[Evo]Forboding_Angel> can someone help me with a bit of lua logic?
[09:32:26] <[Evo]Forboding_Angel> basically the deal is
[09:32:39] <[Evo]Forboding_Angel> sometimes a value is coming back as nil
[09:32:41] <[Evo]Forboding_Angel> which is fine
[09:32:59] <[Evo]Forboding_Angel> because the things that are returning nil don't matter anyway
[09:33:10] <[Evo]Forboding_Angel> however
[09:33:14] <[Evo]Forboding_Angel> function getcover (x,z)
[09:33:14] <[Evo]Forboding_Angel> local tx, tz = tcoord (x,z)
[09:33:14] <[Evo]Forboding_Angel> return cover[tx][tz] or 0
[09:33:14] <[Evo]Forboding_Angel> end
[09:33:25] <[Evo]Forboding_Angel> ^^ this function is still causing an error report
[09:33:43] <[LCC]jK> tx & tz have to be clamped
[09:33:46] <[Evo]Forboding_Angel> can I sinply add "or nil: to line 3?
[09:34:00] <[Evo]Forboding_Angel> I don't understand what clamed means
[09:34:09] <[Evo]Forboding_Angel> clamped*
[09:34:53] <[LCC]jK> clamp = min(max())
[09:35:20] <[LCC]jK> http://en.wikipedia.org/wiki/Clamping_(graphics)
[09:35:41] <[Evo]Forboding_Angel> so you're saying that essentially a minimum and maximum possible value for them needs to be set
[09:35:48] <[Evo]Forboding_Angel> am I reading that correctly?
[09:35:51] <[LCC]jK> yup
[09:36:23] <[Evo]Forboding_Angel> umm
[09:36:55] <[Evo]Forboding_Angel> any chance you would care to help me with that? I don't entirely understand how to do that and I'm guessing that this little snippet of code is not enough
[09:37:05] <[LCC]jK> there is also a faster way/better way in lua iva metatables, but don't think you would be able to implement that
[09:37:24] <[Evo]Forboding_Angel> function tcoord (x,z)
[09:37:25] <[Evo]Forboding_Angel> tx=math.floor ((x/resolution)+0.5)
[09:37:25] <[Evo]Forboding_Angel> tz=math.floor ((z/resolution)+0.5)
[09:37:25] <[Evo]Forboding_Angel> return tx,tz
[09:37:25] <[Evo]Forboding_Angel> end
[09:37:41] <[LCC]jK> no clamping in there
[09:37:43] <[Evo]Forboding_Angel> ehh nm that snip
[09:37:48] <[LCC]jK> so clamp it
[09:38:07] <[Evo]Forboding_Angel> I don't understand what is happening tho
[09:38:24] <[Evo]Forboding_Angel> is it referring to a section of the map?
[09:38:28] <[Evo]Forboding_Angel> well
[09:38:29] <[Evo]Forboding_Angel> sec
[09:38:36] <[Evo]Forboding_Angel> lemmie pastebin gadget for perspective
[09:38:48] <[LCC]jK> it splits the map into a grid and returning the indices of a square in that grid for any map coord
[09:39:01] <[Evo]Forboding_Angel> http://pastebin.com/T5RMNJcU
[09:39:03] <[Evo]Forboding_Angel> Aha
[09:39:12] <[LCC]jK> still it doesn't handle out of map coords, so you need to clamp it
[09:39:13] <[Evo]Forboding_Angel> so it IS referring to a map area
[09:39:29] <[Evo]Forboding_Angel> ohhh
[09:39:39] <[LCC]jK> hmm clamping might not always the best idea
[09:39:47] <[Evo]Forboding_Angel> I think I know why it's happening... features on the edge of the map
[09:39:58] <[Evo]Forboding_Angel> causing the reported area to be "out of bounds"
[09:40:04] <[LCC]jK> better detect out of map situations and handle them seperate
[09:40:43] <[LCC]jK> not only features, units too
[09:40:45] <[Evo]Forboding_Angel> which just put this out of my ability :-/
[09:40:47] <[Evo]Forboding_Angel> damn
[09:40:56] <[Evo]Forboding_Angel> oh well, I'll wait for knorke
[09:41:08] <[Evo]Forboding_Angel> I was hoping for a simple fix
knorke wrote:Thats why it said "for testing only" in the file comment.
infolog wrote:[f=0000000] Using mod Evolution RTS - test-131
possible, just did not think about it yet.It would be neat if aircraft could be covered only when landed