I'm trying to add a Vocation Balancing system via Creaturescripts. But I found a problem. I spent many years incurring it and I'm a little lost.
Nostalrius 7.72 TFS 1.2
OUTP erro:
Login.lua
creaturescrits.lua
healthchange.lua
Can someone help me please?
Nostalrius 7.72 TFS 1.2
OUTP erro:
[Error - CreatureEvent::configureEvent] Invalid type for creature event: balancevoc
[Warning - BaseEvents::loadFromXml] Failed to configure event
Login.lua
Code:
<event type="healthchange" name="balancevoc" script="vocation_balance.lua"/>
creaturescrits.lua
Code:
<event type="healthchange" name="balancevoc" script="vocation_balance.lua"/>
healthchange.lua
Lua:
local balance = {
--All
timesRepeatCondition = 3
intervalCondition = 900
--Knight
canBlock = true,
canBleed = true,
blockChance = 10,
bleedChance = 10,
blockMaxEffect = 70, -- %
blockMinEffect = 20, -- %
bleedMaxDmg = 60, -- this means the percent of the atk dmg =)
bleedMinDmg = 20, -- this means the percent of the atk dmg =)
--Paladin
canHeadShot = true, -- like a critical
canBleedRP = true, --
headshootChance = 20,
bleedChanceRP = 7,
headshootMaxMultiplier = 1.3, -- 2.5x dmg (less than 1 means a dmg reduction instead of a bonus!)
headshootMinMultiplier = 1.0, -- 1.1x dmg (less than 1 means a dmg reduction instead of a bonus!)
bleedMaxDmgRP = 50, -- this means the percent of the atk dmg =)
bleedMinDmgRP = 10, -- this means the percent of the atk dmg =)
--Sorcerer
canBurn = true, -- true or false
canEletrify = true, -- true or false
canCurse = true, -- true or false
burnChance = 10,
eletrifyChance = 10,
curseChance = 10,
burnMaxDmg = 60, -- this means the percent of the atk dmg =)
eletrifyMaxDmg = 60, -- this means the percent of the atk dmg =)
curseMaxDmg = 60, -- this means the percent of the atk dmg =)
burnMinDmg = 20, -- this means the percent of the atk dmg =)
eletrifyMinDmg = 20, -- this means the percent of the atk dmg =)
curseMinDmg = 20, -- this means the percent of the atk dmg =)
--Druid
canParalyze = true, -- true or false
canFreeze = true, -- true or false
paralyzeChance = 10,
freezeChance = 10,
paralyzeMaxEffect = 750, -- for example: 100 = ingame speed 50
paralyzeMinEffect = 350,
freezeMaxDmg = 60, -- this means the percent of the atk dmg =)
freezeMinDmg = 20, -- this means the percent of the atk dmg =)
}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if primaryType == COMBAT_HEALING then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if not attacker then
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
local dmg = 0
local block = math.random(100)
local headshot = math.random(100)
local rand = math.random(100)
local atacado = creature:getMonster()
if not atacado then
atacado = creature
end
if attacker:isPlayer() then
-- KNIGHTS
if attacker:getVocation():getClientId() == 1 then
if balance.canBleed == true then
if rand <= balance.bleedChance then
dmg = primaryDamage * math.random(balance.bleedMinDmg, balance.bleedMaxDmg)/100
local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(balance.timesRepeatCondition, balance.intervalCondition, -dmg)
atacado:addCondition(condition)
end
end
end
-- PALADINS
if attacker:getVocation():getClientId() == 2 then
if balance.canBleedRP == true then
if primaryType == COMBAT_PHYSICALDAMAGE then
if rand <= balance.bleedChanceRP then
dmg = primaryDamage * math.random(balance.bleedMinDmgRP, balance.bleedMaxDmgRP)/100
local condition = Condition(CONDITION_BLEEDING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(balance.timesRepeatCondition, balance.intervalCondition, -dmg)
atacado:addCondition(condition)
end
end
end
if balance.canHeadShot == true then
local hs = (math.random(balance.headshootMinMultiplier, balance.headshootMaxMultiplier))
if headshot <= balance.headshootChance then
if primaryDamage > 0 then
primaryDamage = primaryDamage * hs
creature:say("HEADSHOT!", TALKTYPE_MONSTER_SAY)
end
end
end
end
-- SORCERERS
if attacker:getVocation():getClientId() == 3 then
if balance.canBurn == true then
if primaryType == COMBAT_FIREDAMAGE then
if rand <= balance.burnChance then
dmg = primaryDamage * math.random(balance.burnMinDmg, balance.burnMaxDmg)/100
local condition = Condition(CONDITION_FIRE)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(balance.timesRepeatCondition, balance.intervalCondition, -dmg)
atacado:addCondition(condition)
end
end
end
if balance.canEletrify == true then
if primaryType == COMBAT_ENERGYDAMAGE then
if rand <= balance.eletrifyChance then
dmg = primaryDamage * math.random(balance.eletrifyMinDmg, balance.eletrifyMaxDmg)/100
local condition = Condition(CONDITION_ENERGY)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(balance.timesRepeatCondition, balance.intervalCondition, -dmg)
atacado:addCondition(condition)
end
end
end
if balance.canCurse == true then
if primaryType == COMBAT_DEATHDAMAGE then
if rand <= balance.curseChance then
dmg = primaryDamage * math.random(balance.curseMinDmg, balance.curseMaxDmg)/100
local condition = Condition(CONDITION_CURSED)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(balance.timesRepeatCondition, balance.intervalCondition, -dmg)
atacado:addCondition(condition)
end
end
end
end
-- DRUIDS
if attacker:getVocation():getClientId() == 4 then
if balance.canParalyze == true then
if primaryType == COMBAT_EARTHDAMAGE then
if rand <= balance.paralyzeChance then
local para = math.random(balance.paralyzeMinEffect, balance.paralyzeMaxEffect)
local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 500)
condition:setFormula(-1, para, -1, para)
atacado:addCondition(condition)
end
end
end
if balance.canFreeze == true then
if primaryType == COMBAT_ICEDAMAGE then
if rand <= balance.freezeChance then
dmg = primaryDamage * math.random(balance.freezeMinDmg, balance.freezeMaxDmg)/100
local condition = Condition(CONDITION_FREEZING)
condition:setParameter(CONDITION_PARAM_DELAYED, 1)
condition:addDamage(balance.timesRepeatCondition, balance.intervalCondition, -dmg)
atacado:addCondition(condition)
end
end
end
end
end
-- KNIGHT BLOCK
if creature:isPlayer() and (creature:getVocation():getClientId()) == 1 then
if balance.canBlock == true then
if block <= balance.blockChance then
local blockpercent = math.random(balance.blockMinEffect, balance.blockMaxEffect)
creature:say("BLOCK!", TALKTYPE_MONSTER_SAY)
if primaryDamage > 0 then
primaryDamage = primaryDamage * (blockpercent)/100
end
if secondaryDamage > 0 then
secondaryDamage = secondaryDamage * (blockpercent)/100
end
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
Can someone help me please?
Last edited: