Re: Cracking Open Combat
Posted: Thu Aug 15, 2019 10:21 pm
D
He didn't say locked viewpoint or movement, he simply said movement speed penalty during swing. It's worth trying.
BansheeXYZ wrote: ↑Fri Aug 16, 2019 2:03 amHe didn't say locked viewpoint or movement, he simply said movement speed penalty during swing. It's worth trying.
Likely to be compatible with players who step in and out of combat frequently. If I were running toward the enemy and my strike distance were calculated too far ahead, I could be nose-to-nose with the enemy and still out of range. Your method of making the PC near-stationary could preclude a need for that calculation, as you've observed.l3lessed wrote: ↑Fri Aug 16, 2019 4:06 pm Also, found an interesting inefficiency in the code I think. Will see if "fixing" it causes any unknown errors. However, the original engine was computing weapon range on every single frame processed because the variable assignment was in a constant void/static method that was always running. I can't find any reason for it to be this way, and that seems like super overkill. I now have the range computing at the beginning of every swing/attack instead of every single dam processed frame.
Code: Select all
private void MeleeDamage(FPSWeapon weapon, out bool hitEnemy)
{
hitEnemy = false;
if (!mainCamera || !weapon)
return;
// Fire ray along player facing using weapon range
// Origin point of ray is set back slightly to fix issue where strikes against enemy capsules touching player capsule do not connect
RaycastHit hit;
Ray ray = new Ray(mainCamera.transform.position + -mainCamera.transform.forward * 0.1f, mainCamera.transform.forward);
if (Physics.SphereCast(ray, SphereCastRadius, out hit, weapon.Reach - SphereCastRadius))
{
hitEnemy = WeaponDamage(hit, mainCamera.transform.forward);
}
}
Code: Select all
void UpdateHands()
{
// Get current items
DaggerfallUnityItem rightHandItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.RightHand);
DaggerfallUnityItem leftHandItem = playerEntity.ItemEquipTable.GetItem(EquipSlots.LeftHand);
// Handle shields
holdingShield = false;
if (leftHandItem != null && leftHandItem.IsShield)
{
usingRightHand = true;
holdingShield = true;
leftHandItem = null;
}
// Right-hand item changed
if (!DaggerfallUnityItem.CompareItems(currentRightHandWeapon, rightHandItem))
currentRightHandWeapon = rightHandItem;
// Left-hand item changed
if (!DaggerfallUnityItem.CompareItems(currentLeftHandWeapon, leftHandItem))
currentLeftHandWeapon = leftHandItem;
if (EquipCountdownRightHand > 0)
{
EquipCountdownRightHand -= Time.deltaTime * 980; // Approximating classic update time based off measuring video
if (EquipCountdownRightHand <= 0)
{
EquipCountdownRightHand = 0;
//pulls weapons range from template using itemhelper script as passthrough
ScreenWeapon.Reach = ItemHelper.getItemRange(currentRightHandWeapon);
//outputs message of equiped hand and weapon range.
string message = HardStrings.rightHandEquipped;
DaggerfallUI.Instance.PopupMessage(message);
DaggerfallUI.Instance.PopupMessage("Weapon Range: " + ScreenWeapon.Reach.ToString() + "f");
}
}
if (EquipCountdownLeftHand > 0)
{
EquipCountdownLeftHand -= Time.deltaTime * 980; // Approximating classic update time based off measuring video
if (EquipCountdownLeftHand <= 0)
{
EquipCountdownLeftHand = 0;
//pulls weapons range from template using itemhelper script as passthrough
ScreenWeapon.Reach = ItemHelper.getItemRange(currentLeftHandWeapon);
//outputs message of equiped hand and weapon range.
string message = HardStrings.leftHandEquipped;
DaggerfallUI.Instance.PopupMessage(message);
DaggerfallUI.Instance.PopupMessage("Weapon Range: " + ScreenWeapon.Reach.ToString() + "f");
}
}
// Apply weapon settings
ApplyWeapon();
}