mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-09-23 20:00:45 -04:00
Merge branch 'shuriken' into 'master'
Pass ammo to Hit handler by record id Closes #8664 See merge request OpenMW/openmw!4879
This commit is contained in:
commit
b590cd3421
@ -82,7 +82,7 @@ message(STATUS "Configuring OpenMW...")
|
|||||||
set(OPENMW_VERSION_MAJOR 0)
|
set(OPENMW_VERSION_MAJOR 0)
|
||||||
set(OPENMW_VERSION_MINOR 50)
|
set(OPENMW_VERSION_MINOR 50)
|
||||||
set(OPENMW_VERSION_RELEASE 0)
|
set(OPENMW_VERSION_RELEASE 0)
|
||||||
set(OPENMW_LUA_API_REVISION 93)
|
set(OPENMW_LUA_API_REVISION 94)
|
||||||
set(OPENMW_POSTPROCESSING_API_REVISION 3)
|
set(OPENMW_POSTPROCESSING_API_REVISION 3)
|
||||||
|
|
||||||
set(OPENMW_VERSION_COMMITHASH "")
|
set(OPENMW_VERSION_COMMITHASH "")
|
||||||
|
@ -349,9 +349,8 @@ namespace MWClass
|
|||||||
damage, healthdmg, hitPosition, true, MWMechanics::DamageSourceType::Melee);
|
damage, healthdmg, hitPosition, true, MWMechanics::DamageSourceType::Melee);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages,
|
void Creature::onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, ESM::RefId object,
|
||||||
const MWWorld::Ptr& object, const MWWorld::Ptr& attacker, bool successful,
|
const MWWorld::Ptr& attacker, bool successful, const MWMechanics::DamageSourceType sourceType) const
|
||||||
const MWMechanics::DamageSourceType sourceType) const
|
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
||||||
|
|
||||||
@ -386,8 +385,8 @@ namespace MWClass
|
|||||||
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object.isEmpty())
|
if (!object.empty())
|
||||||
stats.setLastHitAttemptObject(object.getCellRef().getRefId());
|
stats.setLastHitAttemptObject(object);
|
||||||
|
|
||||||
if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer())
|
if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer())
|
||||||
{
|
{
|
||||||
@ -403,8 +402,8 @@ namespace MWClass
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object.isEmpty())
|
if (!object.empty())
|
||||||
stats.setLastHitObject(object.getCellRef().getRefId());
|
stats.setLastHitObject(object);
|
||||||
|
|
||||||
bool hasDamage = false;
|
bool hasDamage = false;
|
||||||
bool hasHealthDamage = false;
|
bool hasHealthDamage = false;
|
||||||
|
@ -66,7 +66,7 @@ namespace MWClass
|
|||||||
void hit(const MWWorld::Ptr& ptr, float attackStrength, int type, const MWWorld::Ptr& victim,
|
void hit(const MWWorld::Ptr& ptr, float attackStrength, int type, const MWWorld::Ptr& victim,
|
||||||
const osg::Vec3f& hitPosition, bool success) const override;
|
const osg::Vec3f& hitPosition, bool success) const override;
|
||||||
|
|
||||||
void onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, const MWWorld::Ptr& object,
|
void onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, ESM::RefId object,
|
||||||
const MWWorld::Ptr& attacker, bool successful,
|
const MWWorld::Ptr& attacker, bool successful,
|
||||||
const MWMechanics::DamageSourceType sourceType) const override;
|
const MWMechanics::DamageSourceType sourceType) const override;
|
||||||
|
|
||||||
|
@ -700,7 +700,7 @@ namespace MWClass
|
|||||||
damage, healthdmg, hitPosition, true, MWMechanics::DamageSourceType::Melee);
|
damage, healthdmg, hitPosition, true, MWMechanics::DamageSourceType::Melee);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Npc::onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, const MWWorld::Ptr& object,
|
void Npc::onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, ESM::RefId object,
|
||||||
const MWWorld::Ptr& attacker, bool successful, const MWMechanics::DamageSourceType sourceType) const
|
const MWWorld::Ptr& attacker, bool successful, const MWMechanics::DamageSourceType sourceType) const
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
MWMechanics::CreatureStats& stats = getCreatureStats(ptr);
|
||||||
@ -735,8 +735,8 @@ namespace MWClass
|
|||||||
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
statsAttacker.setHitAttemptActorId(stats.getActorId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object.isEmpty())
|
if (!object.empty())
|
||||||
stats.setLastHitAttemptObject(object.getCellRef().getRefId());
|
stats.setLastHitAttemptObject(object);
|
||||||
|
|
||||||
if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer())
|
if (setOnPcHitMe && !attacker.isEmpty() && attacker == MWMechanics::getPlayer())
|
||||||
{
|
{
|
||||||
@ -752,8 +752,8 @@ namespace MWClass
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!object.isEmpty())
|
if (!object.empty())
|
||||||
stats.setLastHitObject(object.getCellRef().getRefId());
|
stats.setLastHitObject(object);
|
||||||
|
|
||||||
if (ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())
|
if (ptr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState())
|
||||||
return;
|
return;
|
||||||
|
@ -81,7 +81,7 @@ namespace MWClass
|
|||||||
void hit(const MWWorld::Ptr& ptr, float attackStrength, int type, const MWWorld::Ptr& victim,
|
void hit(const MWWorld::Ptr& ptr, float attackStrength, int type, const MWWorld::Ptr& victim,
|
||||||
const osg::Vec3f& hitPosition, bool success) const override;
|
const osg::Vec3f& hitPosition, bool success) const override;
|
||||||
|
|
||||||
void onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, const MWWorld::Ptr& object,
|
void onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, ESM::RefId object,
|
||||||
const MWWorld::Ptr& attacker, bool successful,
|
const MWWorld::Ptr& attacker, bool successful,
|
||||||
const MWMechanics::DamageSourceType sourceType) const override;
|
const MWMechanics::DamageSourceType sourceType) const override;
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ namespace MWLua
|
|||||||
if (!weapon.isEmpty())
|
if (!weapon.isEmpty())
|
||||||
data["weapon"] = LObject(weapon);
|
data["weapon"] = LObject(weapon);
|
||||||
if (!ammo.isEmpty())
|
if (!ammo.isEmpty())
|
||||||
data["ammo"] = LObject(weapon);
|
data["ammo"] = ammo.getCellRef().getRefId().serializeText();
|
||||||
data["type"] = attackType;
|
data["type"] = attackType;
|
||||||
data["strength"] = attackStrength;
|
data["strength"] = attackStrength;
|
||||||
data["damage"] = damageTable;
|
data["damage"] = damageTable;
|
||||||
|
@ -438,20 +438,27 @@ namespace MWLua
|
|||||||
sourceType = MWMechanics::DamageSourceType::Ranged;
|
sourceType = MWMechanics::DamageSourceType::Ranged;
|
||||||
else if (sourceTypeStr == "magic")
|
else if (sourceTypeStr == "magic")
|
||||||
sourceType = MWMechanics::DamageSourceType::Magical;
|
sourceType = MWMechanics::DamageSourceType::Magical;
|
||||||
sol::optional<Object> weapon = options.get<sol::optional<Object>>("weapon");
|
std::string_view ammoId = options.get_or<std::string_view>("ammo", {});
|
||||||
sol::optional<Object> ammo = options.get<sol::optional<Object>>("ammo");
|
ESM::RefId weaponId = ESM::RefId::deserializeText(ammoId);
|
||||||
|
if (weaponId.empty())
|
||||||
|
{
|
||||||
|
if (sol::optional<Object> weapon = options.get<sol::optional<Object>>("weapon"))
|
||||||
|
{
|
||||||
|
MWWorld::Ptr weaponPtr = weapon->ptrOrEmpty();
|
||||||
|
if (!weaponPtr.isEmpty())
|
||||||
|
weaponId = weaponPtr.getCellRef().getRefId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
context.mLuaManager->addAction(
|
context.mLuaManager->addAction(
|
||||||
[self = Object(self), damages = std::move(damageCpp),
|
[self = Object(self), damages = std::move(damageCpp),
|
||||||
attacker = options.get<sol::optional<Object>>("attacker"), weapon = ammo ? ammo : weapon,
|
attacker = options.get<sol::optional<Object>>("attacker"), weaponId,
|
||||||
successful = options.get<bool>("successful"), sourceType = sourceType] {
|
successful = options.get<bool>("successful"), sourceType = sourceType] {
|
||||||
MWWorld::Ptr attackerPtr;
|
MWWorld::Ptr attackerPtr;
|
||||||
MWWorld::Ptr weaponPtr;
|
MWWorld::Ptr weaponPtr;
|
||||||
if (attacker)
|
if (attacker)
|
||||||
attackerPtr = attacker->ptr();
|
attackerPtr = attacker->ptr();
|
||||||
if (weapon)
|
self.ptr().getClass().onHit(self.ptr(), damages, weaponId, attackerPtr, successful, sourceType);
|
||||||
weaponPtr = weapon->ptr();
|
|
||||||
self.ptr().getClass().onHit(self.ptr(), damages, weaponPtr, attackerPtr, successful, sourceType);
|
|
||||||
},
|
},
|
||||||
"HitAction");
|
"HitAction");
|
||||||
};
|
};
|
||||||
|
@ -359,7 +359,7 @@ namespace
|
|||||||
// Notify the target actor they've been hit
|
// Notify the target actor they've been hit
|
||||||
bool isHarmful = magicEffect->mData.mFlags & ESM::MagicEffect::Harmful;
|
bool isHarmful = magicEffect->mData.mFlags & ESM::MagicEffect::Harmful;
|
||||||
if (target.getClass().isActor() && target != caster && !caster.isEmpty() && isHarmful)
|
if (target.getClass().isActor() && target != caster && !caster.isEmpty() && isHarmful)
|
||||||
target.getClass().onHit(target, {}, MWWorld::Ptr(), caster, true, MWMechanics::DamageSourceType::Magical);
|
target.getClass().onHit(target, {}, {}, caster, true, MWMechanics::DamageSourceType::Magical);
|
||||||
// Apply resistances
|
// Apply resistances
|
||||||
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Ignore_Resistances))
|
if (!(effect.mFlags & ESM::ActiveEffect::Flag_Ignore_Resistances))
|
||||||
{
|
{
|
||||||
|
@ -119,7 +119,7 @@ namespace MWWorld
|
|||||||
throw std::runtime_error("class cannot hit");
|
throw std::runtime_error("class cannot hit");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Class::onHit(const Ptr& ptr, const std::map<std::string, float>& damages, const Ptr& object,
|
void Class::onHit(const Ptr& ptr, const std::map<std::string, float>& damages, ESM::RefId object,
|
||||||
const Ptr& attacker, bool successful, const MWMechanics::DamageSourceType sourceType) const
|
const Ptr& attacker, bool successful, const MWMechanics::DamageSourceType sourceType) const
|
||||||
{
|
{
|
||||||
throw std::runtime_error("class cannot be hit");
|
throw std::runtime_error("class cannot be hit");
|
||||||
|
@ -147,9 +147,8 @@ namespace MWWorld
|
|||||||
/// enums. ignored for creature attacks.
|
/// enums. ignored for creature attacks.
|
||||||
/// (default implementation: throw an exception)
|
/// (default implementation: throw an exception)
|
||||||
|
|
||||||
virtual void onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages,
|
virtual void onHit(const MWWorld::Ptr& ptr, const std::map<std::string, float>& damages, ESM::RefId object,
|
||||||
const MWWorld::Ptr& object, const MWWorld::Ptr& attacker, bool successful,
|
const MWWorld::Ptr& attacker, bool successful, const MWMechanics::DamageSourceType sourceType) const;
|
||||||
const MWMechanics::DamageSourceType sourceType) const;
|
|
||||||
///< Alerts \a ptr that it's being hit for \a damages by \a object (sword, arrow, etc). \a attacker specifies
|
///< Alerts \a ptr that it's being hit for \a damages by \a object (sword, arrow, etc). \a attacker specifies
|
||||||
///< the
|
///< the
|
||||||
/// actor responsible for the attack. \a successful specifies if the hit is
|
/// actor responsible for the attack. \a successful specifies if the hit is
|
||||||
|
@ -192,7 +192,7 @@ local function applyArmor(attack)
|
|||||||
I.SkillProgression.skillUsed(skillid, {useType = I.SkillProgression.SKILL_USE_TYPES.Armor_HitByOpponent})
|
I.SkillProgression.skillUsed(skillid, {useType = I.SkillProgression.SKILL_USE_TYPES.Armor_HitByOpponent})
|
||||||
end
|
end
|
||||||
if item and Armor.objectIsInstance(item) then
|
if item and Armor.objectIsInstance(item) then
|
||||||
local attackerIsUnarmedCreature = attack.attacker and not attack.weapon and Creature.objectIsInstance(attack.attacker)
|
local attackerIsUnarmedCreature = attack.attacker and not attack.weapon and not attack.ammo and Creature.objectIsInstance(attack.attacker)
|
||||||
if settings:get('unarmedCreatureAttacksDamageArmor') or not attackerIsUnarmedCreature then
|
if settings:get('unarmedCreatureAttacksDamageArmor') or not attackerIsUnarmedCreature then
|
||||||
core.sendGlobalEvent('ModifyItemCondition', { actor = self, item = item, amount = diff })
|
core.sendGlobalEvent('ModifyItemCondition', { actor = self, item = item, amount = diff })
|
||||||
end
|
end
|
||||||
@ -307,7 +307,7 @@ end
|
|||||||
-- @field [parent=#AttackInfo] openmw.self#ATTACK_TYPE type (Optional) Attack variant if applicable. For melee attacks this represents chop vs thrust vs slash. For unarmed creatures this implies which of its 3 possible attacks were used. For other attacks this field can be ignored.
|
-- @field [parent=#AttackInfo] openmw.self#ATTACK_TYPE type (Optional) Attack variant if applicable. For melee attacks this represents chop vs thrust vs slash. For unarmed creatures this implies which of its 3 possible attacks were used. For other attacks this field can be ignored.
|
||||||
-- @field [parent=#AttackInfo] openmw.types#Actor attacker (Optional) Attacking actor
|
-- @field [parent=#AttackInfo] openmw.types#Actor attacker (Optional) Attacking actor
|
||||||
-- @field [parent=#AttackInfo] openmw.types#Weapon weapon (Optional) Attacking weapon
|
-- @field [parent=#AttackInfo] openmw.types#Weapon weapon (Optional) Attacking weapon
|
||||||
-- @field [parent=#AttackInfo] openmw.types#Weapon ammo (Optional) Ammo
|
-- @field [parent=#AttackInfo] #string ammo (Optional) Ammo record ID
|
||||||
-- @field [parent=#AttackInfo] openmw.util#Vector3 hitPos (Optional) Where on the victim the attack is landing. Used to spawn blood effects. Blood effects are skipped if nil.
|
-- @field [parent=#AttackInfo] openmw.util#Vector3 hitPos (Optional) Where on the victim the attack is landing. Used to spawn blood effects. Blood effects are skipped if nil.
|
||||||
return {
|
return {
|
||||||
--- Basic combat interface
|
--- Basic combat interface
|
||||||
@ -330,7 +330,7 @@ return {
|
|||||||
interface = {
|
interface = {
|
||||||
--- Interface version
|
--- Interface version
|
||||||
-- @field [parent=#Combat] #number version
|
-- @field [parent=#Combat] #number version
|
||||||
version = 0,
|
version = 1,
|
||||||
|
|
||||||
--- Add new onHit handler for this actor
|
--- Add new onHit handler for this actor
|
||||||
-- If `handler(attack)` returns false, other handlers for
|
-- If `handler(attack)` returns false, other handlers for
|
||||||
|
Loading…
x
Reference in New Issue
Block a user