Skip to content

Commit 0d66c06

Browse files
committed
Merge branch 'ijustwantedtheprivatefunction' into 'master'
Add additional parameters to onHit to disable default behaviour See merge request OpenMW/openmw!5302
2 parents 0490c93 + 8cb4a80 commit 0d66c06

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

files/data-mw/scripts/omw/combat/local.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ local function applyArmor(attack)
192192
core.sendGlobalEvent('ModifyItemCondition', { actor = self, item = item, amount = diff })
193193
end
194194

195+
if attack.muteSound then
196+
return
197+
end
195198
if skillid == 'lightarmor' then
196199
core.sound.playSound3d('Light Armor Hit', self)
197200
elseif skillid == 'mediumarmor' then
@@ -266,15 +269,21 @@ end
266269

267270
local function onHit(data)
268271
if data.successful and not godMode() then
269-
I.Combat.applyArmor(data)
270-
I.Combat.adjustDamageForDifficulty(data)
272+
if not data.ignoreArmor then
273+
I.Combat.applyArmor(data)
274+
end
275+
if not data.ignoreDifficulty then
276+
I.Combat.adjustDamageForDifficulty(data)
277+
end
271278
if getDamage(data, 'health') > 0 then
272-
core.sound.playSound3d('Health Damage', self)
279+
if not data.muteSound then
280+
core.sound.playSound3d('Health Damage', self)
281+
end
273282
if data.hitPos then
274283
I.Combat.spawnBloodEffect(data.hitPos)
275284
end
276285
end
277-
elseif data.attacker and Player.objectIsInstance(data.attacker) then
286+
elseif data.attacker and not data.muteSound and Player.objectIsInstance(data.attacker) then
278287
core.sound.playSound3d('miss', self)
279288
end
280289
Actor._onHit(self, data)

files/data/scripts/omw/combat/interface.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ local onHitHandlers = {}
3030
-- @field [parent=#AttackInfo] openmw.types#Weapon weapon (Optional) Attacking weapon
3131
-- @field [parent=#AttackInfo] #string ammo (Optional) Ammo record ID
3232
-- @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.
33+
-- @field [parent=#AttackInfo] #boolean ignoreArmor (Optional) Whether to ignore armor.
34+
-- @field [parent=#AttackInfo] #boolean ignoreDifficulty (Optional) Whether to ignore difficulty scaling.
35+
-- @field [parent=#AttackInfo] #boolean muteSound (Optional) If true, does not play miss or damage sounds.
3336
return {
3437
--- Basic combat interface
3538
-- @module Combat
@@ -51,7 +54,7 @@ return {
5154
interface = {
5255
--- Interface version
5356
-- @field [parent=#Combat] #number version
54-
version = 1,
57+
version = 2,
5558

5659
--- Add new onHit handler for this actor
5760
-- If `handler(attack)` returns false, other handlers for

0 commit comments

Comments
 (0)