Jump to content

(Simple) Mod Help


sleepyx732

Recommended Posts

As simple of a change it is, because I can't do a simple overwrite (I have to use the SDK for this) I'm not exactly sure what I am doing. I'd like to switch around the triggers for the Ever Vigilant perk and the Deep Cover perk.

 

 

// This is an Unreal Script
class PerkMod extends XComGameState_Ability dependson(X2TacticalGameRuleset, X2Effect, X2AbilityTemplate)

function EventListenerReturn EverVigilantTurnEndListener(Object EventData, Object EventSource, XComGameState GameState, Name EventID)
{
local XComGameState_Unit UnitState;
local UnitValue AttacksThisTurn;
local bool GotValue;
local StateObjectReference OverwatchRef;
local XComGameState_Ability OverwatchState;
local XComGameStateHistory History;
local XComGameState NewGameState;
local EffectAppliedData ApplyData;
local X2Effect VigilantEffect;

History = `XCOMHISTORY;
UnitState = XComGameState_Unit(GameState.GetGameStateForObjectID(OwnerStateObject.ObjectID));
if (UnitState == none)
UnitState = XComGameState_Unit(History.GetGameStateForObjectID(OwnerStateObject.ObjectID));

if (UnitState.NumAllReserveActionPoints() == 0) // don't activate overwatch if the unit is potentially doing another reserve action
{
GotValue = UnitState.GetUnitValue('AttacksThisTurn', AttacksThisTurn);
if (!GotValue || AttacksThisTurn.fValue == 0)
{
OverwatchRef = UnitState.FindAbility('Overwatch');
OverwatchState = XComGameState_Ability(History.GetGameStateForObjectID(OverwatchRef.ObjectID));
if (OverwatchState != none)
{
NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState(string(GetFuncName()));
UnitState = XComGameState_Unit(NewGameState.CreateStateObject(UnitState.Class, UnitState.ObjectID));
// apply the EverVigilantActivated effect directly to the unit
ApplyData.EffectRef.LookupType = TELT_AbilityShooterEffects;
ApplyData.EffectRef.TemplateEffectLookupArrayIndex = 0;
ApplyData.EffectRef.SourceTemplateName = 'EverVigilantTrigger';
ApplyData.PlayerStateObjectRef = UnitState.ControllingPlayer;
ApplyData.SourceStateObjectRef = UnitState.GetReference();
ApplyData.TargetStateObjectRef = UnitState.GetReference();
VigilantEffect = class'X2Effect'.static.GetX2Effect(ApplyData.EffectRef);
`assert(VigilantEffect != none);
VigilantEffect.ApplyEffect(ApplyData, UnitState, NewGameState);

if (UnitState.NumActionPoints() == 0)
{
// give the unit an action point so they can activate overwatch
UnitState.ActionPoints.AddItem(class'X2CharacterTemplateManager'.default.StandardActionPoint);
}
UnitState.SetUnitFloatValue(class'X2Ability_SpecialistAbilitySet'.default.EverVigilantEffectName, 1, eCleanup_BeginTurn);

NewGameState.AddStateObject(UnitState);
`TACTICALRULES.SubmitGameState(NewGameState);
return OverwatchState.AbilityTriggerEventListener_Self(EventData, EventSource, GameState, EventID);
}
}
}

return ELR_NoInterrupt;
}

function EventListenerReturn DeepCoverTurnEndListener(Object EventData, Object EventSource, XComGameState GameState, Name EventID)
{
local XComGameState_Unit UnitState;
local UnitValue NonMoveActionsThisTurn;
local bool GotValue;
local StateObjectReference HunkerDownRef;
local XComGameState_Ability HunkerDownState;
local XComGameStateHistory History;
local XComGameState NewGameState;

History = `XCOMHISTORY;
UnitState = XComGameState_Unit(GameState.GetGameStateForObjectID(OwnerStateObject.ObjectID));
if (UnitState == none)
UnitState = XComGameState_Unit(History.GetGameStateForObjectID(OwnerStateObject.ObjectID));

if (UnitState != none && !UnitState.IsHunkeredDown())
{
GotValue = UnitState.GetUnitValue('NonMoveActionsThisTurn', NonMoveActionsThisTurn);
if (!GotValue || NonMoveActionsThisTurn.fValue == 0)
{
HunkerDownRef = UnitState.FindAbility('HunkerDown');
HunkerDownState = XComGameState_Ability(History.GetGameStateForObjectID(HunkerDownRef.ObjectID));
if (HunkerDownState != none && HunkerDownState.CanActivateAbility(UnitState,,true) == 'AA_Success')
{
if (UnitState.NumActionPoints() == 0)
{
NewGameState = class'XComGameStateContext_ChangeContainer'.static.CreateChangeState(string(GetFuncName()));
UnitState = XComGameState_Unit(NewGameState.CreateStateObject(UnitState.Class, UnitState.ObjectID));
// give the unit an action point so they can activate hunker down
UnitState.ActionPoints.AddItem(class'X2CharacterTemplateManager'.default.DeepCoverActionPoint);
NewGameState.AddStateObject(UnitState);
`TACTICALRULES.SubmitGameState(NewGameState);
}

return HunkerDownState.AbilityTriggerEventListener_Self(EventData, EventSource, GameState, EventID);
}
}
}

return ELR_NoInterrupt;
}

 

 

Now as far as I know as all I have to do is have that in an UnrealSource file under src/modname/classes. I switched around local UnitValue NonMoveActionsThisTurn/AttacksThisTurn and the GotValue reference. However when I attempt to build solution I get 2 errors unrelated to the src file.

 

C:\Program Files (x86)\Steam\steamapps\common\XCOM 2 SDK\Development\Src\XComGame\Classes\X2Ability_Cyberus.uc(1291) : Error, Delegate assignment failed (AbilityEventDelegate): Invalid or unknown function 'AbilityTriggerEventListener_DamagedByEnemyTeleport'

 

C:\Program Files (x86)\Steam\steamapps\common\XCOM 2 SDK\Development\Src\XComGame\Classes\X2TacticalGameRuleset.uc(1447) : Error, Unrecognized member 'CheckForPostBeginPlayActivation' in class 'XComGameState_Ability'

 

I don't know why it's copying and messing with these files anyway, along with all the other class files that come with when selecting New Project -> DefaultMod. I deleted the two files referenced and I still get the errors.

Edited by sleepyx732
Link to comment
Share on other sites

Uhh, the default mod comes with very outdated sources, you should go to the solution directory using the windows explorer and remove the write-lock on all files in MyMod/Src/XComGame/Classes/*.uc

 

Then delete all these files out of ModBuddy.

 

Secondary, overriding XComGameState_Ability is a bad idea. You should rather try to just write two new triggers for the abilities and use OnPostTemplatesCreated to chnage the trigger functions.

 

If you totally don't know how to do that, just ask me to write the code so you can take a look at it.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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