Last active
April 2, 2016 10:05
-
-
Save MalucoMarinero/872dcae0d4581910c18aaa0fea2564f9 to your computer and use it in GitHub Desktop.
AimBonusOnKillStarter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class X2Effect_AimBonusOnKillEffect extends X2Effect_Persistent; | |
var private CachedEffectGameState XComGameState_Effect; | |
function RegisterForEvents(XComGameState_Effect EffectGameState) | |
{ | |
local X2EventManager EventMgr; | |
local Object EffectObj; | |
EventMgr = `XEVENTMGR; | |
EffectObj = EffectGameState; | |
CachedEffectGameState = EffectGameState; | |
EventMgr.RegisterForEvent(EffectObj, 'UnitDied', OnKillEvent, ELD_OnStateSubmitted); | |
} | |
function EventListenerReturn OnKillEvent(Object EventData, Object EventSource, XComGameState GameState, Name EventID) | |
{ | |
local XComGameStateContext_Ability AbilityContext; | |
local XComGameState NewGameState; | |
local XComGameState_Unit SourceUnit, DeadUnit; | |
local XComGameStateHistory History; | |
local UnitValue ImplacableValue; | |
if (!CachedEffectGameState.bRemoved) | |
{ | |
// | |
AbilityContext = XComGameStateContext_Ability(GameState.GetContext()); | |
if (AbilityContext != none) | |
{ | |
if (AbilityContext.InputContext.SourceObject.ObjectID == ApplyEffectParameters.SourceStateObjectRef.ObjectID) | |
{ | |
History = `XCOMHISTORY; | |
SourceUnit = XComGameState_Unit(History.GetGameStateForObjectID(ApplyEffectParameters.SourceStateObjectRef.ObjectID)); | |
DeadUnit = XComGameState_Unit(EventData); | |
if (`TACTICALRULES.GetCachedUnitActionPlayerRef().ObjectID == SourceUnit.ControllingPlayer.ObjectID) | |
{ | |
if (SourceUnit.IsEnemyUnit(DeadUnit)) | |
{ | |
// I've commented out the implacable this turn check, so you'll need to figure out some other way to check | |
// whether the unit has already got the AimBonus Effect | |
// SourceUnit.GetUnitValue(class'X2Effect_Implacable'.default.ImplacableThisTurnValue, ImplacableValue); | |
// if (ImplacableValue.fValue == 0) | |
// { | |
NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState(string(GetFuncName())); | |
XComGameStateContext_ChangeContainer(NewGameState.GetContext()).BuildVisualizationFn = AimBonusOnKillVisualizationFn; | |
// here's where you'll need to add your complementary effect which you'd call AimBonus | |
// might be an example effect you could make use of to get started here? | |
`log('Enemy is dead, you should code in a sweet application of AimBonus here.'); | |
// SourceUnit = XComGameState_Unit(NewGameState.CreateStateObject(SourceUnit.Class, SourceUnit.ObjectID)); | |
// SourceUnit.SetUnitFloatValue(class'X2Effect_Implacable'.default.ImplacableThisTurnValue, 1, eCleanup_BeginTurn); | |
// SourceUnit.ActionPoints.AddItem(class'X2CharacterTemplateManager'.default.MoveActionPoint); | |
NewGameState.AddStateObject(SourceUnit); | |
SubmitNewGameState(NewGameState); | |
// } | |
} | |
} | |
} | |
} | |
} | |
return ELR_NoInterrupt; | |
} | |
// all this code just to float an icon above your head | |
function AimBonusOnKillVisualizationFn(XComGameState VisualizeGameState, out array<VisualizationTrack> OutVisualizationTracks) | |
{ | |
local XComGameState_Unit UnitState; | |
local X2Action_PlaySoundAndFlyOver SoundAndFlyOver; | |
local VisualizationTrack BuildTrack; | |
local XComGameStateHistory History; | |
local X2AbilityTemplate AbilityTemplate; | |
History = `XCOMHISTORY; | |
foreach VisualizeGameState.IterateByClassType(class'XComGameState_Unit', UnitState) | |
{ | |
History.GetCurrentAndPreviousGameStatesForObjectID(UnitState.ObjectID, BuildTrack.StateObject_OldState, BuildTrack.StateObject_NewState, , VisualizeGameState.HistoryIndex); | |
BuildTrack.StateObject_NewState = UnitState; | |
BuildTrack.TrackActor = UnitState.GetVisualizer(); | |
AbilityTemplate = class'X2AbilityTemplateManager'.static.GetAbilityTemplateManager().FindAbilityTemplate('AimBonusOnKill'); | |
if (AbilityTemplate != none) | |
{ | |
SoundAndFlyOver = X2Action_PlaySoundAndFlyOver(class'X2Action_PlaySoundAndFlyOver'.static.AddToVisualizationTrack(BuildTrack, VisualizeGameState.GetContext())); | |
SoundAndFlyOver.SetSoundAndFlyOverParameters(None, AbilityTemplate.LocFlyOverText, '', eColor_Good, AbilityTemplate.IconImage); | |
OutVisualizationTracks.AddItem(BuildTrack); | |
} | |
break; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment