mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-29 21:45:32 +00:00
[General] Add sync for ranged weapon & projectile strike enchantments
This commit is contained in:
parent
3f8d94b030
commit
a86c68c5a1
7 changed files with 48 additions and 11 deletions
|
@ -307,7 +307,6 @@ namespace MWClass
|
|||
if (localAttack)
|
||||
{
|
||||
localAttack->success = true;
|
||||
localAttack->usesStrikeEnchantment = false;
|
||||
MechanicsHelper::assignAttackTarget(localAttack, victim);
|
||||
}
|
||||
/*
|
||||
|
@ -384,7 +383,7 @@ namespace MWClass
|
|||
bool appliedEnchantment = MWMechanics::applyOnStrikeEnchantment(ptr, victim, weapon, hitPosition);
|
||||
|
||||
if (localAttack)
|
||||
localAttack->usesStrikeEnchantment = appliedEnchantment;
|
||||
localAttack->applyWeaponEnchantment = appliedEnchantment;
|
||||
/*
|
||||
End of tes3mp change (minor)
|
||||
*/
|
||||
|
|
|
@ -634,7 +634,6 @@ namespace MWClass
|
|||
if (localAttack)
|
||||
{
|
||||
localAttack->success = true;
|
||||
localAttack->usesStrikeEnchantment = false;
|
||||
MechanicsHelper::assignAttackTarget(localAttack, victim);
|
||||
}
|
||||
/*
|
||||
|
@ -717,7 +716,7 @@ namespace MWClass
|
|||
bool appliedEnchantment = MWMechanics::applyOnStrikeEnchantment(ptr, victim, weapon, hitPosition);
|
||||
|
||||
if (localAttack)
|
||||
localAttack->usesStrikeEnchantment = appliedEnchantment;
|
||||
localAttack->applyWeaponEnchantment = appliedEnchantment;
|
||||
/*
|
||||
End of tes3mp change (minor)
|
||||
*/
|
||||
|
|
|
@ -290,10 +290,29 @@ namespace MWMechanics
|
|||
reduceWeaponCondition(damage, validVictim, weapon, attacker);
|
||||
|
||||
// Apply "On hit" effect of the weapon & projectile
|
||||
|
||||
/*
|
||||
Start of tes3mp change (minor)
|
||||
|
||||
Track whether the strike enchantment is successful for attacks by the
|
||||
LocalPlayer or LocalActors for both their weapon and projectile
|
||||
*/
|
||||
mwmp::Attack *localAttack = MechanicsHelper::getLocalAttack(attacker);
|
||||
|
||||
bool appliedEnchantment = applyOnStrikeEnchantment(attacker, victim, weapon, hitPosition, true);
|
||||
|
||||
if (localAttack)
|
||||
localAttack->applyWeaponEnchantment = appliedEnchantment;
|
||||
|
||||
if (weapon != projectile)
|
||||
appliedEnchantment = applyOnStrikeEnchantment(attacker, victim, projectile, hitPosition, true);
|
||||
|
||||
if (localAttack)
|
||||
localAttack->applyProjectileEnchantment = appliedEnchantment;
|
||||
/*
|
||||
End of tes3mp change (minor)
|
||||
*/
|
||||
|
||||
if (validVictim)
|
||||
{
|
||||
// Non-enchanted arrows shot at enemies have a chance to turn up in their inventory
|
||||
|
|
|
@ -124,6 +124,8 @@ void MechanicsHelper::resetAttack(Attack* attack)
|
|||
attack->success = false;
|
||||
attack->knockdown = false;
|
||||
attack->block = false;
|
||||
attack->applyWeaponEnchantment = false;
|
||||
attack->applyProjectileEnchantment = false;
|
||||
attack->target.guid = RakNet::RakNetGUID();
|
||||
attack->target.refId.clear();
|
||||
}
|
||||
|
@ -170,14 +172,20 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
|
|||
if (attack.type == attack.MELEE)
|
||||
{
|
||||
MWWorld::Ptr weapon;
|
||||
MWWorld::Ptr projectile;
|
||||
|
||||
if (attacker.getClass().hasInventoryStore(attacker))
|
||||
{
|
||||
MWWorld::InventoryStore &inv = attacker.getClass().getInventoryStore(attacker);
|
||||
MWWorld::ContainerStoreIterator weaponslot = inv.getSlot(
|
||||
MWWorld::InventoryStore &inventoryStore = attacker.getClass().getInventoryStore(attacker);
|
||||
MWWorld::ContainerStoreIterator weaponSlot = inventoryStore.getSlot(
|
||||
MWWorld::InventoryStore::Slot_CarriedRight);
|
||||
MWWorld::ContainerStoreIterator projectileSlot = inventoryStore.getSlot(
|
||||
MWWorld::InventoryStore::Slot_Ammunition);
|
||||
|
||||
// TODO: Fix for when arrows, bolts and throwing weapons have just run out
|
||||
weapon = weaponSlot != inventoryStore.end() ? *weaponSlot : MWWorld::Ptr();
|
||||
projectile = projectileSlot != inventoryStore.end() ? *projectileSlot : MWWorld::Ptr();
|
||||
|
||||
weapon = ((weaponslot != inv.end()) ? *weaponslot : MWWorld::Ptr());
|
||||
if (!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name())
|
||||
weapon = MWWorld::Ptr();
|
||||
}
|
||||
|
@ -196,14 +204,23 @@ void MechanicsHelper::processAttack(Attack attack, const MWWorld::Ptr& attacker)
|
|||
}
|
||||
else
|
||||
{
|
||||
LOG_APPEND(Log::LOG_VERBOSE, "- weapon: %s", weapon.getCellRef().getRefId().c_str());
|
||||
|
||||
MWMechanics::blockMeleeAttack(attacker, victim, weapon, attack.damage, 1);
|
||||
|
||||
if (attack.usesStrikeEnchantment)
|
||||
if (attack.applyWeaponEnchantment)
|
||||
{
|
||||
MWMechanics::CastSpell cast(attacker, victim, false);
|
||||
cast.mHitPosition = osg::Vec3f();
|
||||
cast.cast(weapon, false);
|
||||
}
|
||||
|
||||
if (attack.applyProjectileEnchantment)
|
||||
{
|
||||
MWMechanics::CastSpell cast(attacker, victim, false);
|
||||
cast.mHitPosition = osg::Vec3f();
|
||||
cast.cast(projectile, false);
|
||||
}
|
||||
}
|
||||
|
||||
victim.getClass().onHit(victim, attack.damage, healthdmg, weapon, attacker, osg::Vec3f(),
|
||||
|
|
|
@ -53,7 +53,8 @@ namespace mwmp
|
|||
bool pressed;
|
||||
bool instant;
|
||||
bool knockdown;
|
||||
bool usesStrikeEnchantment;
|
||||
bool applyWeaponEnchantment;
|
||||
bool applyProjectileEnchantment;
|
||||
|
||||
bool shouldSend;
|
||||
};
|
||||
|
|
|
@ -25,5 +25,6 @@ void PacketActorAttack::Actor(BaseActor &actor, bool send)
|
|||
RW(actor.attack.block, send);
|
||||
|
||||
RW(actor.attack.instant, send);
|
||||
RW(actor.attack.usesStrikeEnchantment, send);
|
||||
RW(actor.attack.applyWeaponEnchantment, send);
|
||||
RW(actor.attack.applyProjectileEnchantment, send);
|
||||
}
|
||||
|
|
|
@ -30,5 +30,6 @@ void PacketPlayerAttack::Packet(RakNet::BitStream *bs, bool send)
|
|||
RW(player->attack.knockdown, send);
|
||||
RW(player->attack.block, send);
|
||||
|
||||
RW(player->attack.usesStrikeEnchantment, send);
|
||||
RW(player->attack.applyWeaponEnchantment, send);
|
||||
RW(player->attack.applyProjectileEnchantment, send);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue