1. Forum moved (you can use login and pass from old forum)
  2. Many discussions moved to the bugtracker

Battlescape progress and questions

Discussion in 'Coding' started by Istrebitel, Aug 26, 2016.

  1. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    0/28

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    Okay, so since I keep running into things and stuff, and i'm mostly coding when others are absent at IRC, I'm going to post all my questions and other info I encounter while doing battlescape into this topic.
     
    makus likes this.
  2. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    About object display order:

    Right now we have layers, that allows us to display objects on single Z-row in layers (like, a big ufo located in x,y,z 10,10,1 is always displayed above anything else in x,y,1, otherwise a tile directly next to it (11,10,1) would overwrite it (since it's rendered later) which should not be the case.
    However, for battlescape, we also need to have a separate ordering, within a single tile.
    A tile's "scenery" object (like a tree) must be drawn after ground and walls are drawn, but should not be drawn over a wall of a next tile. If there's a tree in 10,10,1, but a right wall in 10,11,1, then that right wall should be drawn after and cover the tree.

    So, we need to make some form of draw order within a tile. It should be GD->LW->RW->SC->Everything else.

    Another thing about displaying walls:

    Both right and left wall sprites contain the intersection point between walls. So, when a tile has both right and left wall, there is no way to just draw them in any specific order and get a proper picture. Vanilla, in this case, seems to draw right wall after left wall, but skips drawing first three left-most pixel columns of the right wall. You can see in the attached image, left part is vanilla, right is openxcom, there are three extra pixels of the left wall that are not drawn in vanilla. I checked and that seems to be the case everywhere.

    Therefore, we need to somehow skip drawing three left columns of an image if it's a right wall drawn with a left wall present in the same tile.
     
  3. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    About controls:

    We need a way to emulate clicks on buttons. Like, on tactical, when I press PageUp, I should hear a click associated with "up arrow" button, I should see it get pressed and de-pressed, and the routine associated with that button press should execute.

    We can already somewhat do it to some controls, but it's unelegant, like, here's for the checkbox:
    this->baseForm->findControlTyped<CheckBox>("BUTTON_TOGGLE_STRATMAP")->setChecked(!this->baseForm->findControlTyped<CheckBox>("BUTTON_TOGGLE_STRATMAP")->isChecked());

    Of couse, I could code it in, so that when pageup is pressed, the sound is played, layer changed etc., but that would be unelegant, as I would duplicate a callback code I have already written plus sound playing code written in the button. Besides, button's click sound is protected, so I cannot actually access it from the form, so I'd either play a generic (probably wrong) sound or have to manually load it from xml, which is totally unelegant.

    I could code this one in if eveyrbody else are okay with it.
     
  4. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    About tactical buttons:

    I am unable to open icon_m.pck from tacdata folder. It should contain buttons, just like icon_m.pck for cities in ufodata folder does. However, neither openxcom nor XED is able to open it.
     
  5. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    About sharing code between city and tactical:

    Is there a way to make a StatRef without specifying a class? Projectile has a property firer which is a StateRef<Vehicle>. Technically, it's just a string that is an index into a map of vehicles to strings. It could as well be a string that is an index into a map of agents to strings as well. Could we somehow have a firer property that can both point to a vehicle and to an agent? without agent and vehicle inheriting same class?
     
  6. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    Information I have been able to deduce so far about tactical files:

    https://github.com/Istrebitel/OpenApoc/blob/master/tools/extractors/docs/tactical.txt
     
  7. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    About stacking sectors vertically:

    As we know, the game creates tactical maps by bunching together several pre-defined cells, or sectors. Like, a two-lift room with a chessboard room in cult of sirius temples. In game this is defined by the amount of cells that should be stacked, x y and z.

    This means that theoretically, for some maps, like senate for example, or apartaments, or luxury appartments, we could get a map that is higher than usual. However, this never happens. At least I never saw it happen. Did anyone?
     
  8. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    64/112

    Joined:
    Jul 17, 2014
    Messages:
    181
    Likes Received:
    31
    Best Answers:
    0
    I've never seen a map stacked vertically. I suspect this was disallowed, as I cannot remember any maps that have lifts/stairs that have a hole in the ground at the lowest Z, unless it removes tiles or something I can't see how that would work.
     
  9. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    Actually it does work! Because for the cases where stacking vertically would result in inaccessible top levels, there were mandatory sections (min number of occurences = 1) with lifts. Example is 14ACNORM. It has sector 8 which is a lift sector, marked as such. Therefore, in case there would be vertical stacking, this sector would always spawn and provide lifting. Same for others. 01SENATE for example, has sector 1 which is mandatory - and provides lifts. And so on.
     
  10. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    Confirmed, it does. Was able to generate those maps with proper height and they're perfectly playable.

    Also, data format is fully decyphered now, thanks to Skin who provided TacEdit. SLS files contain information about AI, spawning and pathing. I haven't decyphered pathing but I think we won't need it anyway. Everything else, we now know.
     
  11. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
  12. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    Some more questions:

    1) What objects need to have id's? Names? Why should they, if id or name always matches their key in the StateRefMap?

    2) Tiles have sound indexes that go from 0 to 8. Where to find them Rawsounds? What do I pass there to get the sound?

    3) Why are we not reading the Overspawn vehicle? Why are we reading one vehicle less than there is in the table?

    4) Why do we think landing pads can't collapse? Lovecraft block on Superhuman (X-Com base in a slum that looks like a giant nail) is proof to that - those pads can collapse and get destroyed, and that prevents flying vehicles from entering or leaving your base.

    5) What's a "weapon" class? It's declared but never defined...
     
  13. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
  14. Meridian

    Meridian Die hard XCOM fan
    0/28

    Joined:
    Aug 28, 2016
    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Here's how OpenXcom handles moving units: https://github.com/SupSuper/OpenXcom/blob/master/src/Battlescape/Map.cpp#L456

    They are not changing the order, in which the tiles are drawn, but rerender some things again to achieve the desired effect.

    Your idea/solution (from the video) looks better to me... but I am quite an amateur in game development, so it's just a feeling :)
     
  15. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    About collapsible map rules:

    After implementing first pass of collapsible map, I found out that the game is inconsistent in how it's physics work. For example, 28SLUMS06 has a wall on it's west side. That wall has a passage. Over that passage is an overhanging wall and feature. Here's how it looks:

    [​IMG]

    As you can see, at a level 3, a feature is floating in the air, as well as a left wall behind it.
    The feature is marked as "supported by north", and wall is "supported by below".
    Therefore, there is absolutely zero way they can stay there!

    More than that!

    You cannot recreate this situation! If you try to destroy left walls below, once you destroy the one under the "T", the right part falls off (left image). And if you remove the feature below, the middle and left part falls off, as well as scenery.
    [​IMG]

    What this proves is that in original situation, handing scenery and left wall defied the laws of ingame physics. They should not stay there, yet they do.

    One faint glimmer of hope is that the flag "independent structure", which is set for the horizontal (but not vertical) sceneries here, is somehow at play here. However, even then, wall is not part of this "independent structure", but destroying wall to the bottom left of the hanging feature and wall causes them to collapse.

    How should we implement this?
     
  16. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    And another problem with vanilla's collapsible map logic
    [​IMG]

    These yellow things (one marked by red circle) should not stay there. Their "supported by" type is "below" - meaning, they should not get support from above. They could get support from the sides, (marked by black circle), but those are marked as "flase" in "provides support" flag. This flag is unset for things that should NOT provide support - things like small features - robots, tables, floor rubble. It is also unset for those map parts. Below them is also nothing. Therefore, there is zero reason for them to stay there, yet they stay there and don't fall.
     
  17. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    Also, bugs in original maps become apparent now.

    For example, battleship has floating "rubble" scenery located at the middle of western map edge at ~level 5.

    Bomber has floating "stick" (it's a wall that looks like a pole) above it's northen lift (it's hard to see, it's located 1 tile northwest from lift's northwestern tile, on level 3).

    What do we do with it? Let it fall? Make it magically float in the air?
     
  18. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    Aaaaand.... Bad news is, we need a new tile rendering algorithm!

    Implementing falling map parts unearthed something we cannot implement in our current algorithm, that draws objects in layers (first z0, then z1 etc.)

    [​IMG]
    (There is a typo, 0,1,0 on the right should read 1,0,0)

    As you can see, we have scenery (indicated with yellow arrow from the left) and two walls. Assume the coordinate of the tile scenery is falling into is 0,0,0 on x,y,z. In that case, wall to the right (bottom right arrow) is the left wall of tile 1,0,0 and wall to the top (top right arrow) is the right wall of tile 0,0,1

    Now, falling scenery indicated with middle left arrow is either located in 0,0,0 or 0,0,1.
    - In case it is located in 0,0,0, the wall at 0,0,1 will be drawn over it
    - In case it is located in 0,0,1, the wall at 1,0,0 will be drawn under it.

    We need to somehow change our rendering algorithm to handle this case properly
     
  19. JonnyH

    JonnyH Well-Known Member Official Developer Administrator
    64/112

    Joined:
    Jul 17, 2014
    Messages:
    181
    Likes Received:
    31
    Best Answers:
    0
    There's also a number of 'bugs' in the cityscape with seemingly unsupported tiles, some grass in one of the walls, and a sewerage plant owned by 'X-Com' that I remember. I suspect the support issues weren't noticed as the original didn't check for tile support unless an adjacent tile was destroyed, so if they started 'magically hovering' they would remain there until something nearby happened to cause them to get re-checked.

    As for the rendering order, we can pretty simply change x/y/z order when looping through the map, though your example appears like this isn't really enough.

    what we could do is loop each 'z' level as the outermost loop, then draw all 'static' scenery on that Z level, then on top of that draw any 'falling' scenery, though the cost of looping through all tiles in the render is quite high on the profiler already, there's plenty we can do to make that faster, so don't worry about that for now.

    Again with your example, I would assume that the walls in {1,0,0} and {0,1,0} would be correct in being drawn on top of the 'falling' scenery at {0,0,0}? As it'll be falling 'behind' the walls? Does the original draw it on top? Maybe 'falling' tiles are considered to be at the higher Z for longer than we do? (I believe we draw based on the 'middle' of the tileObject, maybe the original actually did the 'top' of the object?)
     
  20. Istrebitel

    Istrebitel Well-Known Member Official Developer Administrator
    39/56

    Joined:
    Aug 8, 2016
    Messages:
    189
    Likes Received:
    80
    Best Answers:
    1
    I am not sure I undestand your question, but I've noticed I made a mistake, it's not a 0,1,0 wall but 1,0,0 wall. It doesn't change much though. Screenshot is from vanilla, and this is how it should be drawn. 1,0,0, and 0,0,1 both must be drawn above falling scenery from 0,0,1 to 0,0,0. It's falling behind those walls.

    Assuming falling scenery is drawn in 0,0,1, draw order is:
    ...
    0,0,1
    ...
    1,0,0 / 0,1,0
    ..
     

Share This Page