Tudo que marcot postou
-
Script
Tava olhando o código, não dá pra dar getPlayerPosition(target) dessa forma, vai dar erro no terminal porque você não tem certeza se o player tem um target e nem se esse target é um player
-
Pedido Item Bonus
Tenta rodar com esses: local burnBuff = { storageID = 23000, interval = 1, -- intervalo entre turnos damage = 5, -- dano de cada turno ticks = 5, -- quantidade de turnos effect = CONST_ME_HITBYFIRE, -- efeito } -- FIRE EFFECT local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true) setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, burnBuff.effect) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE) local condition = createConditionObject(CONDITION_FIRE) setConditionParam(condition, CONDITION_PARAM_DELAYED, 1) addDamageCondition(condition, burnBuff.ticks, burnBuff.interval, -burnBuff.damage) setCombatCondition(combat, condition) function onAttack(cid, target) storageStatus = getPlayerStorageValue (cid, burnBuff.storageID) playerPos = getCreaturePosition (cid) targetPos = getCreaturePosition (target) if storageStatus == 0 then return true end -- FIM - jogador sem o buff if getDistanceBetween (playerPos, targetPos) > 1 then return true end -- FIM - jogador longe if storageStatus == 1 then -- Efeito Energy doCombatAreaCondition(cid, targetPos, nil, condition, burnBuff.effect) end return true end local energyBuff = { storageID = 23001, chance = 50, -- % de ativacao, 0~100 effect = CONST_ME_ENERGYHIT, -- efeito } -- ENERGY EFFECT local combat1 = createCombatObject() setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE) setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -0.6, -30, -1.2, 0) local arr = { {0, 0, 0}, {1, 3, 1}, {0, 0, 0} } local area = createCombatArea(arr) setCombatArea(combat1, area) ------------------------------------------------------------------------ function onAttack(cid, target) storageStatus = getPlayerStorageValue (cid, energyBuff.storageID) playerPos = getCreaturePosition (cid) targetPos = getCreaturePosition (target) if storageStatus == 0 then return true end -- FIM - jogador sem o buff if getDistanceBetween (playerPos, targetPos) > 1 then return true end -- FIM - jogador longe if storageStatus == 1 then -- Efeito Energy if math.random (0, 100) < energyBuff.chance then -- % de ativacao doCombat(cid, combat1, numberToVariant(target)) -- Dano em area doSendMagicEffect (targetPos, energyBuff.effect) -- efeito end end return true end local healBuff = { storageID = 23002, chance = 25, -- % de ativacao, 0~100 lifePercentage = 25, -- % de vida em cura, 0~100 effect = CONST_ME_SMALLPLANTS, -- efeito } function onAttack(cid, target) storageStatus = getPlayerStorageValue (cid, healBuff.storageID) playerPos = getCreaturePosition (cid) targetPos = getCreaturePosition (target) if storageStatus == 0 then return true end -- FIM - jogador sem o buff if getDistanceBetween (playerPos, targetPos) > 1 then return true end -- FIM - jogador longe if storageStatus == 1 then -- Efeito de Heal if math.random (0, 100) < healBuff.chance then -- % de ativacao doCreatureAddHealth (cid, getCreatureMaxHealth(cid) * healBuff.lifePercentage / 100) -- formula de Heal doSendMagicEffect (playerPos, healBuff.effect) -- efeito end end return true end local waterBuff = { storageID = 23004, cooldown = 30, -- tempo para ativar proximo cooldownStorage = 23003, -- storage interval = 1, -- intevalo entre turnos effect = CONST_ME_LOSEENERGY, -- efeito } -- WATER EFFECT local combat2 = createCombatObject() setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE) setCombatParam(combat2, COMBAT_PARAM_EFFECT, waterBuff.effect) setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -0.6, -30, -1.2, 0) local arr2 = { {1, 1, 1}, {1, 2, 1}, {1, 1, 1} } local area = createCombatArea(arr2) setCombatArea(combat2, area) function onAttack(cid, target) storageStatus = getPlayerStorageValue (cid, waterBuff.storageID) playerPos = getCreaturePosition (cid) targetPos = getCreaturePosition (target) if storageStatus == 0 then return true end -- FIM - jogador sem o buff if getDistanceBetween (playerPos, targetPos) > 1 then return true end -- FIM - jogador longe if storageStatus == 1 then if getPlayerStorageValue(cid, waterBuff.cooldownStorage) < os.time() then -- respeitando intervalo (para nao stackar 2 skills) setPlayerStorageValue (cid, waterBuff.cooldownStorage, os.time() + waterBuff.cooldown) -- cooldown set addEvent (waterCombat, waterBuff.interval * 1000, cid, waterBuff.cooldown) -- inicia evento waterCombat, responsavel pela skill end end return true end -- evento waterCombat function waterCombat (cid, times) if times == 0 then -- caso base de recursividade, quando termina o evento return true else -- caso recursivo doCombat (cid, combat2, numberToVariant(cid)) -- skill individual addEvent (waterCombat, waterBuff.interval * 1000, cid, times - 1) -- reativa o evento end end Para os testes os StorageIDs estão diferentes uns dos outros e todos são ativados quando o storage guarda 1. Pra adicionar serão necessárias 4 tags e você tem que adicionar pra cada tag uma daquelas linhas do login.lua com o nome correto
-
Pedido Item Bonus
Amanhã vou dar uma otimizada em algumas coisas do script e terminar a parte de configuração. Tem mais algo que você queira? (Mesmo que os itens sejam diferentes ainda dá pra fazer com um só script). @ahrizinhas2 A versão abaixo está um pouco mais intuitiva para configuração e tem uma pequena melhora de desempenho -- Configuracoes do script local globalConfig = { storageID = 23000, } local burnBuff = { interval = 1, -- intervalo entre turnos damage = 5, -- dano de cada turno ticks = 5, -- quantidade de turnos effect = CONST_ME_HITBYFIRE, -- efeito } local energyBuff = { chance = 50, -- % de ativacao, 0~100 effect = CONST_ME_ENERGYHIT, -- efeito } local healBuff = { chance = 25, -- % de ativacao, 0~100 lifePercentage = 25, -- % de vida em cura, 0~100 effect = CONST_ME_SMALLPLANTS, -- efeito } local waterBuff = { cooldown = 30, -- tempo para ativar proximo cooldownStorage = 23001, -- storage interval = 1, -- intevalo entre turnos effect = CONST_ME_LOSEENERGY, -- efeito } -- Caso queira configurar damage/area, que não se apliquem nas configuracoes acima, -- modifique abaixo: -- FIRE EFFECT local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true) setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, burnBuff.effect) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE) local condition = createConditionObject(CONDITION_FIRE) setConditionParam(condition, CONDITION_PARAM_DELAYED, 1) addDamageCondition(condition, burnBuff.ticks, burnBuff.interval, -burnBuff.damage) setCombatCondition(combat, condition) ------------------------------------------------------------------------ -- ENERGY EFFECT local combat1 = createCombatObject() setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE) setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -0.6, -30, -1.2, 0) local arr = { {0, 0, 0}, {1, 3, 1}, {0, 0, 0} } local area = createCombatArea(arr) setCombatArea(combat1, area) ------------------------------------------------------------------------ -- WATER EFFECT local combat2 = createCombatObject() setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE) setCombatParam(combat2, COMBAT_PARAM_EFFECT, waterBuff.effect) setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -0.6, -30, -1.2, 0) local arr2 = { {1, 1, 1}, {1, 2, 1}, {1, 1, 1} } local area = createCombatArea(arr2) setCombatArea(combat2, area) ------------------------------------------------------------------------ function onAttack(cid, target) storageStatus = getPlayerStorageValue (cid, globalConfig.storageID) playerPos = getCreaturePosition (cid) targetPos = getCreaturePosition (target) if storageStatus == 0 then return true end -- FIM - jogador sem o buff if getDistanceBetween (playerPos, targetPos) > 1 then return true end -- FIM - jogador longe if storageStatus == 1 then -- Efeito Energy if math.random (0, 100) < energyBuff.chance then -- % de ativacao doCombat(cid, combat1, numberToVariant(target)) -- Dano em area doSendMagicEffect (targetPos, energyBuff.effect) -- efeito end elseif storageStatus == 2 then -- Efeito de Burn doCombatAreaCondition(cid, targetPos, nil, condition, burnBuff.effect) elseif storageStatus == 3 then -- Efeito de Heal if math.random (0, 100) < healBuff.chance then -- % de ativacao doCreatureAddHealth (cid, getCreatureMaxHealth(cid) * healBuff.lifePercentage / 100) -- formula de Heal doSendMagicEffect (playerPos, healBuff.effect) -- efeito end elseif storageStatus == 4 then if getPlayerStorageValue(cid, waterBuff.cooldownStorage) < os.time() then -- respeitando intervalo (para nao stackar 2 skills) setPlayerStorageValue (cid, waterBuff.cooldownStorage, os.time() + waterBuff.cooldown) -- cooldown set addEvent (waterCombat, waterBuff.interval * 1000, cid, waterBuff.cooldown) -- inicia evento waterCombat, responsavel pela skill end end return true end -- evento waterCombat function waterCombat (cid, times) if times == 0 then -- caso base de recursividade, quando termina o evento return true else -- caso recursivo doCombat (cid, combat2, numberToVariant(cid)) -- skill individual addEvent (waterCombat, waterBuff.interval * 1000, cid, times - 1) -- reativa o evento end end
-
Pedido Item Bonus
@ahrizinhas2, Antes de terminar o script certinho eu gostaria que você me desse um feedback sobre o que devo mudar, o que está faltando, se está tudo errado, etc. achei o tópico um quanto confuso. P.S.: Ainda tenho que mexer algumas coisas pra facilitar a configuração do sistema Em data/creaturescripts/creaturescripts.xml adicione a tag: <event type="attack" name="PlayerAttack" event="script" value="weapon.lua"/> Em data/creaturescripts/scripts crie um arquivo chamado weapon.lua e cole isto dentro dele: local weaponsConfig = { storage = 23000, lightning = { lightChance = 50, lightEffect = 11, }, fire = { burnInterval = 1, -- seconds burnDamage = 5, burnTicks = 5, burnEffect = 15, }, plant = { healPercent = 25, healChance = 25, healEffect = 45, }, water = { cooldown = 30, } } local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, true) setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITBYFIRE) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE) local condition = createConditionObject(CONDITION_FIRE) setConditionParam(condition, CONDITION_PARAM_DELAYED, 1) addDamageCondition(condition, 10, 2000, -10) setCombatCondition(combat, condition) ------------------------------------------------------------------------ local combat1 = createCombatObject() setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE) --setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA) setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, -0.6, -30, -1.2, 0) local arr = { {0, 0, 0}, {1, 3, 1}, {0, 0, 0} } local area = createCombatArea(arr) setCombatArea(combat1, area) ------------------------------------------------------------------------ local combat2 = createCombatObject() setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE) setCombatParam(combat2, COMBAT_PARAM_EFFECT, 1) setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, -0.6, -30, -1.2, 0) local arr2 = { {1, 1, 1}, {1, 2, 1}, {1, 1, 1} } local area = createCombatArea(arr2) setCombatArea(combat2, area) ------------------------------------------------------------------------ function onAttack(cid, target) storageStatus = getPlayerStorageValue (cid, weaponsConfig.storage) if storageStatus == 0 then return true elseif storageStatus == 1 then dist = getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) if dist == 1 then if math.random(0, 100) < weaponsConfig.lightning.lightChance then doCombat(cid, combat1, numberToVariant(target)) doSendMagicEffect (getCreaturePosition(target), weaponsConfig.lightning.lightEffect) end end elseif storageStatus == 2 then dist = getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) if dist == 1 then doCombatAreaCondition(cid, getCreaturePosition (target), nil, condition, weaponsConfig.fire.burnEffect) end elseif storageStatus == 3 then random = math.random (0, 100) dist = getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) if dist == 1 then if random < weaponsConfig.plant.healChance then maxHealth = getCreatureMaxHealth (cid) doCreatureAddHealth (cid, getCreatureMaxHealth(cid) * weaponsConfig.plant.healPercent / 100) doSendMagicEffect (getCreaturePosition (cid), weaponsConfig.plant.healEffect) end end elseif storageStatus == 4 then dist = getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) if dist == 1 then if getPlayerStorageValue(cid, 23001) < os.time() then cooldown = weaponsConfig.water.cooldown setPlayerStorageValue (cid, 23001, os.time() + cooldown) addEvent (waterCombat, 1000, cid, cooldown) end end end return true end function waterCombat (cid, times) if times == 0 then return true else doCombat (cid, combat2, numberToVariant(cid)) addEvent (waterCombat, 1000, cid, times - 1) end end Em data/creaturescripts/scripts/login.lua adicione isso: registerCreatureEvent(cid, "PlayerAttack") Para fazer os testes para trocar entre os modos da arma (alternar entre os storageIDs) você pode usar este script: Em data/actions/actions.xml adicione a tag: <action itemid = "XXXX" event = "script" value = "buffSword.lua" /> XXXX é o ID do item que voce vai dar use para alternar entre as formas Em data/actions/scripts/ crie um arquivo buffSword.lua e cole isto nele: function onUse(cid, item, frompos, item2, topos) storageStatus = getPlayerStorageValue (cid, 23000) print (storageStatus) if storageStatus == 0 or storageStatus == -1 then setPlayerStorageValue(cid, 23000, storageStatus + 1) elseif storageStatus == 1 then setPlayerStorageValue(cid, 23000, storageStatus + 1) elseif storageStatus == 2 then setPlayerStorageValue(cid, 23000, storageStatus + 1) elseif storageStatus == 3 then setPlayerStorageValue(cid, 23000, storageStatus + 1) elseif storageStatus == 4 then setPlayerStorageValue(cid, 23000, 0) end doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "MODE = ".. getPlayerStorageValue(cid, 23000)) return true end
-
order/addon [dxp]
@Danxi aparece algum erro no terminal? Você pode mostrar essas arrays que ele usa na primeira função? flys rides surfs
-
(Resolvido)Spell com posição heelp
print é uma função fora dos callbacks do OTserver, uma função do LUA para imprimir no console (que no caso é o seu executável do servidor). Por exemplo: print ("Olá mundo!") Colocar isso em algo script seu fará com que, ao executá-lo aparaça uma mensagem "Olá mundo!" no console do seu OTServer, geralmente queremos imprimir acompanhado de alguma variável pra checar o valor e conferir se tudo está indo conforme o esperado. Vamos supor que você queira imprimir a posição do target por você achar que ele não está reconhecendo o target, então tentaríamos algo do tipo: pos = getCreatureTarget (cid) print ("POS DO TARGET: X = " .. pos.x .. ", Y = " .. pos.y .. ", Z = " .. pos.z) Isso faria com que aparecesse algo do tipo no seu console: POS DO TARGET: X = 100, Y = 120, Z = 10 Caso estivesse errado pode ser que aparecesse algo do tipo: POS DO TARGET: X = nil, Y = nil, Z = nil nil em LUA é a representação de NULL, ou seja, pos.x/y/z não possuem nenhum conteúdo, por isso em muitos erros ele inclui o "nil value" como mensagem de erro, é quando tentamos fazer uso de uma variável com valor nulo. Outra coisa importante é a presença de "..", print é uma função que recebe uma STRING (um conjunto de caracteres) e a imprime, então o ".." em LUA é o operador responsável por concatenar uma string a um valor. Outra coisa importante para quando estiver começando é sempre abrir tópicos como este quando for fazer scripts: Assim você saberá tudo que pode ser feito e conhecer os limites do que pode ser feito sem mexer na source.
-
Dosetcreatureoutfit valendo rep+++
Pode dar uma testada nessa versão do script? local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA) setCombatParam(combat, COMBAT_PARAM_USECHARGES, true) local area = createCombatArea(AREA_SQUARE1X1) setCombatArea(combat, area) function onGetFormulaValues(cid, level, skill, attack, factor) local skillTotal, levelTotal = skill + attack, level / 5 return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal) end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var, target) mninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} fninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} enemy_mninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} enemy_fninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} target = getCreatureTarget(cid) if target == 0 then transformAroundPos (cid, nil, enemy_mninja, enemy_fninja) else transformAroundPos (cid, getCreaturePosition (target), enemy_mninja, enemy_fninja) end if getPlayerSex (cid) == 0 then doSetCreatureOutfit (cid, mninja, 500) else doSetCreatureOutfit (cid, fninja, 500) end return doCombat (cid, combat, var) end function transformAroundPos (cid, centerPos, male, female) for i = 0, 2 do for j = 0, 2 do initialPos = getCreaturePosition(getCreatureTarget(cid)) if centerPos == nil then initialPos = getEpicenterPos (cid) doSendMagicEffect (initialPos, 35) end initialPos.x = initialPos.x - 1 initialPos.y = initialPos.y - 1 thingPos = initialPos thingPos.x = thingPos.x + i thingPos.y = thingPos.y + j thingPos.stackpos = 255 thing = getThingfromPos(thingPos) thing = thing.uid if isPlayer (thing) then if getPlayerSex (thing) == 0 then doSetCreatureOutfit (thing, male, 500) else doSetCreatureOutfit (thing, female, 500) end elseif isCreature (thing) then doSetCreatureOutfit (thing, male, 500) end end end end function getEpicenterPos (cid) playerDirection = getCreatureLookDirection(cid) skillPos = getCreaturePosition (cid) if playerDirection == NORTH then skillPos.y = skillPos.y - 1 elseif playerDirection == EAST then skillPos.x = skillPos.x + 1 elseif playerDirection == SOUTH then skillPos.y = skillPos.y + 1 elseif playerDirection == WEST then skillPos.x = skillPos.x - 1 end return skillPos end
-
(Resolvido)Spell com posição heelp
Acho que os principais pontos que você teria que trabalhar nesse script são a posição, já que a posição modificada é esta diagonal do personagem: Para ser a posição à direita do personagem você incrementa somente a coordenada X. Outro pronto é trabalhar no retorno dos callbacks LUA, quando você utiliza getPlayerTarget, caso o jogador tenha um target ele receberá um objeto, que no caso é o que ele está targetando, seja uma criatura, um player, etc. e você fez a seguinte comparação: if target == false then Caso o jogador não tenha um target, a função retorna 0. Caso você tenha dúvidas sobre o que a função te retorna, dê um print para aparecer no console o que você possui na variável, isso também é bem útil no debug, pra saber se uma determinada parte do script está sendo utilizada ou não. Exemplo : No teste acima o jogador não tinha um target Sempre que você abrir uma função/if/etc. deixe tudo que está dentro alinhado para a direita e certifique-se que o end está alinhado com com seu respectivo if ou function, isso facilita MUITO a leitura de um código. Exemplo tirado de uma source: No código acima você consegue identificar claramente onde começa e termina um bloco, além de saber o que faz parte de cada um
-
Dosetcreatureoutfit valendo rep+++
@Jeanzim, Como a skill deve funcionar quando não tem target? sai um exori pra frente e troca a outfit? O que mais deve ser modificado?
-
(Resolvido)[SUPORTE] CoolDown na Magia
Quando você dá return false numa skill é como se você tivesse cancelado a execução dela, então ele desconsidera que a skill foi usada, sem gastar mana.
-
(Resolvido)[SUPORTE] CoolDown na Magia
Tenta esse aqui local combatDist = createCombatObject() setCombatParam(combatDist, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combatDist, COMBAT_PARAM_EFFECT, 75) setCombatParam(combatDist, COMBAT_PARAM_DISTANCEEFFECT, 31) setCombatFormula(combatDist, COMBAT_FORMULA_LEVELMAGIC, -13.7, 0, -19.9, 0) local condition = createConditionObject(CONDITION_FIRE) addDamageCondition(condition, 1, 1000, -5) addDamageCondition(condition, 1, 1000, -5) addDamageCondition(condition, 1, 1000, -4) addDamageCondition(condition, 1, 1000, -3) addDamageCondition(condition, 1, 1000, -2) addDamageCondition(condition, 1, 1000, -1) addDamageCondition(condition, 1, 1000, -25000) setCombatCondition(combatDist, condition) local function Cooldown(cid) if isPlayer(cid) == TRUE then doPlayerSendTextMessage(cid,MESSAGE_STATUS_WARNING,'CD: Adori Gran Dark') end end local combat= createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING) setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0) setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE) local exhausted_seconds = 45 -- Segundos que o Player Poderá castar a spell novamente local exhausted_storagevalue = 9389 -- Storage Value do Cool Down function onCastSpell(cid, var) if(os.time() < getPlayerStorageValue(cid, exhausted_storagevalue)) then doPlayerSendCancel(cid,'O Cooldown não está pronto.') return false end if(target == 1) then doPlayerSendCancel(cid,'Select your target.') doSendMagicEffect(getCreaturePosition(cid), 2) return false end local target = getCreatureTarget(cid) if(target ~= 0 and isPlayer(target) == 1) then local congelado = { lookType = getCreatureOutfit(target).lookType,lookHead = 9, lookBody = 9, lookLegs = 9, lookFeet = 9, lookAddons = getCreatureOutfit(target).lookAddons} doSetCreatureOutfit(target, congelado, 3000) setPlayerStorageValue(target, exhausted_storagevalue, os.time() + exhausted_seconds) doTargetCombatCondition(0, target, condition, CONST_ME_NONE) doPlayerSendTextMessage(target,20,'Voce está condenado.') doTargetCombatCondition(0, target, condition, CONST_ME_NONE) doCombat(cid, combatDist, numberToVariant(target)) else local monstro = { lookType = getCreatureOutfit(target).lookType,lookHead = getCreatureOutfit(target).lookHead, lookBody = getCreatureOutfit(target).lookBody, lookLegs = getCreatureOutfit(target).lookLegs, lookFeet = getCreatureOutfit(target).lookFeet, lookAddons = getCreatureOutfit(target).lookAddons} doSetCreatureOutfit(target, monstro, 3000) doTargetCombatCondition(0, target, condition, CONST_ME_NONE) doCombat(cid, combatDist, numberToVariant(target)) end rand = math.random(1,2) if rand == 1 and isPlayer(cid) == 1 then doPlayerSay(cid,"Adori Gran Dark",16) addEvent(Cooldown, 1*45000,cid) setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds) return doCombat(cid, combat, var) elseif rand == 2 and isPlayer(cid) == 1 then doPlayerSay(cid,"Adori Gran Dark",16) addEvent(Cooldown, 1*45000,cid) setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds) return doCombat(cid, combat, var) else addEvent(Cooldown, 1*45000,cid) setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds) return doCombat(cid, combat, var) end end Em versões novas de TFS dê preferência ao return de true/false, pois TRUE/FALSE são constantes 0 e 1, não o tipo bool
-
(Resolvido)[PEDIDO] "x" Bolt só funcionar com "x" Crossbow
Infelizmente não estou sabendo corrigir o bug que ficou, quando o jogador fica com o bow na mão que não seja o correto ele ganha skill como se estivesse batendo normalmente. Eu tentei usar o comando de addSkillTry mas parece que ele buga quando tento um valor negativo. local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1) setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 41) setCombatParam(combat, COMBAT_PARAM_HITCOLOR, 170) setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, 2, 1.2, 2) local combat2 = createCombatObject() setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat2, COMBAT_PARAM_EFFECT, 31) setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 41) setCombatParam(combat2, COMBAT_PARAM_HITCOLOR, 170) setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0, -10000, 0, -13000) local combat3 = createCombatObject() setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat3, COMBAT_PARAM_EFFECT, 31) setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, 41) setCombatParam(combat3, COMBAT_PARAM_HITCOLOR, 170) setCombatFormula(combat3, COMBAT_FORMULA_SKILL, 0, -13000, 0, -15000) local condition = createConditionObject(CONDITION_PARALYZE) setConditionParam(condition, CONDITION_PARAM_TICKS, 5000) setConditionParam(condition, CONDITION_PARAM_SPEED, -400) setConditionFormula(condition, 0, 0, 0, 0) setCombatCondition(combat2, condition) local condition = createConditionObject(CONDITION_PARALYZE) setConditionParam(condition, CONDITION_PARAM_TICKS, 5000) setConditionParam(condition, CONDITION_PARAM_SPEED, -600) setConditionFormula(condition, 0, 0, 0, 0) setCombatCondition(combat3, condition) function onUseWeapon(cid, var) local rand = math.random(1,100) bowID = 13038 itemLeft = getPlayerSlotItem(cid, 6) itemRight = getPlayerSlotItem(cid, 5) if itemLeft.itemid ~= bowID and itemRight.itemid ~= bowID then flechas = getPlayerSlotItem(cid, 10) -- doPlayerAddSkillTry(cid, SKILL_DISTANCE, -1, true) -- BUGA A SKILL DO PERSONAGEM, NAO DESCOMENTAR doPlayerAddItem (cid, flechas.itemid, 1) return false end if rand <= 4 then doSendAnimatedText(getPlayerPosition(cid), "Critical!", TEXTCOLOR_BLACK) doCombat(cid, combat2, var) elseif rand <= 7 then doSendAnimatedText(getPlayerPosition(cid), "Critical!", TEXTCOLOR_BLACK) doCombat(cid, combat3, var) else doCombat(cid, combat, var) end end
-
(Resolvido)[PEDIDO] "x" Bolt só funcionar com "x" Crossbow
Manda, eu aproveito e conserto uma coisa
-
(Resolvido)[PEDIDO] "x" Bolt só funcionar com "x" Crossbow
A forma de configurar vai depender de como você quer funcionando, mas dá pra você fazer algo do tipo, em weapons: local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1) setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1) setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BURSTARROW) setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1, 0, 1, 0) local area = createCombatArea({ {1, 1, 1}, {1, 3, 1}, {1, 1, 1} }) setCombatArea(combat, area) function onUseWeapon(cid, var) bowID = 7438 -- ID do unico bow que pode usar a flecha itemLeft = getPlayerSlotItem(cid, 6) itemRight = getPlayerSlotItem(cid, 5) if itemLeft.itemid ~= bowID and itemRight.itemid ~= bowID then flechas = getPlayerSlotItem(cid, 10) doPlayerAddItem (cid, flechas.itemid, 1) return false end return doCombat(cid, combat, var) end Você não disse qual versão era, então coloquei a verificação para os dois lados da mão do jogador. [Achei uma coisa errada aqui, já edito]
-
ERRO EVENTO DEFEND THE TOWER [DTT]
@Micheel15 Dá uma tentada com esse: LIB: -- This script is part of Defend the Towers -- Copyright (C) 2016 ChaitoSoft -- -- This program is free software: you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation, either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. dtt = { pos = { temple_wait = {x=438, y=1138, z=7}, -- sala de espera tp_create = {x=36, y=151, z=7}, -- onde teleport de entrada sera criado }, --Configurações de abertura days_open = {1, 2, 3, 4, 5, 6, 7}, -- dias de semana que vai abrir min_players = 1, -- numero minimo de jogadores em cada time min_level = 200, -- level minimo permitido para entrar no evento wait_time = 3, -- tempo de espera para iniciar o evento, em minutos block_mc = false, -- false para permitir mcs no evento --Configuraçõe gerais delay_time = 10, -- tempo em segundos de delay ao morrer townid = {init = 1, blue = 3, red = 4}, -- init = templo da cidade, blue = templo do time azul, red = templo do time vermelho --Configurações dos premios reward_items = {6527, 6527}, bonus_time = 240, -- experiencia bonus em minutos bonus_rate = 1, -- porcentagem de experiencia bonus: 1 = 100% | 0.3 = 30% --Configuração dos monstros monster = { pos = { --Monstros do time azul a1 = {x=396, y=1138, z=6, stackpos=253}, -- Blue supreme tower a2 = {x=429, y=1107, z=6, stackpos=253}, -- Blue top tower a3 = {x=430, y=1135, z=6, stackpos=253}, -- Blue middle tower a4 = {x=429, y=1167, z=6, stackpos=253}, -- Blue bottom tower -- Monstros do time vermelho b1 = {x=477, y=1138, z=6, stackpos=253}, -- Red supreme tower b2 = {x=447, y=1107, z=6, stackpos=253}, -- Red top tower b3 = {x=445, y=1139, z=6, stackpos=253}, -- Red middle tower b4 = {x=447, y=1167, z=6, stackpos=253}, -- Red bottom tower -- Monstros buff na jungle mbuff1 = {x=440, y=1122, z=6, stackpos=253}, -- Buff sorecer and paladin 1 + 2 mbuff2 = {x=434, y=1155, z=6, stackpos=253}, -- Buff druid and knight 2 + 2 }, --------------------------------------------------- --NÃO MEXA DAQUI PRA BAIXO ----- ------------------------------------------------ name = { -- Azul a1 = "blue supreme tower", -- Base Tower a2 = "blue top tower", -- Top lane a3 = "blue middle tower", -- Middle lane a4 = "blue bottom tower", -- Bottom lane -- Vermelho b1 = "red supreme tower", -- Base Tower b2 = "red top tower", -- Top lane b3 = "red middle tower", -- Middle lane b4 = "red bottom tower", -- Bottom lane --Monstros Buff buff1 = "serpent of jungle", buff2 = "spider of jungle", }, }, --Storages alocadas storage = { win = 87771, -- GLOBAL STORAGE VENCEDOR kill_blue = 87775, -- GLobal storage frags team blue kill_red = 87776, -- GLobal storage frags team red tower_blue = 87777, -- GLobal storage towers team blue tower_red = 87778, -- GLobal storage towers team red team_blue = 9998, -- PLAYER STORAGE TIME A team_red = 9999, -- PLAYER STORAGE TIME A buffvoc1 = 7001, -- PLAYER STORAGE BUFF buffvoc2 = 7002, -- PLAYER STORAGE BUFF buffvoc3 = 7003, -- PLAYER STORAGE BUFF buffvoc4 = 7004, -- PLAYER STORAGE BUFF exp_bonus = 7005, --PLAYER STORAGE EXP BONUS delay = 7006, --PLAYER STORAGE DELAY }, msg = { win_team_blue = "[Defend The Tower] O time azul acabou de derrotar a Suprema Torre Vermelha e vencer o evento.", win_team_red = "[Defend The Tower] O time vermelho acabou de derrotar a Suprema Torre Azul e vencer o evento. ", reward = "[Defend The Tower] Seu time Venceu, voce recebeu como premio o dobro de experiencia por 4 horas automaticamente e 80 event coins, desejamos parabens.", no_reward = "[Defend The Tower] Derrota, confira as estatisticas da partida no site, desejamos mais sorte na proxima.", warning = "[Defend The Tower] Acabou de abrir, acesse o teleporte do templo principal para participar. Inicia em minutos...", start = "[Defend The Tower] Fechou o teleporte de entrada e iniciou o evento boa sorte aos times.", cancel = "[Defend The Tower] Fechou o teleporte de entrada e cancelou o evento por falta de jogadores.", outfit = "[Defend The Tower] Voce nao pode trocar de outfit durante o evento.", }, } local conditionBlue = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionBlue, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionBlue, {lookType = 128, lookHead = 86, lookBody = 86, lookLegs = 86, lookFeet = 86}) local conditionRed = createConditionObject(CONDITION_OUTFIT) setConditionParam(conditionRed, CONDITION_PARAM_TICKS, -1) addOutfitCondition(conditionRed, {lookType = 128, lookHead = 94, lookBody = 94, lookLegs = 94, lookFeet = 94}) --Metodos set function dtt.setDelay(cid) doPlayerSetStorageValue(cid, dtt.storage.delay, os.time()+(60*dtt.delay_time)) return true end function dtt.setBuff(storTeam, voc1, voc2) local storBuff1 local storBuff2 if (voc1 == 1) and (voc2 == 3) then storBuff1 = dtt.storage.buffvoc1 storBuff2 = dtt.storage.buffvoc3 end if (voc1 == 2) and (voc2 == 4) then storBuff1 = dtt.storage.buffvoc2 storBuff2 = dtt.storage.buffvoc4 end for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, storTeam) == 1 then if (isInArray({voc1, (voc1+4), (voc1+8)}, getPlayerVocation(index.pid))) then doPlayerSetStorageValue(index.pid, storBuff1, 1) end if (isInArray({voc2, (voc2+4), (voc2+8)}, getPlayerVocation(index.pid))) then doPlayerSetStorageValue(index.pid, storBuff2, 1) end end end return true end function dtt.setBonusExp(cid) doPlayerSetStorageValue(cid, dtt.storage.exp_bonus, os.time()+(60*dtt.bonus_time)) return true end function dtt.setTeam() local tmp = 1 local result = db.getResult("SELECT * FROM `dtt_players`;") if result:getID() ~= -1 then repeat pid = tonumber(result:getDataInt("pid")) if(tmp % 2 == 0) then db.query("UPDATE `dtt_players` SET `team` = '0' WHERE `pid` = "..pid..";") tmp = (tmp+1) else db.query("UPDATE `dtt_players` SET `team` = '1' WHERE `pid` = "..pid..";") tmp = (tmp+1) end until(not result:next()) end result:free() end --Metodos GET function dtt.getPlayersInEvent() local result = db.getResult("SELECT * FROM `dtt_players`;") CACHE_PLAYERS = {} if result:getID() ~= -1 then repeat pid = tonumber(result:getDataInt("pid")) team = tonumber(result:getDataInt("team")) -- 0 = blue, 1 = red ip = tonumber(result:getDataInt("ip")) table.insert(CACHE_PLAYERS, {["pid"]=pid,["team"]=team,["ip"]=ip }) until(not result:next()) result:free() return CACHE_PLAYERS end return false end function dtt.getDelay(cid) local statsDelay = getPlayerStorageValue(cid, dtt.storage.delay) if (statsDelay - os.time() > 0) then local delay = 0 local times = dtt.delay_time doCreatureSetNoMove(cid, true) for i = times, 0, -1 do if isPlayer(cid) then addEvent(doPlayerSendCancel, delay, cid, "[Defend The Tower] Volte para a arena em "..i..".") end delay = 2000 + delay if (i == 0) and (isPlayer(cid)) then addEvent(dtt.enableMove, (delay+1000), cid) end end else return false end return true end function dtt.getBonusExp(cid) local statsBonus = getPlayerStorageValue(cid, dtt.storage.exp_bonus) return statsBonus - os.time() > 0 end --Outros métodos function dtt.enableMove(cid) doCreatureSetNoMove(cid, false) doPlayerSendCancel(cid, "[Defend The Tower] GO GO GO! seu time o aguarda.") setPlayerStorageValue(cid, dtt.storage.delay, 0) return true end function dtt.resetGlobalStorages() setGlobalStorageValue(dtt.storage.win, -1) setGlobalStorageValue(dtt.storage.kill_blue, 0) setGlobalStorageValue(dtt.storage.kill_red, 0) setGlobalStorageValue(dtt.storage.tower_blue, 0) setGlobalStorageValue(dtt.storage.tower_red, 0) print("[Defend The Tower] Todos os globais storages foram resetados...") return true end function dtt.resetPlayerStorages() if dtt.getPlayersInEvent() then for _, index in ipairs(dtt.getPlayersInEvent()) do doPlayerSetStorageValue(index.pid, dtt.storage.team_blue, 0) doPlayerSetStorageValue(index.pid, dtt.storage.team_red, 0) doPlayerSetStorageValue(index.pid, dtt.storage.buffvoc1, 0) doPlayerSetStorageValue(index.pid, dtt.storage.buffvoc2, 0) doPlayerSetStorageValue(index.pid, dtt.storage.buffvoc3, 0) doPlayerSetStorageValue(index.pid, dtt.storage.buffvoc4, 0) end print("[Defend The Tower] Todos os players storages foram resetados...") return true else print("[Defend The Tower] Tabela vazia...") end return true end function dtt.createMonsters() doSummonCreature(dtt.monster.name.a1, dtt.monster.pos.a1) doSummonCreature(dtt.monster.name.a2, dtt.monster.pos.a2) doSummonCreature(dtt.monster.name.a3, dtt.monster.pos.a3) doSummonCreature(dtt.monster.name.a4, dtt.monster.pos.a4) doSummonCreature(dtt.monster.name.b1, dtt.monster.pos.b1) doSummonCreature(dtt.monster.name.b2, dtt.monster.pos.b2) doSummonCreature(dtt.monster.name.b3, dtt.monster.pos.b3) doSummonCreature(dtt.monster.name.b4, dtt.monster.pos.b4) doSummonCreature(dtt.monster.name.buff1, dtt.monster.pos.mbuff1) doSummonCreature(dtt.monster.name.buff2, dtt.monster.pos.mbuff2) print("[Defend The Tower] Os monstros da arena battle foram sumonados...") return true end function dtt.countPlayers() local result = db.getResult("SELECT * FROM `dtt_players`;") local qntPlayers = 0 if result:getID() ~= -1 then repeat qntPlayers = (qntPlayers+1) until(not result:next()) end return qntPlayers end function dtt.trucatePlayersInEvent() local result = db.getResult("SELECT * FROM `dtt_players`;") if result:getID() ~= -1 then db.query("TRUNCATE TABLE `dtt_players`;") print("[Defend The Tower] Todos dados da tabela 'dtt_players' foram apagados...") end return true end -- FUNÇÕES PRINCIPAIS -- ABERTURA DO EVENTO function dtt.open() local time = os.date("*t") local timeopen1 = math.ceil(dtt.wait_time / 4) local timeopen2 = math.ceil(dtt.wait_time / 2) if (isInArray(dtt.days_open, time.wday)) then local tp = doCreateItem(1387, 1, dtt.pos.tp_create) doItemSetAttribute(tp, "aid", 9801) dtt.resetGlobalStorages() dtt.trucatePlayersInEvent() dtt.removeItemsTower() doBroadcastMessage(dtt.msg.warning) addEvent(doBroadcastMessage, timeopen1*1000*60, "[Defend The Tower] - Resta(m) ".. timeopen2 .." minuto(s) para iniciar o evento!") if (timeopen2 ~= timeopen1) then addEvent(doBroadcastMessage, timeopen2*1000*60, "[Defend The Tower] - Resta(m) ".. timeopen1 .." minuto(s) para iniciar o evento!") end addEvent(dtt.start, dtt.wait_time*1000*60,nil) end return true end -- COMEÇO DO EVENTO function dtt.start() local tp = getTileItemById(dtt.pos.tp_create, 1387).uid doRemoveItem(tp) if (dtt.min_players <= dtt.countPlayers()) then dtt.createMonsters() dtt.sendPlayersToEvent() doBroadcastMessage(dtt.msg.start) else doBroadcastMessage(dtt.msg.cancel) end return true end -- FECHANDO O EVENTO function dtt.close() for _, index in ipairs(dtt.getPlayersInEvent()) do doRemoveCondition(index.pid, CONDITION_OUTFIT) doRemoveCondition(index.pid, CONDITION_INFIGHT) doPlayerSetPzLocked(index.pid, false) if (getGlobalStorageValue(dtt.storage.win) == "blue") then if (index.team == 0) then doPlayerSetTown(index.pid, dtt.townid.init) doTeleportThing(index.pid, getTownTemplePosition(dtt.townid.init)) dtt.reward(index.pid) else doPlayerSetTown(index.pid, dtt.townid.init) doTeleportThing(index.pid, getTownTemplePosition(dtt.townid.init)) doPlayerSendTextMessage(index.pid, 25, dtt.msg.no_reward) end end if (getGlobalStorageValue(dtt.storage.win) == "red") then if (index.team == 1) then doPlayerSetTown(index.pid, dtt.townid.init) doTeleportThing(index.pid, getTownTemplePosition(dtt.townid.init)) dtt.reward(index.pid) else doPlayerSetTown(index.pid, dtt.townid.init) doTeleportThing(index.pid, getTownTemplePosition(dtt.townid.init)) doPlayerSendTextMessage(index.pid, 25, dtt.msg.no_reward) end end end --- limpando storage dos jogadores dtt.resetPlayerStorages() return true end function dtt.sendPlayersToEvent() dtt.setTeam() dtt.resetPlayerStorages() for _, index in ipairs(dtt.getPlayersInEvent()) do if (index.team == 0) then doAddCondition(index.pid, conditionBlue) doPlayerSetTown(index.pid, dtt.townid.blue) doTeleportThing(index.pid, getTownTemplePosition(dtt.townid.blue)) doPlayerSetStorageValue(index.pid, dtt.storage.team_blue, 1) end if (index.team == 1) then doAddCondition(index.pid, conditionRed) doPlayerSetTown(index.pid, dtt.townid.red) doTeleportThing(index.pid, getTownTemplePosition(dtt.townid.red)) doPlayerSetStorageValue(index.pid, dtt.storage.team_red, 1) end end return true end function dtt.reward(pid) local random_item = dtt.reward_items[math.random(1, #dtt.reward_items)] doPlayerAddItem(pid, 6527, 80) dtt.setBonusExp(pid) doPlayerSendTextMessage(pid, 25, dtt.msg.reward) return true end function dtt.removeItemsTower() if (getTileItemById(dtt.monster.pos.a2, 9596).uid) then doRemoveItem(getTileItemById(dtt.monster.pos.a2, 9596).uid) doRemoveItem(getTileItemById(dtt.monster.pos.a3, 9596).uid) doRemoveItem(getTileItemById(dtt.monster.pos.a4, 9596).uid) doRemoveItem(getTileItemById(dtt.monster.pos.b2, 9596).uid) doRemoveItem(getTileItemById(dtt.monster.pos.b3, 9596).uid) doRemoveItem(getTileItemById(dtt.monster.pos.b4, 9596).uid) print("[DEFEND THE TOWERS] Items torre limpos da arena de batalha...") else print("[DEFEND THE TOWERS] Nenhum item torre na arena de batalha...") end return true end function dtt.resultBattle() local frags_blue = getGlobalStorageValue(dtt.storage.kill_blue) local frags_red = getGlobalStorageValue(dtt.storage.kill_red) local towers_blue = getGlobalStorageValue(dtt.storage.tower_blue) local towers_red = getGlobalStorageValue(dtt.storage.tower_red) local hora = os.date("%X") local data = os.date("%x") db.query("INSERT INTO `dtt_results` VALUES ('', ".. frags_blue .. ",".. frags_red ..", ".. towers_blue ..", ".. towers_red ..", ".. db.escapeString(data) ..", ".. db.escapeString(hora) ..");") return true end function dtt.warningAttack(cid, msg, storTeam) local lifePercent = 100 / (getCreatureMaxHealth(cid) / getCreatureHealth(cid)) if (lifePercent <= 100) and (lifePercent >= 99.9) then for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, storTeam) == 1 then doPlayerSendTextMessage(index.pid, 25, "[Defend The Tower] A torre "..msg.." esta sob ataque. Corra para defender!") end end end if (lifePercent <= 50) and (lifePercent >= 49.9) then for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, storTeam) == 1 then doPlayerSendTextMessage(index.pid, 25, "[Defend The Tower] A torre "..msg.." esta sob ataque. Corra para defender!") end end end if (lifePercent <= 20) and (lifePercent >= 19.9) then for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, storTeam) == 1 then doPlayerSendTextMessage(index.pid, 25, "[Defend The Tower] A torre "..msg.." esta sob ataque. Corra para defender!") end end end return true end function dtt.removeMonsters() for i= 1,4 do thing = getThingfromPos (dtt.monster.pos.a..i) thing = thing.uid thing2 = getThingfromPos (dtt.monster.pos.b..i) thing2 = thing.uid if isCreature (thing) then doRemoveCreature (thing) end if isCreature (thing2) then doRemoveCreature (thing2) end end return true end function dtt.cleanPlayer(cid) doPlayerSetTown(cid, dtt.townid.init) doTeleportThing(cid, getTownTemplePosition(dtt.townid.init)) doPlayerSetStorageValue(cid, dtt.storage.team_blue, 0) doPlayerSetStorageValue(cid, dtt.storage.team_red, 0) doPlayerSetStorageValue(cid, dtt.storage.buffvoc1, 0) doPlayerSetStorageValue(cid, dtt.storage.buffvoc2, 0) doPlayerSetStorageValue(cid, dtt.storage.buffvoc3, 0) doPlayerSetStorageValue(cid, dtt.storage.buffvoc4, 0) return true end Scripts: function onLogin(cid) registerCreatureEvent(cid, "dttDeath") registerCreatureEvent(cid, "dttPrepare") registerCreatureEvent(cid, "dttStats") registerCreatureEvent(cid, "dttOutfit") registerCreatureEvent(cid, "dttKill") registerCreatureEvent(cid, "dttCombat") if (getPlayerStorageValue(cid, dtt.storage.team_blue) == 1) or (getPlayerStorageValue(cid, dtt.storage.team_red) == 1) then dtt.cleanPlayer(cid) end if (dtt.getBonusExp(cid)) then doPlayerSendTextMessage(cid,25, "[DEFEND THE TOWER] Voce esta com "..dtt.bonus_rate.."x de bonus experiencia.") end return true end --Preparar jogadores pra morte function onPrepareDeath(cid, deathList) if not isPlayer(cid) then return true end if (getPlayerStorageValue(cid, dtt.storage.team_blue) == 1) or (getPlayerStorageValue(cid, dtt.storage.team_red) == 1) then local strings = {""} local j, position, corpse = 1, 1, 0 --Dropar corpo ficticio for _, pid in ipairs(deathList) do if isCreature(pid) == true then strings[position] = j == 1 and "" or strings[position] .. ", " strings[position] = strings[position] .. getCreatureName(pid) .. "" j = j + 1 else strings[position] = j == 1 and "" or strings[position] .. ", " strings[position] = strings[position] .."a field item" j = j + 1 end end for i, str in ipairs(strings) do if(str:sub(str:len()) ~= ",") then str = str .. "." end desc = "You recognize " desc = desc .. "" .. getCreatureName(cid) .. ". He was killed by " .. str end if(getPlayerSex(cid) == 1) then corpse = doCreateItem(3058, getCreaturePosition(cid)) else corpse = doCreateItem(3065, getCreaturePosition(cid)) end doItemSetAttribute(corpse, "description", desc) dtt.setDelay(cid) dtt.getDelay(cid) end --Adicionando contagem de frags if (getPlayerStorageValue(cid, dtt.storage.team_blue) == 1) then setGlobalStorageValue(dtt.storage.kill_blue, (getGlobalStorageValue(dtt.storage.kill_blue)+1)) doPlayerSetTown(cid, dtt.townid.blue) elseif (getPlayerStorageValue(cid, dtt.storage.team_red) == 1) then setGlobalStorageValue(dtt.storage.kill_red, (getGlobalStorageValue(dtt.storage.kill_red)+1)) doPlayerSetTown(cid, dtt.townid.red) end return true end --Atacar jogadores do mesmo time function onCombat(cid, target) --Membros do mesmo time se atacando if isPlayer(cid) and isPlayer(target) then if (getPlayerStorageValue(cid, dtt.storage.team_blue) == 1) and (getPlayerStorageValue(target, dtt.storage.team_blue) == 1) then doPlayerSendCancel(cid, "[DEFEND THE TOWER] Nao se pode atacar um membro do mesmo time.") return false end if (getPlayerStorageValue(cid, dtt.storage.team_red) == 1) and (getPlayerStorageValue(target, dtt.storage.team_red) == 1) then doPlayerSendCancel(cid, "[DEFEND THE TOWER] Nao se pode atacar um membro do mesmo time.") return false end end --Membro time azul atacando propria torre if getPlayerStorageValue(cid, dtt.storage.team_blue) == 1 and isMonster(target) then if (getCreatureName(target) == dtt.monster.name.a1) then return false end if (getCreatureName(target) == dtt.monster.name.a2) then return false end if (getCreatureName(target) == dtt.monster.name.a3) then return false end if (getCreatureName(target) == dtt.monster.name.a4) then return false end end --Membro time vermelho atacando propria torre if getPlayerStorageValue(cid, dtt.storage.team_red) == 1 and isMonster(target) then if (getCreatureName(target) == dtt.monster.name.b1) then return false end if (getCreatureName(target) == dtt.monster.name.b2) then return false end if (getCreatureName(target) == dtt.monster.name.b3) then return false end if (getCreatureName(target) == dtt.monster.name.b4) then return false end end --Impedir que ataquem torres secundarias if (getCreatureName(target) == dtt.monster.name.a1) and isMonster(target) then if(isCreature(getThingFromPos(dtt.monster.pos.a2).uid) or isCreature(getThingFromPos(dtt.monster.pos.a3).uid) or isCreature(getThingFromPos(dtt.monster.pos.a4).uid)) then -- SE ALGUM VALOR DER TRUE NÃO VAI PODER ATACAR return false end end if (getCreatureName(target) == dtt.monster.name.b1) and isMonster(target) then if(isCreature(getThingFromPos(dtt.monster.pos.b2).uid) or isCreature(getThingFromPos(dtt.monster.pos.b3).uid) or isCreature(getThingFromPos(dtt.monster.pos.b4).uid)) then -- SE ALGUM VALOR DER TRUE NÃO VAI PODER ATACAR return false end end return true end --Bonus exp function onKill(cid, target) if (dtt.getBonusExp(cid)) and isMonster(target) then doPlayerAddExp(cid, getMonsterInfo(getCreatureName(target)).experience * dtt.bonus_rate) end return true end --Aviso de attack sobre as torres function onStatsChange(cid, attacker, type, combat, value) if not isPlayer(attacker) then return true end -- Avisar que as torres estão sendo atacadas | a2 = top, a3 = middle, a4 = bottom. if (type == STATSCHANGE_HEALTHLOSS) and (getCreatureName(cid) == dtt.monster.name.a2) then dtt.warningAttack(cid, "azul do topo", dtt.storage.team_blue) end if (type == STATSCHANGE_HEALTHLOSS) and (getCreatureName(cid) == dtt.monster.name.a3) then dtt.warningAttack(cid, "azul do meio", dtt.storage.team_blue) end if (type == STATSCHANGE_HEALTHLOSS) and (getCreatureName(cid) == dtt.monster.name.a4) then dtt.warningAttack(cid, "azul de baixo", dtt.storage.team_blue) end if (type == STATSCHANGE_HEALTHLOSS) and (getCreatureName(cid) == dtt.monster.name.b2) then dtt.warningAttack(cid, "vermelha do topo", dtt.storage.team_red) end if (type == STATSCHANGE_HEALTHLOSS) and (getCreatureName(cid) == dtt.monster.name.b3) then dtt.warningAttack(cid, "vermelha do meio", dtt.storage.team_red) end if (type == STATSCHANGE_HEALTHLOSS) and (getCreatureName(cid) == dtt.monster.name.b4) then dtt.warningAttack(cid, "vermelha de baixo", dtt.storage.team_red) end return true end --Impedindo troca de outfit durante o evento function onOutfit(cid, old, current) if getPlayerStorageValue(cid, dtt.storage.team_blue) == 1 or getPlayerStorageValue(cid, dtt.storage.team_red) == 1 then doPlayerSendCancel(cid, dtt.msg.outfit) return false end return true end --Tratando morte dos montros buff e torres function onDeath(cid, corpse, mostDamageKiller) --Avisos de morte torres time azul creatureName = getCreatureName (cid) if creatureName == dtt.monster.name.a2 then doBroadcastMessage("[DEFEND THE TOWER] A torre azul do topo foi destruida.", MESSAGE_EVENT_ADVANCE) doCreateItem(9596, dtt.monster.pos.a2) setGlobalStorageValue(dtt.storage.tower_red, (getGlobalStorageValue(dtt.storage.tower_red)+1)) elseif creatureName == dtt.monster.name.a3 then broadcastMessage("[DEFEND THE TOWER] A torre azul do meio foi destruida.", MESSAGE_EVENT_ADVANCE) doCreateItem(9596, dtt.monster.pos.a3) setGlobalStorageValue(dtt.storage.tower_red, (getGlobalStorageValue(dtt.storage.tower_red)+1)) elseif creatureName == dtt.monster.name.a4 then broadcastMessage("[DEFEND THE TOWER] A torre azul de baixo foi destruida.", MESSAGE_EVENT_ADVANCE) doCreateItem(9596, dtt.monster.pos.a4) setGlobalStorageValue(dtt.storage.tower_red, (getGlobalStorageValue(dtt.storage.tower_red)+1)) --Avisos de morte torres time vermelho elseif creatureName == dtt.monster.name.b2 then broadcastMessage("[DEFEND THE TOWER] A torre vermelha do topo foi destruida.", MESSAGE_EVENT_ADVANCE) doCreateItem(9596, dtt.monster.pos.b2) setGlobalStorageValue(dtt.storage.tower_blue, (getGlobalStorageValue(dtt.storage.tower_blue)+1)) elseif creatureName == dtt.monster.name.b3 then broadcastMessage("[DEFEND THE TOWER] A torre vermelha do meio foi destruida.", MESSAGE_EVENT_ADVANCE) doCreateItem(9596, dtt.monster.pos.b3) setGlobalStorageValue(dtt.storage.tower_blue, (getGlobalStorageValue(dtt.storage.tower_blue)+1)) elseif creatureName == dtt.monster.name.b4 then broadcastMessage("[DEFEND THE TOWER] A torre vermelha de baixo foi destruida.", MESSAGE_EVENT_ADVANCE) doCreateItem(9596, dtt.monster.pos.b4) setGlobalStorageValue(dtt.storage.tower_blue, (getGlobalStorageValue(dtt.storage.tower_blue)+1)) --Aviso ultimas torres e abertura do teleporte elseif creatureName == dtt.monster.name.a1 then dtt.removeMonsters() setGlobalStorageValue(dtt.storage.win, "red") setGlobalStorageValue(dtt.storage.tower_red, (getGlobalStorageValue(dtt.storage.tower_red)+1)) dtt.close() broadcastMessage(dtt.msg.win_team_red, MESSAGE_EVENT_ADVANCE) dtt.resultBattle() --Aviso ultimas torres e abertura do teleporte elseif creatureName == dtt.monster.name.b1 then dtt.removeMonsters() setGlobalStorageValue(dtt.storage.win, "blue") setGlobalStorageValue(dtt.storage.tower_blue, (getGlobalStorageValue(dtt.storage.tower_blue)+1)) dtt.close() broadcastMessage(dtt.msg.win_team_blue, MESSAGE_EVENT_ADVANCE) dtt.resultBattle() --Verificando buff sorcerer and paladin if creatureName == dtt.monster.name.buff1 then if (getPlayerStorageValue(mostDamageKiller[1], dtt.storage.team_blue) == 1) then dtt.setBuff(dtt.storage.team_blue, 1, 3) for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, dtt.storage.team_blue) == 1 then doPlayerSendTextMessage(index.pid, 25, "[DEFEND THE TOWER] Os sorcerers e paladinos do seu time receberao buff, utilize as magias wizard buff ou archer buff.") end end else dtt.setBuff(dtt.storage.team_red, 1, 3) for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, dtt.storage.team_red) == 1 then doPlayerSendTextMessage(index.pid, 25, "[DEFEND THE TOWER] Os sorcerers e paladinos do seu time receberao buff, utilize as magias wizard buff ou archer buff.") end end end end --Verificando buff druid and knight if creatureName == dtt.monster.name.buff2 then if (getPlayerStorageValue(mostDamageKiller[1], dtt.storage.team_blue) == 1) then dtt.setBuff(dtt.storage.team_blue, 2, 4) for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, dtt.storage.team_blue) == 1 then doPlayerSendTextMessage(index.pid, 25, "[DEFEND THE TOWER] Os druids e knights do seu time receberao buff, utilize as magias magician buff ou warrior buff.") end end else dtt.setBuff(dtt.storage.team_red, 2, 4) for _, index in ipairs(dtt.getPlayersInEvent()) do if getPlayerStorageValue(index.pid, dtt.storage.team_red) == 1 then doPlayerSendTextMessage(index.pid, 25, "[DEFEND THE TOWER] Os druids e knights do seu time receberao buff, utilize as magias magician buff ou warrior buff.") end end end end end return true end
-
Dosetcreatureoutfit valendo rep+++
É uma gambiarra que só vai funcionar pra essa área aí, mas tenta esse: local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA) setCombatParam(combat, COMBAT_PARAM_USECHARGES, true) local area = createCombatArea(AREA_SQUARE1X1) setCombatArea(combat, area) function onGetFormulaValues(cid, level, skill, attack, factor) local skillTotal, levelTotal = skill + attack, level / 5 return -(skillTotal * 0.5 + levelTotal), -(skillTotal * 1.5 + levelTotal) end setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues") function onCastSpell(cid, var, target) mninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} fninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} enemy_mninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} enemy_fninja = {lookType = 117, lookHead = 0, lookBody = 0, lookLegs = 0, lookFeet = 0, lookTypeEx = 0, lookAddons = 3} target = getCreatureTarget(cid) if getPlayerSex(cid) == 0 then doSetCreatureOutfit(cid, mninja, 500) else doSetCreatureOutfit(cid, fninja, 500) end for i=-1,1 do for j=-1,1 do -- adjust position thingPos = getCreaturePosition (target) thingPos.x = thingPos.x + i thingPos.y = thingPos.y + j thingPos.stackpos = 255 -- thing = getThingfromPos(thingPos) thing = thing.uid if isPlayer (thing) then if getPlayerSex (thing) == 0 then doSetCreatureOutfit (thing, enemy_mninja, 500) else doSetCreatureOutfit (thing, enemy_fninja, 500) end end end end return doCombat(cid, combat, var) end
-
Script Blood Item Para 8.60
O script sorteia uma das 3 criaturas pra você se transformar e enquanto está transformado sua regen aumenta conforme a criatura em que você se transformou.
-
Como usar addEvent
Use a recursividade pra isso, exemplo: function doSomething (cid, times) if times == 0 then -- CRITÉRIO DE PARADA return true else addEvent (doSomething, 1000, cid, times - 1) -- AO CHAMAR A FUNÇÃO NOVAMENTE TENHA CERTEZA Q SEU CRITERIO DE PARADA SERA ATINGIDO -- funcao intervalo parametros end end O que vai acontecer se eu chamar a função com doSomething (cid, 5)? 1) Vai para doSomething, times é diferente de 0 então vamos para o else. Else adiciona um evento para executar doSomething (cid, 4) Passa um segundo do addEvent. 2) Vai para doSomething, times é diferente de 0 então vamos para o else. Else adiciona um evento para executar doSomething (cid, 3) Passa um segundo do addEvent. 3) Vai para doSomething, times é diferente de 0 então vamos para o else. Else adiciona um evento para executar doSomething (cid, 2) Passa um segundo do addEvent. 4) Vai para doSomething, times é diferente de 0, então vamos para o else. Else adiciona um evento para executar doSomething (cid, 1) Passa um segundo do addEvent. 5) Vai para doSomething, times é IGUAL a zero, então encerramos a execução. Nos slides desse site da federal de ouro preto: http://www.decom.ufop.br/romildo/2012-1/bcc222/slides/06-recursividade.pdf você tem a explicação com a linguagem de prog Haskell, a única coisa que você precisa saber pra não ficar perdido é que pot2 n | n == 0 = 1 | n > 0 = 2 * pot2 (n-1) É equivalente ao que tem abaixo, em LUA: function pot2(n) if n == 0 then return 1 elseif n > 0 then return 2 * pot2 (n - 1) end end
-
Função que verifica se o player andou
Eu não conheço uma função que faça essa checagem, mas dá pra fazer uma gambiarra adaptando isso: moved = "false" function onUse(cid, item, frompos, item2, topos) getPlayerMoved(cid, 2000, getThingPosition(cid)) return true end function getPlayerMoved (cid, interval, initialPos) if interval <= 0 then doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, "NAO SE MOVEU") return else if comparePosition(initialPos, getThingPosition(cid)) then addEvent(getPlayerMoved, 125, cid, interval - 125, initialPos) else doPlayerSendTextMessage (cid, MESSAGE_STATUS_CONSOLE_ORANGE, "SE MOVEU") return end end end function comparePosition (pos1, pos2) if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then return true else return false end end O script acima ele checa no intervalo de 2 segundos se o player se moveu, caso tenha se movido ele manda ao jogador "SE MOVEU", caso nao ande durante o tempo estimado, "NAO SE MOVEU", daria pra substituir esses prints por algo que você queira que ele faça. Sinceramente eu não sei se da pra pegar retorno de uma função chamada por um addEvent
-
Modal Compra por alavanca 1.2
Pode ser meio frescura mas acho que ficaria melhor para configurar o script se você unificar as 3 variáveis id_potion, price, cap em uma array de itens, onde cada item tem um id/preco/cap. Quando tem poucos fica fácil de ver, mas quando tiver muito item vai ficar complicado saber se ta tudo certinho, mas achei bem legal isso do OTx, estou pensando seriamente em migrar xD mt legal a facilidade de criar janelinhas nele
-
[ajuda] não consigo abrir bag dxp
Mostra o script responsável pelo pack inicial, recomendo testar abrir sem esse script rolando também.
-
Magia que cria item em área REP++
Na skill que eu usava era assim: <item id="6610" name="snow"> <attribute key="type" value="magicfield"/> <attribute key="decayTo" value="0"/> <attribute key="duration" value="20"/> </item>
-
Adicionar delay
Diga em poucas palavras a base utilizada (Nome do servidor ou nome do website). Ex. TFS 1.3; Base: TFS 0.4 Qual erro está surgindo/O que você procura? Estou querendo fazer um script de bomba que consiste em o jogador dar use num item, e aí começa a pulsar uma bomba no local, depois de tempo X essa bomba explode. O problema que encontrei, porém, é que não estou conseguindo fazer com que a posição em que a spell é executada seja na posição em que aparece a pulsação, ou seja, a posição inicial do jogador. Consigo mexer nisso sem mexer na source? Dei uma olhadinha lá e ela pega a posição da criatura caster na hora que executa a spell Você tem o código disponível? Se tiver publique-o aqui: local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, 5) setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.5, -30, -1.1, 0) local arr = { {0, 1, 0}, {1, 3, 1}, {0, 1, 0}, } local area = createCombatArea(arr) setCombatArea(combat, area) function onUse(cid, item, frompos, item2, topos) playerPosition = getCreaturePosition (cid) antigoCid = cid bombSimulator (cid, 4, playerPosition) addEvent (doCombat, 2000, cid, combat, numberToVariant(cid)) return true end function bombSimulator (cid, times, pPos) if times == 0 then return true else doSendMagicEffect(pPos, 7) addEvent (bombSimulator, 500, cid, times - 1, pPos) end end Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui.
-
Magia que cria item em área REP++
Se não mudou nada da versão de 8.1 que tenho aqui seria só adicionar na lista dos parâmetros do combate: setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 6610) O tempo eu controlei pelo items.xml
-
Dosetcreatureoutfit valendo rep+++
Impossível e uma palavra bem forte, basta pensar em uma forma viavel, se nao me engano ainda tem um recurso das conditions de spells que trocam outfit, só que na minha cabeça o problema seria fazer as checagens. A área da skill é essa daí mesmo?