kite28
Member
- Joined
- May 15, 2012
- Messages
- 69
- Reaction score
- 5
hello, I have a little problem with the code because I found it somewhere on the Internet, I'm trying to implement it into tfs 1.4.2 and unfortunately it doesn't work, I'm a beginner scripter who is still learning, could someone help me with it?
local BUFF_SUBID = 1
local Storages = {
LeeBuffExhaust = "LeeBuffExhaust"
}
local SKILL_TAIJUTSU = 1
local CONDITION_PARAM_SKILL_FIST = 590
local CONDITION_PARAM_SKILL_AXE = 591
local c = {
exhaustTime = 30000, -- tempo do exausted pra usar denovo ao fechar
gateInfo = {
[1] = {
onUseSay = {"KAIMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 10},
hitDamage = 20,
hitDelay = 1000,
stopInHealthPercent = 10,
outfit = 138,
effect = {425, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.10,
speedMultiplier = 1.20,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 5,
[CONDITION_PARAM_SKILL_AXE] = 5
},
},
[2] = {
onUseSay = {"KYUUMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 25},
hitDamage = 30,
hitDelay = 1000,
stopInHealthPercent = 10,
outfit = 139,
effect = {425, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.20,
speedMultiplier = 1.40,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 8,
[CONDITION_PARAM_SKILL_AXE] = 8
},
},
[3] = {
onUseSay = {"SEIMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 40},
hitDamage = 40,
hitDelay = 1000,
stopInHealthPercent = 10,
outfit = 140,
effect = {425, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.30,
speedMultiplier = 1.60,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 12,
[CONDITION_PARAM_SKILL_AXE] = 12
},
},
[4] = {
onUseSay = {"SHOOMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 60},
hitDamage = 50,
hitDelay = 1000,
stopInHealthPercent = 10,
outfit = 141,
effect = {425, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.40,
speedMultiplier = 1.80,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 15,
[CONDITION_PARAM_SKILL_AXE] = 15
},
},
[5] = {
onUseSay = {"TOMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 70},
hitDamage = 75,
hitDelay = 1000,
stopInHealthPercent = 10,
outfit = 142,
effect = {425, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.50,
speedMultiplier = 2.00,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 20,
[CONDITION_PARAM_SKILL_AXE] = 20
},
},
[6] = {
onUseSay = {"KEIMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 80},
hitDamage = 100,
hitDelay = 1000,
stopInHealthPercent = 10,
outfit = 143,
effect = {425, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.60,
speedMultiplier = 2.20,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 24,
[CONDITION_PARAM_SKILL_AXE] = 24
},
},
[7] = {
onUseSay = {"KYOOMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 100},
hitDamage = 150,
hitDelay = 1000,
stopInHealthPercent = 10,
outfit = 144,
effect = {424, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.70,
speedMultiplier = 2.50,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 30,
[CONDITION_PARAM_SKILL_AXE] = 30
},
},
[8] = {
onUseSay = {"HACHIMON!", 56},
neededSkill = {SKILL_TAIJUTSU, 140},
hitDamage = 200,
hitDelay = 1000,
stopInHealthPercent = 0,
outfit = 145,
effect = {426, {1, 0}},
effectDelay = 500,
damageMultiplier = 1.80,
speedMultiplier = 3.00,
giveSkills = {
[CONDITION_PARAM_SKILL_FIST] = 40,
[CONDITION_PARAM_SKILL_AXE] = 40
},
}
}
}
local gateHandler = {}
local conditions = {}
for n, i in ipairs(c.gateInfo) do
conditions[n] = {}
if (i.giveSkills) then
local attributesCondition = Condition(CONDITION_ATTRIBUTES, -1, true, BUFF_SUBID)
for paramId, value in pairs(i.giveSkills) do
Condition.setParameter(attributesCondition, paramId, value)
end
conditions[n][#conditions[n] + 1] = attributesCondition
end
if (i.speedMultiplier) then
local speedCondition = Condition(CONDITION_HASTE, -1, true, BUFF_SUBID)
Condition.setFormula(speedCondition, i.speedMultiplier, 0, i.speedMultiplier, 0)
conditions[n][#conditions[n] + 1] = speedCondition
end
end
local function closeGates(cid, full)
if (isCreature(cid)) then
player:removeCondition(cid, CONDITION_ATTRIBUTES, BUFF_SUBID)
player:removeCondition(cid, CONDITION_HASTE, BUFF_SUBID)
player:removeCondition(cid, CONDITION_OUTFIT, 0)
if (full) then
Game.sendAnimatedText("KAI!", position, 215)
doCreatureEraseStorage(cid, Storages.LeeBuff)
timeStorage.set(cid, Storages.LeeBuffExhaust, c.exhaustTime)
gateHandler[cid] = nil
end
end
end
local function hitHealthEvent(cid, serial)
if (isCreature(cid)) then
local handler = gateHandler[cid]
if (not handler or handler.serial ~= serial) then
return
end
local hitDamage = handler.hitHealthStack + handler.gateInfo.hitDamage
local stopInHealthPercent = handler.gateInfo.stopInHealthPercent
if (stopInHealthPercent > 0 and getCreatureHealthPercent(cid, hitDamage) <= stopInHealthPercent) then
closeGates(cid, true)
return
end
player:addHealth(cid, -hitDamage)
gateHandler[cid].hitHealthStack = hitDamage
addEvent(hitHealthEvent, handler.gateInfo.hitDelay, cid, serial)
else
gateHandler[cid] = nil
end
end
local function sendEffectEvent(cid, serial)
if (isCreature(cid)) then
local handler = gateHandler[cid]
if (not handler or handler.serial ~= serial) then
return
end
doSendMagicEffectWithOffset(getThingPosition(cid), handler.gateInfo.effect[1], handler.gateInfo.effect[2])
addEvent(sendEffectEvent, handler.gateInfo.effectDelay, cid, serial)
end
end
function onCastSpell(cid, var)
local player = Player(cid)
local param = var.string:lower()
if (param == "kai") then
if (gateHandler[cid]) then
closeGates(cid, true)
return true
else
player:sendCancelMessageWithEffect(cid, "You do not have any gate open.", CONST_ME_POFF)
return false
end
end
local gateNumber = tonumber(param)
local i = c.gateInfo[gateNumber]
if (i) then
if (timeStorage.has(cid, Storages.LeeBuffExhaust)) then
player:sendCancelMessageWithEffect(cid, "Wait for the cooldown [" .. timeStorage.getCooldown(cid, Storages.LeeBuffExhaust) .. "s].", CONST_ME_POFF)
return false
end
if (getPlayerSkill(cid, i.neededSkill[1]) < i.neededSkill[2]) then
player:sendCancelMessageWithEffect(cid, "You do not have enough " .. SKILL_NAMES[i.neededSkill[1]] .. " (needed: " .. i.neededSkill[2] .. ").", CONST_ME_POFF)
return false
end
local startHitStack = 0
local previousGate = gateHandler[cid]
if (previousGate) then
if (previousGate.gateInfo == i) then
player:sendCancelMessageWithEffect(cid, "You are already with this gate open.", CONST_ME_POFF)
return false
end
startHitStack = previousGate.hitHealthStack
closeGates(cid, false)
end
if (i.onUseSay) then
Game.sendAnimatedText(getThingPosition(cid), i.onUseSay[1], i.onUseSay[2])
end
if (i.outfit) then
playerutfit(cid, {lookType = i.outfit}, -1)
end
local newSerial = genSerial()
gateHandler[cid] = {hitHealthStack = startHitStack, gateInfo = i, serial = newSerial}
player:setStorageValue(cid, Storages.LeeBuff, i.damageMultiplier)
sendEffectEvent(cid, newSerial)
hitHealthEvent(cid, newSerial)
for _, condition in ipairs(conditions[gateNumber]) do
player:addCondition(cid, condition)
end
return true
else
player:sendCancelMessageWithEffect(cid, "How to use: \"open gates kai\", \"open gates 1\", \"open gates 2\"...", CONST_ME_POFF)
end
return false
end