Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RevScriptSys Monster enhanced attack conditions #3499

Merged
4 commits merged into from
Sep 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
348 changes: 113 additions & 235 deletions data/scripts/lib/register_monster_type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -260,130 +260,122 @@ registerMonsterType.immunities = function(mtype, mask)
end
end
end
registerMonsterType.attacks = function(mtype, mask)
if type(mask.attacks) == "table" then
for _, attack in pairs(mask.attacks) do
local spell = MonsterSpell()
if attack.name then
if attack.name == "melee" then
spell:setType("melee")
if attack.attack and attack.skill then
spell:setAttackValue(attack.attack, attack.skill)
end
if attack.minDamage and attack.maxDamage then
spell:setCombatValue(attack.minDamage, attack.maxDamage)
end
if attack.interval then
spell:setInterval(attack.interval)
end
if attack.effect then
spell:setCombatEffect(attack.effect)
end
if attack.condition then
if attack.condition.type then
spell:setConditionType(attack.condition.type)
end
local startDamage = 0
if attack.condition.startDamage then
startDamage = attack.condition.startDamage
end
if attack.condition.minDamage and attack.condition.maxDamage then
spell:setConditionDamage(attack.condition.minDamage, attack.condition.maxDamage, startDamage)
end
if attack.condition.duration then
spell:setConditionDuration(attack.condition.duration)
end
if attack.condition.interval then
spell:setConditionTickInterval(attack.condition.interval)
end
end
else
spell:setType(attack.name)
if attack.type then
if attack.name == "combat" then
spell:setCombatType(attack.type)
else
spell:setConditionType(attack.type)
end
end
if attack.interval then
spell:setInterval(attack.interval)
end
if attack.chance then
spell:setChance(attack.chance)
end
if attack.range then
spell:setRange(attack.range)
end
if attack.duration then
spell:setConditionDuration(attack.duration)
end
if attack.speed then
if type(attack.speed) ~= "table" then
spell:setConditionSpeedChange(attack.speed)
elseif type(attack.speed) == "table" then
if attack.speed.min and attack.speed.max then
spell:setConditionSpeedChange(attack.speed.min, attack.speed.max)
end
end
end
if attack.target then
spell:setNeedTarget(attack.target)
end
if attack.length then
spell:setCombatLength(attack.length)
end
if attack.spread then
spell:setCombatSpread(attack.spread)
end
if attack.radius then
spell:setCombatRadius(attack.radius)
end
if attack.ring then
spell:setCombatRing(attack.ring)
end
if attack.minDamage and attack.maxDamage then
if attack.name == "combat" then
spell:setCombatValue(attack.minDamage, attack.maxDamage)
else
local startDamage = 0
if attack.startDamage then
startDamage = attack.startDamage
end
spell:setConditionDamage(attack.minDamage, attack.maxDamage, startDamage)
end
end
if attack.effect then
spell:setCombatEffect(attack.effect)
end
if attack.shootEffect then
spell:setCombatShootEffect(attack.shootEffect)
end
if attack.name == "drunk" then
spell:setConditionType(CONDITION_DRUNK)
if attack.drunkenness then
spell:setConditionDrunkenness(attack.drunkenness)
end
local function AbilityTableToSpell(ability)
local spell = MonsterSpell()
if ability.name then
if ability.name == "melee" then
spell:setType("melee")
if ability.attack and ability.skill then
spell:setAttackValue(ability.attack, ability.skill)
end
if ability.minDamage and ability.maxDamage then
spell:setCombatValue(ability.minDamage, ability.maxDamage)
end
if ability.interval then
spell:setInterval(ability.interval)
end
if ability.effect then
spell:setCombatEffect(ability.effect)
end
else
spell:setType(ability.name)
if ability.type then
spell:setCombatType(ability.type)
end
if ability.interval then
spell:setInterval(ability.interval)
end
if ability.chance then
spell:setChance(ability.chance)
end
if ability.range then
spell:setRange(ability.range)
end
if ability.duration then
spell:setConditionDuration(ability.duration)
end
if ability.speed then
if type(ability.speed) ~= "table" then
spell:setConditionSpeedChange(ability.speed)
elseif type(ability.speed) == "table" then
if ability.speed.min and ability.speed.max then
spell:setConditionSpeedChange(ability.speed.min, ability.speed.max)
end
end
elseif attack.script then
spell:setScriptName(attack.script)
if attack.interval then
spell:setInterval(attack.interval)
end
if attack.chance then
spell:setChance(attack.chance)
end
if attack.minDamage and attack.maxDamage then
spell:setCombatValue(attack.minDamage, attack.maxDamage)
end
if attack.target then
spell:setNeedTarget(attack.target)
end
if attack.direction then
spell:setNeedDirection(attack.direction)
end
if ability.target then
spell:setNeedTarget(ability.target)
end
if ability.length then
spell:setCombatLength(ability.length)
end
if ability.spread then
spell:setCombatSpread(ability.spread)
end
if ability.radius then
spell:setCombatRadius(ability.radius)
end
if ability.ring then
spell:setCombatRing(ability.ring)
end
if ability.minDamage and ability.maxDamage then
spell:setCombatValue(ability.minDamage, ability.maxDamage)
end
if ability.effect then
spell:setCombatEffect(ability.effect)
end
if ability.shootEffect then
spell:setCombatShootEffect(ability.shootEffect)
end
if ability.name == "drunk" then
spell:setConditionType(CONDITION_DRUNK)
if ability.drunkenness then
spell:setConditionDrunkenness(ability.drunkenness)
end
end
end
if ability.condition then
if ability.condition.type then
spell:setConditionType(ability.condition.type)
end
local startDamage = 0
if ability.condition.startDamage then
startDamage = ability.condition.startDamage
end
if ability.condition.minDamage and ability.condition.maxDamage then
spell:setConditionDamage(ability.condition.minDamage, ability.condition.maxDamage, startDamage)
end
if ability.condition.duration then
spell:setConditionDuration(ability.condition.duration)
end
if ability.condition.interval then
spell:setConditionTickInterval(ability.condition.interval)
end
end
elseif ability.script then
spell:setScriptName(ability.script)
if ability.interval then
spell:setInterval(ability.interval)
end
if ability.chance then
spell:setChance(ability.chance)
end
if ability.minDamage and ability.maxDamage then
spell:setCombatValue(ability.minDamage, ability.maxDamage)
end
if ability.target then
spell:setNeedTarget(ability.target)
end
if ability.direction then
spell:setNeedDirection(ability.direction)
end
end
return spell
end
registerMonsterType.attacks = function(mtype, mask)
if type(mask.attacks) == "table" then
for _, attack in pairs(mask.attacks) do
local spell = AbilityTableToSpell(attack)
mtype:addAttack(spell)
end
end
Expand All @@ -398,121 +390,7 @@ registerMonsterType.defenses = function(mtype, mask)
end
for _, defense in pairs(mask.defenses) do
if type(defense) == "table" then
local spell = MonsterSpell()
if defense.name then
if defense.name == "melee" then
spell:setType("melee")
if defense.attack and defense.skill then
spell:setAttackValue(defense.attack, defense.skill)
end
if defense.minDamage and defense.maxDamage then
spell:setCombatValue(defense.minDamage, defense.maxDamage)
end
if defense.interval then
spell:setInterval(defense.interval)
end
if defense.effect then
spell:setCombatEffect(defense.effect)
end
if defense.condition then
if defense.condition.type then
spell:setConditionType(defense.condition.type)
end
local startDamage = 0
if defense.condition.startDamage then
startDamage = defense.condition.startDamage
end
if defense.condition.minDamage and defense.condition.maxDamage then
spell:setConditionDamage(defense.condition.minDamage, defense.condition.maxDamage, startDamage)
end
if defense.condition.duration then
spell:setConditionDuration(defense.condition.duration)
end
if defense.condition.interval then
spell:setConditionTickInterval(defense.condition.interval)
end
end
else
spell:setType(defense.name)
if defense.type then
if defense.name == "combat" then
spell:setCombatType(defense.type)
else
spell:setConditionType(defense.type)
end
end
if defense.interval then
spell:setInterval(defense.interval)
end
if defense.chance then
spell:setChance(defense.chance)
end
if defense.range then
spell:setRange(defense.range)
end
if defense.duration then
spell:setConditionDuration(defense.duration)
end
if defense.speed then
if type(defense.speed) ~= "table" then
spell:setConditionSpeedChange(defense.speed)
elseif type(defense.speed) == "table" then
if defense.speed.min and defense.speed.max then
spell:setConditionSpeedChange(defense.speed.min, defense.speed.max)
end
end
end
if defense.target then
spell:setNeedTarget(defense.target)
end
if defense.length then
spell:setCombatLength(defense.length)
end
if defense.spread then
spell:setCombatSpread(defense.spread)
end
if defense.radius then
spell:setCombatRadius(defense.radius)
end
if defense.ring then
spell:setCombatRing(defense.ring)
end
if defense.minDamage and defense.maxDamage then
if defense.name == "combat" then
spell:setCombatValue(defense.minDamage, defense.maxDamage)
else
local startDamage = 0
if defense.startDamage then
startDamage = defense.startDamage
end
spell:setConditionDamage(defense.minDamage, defense.maxDamage, startDamage)
end
end
if defense.effect then
spell:setCombatEffect(defense.effect)
end
if defense.shootEffect then
spell:setCombatShootEffect(defense.shootEffect)
end
end
elseif defense.script then
spell:setScriptName(defense.script)
if defense.interval then
spell:setInterval(defense.interval)
end
if defense.chance then
spell:setChance(defense.chance)
end
if defense.minDamage and defense.maxDamage then
spell:setCombatValue(defense.minDamage, defense.maxDamage)
end
if defense.target then
spell:setNeedTarget(defense.target)
end
if defense.direction then
spell:setNeedDirection(defense.direction)
end
end
local spell = AbilityTableToSpell(defense)
mtype:addDefense(spell)
end
end
Expand Down
Loading