Hello I am hoping I can get some advice with an ability I've made.
Basically I've got an ability that gives a unit a 25% chance of taking an overwatch shot in certain circumstances.
I want to create an ability that alters this chance to 50% but I don't really know where to start. I've looked at Suppression and Run And Gun in LW but I can't see how I could use these to increase a % chance.
Help with Ability (Again)
Re: Help with Ability (Again)
I think I've made some progress. Having had a look at how Extra Conditioning affects Run and Gun I've made a new "X2AbilityToHitCalc" file which I want to insert the % values depending on whether the second ability is present or not. Only problem now is that I'm getting an error when building...
And the error I get is:
Any ideas?
Code: Select all
class X2AbilityToHitCalc_QuickTarget extends X2AbilityToHitCalc_PercentChance config(GameData_SoldierSkills);
var config int OP_POINTMAN_CHANCE;
var config int OP_POINTMAN2_CHANCE;
function RollForAbilityHit(XComGameState_Ability kAbility, AvailableTarget kTarget, out AbilityResultContext ResultContext)
{
if (XComGameState_Unit(AffectState).HasSoldierAbility('Op_QuickTarget'))
{
return default.OP_POINTMAN2_CHANCE;
}
return default.OP_POINTMAN_CHANCE;
}
Code: Select all
\X2AbilityToHitCalc_QuickTarget.uc(8) : Error, Bad or missing expression for token: XComGameState_Unit, in 'If'
Re: Help with Ability (Again)
Code: Select all
XComGameState_Unit(AffectState).HasSoldierAbility('Op_QuickTarget')
Code: Select all
function RollForAbilityHit(XComGameState_Ability kAbility, AvailableTarget kTarget, out AbilityResultContext ResultContext)
{
local XComGameStateHistory History;
local XComGameState_Unit SourceUnit;
local int iRoll, iHitTarget;
History = `XCOMHISTORY;
SourceUnit = XComGameState_Unit(History.GetGameStateForObjectID(kAbility.OwnerStateObject.ObjectID));
if (SourceUnit.HasSoldierAbility('Op_QuickTarget'))
iHitTarget = default.OP_POINTMAN_CHANCE2;
else
iHitTarget = default.OP_POINTMAN_CHANCE;
iRoll = `SYNC_RAND(100);
ResultContext.HitResult = eHit_Miss;
if (iRoll > iHitTarget)
ResultContext.HitResult = eHit_Success;
return;
}
Re: Help with Ability (Again)
Try replacing the whole X2AbilityToHitCalc_QuickTarget class with the code below. I got this working with your abilities using fixed values of 0 and 100 and the config variables you have setup look correct, so it should work. Let me know how it goes:
BTW, I have no idea what the armor mitigation stuff is doing. You could try commenting it out and seeing what happens and possibly get rid of it if it's actually giving the attacks armor mitigation (I just copied this straight from the original X2AbilityToHitCalc_PercentChance and modified the parts handling the hit chance).
Code: Select all
class X2AbilityToHitCalc_QuickTarget extends X2AbilityToHitCalc config(GameData_SoldierSkills);
var config int OP_POINTMAN_CHANCE;
var config int OP_POINTMAN2_CHANCE;
protected function int GetHitChance(XComGameState_Ability kAbility, AvailableTarget kTarget, optional bool bDebugLog=false)
{
local XComGameStateHistory History;
local XComGameState_Unit SourceUnit;
History = `XCOMHISTORY;
SourceUnit = XComGameState_Unit(History.GetGameStateForObjectID(kAbility.OwnerStateObject.ObjectID));
if (SourceUnit.HasSoldierAbility('Op_QuickTarget'))
return default.OP_POINTMAN2_CHANCE;
else
return default.OP_POINTMAN_CHANCE;
}
function RollForAbilityHit(XComGameState_Ability kAbility, AvailableTarget kTarget, out AbilityResultContext ResultContext)
{
local int MultiIndex, RandRoll, PercentToHit;
local ArmorMitigationResults NoArmor;
PercentToHit = GetHitChance(kAbility, kTarget);
RandRoll = `SYNC_RAND_TYPED(100, ESyncRandType_Generic);
ResultContext.HitResult = RandRoll <= PercentToHit ? eHit_Success : eHit_Miss;
ResultContext.ArmorMitigation = NoArmor;
ResultContext.CalculatedHitChance = PercentToHit;
for (MultiIndex = 0; MultiIndex < kTarget.AdditionalTargets.Length; ++MultiIndex)
{
RandRoll = `SYNC_RAND_TYPED(100, ESyncRandType_Generic);
ResultContext.MultiTargetHitResults.AddItem(RandRoll < PercentToHit ? eHit_Success : eHit_Miss);
ResultContext.MultiTargetArmorMitigation.AddItem(NoArmor);
ResultContext.MultiTargetStatContestResult.AddItem(0);
}
}
Re: Help with Ability (Again)
Use this for the damage modifying effect:
Remove the instance of this effect in the Op_PointmanShot ability itself and add this persistent effect to Op_Spearhead. Use the MayhemBonuses ability in the X2Ability_PerkPackAbilitySet as a reference point.
Code: Select all
class X2Effect_Spearhead extends X2Effect_Persistent config (GameData_SoldierSkills);
var config float OP_SPEARHEAD_DAMAGE_BONUS;
function int GetAttackingDamageModifier(XComGameState_Effect EffectState, XComGameState_Unit Attacker, Damageable TargetDamageable, XComGameState_Ability AbilityState, const out EffectAppliedData AppliedData, const int CurrentDamage, optional XComGameState NewGameState)
{
local XComGameState_Item SourceWeapon;
local XComGameState_Unit TargetUnit;
if (AbilityState.GetMyTemplateName() == 'Op_PointmanShot')
{
if (AppliedData.AbilityResultContext.HitResult == eHit_success)
{
SourceWeapon = AbilityState.GetSourceWeapon();
if (SourceWeapon != none)
{
TargetUnit = XComGameState_Unit(TargetDamageable);
if (TargetUnit != none)
{
return int(CurrentDamage * (default.OP_SPEARHEAD_DAMAGE_BONUS / 100));
}
}
}
}
return 0;
}