Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function name PAShakeUpApplyChance(const out EffectAppliedData ApplyEffectParameters, XComGameState_BaseObject kNewTargetState, XComGameState NewGameState)
- {
- // this mimics the panic hit roll without actually BEING the panic hit roll
- local XComGameState_Unit TargetUnit, SourceUnit;
- local name ImmuneName;
- local int TargetRoll, RandRoll;
- local int Value, BadGuysValue;
- SourceUnit = XComGameState_Unit(`XCOMHISTORY.GetGameStateForObjectID(ApplyEffectParameters.SourceStateObjectRef.ObjectID));
- TargetUnit = XComGameState_Unit(kNewTargetState);
- if (TargetUnit != none && SourceUnit != none)
- {
- Value = CountVisibleUnitsForUnit(SourceUnit);
- foreach class'X2AbilityToHitCalc_PanicCheck'.default.PanicImmunityAbilities(ImmuneName)
- {
- if (TargetUnit.FindAbility(ImmuneName).ObjectID != 0)
- {
- return 'AA_UnitIsImmune';
- }
- if (default.PAShakeUp_BerserkerImmunity)
- {
- if (TargetUnit.GetMyTemplate().CharacterGroupName == 'Berserker')
- {
- return 'AA_UnitIsImmune';
- }
- }
- }
- BadGuysValue = Value * default.PAShakeUp_DECREASE_PER_VISIBLE_ENEMY;
- TargetRoll = default.PAShakeUp_BASE_CHANCE - BadGuysValue;
- RandRoll = `SYNC_RAND(100);
- if (RandRoll < TargetRoll)
- {
- return 'AA_Success';
- }
- }
- return 'AA_EffectChanceFailed';
- }
- simulated function int CountVisibleUnitsForUnit(XComGameState_Unit SourceUnit, bool bSquadSight = false)
- {
- local X2GameRulesetVisibilityManager VisibilityMgr;
- local array<StateObjectReference> VisibleUnits;
- local array<X2Condition> RequiredConditions;
- local StateObjectReference UnitRef;
- local int Count;
- VisibilityMgr = `TACTICALRULES.VisibilityMgr;
- //Set default conditions (visible units need to be alive and game play visible) if no conditions were specified
- if( RequiredConditions.Length == 0 )
- {
- RequiredConditions = class'X2TacticalVisibilityHelpers'.default.LivingGameplayVisibleFilter;
- }
- if (bSquadSight)
- {
- class'X2TacticalVisibilityHelpers'.static.GetAllVisibleObjectsForPlayer(SourceUnit.ControllingPlayer.ObjectID, VisibleUnits, RequiredConditions, -1);
- }
- else
- {
- VisibilityMgr.GetAllVisibleToSource(SourceUnit.ObjectID, VisibleUnits, class'XComGameState_Unit', -1, RequiredConditions);
- }
- foreach VisibleUnits(UnitRef)
- {
- if (SourceUnit.TargetIsEnemy(UnitRef.ObjectID, -1))
- {
- Count++;
- }
- }
- return Count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement