Skip to content

Commit

Permalink
Fixes for Reforger 1.1 (#36)
Browse files Browse the repository at this point in the history
* New argument in EOnEditorPlace

* Move target visibility handling to EvaluateWeaponAndTarget

* Rename damage manager and use new SCR_HijackDamageHandling method
  • Loading branch information
Kexanone authored Feb 29, 2024
1 parent 9820672 commit a1d573e
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 57 deletions.
32 changes: 19 additions & 13 deletions Scripts/Game/ODIN/AI/Components/SCR_AICombatComponent.c
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@


//------------------------------------------------------------------------------------------------
modded class SCR_AICombatComponent : ScriptComponent
{
override bool SelectTarget(BaseTarget newTarget)
//------------------------------------------------------------------------------------------------
//! Resets selected target if it is not visible
override void EvaluateWeaponAndTarget(out bool outWeaponEvent, out bool outSelectedTargetChanged,
out BaseTarget outPrevTarget, out BaseTarget outCurrentTarget,
out bool outRetreatTargetChanged, out bool outCompartmentChanged)
{
// gotta do null check as otherwise we crash, as when there is no targets at spawn, NewTarget is null. So we just call super and call it a day
if (!newTarget)
return super.SelectTarget(newTarget);
BaseTarget prevTarget = m_SelectedTarget;
super.EvaluateWeaponAndTarget(outWeaponEvent, outSelectedTargetChanged, outPrevTarget, outCurrentTarget, outRetreatTargetChanged, outCompartmentChanged);

// get visibility, if not visible AI can't change to that target, otherwise up to super
bool visible = ODIN_VisibilityHelper.GetVisibility(newTarget.GetTargetEntity());
if (!visible)
return false;
else
return super.SelectTarget(newTarget);
if (!outCurrentTarget)
return;

bool visible = ODIN_VisibilityHelper.GetVisibility(outCurrentTarget.GetTargetEntity());
if (visible)
return;

m_SelectedTarget = prevTarget;
outCurrentTarget = prevTarget;
outSelectedTargetChanged = false;
}
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Special configuration for editable waypoint cycle.
*/
class ODIN_EditableWaypointCycleComponent : SCR_EditableWaypointComponent
{
override SCR_EditableEntityComponent EOnEditorPlace(out SCR_EditableEntityComponent parent, SCR_EditableEntityComponent recipient, EEditorPlacingFlags flags, bool isQueue)
override SCR_EditableEntityComponent EOnEditorPlace(out SCR_EditableEntityComponent parent, SCR_EditableEntityComponent recipient, EEditorPlacingFlags flags, bool isQueue, int playerID = 0)
{
//--- Add the group's waypoints to the waypoint cycle
if (recipient)
Expand All @@ -26,7 +26,7 @@ class ODIN_EditableWaypointCycleComponent : SCR_EditableWaypointComponent
};
};

return super.EOnEditorPlace(parent, recipient, flags, isQueue);
return super.EOnEditorPlace(parent, recipient, flags, isQueue, playerID);
}

override void OnDelete(IEntity owner)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ODIN_ToggleDamageEditorAttribute : SCR_BaseEditorAttribute
if (!SCR_ChimeraCharacter.Cast(owner))
return null;

ScriptedDamageManagerComponent damageComponent = ScriptedDamageManagerComponent.Cast(owner.FindComponent(ScriptedDamageManagerComponent));
SCR_DamageManagerComponent damageComponent = SCR_DamageManagerComponent.Cast(owner.FindComponent(SCR_DamageManagerComponent));
if (!damageComponent)
return null;

Expand All @@ -36,7 +36,7 @@ class ODIN_ToggleDamageEditorAttribute : SCR_BaseEditorAttribute
return;

// todo, move it to helper when verified it works
ScriptedDamageManagerComponent damageComponent = ScriptedDamageManagerComponent.Cast(owner.FindComponent(ScriptedDamageManagerComponent));
SCR_DamageManagerComponent damageComponent = SCR_DamageManagerComponent.Cast(owner.FindComponent(SCR_DamageManagerComponent));
if (!damageComponent)
return;

Expand Down
26 changes: 26 additions & 0 deletions Scripts/GameCode/ODIN/Components/SCR_DamageManagerComponent.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------------------------
modded class SCR_DamageManagerComponent : BaseSCR_DamageManagerComponent
{
protected bool m_bODIN_isDamageEnabled = true;

//------------------------------------------------------------------------------------------------
bool ODIN_IsDamageEnabled()
{
return m_bODIN_isDamageEnabled;
}

//------------------------------------------------------------------------------------------------
void ODIN_SetDamageEnabled(bool enabled)
{
m_bODIN_isDamageEnabled = enabled;
}

//------------------------------------------------------------------------------------------------
override bool SCR_HijackDamageHandling(notnull BaseDamageContext damageContext)
{
if (m_bODIN_isDamageEnabled)
return super.SCR_HijackDamageHandling(damageContext);

return true;
}
}
40 changes: 0 additions & 40 deletions Scripts/GameCode/ODIN/Components/ScriptedDamageManagerComponent.c

This file was deleted.

0 comments on commit a1d573e

Please sign in to comment.