Jump to content

Squadsight Aim Penalties


Amineri

Recommended Posts

Oh, no, this is very very interesting. Although I title this thread post "Squadsight Aim Penalty", I actually labeled my working notes as "Aim Penalty for Long Range". Your discovery of the interactions between:

1) Perk : Squadsight

2) Ability range : Squadsight

3) Weapon range

make the possibilities much greater.

 

I'm going to restate your conclusions, just to be sure I understand them correctly:

1) Perk : Squadsight -- allows the unit to shoot beyond visual range. Without this perk, the unit can only shoot units that are within its own direct visual range.

2) Ability range : Squadsight

a) Ability ignores weapon range. Any unit directly visible (via own visual range) or indirectly visible (via squadsight perk) can have this ability used on it.

3) Ability range : Weapon

a) Ability is restricted to affecting units within the range defined by the weapon used.

4) Ability range : sight

a) Limited to unit's visual range

 

-----------------------------------------

 

I did a bit more digging, and found the functions that actually create the various arrays of enemies that fall into each category.

 

The starting function is XGUnitNativeBase.CallGetTargetsInRange, which appears to be only called from the native code. However, the execution of the function threads through XcomGame.upk

 

CallGetTargetsInRange is just a passthrough for : XGUnit.GetTargetsInRange

 

The key parameters are iTargetType and iRangeType:

 

enum EAbilityTarget -- iTargetType
0 eTarget_None,
1 eTarget_Self,
2 eTarget_SingleEnemy,
3 eTarget_MultipleEnemies,
4 eTarget_SingleAlly,
5 eTarget_SingleAllyOrSelf,
6 eTarget_MultipleAllies,
7 eTarget_SectoidAllies,
8 eTarget_Location,
9 eTarget_SingleDeadAlly,
10 eTarget_SingleDeadEnemy,
11 eTarget_MutonAllies,
enum EAbilityRange -- iRangeType
0 eRange_None,
1 eRange_Weapon,
2 eRange_Sight,
3 eRange_SquadSight,
4 eRange_Loot,
5 eRange_Unlimited,

For target types 2 and 3 (single or multiple enemies), it switches on iRangeType:

1: DetermineEnemiesInRangeByWeapon(kWeapon, 0.0, arrTargets,
2: DetermineEnemiesInSight(arrTargets, arrDistToTargetSq,
3: DetermineEnemiesInSquadSight(arrTargets,
5: DetermineAllEnemies(arrTargets, arrDistToTargetSq,
case 4 (Loot) has no implementation.
Each of these "Determine" functions (which are defined in XGUnit) in turn calls another XGUnit 'helper function':
DetermineAllEnemies
calls AddAllTargets
DetermineEnemiesInRangeByWeapon
calls AddEnemiesInRangeByWeapon
DetermineEnemiesInSight
calls AddTargetsInSight
DetermineEnemiesInSquadsight
calls AddTargetsInSquadSight
These "Add" functions test individual units for inclusion in the array being built.
AddAllTargets
draws from m_kBattle.GetEnemySquad(GetPlayer())
AddEnemiesInRangeByWeapon:
draws from m_arrEnemiesInRange (an array of unit visibility info)
calls IsPointWithinFiringRange
for each unit that passes, unit is added to arrEnemiesInRangeOfWeapon (returned array)
AddTargetsInSight
draws from either m_arrVisibleCivilians or m_arrVisibleEnemies
also if((IsPanicActive()) && arrVisibleTargetsToUse.Length == 0)
{arrVisibleTargetsToUse = m_arrVisibleFriends;}
AddTargetsInSquadsight
calls SightManager to GetAllVisibleTargets() (of type enemy or civilian)

----------------------------------------------------

 

The original invokation of these functions is hidden from us in the native code, but some of the results are available. They are defined in XGUnitNativeBase (and so are accessible via XGUnit). However, they are maintained and updated through calls from the native code. (via the CallGetTargetsInRange, which passes the arrays being modified as function arguments)

 

Within XGUnit, I've determined the addresses for the following:

m_arrEnemiesSeenBy : 9A 30 00 00

m_arrVisibleEnemies : 9C 30 00 00

m_arrEnemiesInRange : 97 30 00 00

 

Additional arrays defined in XGUnitNativeBase include:

m_arrEnemiesEngagedBy

m_arrEnemiesInCloseRange

m_arrEnemiesRevealedWhileMoving

m_arrFlankingUnits

m_arrSuppressingEnemies

m_arrSuppressionExecutingEnemies

m_arrSuppressionTargets

 

There are also some arrays to store Civilian info, which I won't list here.

 

I'm not 100% sure what the criteria are for inclusion in the different arrays.

It appears that m_arrVisibleEnemies does not have any restrictions on range -- it appears to contain the list of all enemies that can have LOS drawn to them.

 

 

 

Link to comment
Share on other sites

There are three candidate arrays I could use to offset the squadsight penalty:

m_arrEnemiesSeenBy
m_arrEnemiesInRange
m_arrVisibleEnemies

The first is based upon XCOM units seeing the target unit. This array includes Battlescanners and snipers that can see the unit via Squadsight.

The second and third are based upon which XCOM units the target unit can see. In practice the count is the same for these two, since weapon range and visibility range are generally identical. However, XCOM hunkered-down units will also be on this list (because the target unit can see hunkered-down unit). Battlescanners do not count, since they cannot be targeted. Ghost-cloaked units would also not count.

Either case leaves open a possible "exploit".
1) In the first case, a single scout could sight for three squadsight snipers. Since all three squadsight snipers can see the target, the game logic counts four units as seeing the target, even though only one is in visual range.

2) In the second and third cases, multiple scouts within "visual range" are required. However, they can hunker down and the squadsight sniper still gets the bonus. This is particularly important if the sniper is using an overwatch shot during the alien turn, while his friendly units are hunkered down. However, at least one unit would have to have visual sight range to the target to allow the sniper to take the shot at all.

I'm leaning toward using m_arrVisibleEnemies as the default, since the "exploit" conditions are more difficult to obtain, and the effect is "weaker". This will mean that battlescanners will only show the area and allow squadsight shots to be taken, but would not offset the squadsight aim penalty (thus slightly weakening the battlescanners, which I'm fine with). However, it also means that ghosted units don't contribute, which I'm not happy about.

Edited by Amineri
Link to comment
Share on other sites

I have succeeded beyond what I thought I would be able to.

All of the changes are in, everything works. I confirmed that a savegame in which the sniper previously hit (just before save game) failed to hit with the mod applied.

 

Additionally, I was able to correct all of the UI to-hit displays. Everything should work properly.

 

I've tried something different this time. I uploaded all of the hex changes, decompiled code, my development notes, and even some example pictures to the wiki:

 

http://wiki.tesnexus.com/index.php/XCOM_Squadsight_Aim_Penalty_Mod


Let me know if this wiki format is an effective way to distribute this information. Everything that I did (saving what is in my brain) is in those pages.

 

-------------------------------------------------------

 

A word of caution!

If squadsight is given to aliens, they will be affected by this mod in the same way as the player. Range penalties and Unit-sight bonuses will be applied.

 

However:

1) This does not modify the unit variable m_iHitChance (which is returned by GetHitChance()). Since this is what is used by the AI to determine what moves it should make, the AI will be making its decisions based on incorrect information (that it has a higher chance to hit than it actually does). It would function essentially the same as if the UI always displayed a higher to-hit chance than the real one. Poor decisions

 

2) The AI will not have any capabilities to take actions to improve its to-hit chances with squadsight. It won't know to get closer, or to get more units within sight range. This may lead to erratic behavior by the AI.

Link to comment
Share on other sites

well done, I'm glad you've made it. About the wiki page, at first it's pretty daunting with so many links and it isn't quite clear how it works and why it does what it does, but then with the notes for each change it becomes clearer. Maybe those notes could be moved to an entry of their own for each function involved, since the code's been cracked down and it could be useful for other mods too. In any case thanks for taking the time to post the code and notes.

Link to comment
Share on other sites

I've been adding a little bit to the main page, to help with the initial navigation. Feel free to toss in changes to help clarify things, too!

 

I'm trying to strike a balance between:

1) Making the information accessible

2) Making the information quick to post

 

Hence why I used the < nowiki > option when putting up the notes. Trying to reformat all of my notes documents to be compatible with wiki formatting would be really time consuming. It would likely take as much time as creating the mod itself. If anyone wanted to take on the task of reformatting the raw text notes (I create them while I'm working in Notepad++) into wiki-style pages, I happily give my permission.

 

I have such notes documents for every mod I've created. Once we get an workable template/format worked out for describing a mod, I can start posting up the details about each mod I've made.

 

--------------------------------

 

Regarding the Squadsight Aim penalty mod, I put up some new information about how to tweak the penalty formula as well.

Link to comment
Share on other sites

Frankly I'm very happy to see this sort of mod posted to the Wiki, as it makes it easier to locate something I saw in a thread months ago that I want to try out later. The development notes breaking out the original and new hex are extremely helpful in identifying something you want to try changing to a different value. And the Wiki is a better place to present and preserve such investigatory work. Well done, and thank you.

 

In a cursory quick look at the 'UI Shot Summary Hex Changes' page, I notice the function name is 'UIUnitGermanMode_ShotInfo' in XcomGame.upk. The 'GermanMode' part of the name makes me wonder if there are language specific instances of functions or if this is 'just one of those naming things'?

 

-Dubious-

Link to comment
Share on other sites

The "GermanMode" thing threw me off at first as well. I initially thought it was some sort of localized code, but it seems that GermanMode refers to the "over the shoulder zoomed in looking at the target" mode. I'm guessing it is just one of those naming things. Probably an interesting story behind it.

 

Regarding the wiki, I put a new category tag "XCOM Mods" at the bottom to help label actual created mods (as opposed to general information or tutorials).

Link to comment
Share on other sites

Regarding the wiki, I put a new category tag "XCOM Mods" at the bottom to help label actual created mods (as opposed to general information or tutorials).

Saw that as a great idea, and did some reorganizing to reduce some of the clutter in the upper 'category' pages. The 'XCOM Mods' category now has only the first or primary 'descriptive' page for each mod, and there is a category page for the mod off that primary page which lists all the related mod pages. It means one more layer to drill down, but avoids the confusion of having lots of entries at the upper category levels unrelated to everything else to wade through to find the major topics.

 

If it really gives you a heartache, let me know and I'll try something else. I've also tried to ensure there are at least two category links to each page to prevent losing track of one by accidental link deletion.

 

-Dubious-

Edited by dubiousintent
Link to comment
Share on other sites

No, that's perfect. There's no need to clutter up the category page with all of the subpages.

 

I appreciate any help making the wiki page more readable / organized. I get so mentally close to the mod that I can't see the forest for the trees any longer ^_^

Link to comment
Share on other sites

Occurred to me there's a bug in squadsight you might be able to fix within all these changes. Snipers on overwatch are able to fire their pistols at squad-sighted targets (beyond normal range) that enter their field of view. This lets you move your sniper, go on overwatch with a pistol, and take shots across the map. Squadsight shots should be limited to sniper rifles at all times -- Did you see a place where that could be fixed?

Edited by johnnylump
Link to comment
Share on other sites

  • Recently Browsing   0 members

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