TrinityDeath Posted April 4, 2013 Report Share Posted April 4, 2013 Hi, I'm new to this game.I would like to start participate into 0 A.D. development.I'm going to start with ticket 1848.Wondering if anyone can help on understanding the structure of 0 A.D. development files.I found the fireworldclickevent.I think i might need to find the place where it identifys the selection of a building.anyone could tell me where it is? or give me some suggestions or ideas?thanks in advance 1 Quote Link to comment Share on other sites More sharing options...
Pedro Falcão Posted April 5, 2013 Report Share Posted April 5, 2013 Hi! You can talk directly with the developers here: http://webchat.quakenet.org/There are two channels: #0ad and #0ad-dev . The first is more used to organize multiplayer matches, but i'm sure you can find some programmers there, too. Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 I found the info here quite useful:TDD_Simulation – Wildfire Games Quote Link to comment Share on other sites More sharing options...
madmax Posted April 6, 2013 Report Share Posted April 6, 2013 (edited) So to carry on this discussion CMiniMap::FireWorldClickEvent() seems to be sending a ScriptEvent("worldclick", coords);Where would this event be received in the JS ?------ok its received in gui/session/session.xml and sent to handleMinimapEvent Edited April 6, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
leper Posted April 6, 2013 Report Share Posted April 6, 2013 You should take a look at gui/session/input.js around line 415 (determineAction()).The worldclick is handled in gui/session/session.xml which just calls handleMinimapEvents() in input.js (which is probably where you should start with this ticket). Quote Link to comment Share on other sites More sharing options...
madmax Posted April 7, 2013 Report Share Posted April 7, 2013 (edited) Hmm was looking atfunction determineAction(x, y, fromMinimap)It seems the mouse x, y that gets passed in is undefined.If I right click on the world somewhere then the x, y is passed in correctly so the rally point is set. But if I right click on the minimap then the x,y is undefined. Seems like the code that sets the rally point is not the issue. But the interpretation of the mouse position when right clicked on the minimap is the problem. Edited April 7, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
madmax Posted April 7, 2013 Report Share Posted April 7, 2013 (edited) Hmm so in input.js the code is as follows :function handleMinimapEvent(target){// Partly duplicated from handleInputAfterGui(), but with the input being// world coordinates instead of screen coordinates.if (inputState == INPUT_NORMAL){ var fromMinimap = true; var action = determineAction(undefined, undefined, fromMinimap); if (!action) return false;..............I tried making it :function handleMinimapEvent(target){// Partly duplicated from handleInputAfterGui(), but with the input being// world coordinates instead of screen coordinates.if (inputState == INPUT_NORMAL){ var fromMinimap = true; var action = determineAction(target.x, target.z, fromMinimap); if (!action) return false;Doesnt seem to work though. I think the call to targets = Engine.PickEntitiesAtPoint(x, y) in determineAction() is the key here. Unless Engine.PickEntitiesAtPoint() gets called and returns valid targets the rally point cant be set. Edited April 7, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
madmax Posted April 9, 2013 Report Share Posted April 9, 2013 (edited) Does anyone know about the various co-ordinates system in use. As far as I can see there are 2 :world-coords : Used to locate entities on the 0ad map, has x,y & zscreen-coords: Only x & y, used to locate mouse pointer, minimap click point etc.So everything is actually fine till :function handleMinimapEvent(target){.....case "set-rallypoint":Engine.PostNetworkCommand({"type": "set-rallypoint", "entities": selection, "x": target.x, "z": target.z});// Display rally point at the new coordinates, to avoid display lagEngine.GuiInterfaceCall("DisplayRallyPoint", {"entities": selection,"x": target.x,"z": target.z});return true;...Also if I understand correctly, void CMiniMap::GetMouseWorldCoordinates(float& x, float& z) will convert the mouse screen-coordinates to the 0ad world coods so the rally point on the terrain can be located ?void CMiniMap::GetMouseWorldCoordinates(float& x, float& z){// Determine X and Z according to proportion of mouse position and minimapCPos mousePos = GetMousePos();float px = (mousePos.x - m_CachedActualSize.left) / m_CachedActualSize.GetWidth();float py = (m_CachedActualSize.bottom - mousePos.y) / m_CachedActualSize.GetHeight();float angle = GetAngle();// Scale world coordinates for shrunken square mapx = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5);z = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5);} Edited April 9, 2013 by madmax Quote Link to comment Share on other sites More sharing options...
wraitii Posted May 5, 2013 Report Share Posted May 5, 2013 There are at least 3 coordinate systems:-World position-"Tile" position (usually world position /4 except Y which if I recall correctly doesn't change), which theoretically shouldn't really be used by simulation code.-screen position.Your assumption seems to be right to me (you can see it's multiplied by Terrain_Tile_Size, which is 4, to go from world to "tile" position)Giving a look at the code, it seems to work properly, and detect the action properly (if I "warn(uneval(action))" right after calling determineaction, I get "set-rallypoint". However apparently the DetermineAction thing expects "GetActionInfo" to return position and tooltip information, which it obviously does not.I suggest you fix the bug in GetActionInfo: it should return more information for set-rallypoint. This should make it work, unless something else goes wrong. Quote Link to comment Share on other sites More sharing options...
TrinityDeath Posted May 22, 2013 Author Report Share Posted May 22, 2013 (edited) hi, guys. sorry. i got some family issues. i started the topic. then i banished XD. sorry about that.and i'm back, i would be pretty much full time working on this topic and the game since i'm going to graduate XD.wondering if anyone made any progress so i could just pick it up and continue to save some time? Edited May 22, 2013 by TrinityDeath Quote Link to comment Share on other sites More sharing options...
TrinityDeath Posted May 22, 2013 Author Report Share Posted May 22, 2013 also..i just made some trial changes in the input.js...my question is..how do I compile it again? i'm using ubuntu...Sorry. this is my first FOSSD project...some of my questions might seem silly >.< Quote Link to comment Share on other sites More sharing options...
zoot Posted May 22, 2013 Report Share Posted May 22, 2013 You don't need to recompile if you only made changes to JS. Quote Link to comment Share on other sites More sharing options...
TrinityDeath Posted May 22, 2013 Author Report Share Posted May 22, 2013 where can i find the method PostNetworkCommandand the implementation for Engine object used in handleMinimapEvent(target)method in input.jsYou don't need to recompile if you only made changes to JS.oh, thanks. XD Quote Link to comment Share on other sites More sharing options...
TrinityDeath Posted May 23, 2013 Author Report Share Posted May 23, 2013 Does anyone know about the various co-ordinates system in use. As far as I can see there are 2 :world-coords : Used to locate entities on the 0ad map, has x,y & zscreen-coords: Only x & y, used to locate mouse pointer, minimap click point etc.So everything is actually fine till :function handleMinimapEvent(target){.....case "set-rallypoint":Engine.PostNetworkCommand({"type": "set-rallypoint", "entities": selection, "x": target.x, "z": target.z});// Display rally point at the new coordinates, to avoid display lagEngine.GuiInterfaceCall("DisplayRallyPoint", {"entities": selection,"x": target.x,"z": target.z});return true;...Also if I understand correctly, void CMiniMap::GetMouseWorldCoordinates(float& x, float& z) will convert the mouse screen-coordinates to the 0ad world coods so the rally point on the terrain can be located ?void CMiniMap::GetMouseWorldCoordinates(float& x, float& z){// Determine X and Z according to proportion of mouse position and minimapCPos mousePos = GetMousePos();float px = (mousePos.x - m_CachedActualSize.left) / m_CachedActualSize.GetWidth();float py = (m_CachedActualSize.bottom - mousePos.y) / m_CachedActualSize.GetHeight();float angle = GetAngle();// Scale world coordinates for shrunken square mapx = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(px-0.5) - sin(angle)*(py-0.5)) + 0.5);z = TERRAIN_TILE_SIZE * m_MapSize * (m_MapScale * (cos(angle)*(py-0.5) + sin(angle)*(px-0.5)) + 0.5);}There are at least 3 coordinate systems:-World position-"Tile" position (usually world position /4 except Y which if I recall correctly doesn't change), which theoretically shouldn't really be used by simulation code.-screen position.Your assumption seems to be right to me (you can see it's multiplied by Terrain_Tile_Size, which is 4, to go from world to "tile" position)Giving a look at the code, it seems to work properly, and detect the action properly (if I "warn(uneval(action))" right after calling determineaction, I get "set-rallypoint". However apparently the DetermineAction thing expects "GetActionInfo" to return position and tooltip information, which it obviously does not.I suggest you fix the bug in GetActionInfo: it should return more information for set-rallypoint. This should make it work, unless something else goes wrong.any one knows where i should look at for normal click with a building selected? ( not from mini map)i'm thinking this should make the rally point set. and it works fine.but from mini map. it's not working. i want to have a look at both of them. and compare them. i think it should be a tiny mistake. and i don't think the coordinates are wrong. because the case "move" works fine with coordinates target.x and target.z.currently i can't find the normal click not through mini map. hope someone can help me with itplease correct me if i'm wrong.thanks in advance. Quote Link to comment Share on other sites More sharing options...
TrinityDeath Posted May 23, 2013 Author Report Share Posted May 23, 2013 (edited) i fixed it.. it's a really tiny mistake.Engine.GuiInterfaceCall("DisplayRallyPoint", {"entities": selection,"x": target.x,"z": target.z,"queued": queued});just add: , "queued" : queuedafter target.zand this would be fixed.http://trac.wildfiregames.com/ticket/1848 Edited May 23, 2013 by TrinityDeath Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.