Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add More Substantial Override Paths For Physical Combat, 9/11/2024 #2698

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions Assets/Scripts/Game/EnemyAttack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ public class EnemyAttack : MonoBehaviour
MobileUnit mobile;
DaggerfallEntityBehaviour entityBehaviour;
int damage = 0;

public delegate int ApplyDamageToPlayerCallback(Items.DaggerfallUnityItem weapon);
public delegate int ApplyDamageToNonPlayerCallback(Items.DaggerfallUnityItem weapon, Vector3 direction, bool bowAttack = false);

public ApplyDamageToPlayerCallback ApplyDamageToPlayer { get; set; }
public ApplyDamageToNonPlayerCallback ApplyDamageToNonPlayer { get; set; }

void Start()
{
Expand All @@ -46,6 +52,9 @@ void Start()
sounds = GetComponent<EnemySounds>();
mobile = GetComponent<DaggerfallEnemy>().MobileUnit;
entityBehaviour = GetComponent<DaggerfallEntityBehaviour>();

ApplyDamageToPlayer = DefaultApplyDamageToPlayer;
ApplyDamageToNonPlayer = DefaultApplyDamageToNonPlayer;
}

void FixedUpdate()
Expand Down Expand Up @@ -242,7 +251,7 @@ private void ShootBow()
}
}

private int ApplyDamageToPlayer(Items.DaggerfallUnityItem weapon)
private int DefaultApplyDamageToPlayer(Items.DaggerfallUnityItem weapon)
{
const int doYouSurrenderToGuardsTextID = 15;

Expand Down Expand Up @@ -300,7 +309,7 @@ private int ApplyDamageToPlayer(Items.DaggerfallUnityItem weapon)
return damage;
}

private int ApplyDamageToNonPlayer(Items.DaggerfallUnityItem weapon, Vector3 direction, bool bowAttack = false)
private int DefaultApplyDamageToNonPlayer(Items.DaggerfallUnityItem weapon, Vector3 direction, bool bowAttack = false)
{
if (senses.Target == null)
return 0;
Expand Down
7 changes: 6 additions & 1 deletion Assets/Scripts/Game/WeaponManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ public class WeaponManager : MonoBehaviour

public float EquipCountdownRightHand;
public float EquipCountdownLeftHand;

public delegate bool WeaponDamageCallback(DaggerfallUnityItem strikingWeapon, bool arrowHit, bool arrowSummoned, Transform hitTransform, Vector3 impactPosition, Vector3 direction);
public WeaponDamageCallback WeaponDamage { get; set; }

#region Properties

Expand Down Expand Up @@ -200,6 +203,8 @@ void Start()
_gesture = new Gesture();
_longestDim = Math.Max(Screen.width, Screen.height);
SetMelee(ScreenWeapon);

WeaponDamage = DefaultWeaponDamage;
}

void Update()
Expand Down Expand Up @@ -484,7 +489,7 @@ public bool WeaponEnvDamage(DaggerfallUnityItem strikingWeapon, RaycastHit hit)
}

// Returns true if hit an enemy entity
public bool WeaponDamage(DaggerfallUnityItem strikingWeapon, bool arrowHit, bool arrowSummoned, Transform hitTransform, Vector3 impactPosition, Vector3 direction)
public bool DefaultWeaponDamage(DaggerfallUnityItem strikingWeapon, bool arrowHit, bool arrowSummoned, Transform hitTransform, Vector3 impactPosition, Vector3 direction)
{
DaggerfallEntityBehaviour entityBehaviour = hitTransform.GetComponent<DaggerfallEntityBehaviour>();
var entityMobileUnit = hitTransform.GetComponentInChildren<MobileUnit>();
Expand Down