Jump to content

FeXoR

WFG Retired
  • Posts

    1.426
  • Joined

  • Last visited

  • Days Won

    28

Everything posted by FeXoR

  1. Hehe, U made the same "mistake" like me. Swap sin and cos ^^
  2. But you insist of define coordinated one by one. Do you think that is wise? Or tell me a reason? Well, sry, your decision...
  3. I think something like that should be added to one of the rmgen .js files to make it easier for random map designers. They still can make there own arrangements of starting units if they like. Perhaps some value checks of function parameters should be added... Perhaps the starting units should be placed right (female peasants), left (male peasants) and in front (Scout) to need less space (smaller maximum distance to start location). Greetings U gorgeous bunch of individuals! Oh, did'nt see this, thx!
  4. Got some strange formation issues in the post writer tool... well... Here's a more reasonable version. Swapped sin and cos so unit orientation and mathematical point calculation matches. Still I think that's a little strange... Many variables are set in the loop now with var over and over again... is this OK? But it's much shorter now: // Funtion to place civil centre and starting units at given location for a given player function placeStartUnits(startLocation, playerId) // "startLocation" should be a list of length 2 with floats determining the 2d-point where the starting entities shall be placed. // "startLocation[0]" should be an float determining the x coordinate of the start location. // "startLocation[1]" should be an float determining the z coordinate of the start location. (Should by y in my book though) // "playerId" should be the player number like seen in Atlas or the game settings ingame (Starting with 1 for the first player with default colour blue, 0 is Gaia) { // Some checks. Enhance if needed... // Setting some variables // Setting default building angle, can be got from the global "BUILDING_ANGlE" in further versions var buildingOrientation = 3*Math.PI/4; // Getting civilisation dependent default starting entities var civEntities = g_CivData[g_MapSettings.PlayerData[i].Civ].StartEntities; // Place civil centre on the start location placeObject(startLocation[0], startLocation[1], civEntities[0].Template, playerId, buildingOrientation); // Place starting units // Minimal distance to start location so that units don't stand in the civil centere var minDistToCC = 4; // Minimal distance between units so they don't overlap var minDist = 1; // Set angle width units should be spread over var angleSpread = PI/4; // Outer loop for the diffrent unit types to place beside the civil centre (so starting with 1) for (var unitTypeIndex = 1; unitTypeIndex < civEntities.length; ++unitTypeIndex) { // Reset default number of units of that type var unitCount = (civEntities[unitTypeIndex].Count !== undefined ? civEntities[unitTypeIndex].Count : 1); // Reset the angle added per unit of that type depending on the number of them, for multiple units of that type only (otherwise 0 devision) if (unitCount > 1) {var angleAdd = angleSpread/(unitCount-1)}; // Inner loop for multiple units of the same type for (var unitIndex = 0; unitIndex < unitCount; unitIndex++) { // Resetting the angle the unit will be placed in comperison to the city centre if (unitCount > 1) {var angleActual = buildingOrientation - angleSpread/2 + unitIndex*angleAdd} else {var angleActual = buildingOrientation}; // Place the unit placeObject( startLocation[0] + (minDistToCC + minDist*unitTypeIndex)*sin(angleActual), startLocation[1] + (minDistToCC + minDist*unitTypeIndex)*cos(angleActual), civEntities[unitTypeIndex].Template, playerId, angleActual); }; }; };
  5. Sooo... Here's a function to place civil center and starting units just by giving the location and the player index of the player the units should be placed for. This is the (very) detailed version for (hopefully) good readability, a shorter version will be added: // Funtion to place civil centre and starting units at given location for a given player function placeStartUnits0adAlike(startLocation, playerId) // "startLocation" should be a list of length 2 with floats determining the 2d-point where the starting entities shall be placed. // "startLocation[0]" should be an float determining the x coordinate of the start location. // "startLocation[1]" should be an float determining the z coordinate of the start location. (Should by y in my book though) // "playerId" should be the player number like seen in Atlas or the game settings ingame (Starting with 1 for the first player with default colour blue, 0 is Gaia) { // Some checks. Enhance if needed... // Setting some variables // Setting default building angle var buildingAngle = 3*Math.PI/4; // Getting civilisation string var civ = g_MapSettings.PlayerData[i].Civ; // Getting civilisation dependent default starting entities var civEntities = g_CivData[civ].StartEntities; // Setting start tile. Not needed but done in the other RMGs so.... var startTile = new Array(2) startTile[0]= round(startLocation[0]) startTile[1]= round(startLocation[1]) // Place civil centre on the start tile placeObject(startTile[0], startTile[1], civEntities[0].Template, playerId, buildingAngle); // Place starting units // Minimal distance to start location so that units don't stand in the civil centere var minDistToCC = 4; // Minimal distance between units so they don't overlap var minDist = 1; // Set general orientation of units var angleMain = -(buildingAngle - PI/2); // This is a bug in my book, it should be the same as building orientation... // Set angle width units should be spread over var angleSpread = PI/4; // Preset angle the first unit should be placed, reset in the outer loop var angleStart = angleMain - angleSpread/2; // Preset angle distance between one unit and the next of the same type, reset in the outer loop var angleAdd = 0; // Preset the angle a unit will be placed in comperison to the civil centre, reset inside the inner loop var angleActual = angleStart; // Preset number of units to place by default of the same type, reset in outer loop var numberOfUnitsOfSameType = 1; // Preset unit template, reset in the outer loop var unitTemplate = ''; // Preset postition the unit will be placed, reset inside the inner loop var unitPosition = new Array(2); unitPosition[0] = startTile[0]; unitPosition[1] = startTile[1]; // Preset orientation of placed unit, reset in the inner loop var unitOrientation = 0; // Outer loop for the diffrent unit types to place beside the civil centre (so starting with 1) for (var unitTypeIndex = 1; unitTypeIndex < civEntities.length; ++unitTypeIndex) { // Reset default number of units of that type numberOfUnitsOfSameType = (civEntities[unitTypeIndex].Count !== undefined ? civEntities[unitTypeIndex].Count : 1); // Reset the angle added per unit of that type depending on the number of them, for multiple units of that type only (otherwise 0 devision) if (numberOfUnitsOfSameType > 1) {angleAdd = angleSpread/(numberOfUnitsOfSameType-1)}; // Reset unit tamplate unitTemplate = civEntities[unitTypeIndex].Template; // Inner loop for multiple units of the same type for (var unitIndex = 0; unitIndex < numberOfUnitsOfSameType; unitIndex++) { // Resetting the angle the unit if (numberOfUnitsOfSameType > 1) {angleActual = angleStart + unitIndex*angleAdd} else {angleActual = angleMain}; // Reset the angle the unit will be placed in comperison to the civil centre unitPosition[0] = startTile[0] + (minDistToCC + minDist*unitTypeIndex)*cos(angleActual); unitPosition[1] = startTile[1] + (minDistToCC + minDist*unitTypeIndex)*sin(angleActual); // Reset orientation of placed unit unitOrientation = -(angleActual - PI/2); // Here is the bug again... // Place the unit placeObject(unitPosition[0], unitPosition[1], unitTemplate, playerId, unitOrientation); }; }; }; BTW, this does'nt seam to be a good place to put this, suggestions very welcome.P.S.: Did I mention this game is pure @#$%ing awesomeness?P.P.S.: Oh, I hope I did'nt break any forum rules now ;0|
  6. BTW! The mathematical orientation (defined by cos/sin in x/y direction) and the unit/building orientation differs. I think unit orientation is: -(mathematical orientation - PI/2) How did that happen? And why is the second vertical orientation named "z" instead of "y"? I thought "z" would be the hight over ground or to a base hight but in 0ad it's "y"? Sorry, questions and more questions x)
  7. Oh, and for those preferring .zip: fexor_rmg.zip EDIT: My dear, wrong version, now it should work... [hope]
  8. THX for the reply! The problem was within my file and it's fixed now. However, the building orientation IS inside the grid the AI and the start orientation in-game uses, but there are still the 4 possibilities. Well, not a big issue since it works fine now. I did many things very different then it is handled in the other RMGs. Mine is a very early state until now and more for getting to know the functions, but if anyone wants to take a look: fexor_rmg.rar
  9. THX, that helps. I made the different civil centers align to the diagonal grid that is used in-game for placing structures by default but roughly facing the center of the map (1*PI/4, 3*PI/4, 5*PI/4 and 7*PI/4). I thought that wouldn't result in problems since a change of the wired const "BUILDING_ANGlE" (with a small written "L" ^^) did'nt change anything in-game (but the orientation of all map-generated buildings of cause). So I made them different for each player and set them as a variable. Well, but sometimes, often enough to occur 50% at 8 player maps, one or two civil centers are facing in a non-alligned directions (And some functions afterwards are not called). Is the orientation for buildings in general needed as a const or even need to be named "BUILDING_ANGlE"?
  10. I wrote a random map generator and now want to know where to talk about it and where to share it if it's good enough. I found it hard to find the things I need inside the code of the helper functions inside the "rmgen" directory. Is there a documentation or a small tutorial out there? And what variables can be set in the .json file? For those who have similar issues: - The directory own scripts can be added and then work with the game and the editor in windows is (similar to the player made "scenarios" folder): c:\users\[username]\AppData\Roaming\0ad\cache\mods\public\maps\random
  11. When a move order is given to an army (e.g. to retreat) and some (well, OK, at least about 1/4th of the army size) units are located in the opposite direction (related to the main part of the army) of the given point to move, the units of the main army heads the "wrong" direction. I don't think that this is a bug, but it's at least annoying. It could be easily solved by adding a "no formation" formation, that gives the order given to an army to each unit of the army instead. This would be really nice... More in the sense of the game, perhaps, would be this behavior: - All units stop. (Or get a mark that they have not been given the order right now) - Determine the length of the shortest path for all units in the formation. From now on "closest" means the shortest length of this path. - The "closest" unit "walks" the above determined path towards the point of the given order. - The next "closest" unit "runs" towards the point of order (until it is as close as the "closest" unit) if the point is closer then the next walking unit of it's formation. Otherwise it "runs" towards the next "walking" unit of it's formation. ...and so on. This may result in an army split into 2 or 3 until they reach the destination but no unit would have to travel a "much" longer way then needed and no unit moves the "wrong" direction. THX for your gorgeous game
  12. When a formation button is clicked while an army has a "garrison into building/unit" order, the army is instantly garrisoned into the target building/unit independent of the distance. EDIT(Start) I'm sorry it's the "stand ground" or "violent" etc. orders to klick... To reproduce this: - Select a number of units (less then the building to garrison in can carry) - Give them the garrison order to a distant building as usual (They begin to walk towards the building) - With the units still selected (and them walking towards the building to garrison into it) click for example stand ground. - They will disappear instantly and now can be found inside the building they where walking towards This can be done even if the building (or ship or siege weapon) is not reachable at all for the foot troops like a ship in the middle of the water or a siege tower on en enemy island. EDIT(End) P.S.: THX for this awesome game!
×
×
  • Create New...