improvement: use the new attack structure

Replace accuracy and isAerial by attacktype and element
This commit is contained in:
Kazhnuz 2021-05-15 15:01:02 +02:00
parent a22871dcbc
commit 1991b5005f
9 changed files with 25 additions and 23 deletions

View file

@ -0,0 +1,6 @@
local CONST = {}
CONST.ACCURACY = 100
CONST.ATKWRONGTYPE = 0.66
return CONST

View file

@ -14,7 +14,7 @@ return {
choregraphy = { -- the main attack choregraphy
{"goTo", "none", "target", -0.4, 0, 0.5, true},
{"sendDamage", "none", 120, 100, false, false},
{"sendDamage", "none", 120, "basic", "none", false},
{'addGFX', "sentDamage", 'hitGFX', "target", -0.4, 0, true, false},
{'playSFX', "sentDamage", 'hitconnect'},
{'jumpBack', "none", 0.3, true},

View file

@ -18,7 +18,7 @@ return {
{"addQTE", "none", {"simplePrompt", {{"A", 1}}, 0.2}, "target", false},
{'playSFX', "none", 'hit'},
{'setAnimation', "none", 'hit1start', true},
{'sendDamage', "none", 33, 100, false, false},
{'sendDamage', "none", 33, "basic", "none", false},
{'addGFX',"sentDamage", 'hitGFX', "actor", 0.75, 0, true, false},
{'playSFX', "sentDamage", 'hitconnect'},
{'setAnimation', "none", 'hit1end', true},
@ -26,7 +26,7 @@ return {
{"addQTE", "none", {"simplePrompt", {{"A", 1}}, 0.2}, "target", false},
{'playSFX', "none", 'hit'},
{'setAnimation', "none", 'hit2start', true},
{'sendDamage', "none", 33, 100, false, false},
{'sendDamage', "none", 33, "basic", "none", false},
{'addGFX',"sentDamage", 'hitGFX', "actor", 0.75, 0, true, false},
{'playSFX', "sentDamage", 'hitconnect'},
{'setAnimation', "none", 'hit2end', true},
@ -34,7 +34,7 @@ return {
{"addQTE", "none", {"simplePrompt", {{"A", 1}}, 0.2}, "target", false},
{'playSFX', "none", 'hit'},
{'setAnimation', "none", 'hit3start', true},
{'sendDamage', "none", 33, 100, false, false},
{'sendDamage', "none", 33, "basic", "none", false},
{'addGFX',"sentDamage", 'hitGFX', "actor", 0.75, 0, true, false},
{'playSFX', "sentDamage", 'hitconnect'},
{'setAnimation', "none", 'hit3end', true},

View file

@ -19,7 +19,7 @@ return {
{"setAnimation", "none", "spin", false},
{'playSFX', "none", 'spinrelease'},
{"waitActorFinished", "none", "goTo"},
{"sendDamage", "none", 120, 100, false, false},
{"sendDamage", "none", 120, "basic", "none", false},
{'addGFX', "sentDamage", 'hitGFX', "target", 0, 0, true, false},
{'playSFX', "sentDamage", 'hitconnect'},
{'jumpBack', "none", 0.3, true},

View file

@ -14,7 +14,7 @@ return {
{"setAnimation", "none", "spin", false},
{'playSFX', "none", 'spinrelease'},
{"goTo", "none", "target", 0, 0, 0.3, true},
{"sendDamage", "none", 120, 100, false, false},
{"sendDamage", "none", 120, "basic", "none", false},
{'addGFX', "sentDamage", 'hitGFX', "target", 0, 0, true, false},
{'playSFX', "sentDamage", 'hitconnect'},
{'jumpBack', "none", 0.3, true},

View file

@ -2,7 +2,7 @@ return {
["wait"] = {"duration"},
["addGFX"] = {'sprite', "origin", "x", "y", "affectedByDirection", 'blockProcess'},
["playSFX"] = {"sfx"},
["sendDamage"] = {"power", "accuracy", "isSpecial", "isAerial"},
["sendDamage"] = {"power", "type", "element", "isSpecial"},
["goTo"] = {"origin", "x", "y", "duration", "blockProcess"},
["setAnimation"] = {"animation", "blockProcess"},
["jump"] = {"power", "bounceNumber", "blockProcess"},

View file

@ -1,8 +1,6 @@
local FighterParent = Object:extend()
local counter = 0
local AERIAL_ACCURACY_FACTOR = 0
local CONST = require "datas.cbs"
function FighterParent:new(owner, isHero, id)
self.owner = owner
@ -76,7 +74,7 @@ function FighterParent:haveProtecType(type)
return self.abstract:haveProtecType(type)
end
function FighterParent:sendDamage(target, value, accuracy, isSpecial, isAerial)
function FighterParent:sendDamage(target, value, type, element, isSpecial)
local stats = self:getStats()
local value = value / 10
@ -88,10 +86,11 @@ function FighterParent:sendDamage(target, value, accuracy, isSpecial, isAerial)
core.debug:print("cbs/battler", "Sending " .. value .." damage at " .. target.name)
return target:receiveDamage(value, accuracy, isSpecial, isAerial, self)
return target:receiveDamage(value, type, element, isSpecial, self)
end
function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
function FighterParent:receiveDamage(value, type, element, isSpecial, fromWho)
local accuracy = 100
local stats = self:getStats()
local isSuccess = true
@ -101,8 +100,8 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromW
value = value / stats.defense
end
if (self:haveProtecType("aerial") and not isAerial) then
accuracy = accuracy * AERIAL_ACCURACY_FACTOR
if (self:haveProtecType("aerial") and type == "basic") then
value = value * CONST.ATKWRONGTYPE
end
isSuccess = (math.random(100) <= accuracy)
@ -143,7 +142,6 @@ function FighterParent:updateAssets(dt)
end
function FighterParent:setActive()
counter = 0
self.isActive = true
if (self.isDefending) then
self.actor:changeAnimation("idle")

View file

@ -72,10 +72,10 @@ function ChoregraphySystem:endQte(success)
self.qte.wasSuccess = success
end
function ChoregraphySystem:sendDamage(power, accuracy, isSpecial, isAerial)
function ChoregraphySystem:sendDamage(power, type, element, isSpecial)
if (self.target ~= nil) then
if (self.fighter.isAlive) then
self.haveSentDamage = self.fighter:sendDamage(self.target, power, accuracy, isSpecial, isAerial)
self.haveSentDamage = self.fighter:sendDamage(self.target, power, type, element, isSpecial)
else
self.haveSentDamage = false
end

View file

@ -9,13 +9,11 @@ end
function SendDamage:start()
local power = self.arguments.power
local accuracy = self.arguments.accuracy
local isSpecial = self.arguments.isSpecial
local isAerial = self.arguments.isAerial
local type = self.arguments.type
local element = self.arguments.element
self.choregraphy:sendDamage(power, accuracy, isSpecial, isAerial)
self.choregraphy:sendDamage(power, type, element, isSpecial)
self:finish()
end