Improve attack hit timing and camera shake

This commit is contained in:
2026-07-10 00:35:50 +09:00
parent 701769fcd7
commit 9bc71c0e32
6 changed files with 251 additions and 75 deletions

View File

@@ -313,6 +313,108 @@ if amount < 0 then
end
self.PlayerBlock = self.PlayerBlock + amount
return amount`, [{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'base' }], 0, 'number'),
method('RunAttackSequence', `if hitDamages == nil or #hitDamages <= 0 then
return
end
local function countAliveMonsters()
local n = 0
if self.Monsters ~= nil then
for mi = 1, #self.Monsters do
local om = self.Monsters[mi]
if om ~= nil and om.alive == true then
n = n + 1
end
end
end
return n
end
local function randomAliveMonsterIndex()
local alive = {}
if self.Monsters ~= nil then
for mi = 1, #self.Monsters do
local om = self.Monsters[mi]
if om ~= nil and om.alive == true then
table.insert(alive, mi)
end
end
end
if #alive <= 0 then
return 0
end
return alive[math.random(1, #alive)]
end
self.FxBusy = true
local hitIndex = 1
local lockedTargetIndex = self.TargetIndex or 0
local function finishSequence()
self.FxBusy = false
self.ActiveAttackDamageVsWeakMultiplier = 1
self:RenderCombat()
self:CheckCombatEnd()
end
local function step()
if self.CombatOver == true then
finishSequence()
return
end
if countAliveMonsters() <= 0 then
finishSequence()
return
end
if hitIndex == 1 then
self.DamageDealtThisTurn = (self.DamageDealtThisTurn or 0) + (roundPlannedDamage or 0)
end
local roundKilled = false
if useAoe == true then
roundKilled = self:DealDamageToAllMonsters(hitDamages[hitIndex] or 0, true)
else
local targetIdx = lockedTargetIndex
if randomTargetEachHit == true then
targetIdx = randomAliveMonsterIndex()
end
if targetIdx ~= nil and targetIdx > 0 then
if randomTargetEachHit ~= true then
local lockedMonster = nil
if self.Monsters ~= nil then
lockedMonster = self.Monsters[targetIdx]
end
if lockedMonster == nil or lockedMonster.alive ~= true then
finishSequence()
return
end
end
local prev = self.TargetIndex
self.TargetIndex = targetIdx
roundKilled = self:DealDamageToTarget(hitDamages[hitIndex] or 0, pierce == true)
self.TargetIndex = prev
end
end
self:RenderCombat()
self:CheckCombatEnd()
hitIndex = hitIndex + 1
if self.CombatOver == true then
finishSequence()
return
end
if hitIndex <= #hitDamages then
_TimerService:SetTimerOnce(step, 0.2)
return
end
if repeatOnKill == true and roundKilled == true and countAliveMonsters() > 0 then
hitIndex = 1
_TimerService:SetTimerOnce(step, 0.2)
return
end
finishSequence()
end
step()`, [
{ Type: 'any', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'hitDamages' },
{ Type: 'number', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'roundPlannedDamage' },
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'useAoe' },
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'randomTargetEachHit' },
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'pierce' },
{ Type: 'boolean', DefaultValue: null, SyncDirection: 0, Attributes: [], Name: 'repeatOnKill' },
]),
method('CountOtherHandSkills', `if self.Hand == nil then
return 0
end
@@ -808,65 +910,7 @@ if c.kind == "Attack" then
if c.class == "shiv" and self.ShivFirstDamageBonusUsed ~= true and self:HasPowerField("firstShivDamageBonus") == true then
self.ShivFirstDamageBonusUsed = true
end
local function countAliveMonsters()
local n = 0
if self.Monsters ~= nil then
for mi = 1, #self.Monsters do
local om = self.Monsters[mi]
if om ~= nil and om.alive == true then n = n + 1 end
end
end
return n
end
local function randomAliveMonsterIndex()
local alive = {}
if self.Monsters ~= nil then
for mi = 1, #self.Monsters do
local om = self.Monsters[mi]
if om ~= nil and om.alive == true then
table.insert(alive, mi)
end
end
end
if #alive <= 0 then
return 0
end
return alive[math.random(1, #alive)]
end
local function resolveAttackRound()
local roundKilled = false
if useAoe == true then
local killed = self:DealDamageToAllMonsters(total, true)
if killed == true then roundKilled = true end
elseif c.randomTargetEachHit == true then
for h = 1, hitN do
local targetIdx = randomAliveMonsterIndex()
if targetIdx ~= nil and targetIdx > 0 then
local prev = self.TargetIndex
self.TargetIndex = targetIdx
local killed = self:DealDamageToTarget(hitDamages[h] or 0, c.pierce == true)
self.TargetIndex = prev
if killed == true then roundKilled = true end
end
end
elseif hitN > 1 then
for h = 1, hitN do
local killed = self:DealDamageToTarget(hitDamages[h] or 0, c.pierce == true)
if killed == true then roundKilled = true end
end
else
local killed = self:DealDamageToTarget(total, c.pierce == true)
if killed == true then roundKilled = true end
end
return roundKilled
end
local totalDamage = 0
local roundKilled = false
repeat
roundKilled = resolveAttackRound()
totalDamage = totalDamage + total
until c.repeatOnKill ~= true or roundKilled ~= true or countAliveMonsters() <= 0
self.DamageDealtThisTurn = (self.DamageDealtThisTurn or 0) + totalDamage
self:RunAttackSequence(hitDamages, total, useAoe, c.randomTargetEachHit == true, c.pierce == true, c.repeatOnKill == true)
end
if c.block ~= nil then
self:AddCardBlock(c.block + (self.HolyChargeCount or 0) * (c.blockPerHolyCharge or 0))