https://code.google.com/p/evolutionrts/ ... etail?id=8
^^ just the issue tracker
https://code.google.com/p/evolutionrts/ ... i_Tech.lua
^^ the file in question
Ok, what is going on is...
The above file is the tech gadget that evo uses. It was written by zwzsg. It is meant to function as as gateway to use almost any type of teching system. In particular, evo uses the ranged system.
Now, the problem is in the checks. When the checks are run to see if a command is valid, it gets the position of the builder, meaning that the builder must be in range of the tech source in order for the unit to be be built.
What I want to do is either get the position of the mouse cursor or where the order is given via click (in other words, I click a unit on the build menu, and try to build it at a location. The script checks that position to see if there is power there, returns with yes or no.).
The check starts on line 507.
Lines 899 and 904 are relevant as well.
Please help?
Need some help with a bug
Moderator: Moderators
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Need some help with a bug
If the command ID is less than zero then it is a building, at which point the command parameters would be be {x, y, z, facing}. So to use the building position rather than builder position when checking tech requirements of buildings you would use something like this:
Disclaimer: I didn't read any other parts of the gadget.
Code: Select all
function gadget:AllowCommand(u,ud,team,cmd,param,opt,synced)
if cmd < 0 then
return CheckCmd(cmd, team, param[1], param[2], param[3])
else
return CheckCmd(cmd, team, Spring.GetUnitPosition(u))
end
end
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Need some help with a bug
Cool thanks 
One small issue. While I understand what you said, I have no idea how to implement that into this gadget. The checking portion of it looks like a bunch of gobbledegook to me.
Care to explain it as though you're talking to a 5th grader?

One small issue. While I understand what you said, I have no idea how to implement that into this gadget. The checking portion of it looks like a bunch of gobbledegook to me.
Care to explain it as though you're talking to a 5th grader?
Re: Need some help with a bug
I understand that like you want a better preview if building is possible or not?What I want to do is either get the position of the mouse cursor or where the order is given via click (in other words, I click a unit on the build menu, and try to build it at a location. The script checks that position to see if there is power there, returns with yes or no.).
Like in the C&C example.

Anyway, I wanted to do something similiar, first step was to see what unit the player has selected for placing and where he is trying to do that:
Code: Select all
function widget:GameFrame (f)
local index,cmd_id, cmd_type, cmd_name = Spring.GetActiveCommand ()
if (cmd_id and cmd_id > 0) then return end -- < 0 means building something, >0 is move,patrol etc cmd_id=-unitdefif (???)
if (cmd_name) then
local x,z = getCursorWorldCoord()
Spring.Echo ("trying to place a " .. cmd_name .." at " .. math.floor(x) .. ":" .. math.floor(z))
end
end
function getCursorWorldCoord ()
local mx,my = Spring.GetMouseState()
local _,pos = Spring.TraceScreenRay(mx,my,true)
if (pos~=nil) then return pos[1],pos[3] end --[1] = number x, [2] = number y, [3] = number z
end
It should spam you with "trying to place arm_mex at 456:3549" etc.
AllowCommand will not work for this I think because the command is not yet actually given the unit.
Now just needs something like
if canBuildHere (x,z) then drawOKgraphic
else
drawDENIEDgraphic
end
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Need some help with a bug
No knorke, I don't want to change the visuals. The visuals are fine. I want to change the location of where the check is being done.
I figured that if it wasn't possible in the statement I could just play a sound and an echo "You needs moa powah!" or summat.
I figured that if it wasn't possible in the statement I could just play a sound and an echo "You needs moa powah!" or summat.
Last edited by Forboding Angel on 30 Jun 2011, 01:21, edited 1 time in total.
Re: Need some help with a bug
well, you still need to get what&where the player is currently trying to place. this allows for that.
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Need some help with a bug
Oops, I'm sorry, I didn't realize what I was looking at. my bad 

Re: Need some help with a bug
Try replacing AllowCommand by:
Warning: I wrote that gadget long ago, and am not in the mood to go back deeply go into it. So it's likely that I am NOW thinking much much less clearly than THEN. No guarantee that this won't introduce nasty side effect or plain not work right.
Though somewhat reassuring is that Niobium came up with nearly the same answer as me, independantly.
Edit: My way to check that a command pass location for parameter is pretty poor:
- At least theorically, there could be commands with 3 parameters where those 3 parameters are not locations.
- Reading Niob post, I see: {x, y, z, facing}
Note to Niobium: My tech gadget may be used to limit not only build commands, but any commands.
So I suggest using "if param and (#param==3 or (cmd<0 and #param==4)) then".
I just realised that some commands can be issued over a disk, or over a rectangle. And testing just the corners or center won't do in all case. Argh!
Oh wait, for stuff like a turret needing tech to fire, you want to check the turret is powered, not the target! So use:
if param and cmd<0 and #param==4 then
Code: Select all
function gadget:AllowCommand(u,ud,team,cmd,param,opt,synced)
if param and #param==3 then
return CheckCmd(cmd,team,param[1],param[2],param[3])
else
return CheckCmd(cmd,team,Spring.GetUnitPosition(u))
end
end
Though somewhat reassuring is that Niobium came up with nearly the same answer as me, independantly.
Edit: My way to check that a command pass location for parameter is pretty poor:
- At least theorically, there could be commands with 3 parameters where those 3 parameters are not locations.
- Reading Niob post, I see: {x, y, z, facing}
Note to Niobium: My tech gadget may be used to limit not only build commands, but any commands.
So I suggest using "if param and (#param==3 or (cmd<0 and #param==4)) then".
I just realised that some commands can be issued over a disk, or over a rectangle. And testing just the corners or center won't do in all case. Argh!
Oh wait, for stuff like a turret needing tech to fire, you want to check the turret is powered, not the target! So use:
if param and cmd<0 and #param==4 then
- Forboding Angel
- Evolution RTS Developer
- Posts: 14673
- Joined: 17 Nov 2005, 02:43
Re: Need some help with a bug
Giant thanks to everyone that helped out. An z, I cannot thank you enough. This issue has been a pretty big complaint from players, and it is a massive relief to have it solved.
Knorke, nio, lurker, thank you guys for helping me out, I appreciate it more than I can express. And of course, thank you, Z, for telling me how to fix it
Knorke, nio, lurker, thank you guys for helping me out, I appreciate it more than I can express. And of course, thank you, Z, for telling me how to fix it
