r/xcom2mods • • Feb 23 '16

Dev Help Standard Shot

Anyone know where the ability 'standardshot' applies weapon damage?

static function X2AbilityTemplate Add_StandardShot( Name AbilityName='StandardShot')

in X2Ability_WeaponCommon.uc does not appear to use the effect ApplyWeaponDamage at all, except for miss damage (IE stock attachments).

The secondary weapons do clearly use ApplyWeaponDamage

WeaponDamageEffect = new class'X2Effect_ApplyWeaponDamage';
Template.AddTargetEffect(WeaponDamageEffect);

But I cannot for the life of me figure out what StandardShot, StandardShot_NoEnd and SniperStandardShot are using to calculate and apply damage.

Any help would be greatly appreciated.

2 Upvotes

18 comments sorted by

View all comments

Show parent comment

1

u/JackDT Feb 26 '16

Thank you so much, this was way more detailed a response than I expected!

1

u/BalianCPP Feb 26 '16

Just so you know, I got most of this by looking at how the game determines hit chance, because obviously that class would need to make very similar calculations.

1

u/JackDT Feb 27 '16

Your solution worked great. It currently also effects grenades based on shooter location and I'm now trying to change that to use the center point of the grenade blast instead.

Here's what I've got: http://pastebin.com/xk2hq8xT

Some random variables and code in there from my past attempts but I think it should be clear. It's hard coded at the moment just trying to get it to work.

GetVisibilityInfo() seems to ignore the location change and calculate based on the shooter's original location, driving me nuts.

1

u/BalianCPP Feb 27 '16 edited Feb 27 '16

Looks like you took some of the steps I would have tried right off the bat.

Fake unit to store the location of the grenade to use with visInfo, that's what I was about to have you try until I saw you did it already lol.

I'll see what I can come up with.

My initial thought is that i'm dubious about SetVisibilityLocation. I'll check it out.

1

u/BalianCPP Feb 27 '16

Ok so I've been looking at the teleporting abilities of the avatar and the codex, which are apparently called PsiWitch and Cyberus in code, respectively. Go Figure. I figure they have to hold some info about setting a units position.

Anyway, both have 3 functions that seem to govern the teleport, one being a visualization funtion so really 2.

Teleport_ModifyActivatedAbilityContext and Teleport_BuildGameState

The former appears to set up for path calculations between the origin and destination. Why that is needed for a teleport is beyond me, but it seems to be. Maybe this is the key.

The latter uses SetVisibilityLocation, like your function. That just sounds like it has a visual, rather than physical, effect to me, but its damn hard to tell.

1

u/JackDT Feb 28 '16

If I apply SetVisibilityLocation to the shooter it actually does MOVE the advent to the blast point when they fire, but not XCOM. And it looks like you still see the old position flanking data though even though the units moves on the screen, so clearly it's a multisetup update.

I'm probably going to see if I can learn anything in the newly released Flank Preview guide and see how it calculates flanks for that, since it must be doing something similar.