Jump to content

Bringing the LoS indicator from XCOM2 to LW/EW


tracktwo

Recommended Posts

Over the past few days I've been working on a little mod to bring the LoS indicators from XCOM2 to LW. These are the indicators that tell you which enemies will be visible while you're hovering over a tile for a potential move.

 

I started this a few weeks ago, but quickly gave up cause it was super buggy. I decided to take another look and made some real breakthroughs, but I'm still having a fairly serious bug. I'm posting this here to try to see if anyone else has some ideas on how to address this. The bug isn't really related to LoS itself - that aspect of it seems to work perfectly from what I've tested. The problem is the side effects of how I did it interfere with the game in some major ways.

 

To get this to work for EW, it's a real hack. There is no direct way that I could find to query the LoS engine to ask "If this unit was standing in this position, which enemies would be visible?". The existing game logic, including the AI, use an approximation. And this approximation is buggy, which is extremely unhelpful for a mod that tries to help combat LoS bugs. The query you can make is: can unit X see this location? That's often good enough, by making the assumption that if they can see me then I can see them, but this isn't always true and is complicated by factors like whether or not the unit is cover-using, as this affects stepping out behavior.

 

So the way I did it is this: I spawn a sectoid and a chrysallid, make them invisible, add them to the neutral team, and disable all physics on them. As you move the cursor around, the units follow it and the engine updates what they can see, and I use that to determine whether I should show the LoS indicator or not. I need both units so I can test LoS using the Sectoid for normal units and using the Chryssalid for SHIVs/MECs/etc that don't use cover and don't step out. This all works like a charm, and is completely invisible to the player (so far, at least).

 

The last major problem I have right now is moving these units around appears to disturb tile blocking. I already needed to clear the tile blocking (via XComWorldData.ClearTileBlockedByUnitFlag) when moving the helper units around so they don't accidentally block the tile they're standing on so the selected unit can't move to it. More problematic was if you were standing behind high cover and move the mouse to the tile you peek out from, the helper would block the peeking tile and currently visible aliens would disappear, exactly as if something was blocking that peeking tile (cause there is!). But even temporarily disabling this unblocking to ensure it isn't the cause, there are problems where these units leave the tiles they were on in an "unoccupied" state. So moving to that tile (currently occupied by the invisible helper), and then selecting another unit, you can move that new unit right on top of the one you just moved. Gross.

 

Anyone have any ideas on how to debug and fix this? If you want to try experimenting with the current state of the mod, I can provide a build & post the source on GitHub. I'm going to keep poking at it and see if I can fix it, but hopefully someone else will have a bright idea.

Link to comment
Share on other sites

Thanks, and just playing with it to try to find any more bugs would be appreciated. I'll upload the sources and a build to github later tonight but I don't want to add it to nexus quite yet cause it's not quite ready for general use with this bug.

 

I think tonight I'll try removing all the funny stuff from the helper units and just make them neutral. There will be visible units following the mouse around the map but it'll be useful to see if it's something to do with all the various visibility and physics changes or just bug with teleporting units around.

Link to comment
Share on other sites

Hey SpazmoJones, long time no see :) are you back for some xcom2 modding?

 

I actually used a drone instead of the chryssalid initially, but even when invisible it made the annoying drone hover sound. So I replaced it with a seeker, which then caused the cursor to go crazy when leaving it in the same spot (presumably due to the wavy tentacles) so I changed that to the chryssalid. It remains to be seen if the chryssalid will occasionally make idle chryssalid scream noises, but so far I haven't heard anything :)

 

But to answer your original question, no it doesn't help because they need to be landed to get correct LoS calculations, and I need it to be a cover using unit in order to get correct step-out behavior. If I move it up, it may change the distance to the target, and there may be locations in the map where moving it up would move it across some LoS blocking geometry like a ceiling.

Link to comment
Share on other sites

Ok I think I've fixed the movement bug. The problem occurred because there were a few situations where I was dropping the helper units on top of an existing one or when moving an existing unit they'd land on the helper. The particular settings of the helper didn't seem to matter, it looks to be entirely a problem with two units occupying the same tile - it'd be interesting to see if the same sort of bugs occur when you happen to be standing on a tile where a drop-in occurs. I've fixed this by always shuffling the helpers out of the way before beginning a move action and this looks like it works, but more testing would be great.

 

Anyway, that's the last of my major known bugs, so I've pushed the sources up to github and added a pre-release to the releases tab. You can install it with the installation instructions in the README.md file included in the release .zip file and also on the github page. Feedback and any new bug reports are very welcome so I can get a reasonable 1.0 release out here on Nexus. This is an incredibly beta release, please don't try it on an ironman campaign you really don't want to lose.

 

Also please try modifying the SIGHTLINE_TICK_DELAY config value as documented in the readme. I can't tell for sure if it's really slowing my computer down having very low tick values or if it's just my imagination. Task manager shows no difference in CPU usage, but it *feels* slower. For the record my CPU is rather old.

 

Github repo: https://github.com/tracktwo/sightlines

 

Oh, and I suppose I should say how it's intended to work. Enemies that will be visible from the tile you're hovering over will have the little overwatch eye icon displayed, but in XCOM blue instead of Alien red. Aliens that are on overwatch will toggle back and forth between the blue and red states to remind you they're on overwatch (and the toggle period is configurable, see the readme). There is a delay between moving the cursor and the UI refresh (also configurable) so give it a moment to update as you're mousing around.

 

I'm very interested especially in any bugs in the actual LoS computation. Moving somewhere and finding the results don't match what the indicator said are very bad and I would really appreciate a save file showing the problem. Other bugs are good to know too, like if you can ever actually spot or observe any side-effect of the invisible helper units.

Edited by tracktwo
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...