Ir para conteúdo

Zaruss

Campones
  • Total de itens

    93
  • Registro em

  • Última visita

Histórico de Reputação

  1. Upvote
    Zaruss recebeu reputação de AnneMotta em Players/monstros em uma área   
    Assim
    local config = { fromPosition = {x = 856, y = 785, z = 7}, -- começo da area toPosition = {x = 876, y = 810, z = 7}, -- fim da area } if isInArea(getPlayerPosition(cid), config.fromPosition, config.toPosition) then doPlayerAddItem(cid, item, count) end ou assim:
    local config = { fromPosition = {x = 856, y = 785, z = 7}, -- começo da area toPosition = {x = 876, y = 810, z = 7}, -- fim da area } for x = config.fromPosition.x, config.toPosition.x do for y = config.fromPosition.y, config.toPosition.y do for z = config.fromPosition.z, config.toPosition.z do area = {x = x, y = y, z = z, stackpos = 253} allplayers = getThingfromPos(area) if isPlayer(allplayers.uid) then doPlayerAddItem(cid, item, count) end end end end pra ve se tem monsters e so trocar o isPlayer por isMonster
  2. Upvote
    Zaruss deu reputação a Vodkart em [Gfs] Guild Frag System   
    Antes de mais nada execute essas querys no seu banco de dados

    ALTER TABLE `guilds` ADD `frags` INT(11) NOT NULL DEFAULT 0; ALTER TABLE `guilds` ADD `acesstime` INT(15) NOT NULL DEFAULT 0;
     
    Não sabe executar a query? abra o spoiler e aprenda!
     
     
     
     
     
    Sistema
     
     
     
     
     
    Por Mod
     
     
     
     
    Npc (obs: o NPC funciona caso você use MOD tbm)
     
     
     
     
     
     
    Configuração
     
     
  3. Upvote
    Zaruss deu reputação a vital900 em Mapa dota   
    Tenta ai.
  4. Upvote
    Zaruss deu reputação a Killua em [Blood Castle] Evento Otimizado![12/04/14]   
    Últimas atualizações:
    16/12/2013:

    [ATUALIZADO 12/04/2014]

    Introdução:
     
     
    Eai gente, vcs conhecem o evento Blood Castle que tem no jogo MU? Então, eu resolvi criar esse evento para OpenTibia e ficou bem legal
     
     
     
     
    Informações:  
     
    OBS: NÃO é obrigatório o uso do mapa que vou por aqui, ele serve somente para exemplo.
     
    #Dica: Acho que fica legal o premio do evento ser um item que da double exp por um tempo.
     
    Atualização:

    Resolvi refazer o código, para facilitar a instalação e melhorar o funcionamento do evento.

    O que mudou?
     
     

     
     
    Instalando o evento:

    Lib:
     
     
    Movements:

     
    Creaturescripts:

     
    Monsters:
    O evento pode acontecer de duas maneiras: automática ou manualmente. Vou por as duas possibilidades: Automático:  
    Manual:
     
     
    Como Configurar:

    * Se você for colocar, dentro do evento, um teleporte para as pessoas que não quiserem mais participar, coloque o Action ID 9371 nele.
     
    * Lembre-se de por NO-LOGOUT tool e NO-PVP tool em toda área do evento!!
     
    Todas as demais explicações estão na lib, mas vou demonstrar como configurar os mais "confusos".
     
    No modo automático, você configura de quanto em quanto o tempo o evento vai acontecer. Nessa tag:
    <globalevent name="Blood Castle" interval="3600" event="script" value="BloodGlobalEvent.lua"/> Aqui está 3600 segundos, ou seja, 1 hora.
    * Se seu servidor for em milisegundos, multiplique o número por 1000, assim: 3600 segundos * 1000 = 3600000 milisegundos = 1 hora.
     
    No modo manual, para iniciar o evento, basta usar a talkaction /blood-start com seu god.
     
    Em posGuarda, vc deve colocar a posicao do Guarda do Portao, como mostrado abaixo:
    As posPedras são onde ficam as pedras que tampam a passagem enquanto o evento não esta aberto, conforme na imagem abaixo:
    Em estátua, vc deve colocar a posição em que o arcanjo vai ser criado, conforme na imagem abaixo:
    Nas posParedes, vc deve por a posição das paredes que bloqueiam a entrada do castelo e que são removidas quando o guarda morre, conforme abaixo:
    Em fromPos e toPos, você vai por o canto superior esquerdo e o canto inferior direito do mapa do seu evento, respectivamente. Dessa maneira:
    As outras configurações eu acredito que já estejam bem explicadas. Espero que gostem dessa nova versão. Recomendo a todos que já usam o evento, reinstalar com essa nova versão. Qualquer dúvida ou bug, postem que irei responder. Download do mapa exemplo: Blood Castle.rar
  5. Upvote
    Zaruss recebeu reputação de kinhozinho157 em Erro no zombie event.   
    Quando o zombie event inicia e aparece da uns erros na distro esse aki:
    [22/10/2013 05:42:32] [Error - CreatureScript Interface] [22/10/2013 05:42:32] data/creaturescripts/scripts/zombie.lua:onStatsChange [22/10/2013 05:42:32] Description: [22/10/2013 05:42:33] data/lib/032-position.lua:2: attempt to index global 'position' (a nil value) [22/10/2013 05:42:33] stack traceback: [22/10/2013 05:42:33] data/lib/032-position.lua:2: in function 'isInArea' [22/10/2013 05:42:33] data/creaturescripts/scripts/zombie.lua:17: in function <data/creaturescripts/scripts/zombie.lua:15> e tambem os players pode atacar os zombies sendo que ja colocquei no-pvp e no-logout la na area e os zombies atacam os players e eles nao vao pro templo.
    Eu tentei arrumar isso ai so que so deu em merda.
     
    Aki o zombie.lua
     
    e aki o 032-position:
     
    @------------------------------------Resolvido------------------------------------------
    Ja resolvi esse meu problema esta aqui embaixo a soluçao caso alguem esteja com o mesmo problema(e meio improvavel).
     
    data/creaturescripts/scripts/onthink.lua
     
     
     
    data/creaturescripts/scripts/ondeath.lua
     
     
     
     
    tags:
    <event type="think" name="ZombieThink" event="script" value="zombie/onthink.lua"/> <event type="death" name="ZombieDeath" event="script" value="zombie/ondeath.lua"/> e adicione isso no monster zombie event:
    <script> <event name="ZombieThink"/> <event name="ZombieDeath"/> </script> Acho que e so eu mesmo que tinha esse problema mesmo so muito burro.
  6. Upvote
    Zaruss deu reputação a Omega em Dropa apenas um item   
    Assim:
    function onDeath(cid, corpse, deathList) local itemIds = {2160, 2148, 3213} local monsterName = "Demon" if((isMonster(cid)) and (getCreatureName(cid) == monsterName)) then local backpack = doAddContainerItem(corpse.uid, 10518) doAddContainerItem(backpack, itemIds[math.random(#itemIds)]) end return true end
  7. Upvote
    Zaruss deu reputação a Skymagnum em Dropa apenas um item   
    Não coloque nenhum loot no script do monstro.
    function onDeath(cid, corpse, deathList) local itemIds = {2160, 2148, 3213} local monsterName = "Demon" if((isMonster(cid)) and (getCreatureName(cid) == monsterName)) then doAddContainerItem(corpse.uid, itemIds[math.random(#itemIds)]) end return true end
  8. Upvote
    Zaruss recebeu reputação de Mycry em Monster com bug   
    Ta aqui se nao funcionar me manda o erro da distro(se tiver):
     

  9. Upvote
    Zaruss deu reputação a meubk em Acabar Mana Perder Vida   
    healthLostMana.lua :
    local config = { voc = {1, 5, 2, 6}, -- quais vocação perde dano quando n tem mana seconds = 1, -- a cada quantos segundos vai perder dano damage = 1 -- quanto de dano ira perder } function startManaHealth(cid, seconds, damage) if not isCreature(cid) then return true end if getCreatureMana(cid) == 0 then doCreatureAddHealth(cid, -damage) end addEvent(startManaHealth, 1000 * seconds, cid, seconds, damage) end function onLogin(cid) if isInArray(config.voc, getPlayerVocation(cid)) then startManaHealth(cid, config.seconds, config.damage) end return true end tag:
    <event type="login" name="healthLostMana" event="script" value="healthLostMana.lua"/> as configurações ta no script, vc pode escolher se só algumas vocações vão ter este problema kk e os segundos e dano ...
  10. Upvote
    Zaruss recebeu reputação de Omega em Monster com bug   
    Ta aqui se nao funcionar me manda o erro da distro(se tiver):
     

  11. Upvote
    Zaruss recebeu reputação de kaizy536 em Erro nos monstro   
    Spectral lord:
     

     
    Medusa spectral
     

     
    Dre val disposer:
     

     
    spectral assasin
     

     
     
    spectral dragon:
     

  12. Upvote
    Zaruss recebeu reputação de Mycry em Voltar o pet   
    isso aqui:
     
    for _, pid in ipairs(getCreatureSummons(cid)) do doRemoveCreature(pid) doCreatureSay(cid, "Volte pet", TALKTYPE_ORANGE_1) return true end
  13. Upvote
    Zaruss deu reputação a Omega em ID Das Skills   
    Abra a pasta do seu otserver, em seguida a pasta data, que contém uma pasta chamada lib. Nessa pasta, abra o arquivo 000-constant.lua. É nesse arquivo que tem todos esses IDs e várias outras constantes. Lá, procure por
    SKILL_SHIELD E
    SKILL_SWORD
  14. Upvote
    Zaruss recebeu reputação de matheuspeixoto12 em [Encerrado] erro config.lua   
    Troca por esse.
    accountManager = true namelockManager = true newPlayerChooseVoc = true newPlayerSpawnPosX = 1021 newPlayerSpawnPosY = 1023 newPlayerSpawnPosZ = 7 newPlayerTownId = 1 newPlayerLevel = 1 newPlayerMagicLevel = 100 generateAccountNumber = false redSkullLength = 1 * 24 * 60 * 60 blackSkullLength = 2 * 24 * 60 * 60 dailyFragsToRedSkull = 10 weeklyFragsToRedSkull = 20 monthlyFragsToRedSkull = 30 dailyFragsToBlackSkull = 15 weeklyFragsToBlackSkull = 25 monthlyFragsToBlackSkull = 35 dailyFragsToBanishment = dailyFragsToRedSkull weeklyFragsToBanishment = weeklyFragsToRedSkull monthlyFragsToBanishment = monthlyFragsToRedSkull blackSkulledDeathHealth = 0 blackSkulledDeathMana = 0 useBlackSkull = true useFragHandler = true advancedFragList = false notationsToBan = 2 warningsToFinalBan = 10 warningsToDeletion = 15 banLength = 7 * 24 * 60 * 60 killsBanLength = 1 * 24 * 60 * 60 finalBanLength = 7 * 24 * 60 * 60 ipBanishmentLength = 10 * 24 * 60 * 60 broadcastBanishments = true maxViolationCommentSize = 200 violationNameReportActionType = 2 autoBanishUnknownBytes = false worldType = "pvp" protectionLevel = 200 pvpTileIgnoreLevelAndVocationProtection = true pzLocked = 30 * 1000 huntingDuration = 30 * 1000 criticalHitChance = 6 criticalHitMultiplier = 2 displayCriticalHitNotify = true removeWeaponAmmunition = true removeWeaponCharges = true removeRuneCharges = true whiteSkullTime = 5 * 60 * 1000 noDamageToSameLookfeet = false showHealingDamage = true showHealingDamageForMonsters = false fieldOwnershipDuration = 5 * 1000 stopAttackingAtExit = true oldConditionAccuracy = false loginProtectionPeriod = 10 * 1000 deathLostPercent = 5 stairhopDelay = 2 * 1000 pushCreatureDelay = 1 * 1000 deathContainerId = 1987 gainExperienceColor = 215 addManaSpentInPvPZone = true squareColor = 0 allowFightback = true worldId = 0 ip = "127.0.0.1" bindOnlyConfiguredIpAddress = false loginPort = 7171 gamePort = 7172 adminPort = 7171 statusPort = 7171 loginTries = 10 retryTimeout = 5 * 1000 loginTimeout = 60 * 1000 maxPlayers = 125 motd = "Bem Vindo ao Naruto Storm!" displayOnOrOffAtCharlist = false onePlayerOnlinePerAccount = false allowClones = false serverName = "Naruto Storm" loginMessage = "Bem Vindo ao Naruto Storm." statusTimeout = 5 * 60 * 1000 replaceKickOnLogin = true forceSlowConnectionsToDisconnect = false loginOnlyWithLoginServer = false premiumPlayerSkipWaitList = false sqlType = "mysql" sqlHost = "localhost" sqlPort = 3306 sqlUser = "root" sqlPass = "druidsinho22" sqlDatabase = "naruto" sqlFile = "naruto.s3db" sqlKeepAlive = 0 mysqlReadTimeout = 10 mysqlWriteTimeout = 10 encryptionType = "plain" deathListEnabled = true deathListRequiredTime = 1 * 60 * 1000 deathAssistCount = 19 maxDeathRecords = 5 ingameGuildManagement = true levelToFormGuild = 100 premiumDaysToFormGuild = 0 guildNameMinLength = 3 guildNameMaxLength = 20 highscoreDisplayPlayers = 20 updateHighscoresAfterMinutes = 1 buyableAndSellableHouses = true houseNeedPremium = false bedsRequirePremium = false levelToBuyHouse = 300 housesPerAccount = 1 houseRentAsPrice = false housePriceAsRent = false housePriceEachSquare = 60000 houseRentPeriod = "week" houseCleanOld = 0 guildHalls = false timeBetweenActions = 500 timeBetweenExActions = 1000 hotkeyAimbotEnabled = true mapName = "naruto" mapAuthor = "Lks" randomizeTiles = true storeTrash = true cleanProtectedZones = true mailboxDisabledTowns = "-1" defaultPriority = "high" niceLevel = 5 coresUsed = "-1" optimizeDatabaseAtStartup = true removePremiumOnInit = true confirmOutdatedVersion = false formulaLevel = 5.0 formulaMagic = 1.0 bufferMutedOnSpellFailure = false spellNameInsteadOfWords = true emoteSpells = true allowChangeOutfit = true allowChangeColors = true allowChangeAddons = true disableOutfitsForPrivilegedPlayers = false addonsOnlyPremium = false dataDirectory = "data/" bankSystem = true displaySkillLevelOnAdvance = true promptExceptionTracerErrorBox = true separateViplistPerCharacter = false maximumDoorLevel = 500 maxMessageBuffer = 20 saveGlobalStorage = true useHouseDataStorage = false storePlayerDirection = false checkCorpseOwner = true monsterLootMessage = 3 monsterLootMessageType = 25 ghostModeInvisibleEffect = true ghostModeSpellEffects = true idleWarningTime = 14 * 60 * 1000 idleKickTime = 30 * 60 * 1000 expireReportsAfterReads = 1 playerQueryDeepness = 2 maxItemsPerPZTile = 0 maxItemsPerHouseTile = 0 freePremium = false premiumForPromotion = false blessingOnlyPremium = true blessingReductionBase = 30 blessingReductionDecreament = 3 eachBlessReduction = 8 experienceStages = false rateExperience = 300 rateExperienceFromPlayers = 0 rateSkill = 30 rateMagic = 0 rateLoot = 3 rateSpawn = 7 rateMonsterHealth = 1.0 rateMonsterMana = 1.0 rateMonsterAttack = 1.0 rateMonsterDefense = 1.0 minLevelThresholdForKilledPlayer = 0.9 maxLevelThresholdForKilledPlayer = 1.1 rateStaminaLoss = 7 rateStaminaGain = 3 rateStaminaThresholdGain = 12 staminaRatingLimitTop = 2 * 60 staminaRatingLimitBottom = 1 * 60 rateStaminaAboveNormal = 1.5 rateStaminaUnderNormal = 0.5 staminaThresholdOnlyPremium = true experienceShareRadiusX = 30 experienceShareRadiusY = 30 experienceShareRadiusZ = 1 experienceShareLevelDifference = 2 / 3 extraPartyExperienceLimit = 20 extraPartyExperiencePercent = 5 experienceShareActivity = 2 * 60 * 1000 globalSaveEnabled = false globalSaveHour = 8 shutdownAtGlobalSave = true cleanMapAtGlobalSave = false deSpawnRange = 2 deSpawnRadius = 50 maxPlayerSummons = 4 teleportAllSummons = true teleportPlayerSummons = true ownerName = "Naruto Storm" ownerEmail = "matheuspeixoto12@hotmail.com" url = "matheuspeixoto3.wix.com/nto-louther" location = "Brazil" displayGamemastersWithOnlineCommand = false adminLogsEnabled = false displayPlayersLogging = true prefixChannelLogs = "" runFile = "" outLogName = "" errorLogName = "" truncateLogsOnStartup = false
  15. Upvote
    Zaruss deu reputação a Vodkart em [Talk] Deathlist [Fixed/no Crash]   
    Atualizado V1.0:

    Mostra últimas mortes do servidor:


    você pode usar o comando !deathlist NOME
    ex: !deathlist Carlin:





    in your db execute this query:


    CREATE TABLE death_list ( id INTEGER NOT NULL, player_id INTEGER NOT NULL, date INTEGER NOT NULL, level INTEGER NOT NULL, killer_name INTEGER NOT NULL, PRIMARY KEY ( id ) );
    creaturescript

    death_list.lua
    function onDeath(cid, corpse, deathList) local str = "" for _, pid in ipairs(deathList) do if isCreature(pid) == true then str = str.."".. (str == "" and "" or ",") ..""..getCreatureName(pid) else str = str.."".. (str == "" and "" or ",") .." a field item" end end str = str.."." death = str .. " ".. (getPlayerBlessing(cid, 5) and "[Blessed]" or getPlayerSlotItem(cid, 2).itemid == 2173 and "[AOL]" or "") db.executeQuery("INSERT INTO `death_list` (`player_id`, `date`, `level`, `killer_name`) VALUES ('".. getPlayerGUID(cid).."', '".. os.time() .."', '".. getPlayerLevel(cid) .."', '".. death .."');") return true end
    creaturescript.xml
    <event type="death" name="DeathList" event="script" value="death_list.lua"/>
    creaturescript/script/login.lua
    registerCreatureEvent(cid, "DeathList")
    talkactions

    deathlist.lua
    limit = 5 function onSay(cid, words, param, channel) str = "" if param == "" then local qry = db.getResult("SELECT `player_id`, `date`, `level`, `killer_name` FROM `death_list` ORDER BY `date` DESC LIMIT 0, " .. limit) if(qry:getID() ~= -1) then repeat str = str .."\n "..os.date("%d %B %Y %X ", qry:getDataInt("date")).." "..getPlayerNameByGUID(qry:getDataString("player_id")).." died at level "..qry:getDataInt("level").." by:\n"..qry:getDataString("killer_name") until not(qry:next()) qry:free() else str = "Não há mortes no servidor." end doPlayerPopupFYI(cid, "Last Deaths:\n\n" .. str) return true end local getGuid = getPlayerGUIDByName(param:lower()) if not getGuid then doPlayerSendCancel(cid, "Este Player não existe.") return true end local qry = db.getResult("SELECT `id`, `date`, `level`, `killer_name` FROM `death_list` WHERE `player_id` = " .. getGuid .." ORDER BY `date` DESC LIMIT 0, " .. limit) if(qry:getID() ~= -1) then repeat str = str .."\n "..os.date("%d %B %Y %X ", qry:getDataInt("date")).." died at level "..qry:getDataInt("level").." by:\n"..qry:getDataString("killer_name") until not(qry:next()) qry:free() else str = "Não há mortes." end doPlayerPopupFYI(cid, "Last Deaths of: " .. param .. ".\n\n" .. str) return true end
    talkactions.xml
    <talkaction words="!deathlist" script="deathlist.lua"/>
  16. Upvote
    Zaruss recebeu reputação de brunoi123 em Mudar versão do mapa   
    Se muda com o Remere's aqui um tutorial ensinando
    [topic=http://www.xtibia.com/forum/topic/122394-mudar-a-versao-do-mapa/]Mudar Versao do Mapa[/topic]
  17. Upvote
    Zaruss recebeu reputação de mylorc em Preciso de um Vocations.xml   
    TA AE
     
     
  18. Upvote
    Zaruss recebeu reputação de rafanh20 em ITENS EDITADOS NÃO FUNCIONA   
    Em movements.xml:
     
    <movevent type="DeEquip" itemid="IDDOITEM" slot="head" event="function" value="onDeEquipItem"/> <movevent type="Equip" itemid="IDDOITEM" slot="head" event="function" value="onEquipItem"/>
  19. Upvote
    Zaruss deu reputação a Oneshot em Oneshot Spell Lib   
    Nenhuma vantagem e desvantagem, colega. Eu só senti vontade de desenvolver uma biblioteca orientada a objetos para desenvolvimento de magias. Não preciso convencer com quaisquer argumentos o uso dela.
     
    Quanto as duas funções:
     

    combat:SetID(2)  
    Isso vai dar o tileid igual a 2 para um combat, aí você vai poder chamar ela na área da sua magia com isso
     

    local area = { {2}, {3}, }  
    E a função:
     

    combat:SetDelay(200)  
    É o delay, intervalo de tempo para o combat ser chamado em um sqm.
     
    Abraços.
  20. Upvote
    Zaruss deu reputação a Oneshot em Oneshot Spell Lib   
    Oneshot Spell Lib

    Boa tarde, meus queridos.
     
    Como eu disse no último post do tópico do Spell Forge, sim, ele estava ficando funcional o bastante, mas uma coisa não me agradava, o nível de dificuldade de configuração do sistema estava aumentando, e uma hora, não teria como OT-admins usarem meu sistema, pois não saberiam configurar.
     
    Então resolvi parar o desenvolvimento dele por enquanto, mas segue minha biblioteca que estava usando para desenvolvimento do sistema.
     
    Uma biblioteca completa para desenvolvimento de magias, orientada a objetos, torna a coisa bem mais interessante.
     
    Para utilizar minha biblioteca, basta criar arquivo com qualquer nome na pasta data/lib do seu servidor e colar o seguinte conteúdo abaixo:
    -- This library is part of Oneshot Spell System -- Copyright (C) 2013 Oneshot -- -- 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/>. -- constant CONST_SPELL_AREA = 0 -- area spells, like exevo gran mas vis CONST_SPELL_DIRECTION = 1 -- wave spells, like exevo flam hur CONST_SPELL_TARGETORDIRECTION = 2 -- mix between area and wave spells WEAPON_SKILLS = { [WEAPON_SWORD] = SKILL_SWORD, [WEAPON_CLUB] = SKILL_CLUB, [WEAPON_AXE] = SKILL_AXE, } -- class for combats (spell instances) Combat = { type = 0, me = 0, ani = 0, formula = { type = 0, values = {}, }, condition = nil, delay = 0, id = 0, } function Combat:New(_type, me, ani, delay, id) local new_spellinstance = { type = _type or COMBAT_NONE, me = me or CONST_ME_NONE, ani = ani or CONST_ANI_NONE, formula = { type = COMBAT_FORMULA_UNDEFINED, values = {0, 0, 0, 0, 0, 0, 0, 0}, }, condition = nil, delay = delay or -1, id = id or 1, } return setmetatable(new_spellinstance, {__index = self}) end function Combat:SetType(_type) self.type = (tonumber(_type) and _type or COMBAT_NONE) end function Combat:SetEffect(me) self.me = (tonumber(me) and me or CONST_ME_NONE) end function Combat:SetDistanceEffect(ani) self.ani = (tonumber(ani) and ani or CONST_ANI_NONE) end function Combat:SetFormula(_type, ...) local args = select("#", ...) self.formula.type = (tonumber(_type and _type or COMBAT_FORMULA_UNDEFINED)) local minc, maxc if args > 8 then minc, maxc = select(9, ...) end local minm, maxm = getConfigValue("formulaMagic") or 1 maxm = minm local minl, maxl = getConfigValue("formulaLevel") or 5 maxl = minl if args > 6 then minm, maxm = select(7, ...) end if args > 4 then minl, maxl = select(5, ...) end local mina, minb, maxa, maxb = select(1, ...) self.formula.values = {mina, minb, maxa, maxb, minl, maxl, minm, maxm, minc, maxc} end function Combat:SetCondition(condition) -- condition needs to be a createConditionObject(), e.g -- local condition = createConditionObject(CONDITION_FIRE) -- setConditionParam(condition, CONDITION_PARAM_TICKS, 1 * 1000) self.condition = condition end function Combat:GetDelay() return self.delay end function Combat:SetDelay(delay) self.delay = (tonumber(delay) and delay or -1) end function Combat:GetId() return self.id end function Combat:SetId(id) self.id = (tonumber(id) and id or 1) end function Combat:getMinMaxValues(cid, ex) local min, max = 0, 0 local n = self.formula.values if not isCreature(cid) then return false end if not isPlayer(cid) then self.formula.type = COMBAT_FORMULA_DAMAGE end if self.formula.type == COMBAT_FORMULA_LEVELMAGIC then min = (getPlayerLevel(cid) / n[5] + getPlayerMagLevel(cid) * n[7]) * n[1] + n[2] max = (getPlayerLevel(cid) / n[6] + getPlayerMagLevel(cid) * n[8]) * n[3] + n[4] if n[9] then min = math.max(n[9], min) end if n[10] then max = math.max(n[10], max) end elseif self.formula.type == COMBAT_FORMULA_SKILL then local weapon = getPlayerWeapon(cid) if weapon.uid > 0 then max = getPlayerWeaponDamage(cid, weapon) * n[3] + n[4] else max = n[4] end if n[10] then max = math.max(n[10], max) end elseif self.formula.type == COMBAT_FORMULA_DAMAGE then min = n[2] max = n[4] end return min, max end function Combat:Callback(position, cid, ex) if not isCreature(cid) then return false end local min, max = self:getMinMaxValues(cid, ex) doCombatAreaHealth(cid, self.type, position, 0, min, max, self.me) if self.condition then doCombatAreaCondition(cid, position, 0, self.condition, CONST_ME_NONE) end return true end -- class for spells Spell = { type = 0, level = 0, maglevel = 0, mana = 0, needtarget = false, target_or_direction = false, range = 0, needweapon = false, selftarget = false, vocations = {}, combats = {}, } function Spell:New(_type, level, maglevel, mana, needtarget, range, needweapon, selftarget, ...) local new_spell = { type = _type or CONST_SPELL_AREA, level = level or 1, maglevel = maglevel or 0, mana = mana or 0, needtarget = needtarget or false, range = range or 1, needweapon = needweapon or false, selftarget = selftarget or false, vocations = {...}, combat = {}, area = {{3}}, } return setmetatable(new_spell, {__index = self}) end function Spell:SetType(_type) self.type = (tonumber(_type) and _type or CONST_SPELLarea) end function Spell:SetLevel(level) self.level = (tonumber(level) and level or 1) end function Spell:SetMagLevel(maglevel) self.maglevel = (tonumber(maglevel) and maglevel or 0) end function Spell:SetMana(mana) self.mana = (tonumber(mana) and mana or 0) end function Spell:SetNeedTarget(needtarget) self.needtarget = (type(needtarget) == "boolean" and needtarget or false) end function Spell:SetRange(range) self.range = (tonumber(range) and range or 1) end function Spell:SetNeedWeapon(needweapon) self.needweapon = (type(needweapon) == "boolean" and needweapon or false) end function Spell:SetSelfTarget(selftarget) self.selftarget = (type(selftarget) == "boolean" and selftarget or false) end function Spell:SetVocations(...) self.vocations = {...} end function Spell:Append(...) local t = {...} for i = 1, #t do self.combat[t[i]:GetId()] = t[i] end end function Spell:SetArea(area) self.area = area end function Spell:Cast(cid) if not isCreature(cid) then return false end if #self.combat == 0 then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) return false end if isPlayer(cid) then if not getPlayerFlagValue(cid, PLAYERFLAG_IGNORESPELLCHECK) then if getPlayerLevel(cid) < self.level then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHLEVEL) return false end if getCreatureMana(cid) < self.mana then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMANA) return false end if getPlayerMagLevel(cid) < self.maglevel then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHMAGICLEVEL) return false end if self.needweapon and (getPlayerWeapon(cid).uid == 0) then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUNEEDAWEAPONTOUSETHISSPELL) return false end local vocation = getPlayerVocation(cid) if #self.vocations > 0 and not (table.find(self.vocations, vocation) or table.find(self.vocations, getVocationInfo(vocation).fromVocation)) then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) doPlayerSendDefaultCancel(cid, RETURNVALUE_YOURVOCATIONCANNOTUSETHISSPELL) return false end end end local target = getCreatureTarget(cid) if self.needtarget == true then if self.type == CONST_SPELL_DIRECTION then self.type = CONST_SPELL_TARGETORDIRECTION elseif self.type == CONST_SPELL_AREA and not isCreature(target) then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUCANONLYUSEITONCREATURES) return false end end if self.range and isCreature(target) then if getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) > self.range then doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF) doPlayerSendDefaultCancel(cid, RETURNVALUE_TOOFARAWAY) return false end end local area = self.area if self.type == CONST_SPELL_DIRECTION or (self.type == CONST_SPELL_TARGETORDIRECTION and not isCreature(target)) then area = getAreaByDir(area, getCreatureLookDirection(cid)) end local centre = getCreaturePosition(cid) local target = getCreatureTarget(cid) if self.type == CONST_SPELL_DIRECTION then centre = getPosByDir(getCreaturePosition(cid), getCreatureLookDirection(cid), 1) elseif self.type == CONST_SPELL_TARGETORDIRECTION then centre = (isCreature(target) and getCreaturePosition(target) or getPosByDir(getCreaturePosition(cid), getCreatureLookDirection(cid), 1)) elseif self.type == CONST_SPELL_AREA then if self.needtarget and isCreature(target) then centre = getCreaturePosition(target) end end local positions = getAreaPositions(area, centre) for i = 1, #area do for j = 1, #area[i] do local tmp = area[i][j] if tmp == 3 then for k = 1, #self.combat do local combat = self.combat[k] if combat then addEvent(function() if self.selftarget then combat:Callback(positions[i][j], 0) else combat:Callback(positions[i][j], cid) end doSendDistanceShoot(getCreaturePosition(cid), centre, combat.ani) end, combat:GetDelay()) end end elseif type(tmp) == "number" and self.combat[tmp] then local combat = self.combat[tmp] if combat then addEvent(function() if self.selftarget then combat:Callback(positions[i][j], 0) else combat:Callback(positions[i][j], cid) end doSendDistanceShoot(getCreaturePosition(cid), centre, combat.ani) end, combat:GetDelay()) end elseif type(tmp) == "table" then for k = 1, #tmp do local tile = tmp[k] local combat = self.combat[tile] if combat then addEvent(function() if self.selftarget then combat:Callback(positions[i][j], 0) else combat:Callback(positions[i][j], cid) end doSendDistanceShoot(getCreaturePosition(cid), centre, combat.ani) end, combat:GetDelay()) end end end end end if self.mana > 0 then doCreatureAddMana(cid, -self.mana, 0) end return true end function rotate(area) local ret = {} for i = 1, #area do for j = 1, #area[i] do if not ret[#area[i]-j+1] then ret[#area[i]-j+1] = {} end ret[#area[i]-j+1][i] = area[i][j] end end return ret end function getAreaByDir(area, direction) local ret = area if direction > NORTH then local n = (4 - direction) repeat ret = rotate(ret) n = n - 1 until n == 0 end return ret end function getAreaCentre(area) local x, y = 0, 0 for i = 1, #area do for j = 1, #area[i] do if area[i][j] == 3 then x = j y = i break end end end return x, y end function getAreaPositions(area, centre) local ret = {} local x, y = getAreaCentre(area) for i = 1, #area do for j = 1, #area[i] do if not ret[i] then ret[i] = {} end ret[i][j] = {x = centre.x + (j - x), y = centre.y + (i - y), z = centre.z} end end return ret end function getPlayerMeleeDamage(cid, item) local skill, attack if item.uid > 0 then local info = getItemInfo(item.itemid) skill = getPlayerSkillLevel(cid, WEAPON_SKILLS[getItemWeaponType(item.uid)]) attack = ((getItemAttribute(item.uid, "attack") or info.attack) + (getItemAttribute(item.uid, "extraAttack") or info.extraAttack) - info.abilities.elementDamage) else skill = getPlayerSkillLevel(cid, SKILL_FIST) attack = 0 end local damage = math.ceil((2 * (attack * (skill + 5.8) / 25 + (getPlayerLevel(cid) - 1) / 10.)) / getPlayerAttackFactor(cid)) return -math.random(0, damage) end function getPlayerAttackFactor(cid) local switch = { 1.0, 1.2, 2.0, } return switch[(getPlayerModes(cid).fight + 1)] end dofile(getDataDir() .."/spells/lib/spells.lua") É uma biblioteca orientada a objetos que facilita o desenvolvimento de magias. Comparando a forma dos scripts de magias, com a minha biblioteca e sem, podemos ver a diferença.
     
    Sem a biblioteca:
    local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY) setAttackFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 4.5, 9) local area = createCombatArea(AREA_SQUAREWAVE5, AREADIAGONAL_SQUAREWAVE5) setCombatArea(combat, area) function onCastSpell(cid, var) return doCombat(cid, combat, var) end Com a biblioteca:
    local combat = Combat:New(COMBAT_ENERGYDAMAGE, CONST_ME_ENERGYAREA, CONST_ANI_ENERGY) combat:SetFormula(COMBAT_FORMULA_LEVELMAGIC, -1, 0, -1, 0, 5, 5, 4.5, 9) local spell = Spell:New(CONST_SPELL_DIRECTION) spell:Append(combat) spell:SetArea(AREA_WAVE4) function onCastSpell(cid, var) return spell:Cast(cid) end Mas o melhor mesmo é notado quando você quer desenvolver as magias com mais de uma variável combat. Aquelas magias de múltiplos hits e efeitos.
     
    Vou pegar uma magia de 3 efeitos e danos diferentes.
    local combat1 = createCombatObject() setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE) setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA) setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY) setAttackFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 4.5, 9) local combat2 = createCombatObject() setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE) setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA) setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE) setAttackFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 1, 2) local combat3 = createCombatObject() setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_EARTHDAMAGE) setCombatParam(combat3, COMBAT_PARAM_EFFECT, CONST_ME_SMALLPLANTS) setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH) setAttackFormula(combat3, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 3.5, 7) local area = createCombatArea(AREA_SQUAREWAVE5, AREADIAGONAL_SQUAREWAVE5) setCombatArea(combat1, area) setCombatArea(combat2, area) setCombatArea(combat3, area) function onCastSpell1(cid, var) doCombat(cid, combat1, var) end function onCastSpell2(cid, var) doCombat(cid, combat2, var) end function onCastSpell3(cid, var) doCombat(cid, combat3, var) end function onCastSpell(cid, var) onCastSpell1(cid, var) addEvent(onCastSpell2, 300, cid, var) addEvent(onCastSpell3, 600, cid, var) return true end Com o uso da minha biblioteca, podemos notar a redução de linhas, e a limpeza do código:
    local combat1 = Combat:New(COMBAT_ENERGYDAMAGE, CONST_ME_ENERGYAREA, CONST_ANI_ENERGY) combat1:SetFormula(COMBAT_FORMULA_LEVELMAGIC, -1, 0, -1, 0, 5, 5, 4.5, 9) local combat2 = Combat:New(COMBAT_ICEDAMAGE, CONST_ME_ICEAREA, CONST_ANI_ICE) combat2:SetFormula(COMBAT_FORMULA_LEVELMAGIC, -1, 0, -1, 0, 5, 5, 1, 2) combat2:SetId(2) combat2:SetDelay(300) local combat3 = Combat:New(COMBAT_EARTHDAMAGE, CONST_ME_SMALLPLANTS, CONST_ANI_EARTH) combat3:SetFormula(COMBAT_FORMULA_LEVELMAGIC, -1, 0, -1, 0, 5, 5, 3.5, 7) combat3:SetId(4) combat3:SetDelay(600) local T = {1, 2, 4} local area = { {T, T, T}, {T, T, T}, {T, T, T}, {0, T, 0}, {0, 3, 0}, } local spell = Spell:New(CONST_SPELL_DIRECTION) spell:SetArea(area) spell:Append(combat1, combat2, combat3) function onCastSpell(cid, var) return spell:Cast(cid) end Qualquer dúvida quanto ao uso da biblioteca no desenvolvimento de magias, basta postar neste tópico que estarei esclarecendo.
     
     
    Grande Abraço,
    Oneshot.
  21. Upvote
    Zaruss recebeu reputação de DavyziinC em Food   
    claro manim aki
    local FOODS = { [2362] = {8, "Crunch."}, [2666] = {15, "Munch."}, [2667] = {12, "Munch."}, [2668] = {10, "Mmmm."}, [2669] = {17, "Munch."}, [2670] = {4, "Gulp."}, [2671] = {30, "Chomp."}, [2672] = {60, "Chomp."}, [2673] = {5, "Yum."}, [2674] = {6, "Yum."}, [2675] = {13, "Yum."}, [2676] = {8, "Yum."}, [2677] = {1, "Yum."}, [2678] = {18, "Slurp."}, [2679] = {1, "Yum."}, [2680] = {2, "Yum."}, [2681] = {9, "Yum."}, [2682] = {20, "Yum."}, [2683] = {17, "Munch."}, [2684] = {8, "Crunch."}, [2685] = {6, "Munch."}, [2686] = {9, "Crunch."}, [2687] = {2, "Crunch."}, [2688] = {9, "Munch."}, [2689] = {10, "Crunch."}, [2690] = {3, "Crunch."}, [2691] = {8, "Crunch."}, [2792] = {6, "Munch."}, [2793] = {9, "Munch."}, [2695] = {6, "Gulp."}, [2696] = {9, "Smack."}, [2787] = {9, "Munch."}, [2788] = {4, "Munch."}, [2789] = {22, "Munch."}, [2790] = {30, "Munch."}, [2791] = {30, "Munch."}, [2792] = {6, "Munch."}, [2794] = {3, "Munch."}, [2795] = {36, "Munch."}, [2796] = {5, "Munch."}, [2793] = {9, "Munch."}, [5097] = {4, "Yum."}, [6125] = {8, "Gulp."}, [6278] = {10, "Mmmm."}, [6279] = {15, "Mmmm."}, [6393] = {12, "Mmmm."}, [6394] = {15, "Mmmm."}, [6501] = {20, "Mmmm."}, [6541] = {6, "Gulp."}, [6542] = {6, "Gulp."}, [6543] = {6, "Gulp."}, [6544] = {6, "Gulp."}, [6545] = {6, "Gulp."}, [6569] = {1, "Mmmm."}, [6574] = {4, "Mmmm."}, [7158] = {15, "Munch."}, [7159] = {13, "Munch."}, [7372] = {7, "Yum."}, [7373] = {7, "Yum."}, [7374] = {7, "Yum."}, [7375] = {7, "Yum."}, [7376] = {7, "Yum."}, [7377] = {7, "Yum."}, [7909] = {4, "Crunch."}, [8838] = {7, "Gulp."}, [8839] = {5, "Yum."}, [8840] = {2, "Yum."}, [8841] = {3, "Urgh."}, [8842] = {3, "Munch."}, [8843] = {3, "Crunch."}, [8844] = {3, "Gulp."}, [8845] = {2, "Munch."}, [8847] = {11, "Yum."} } function onUse(cid, item, fromPosition, itemEx, toPosition) local food = FOODS[item.itemid] if(not food) then return false end if((getPlayerFood(cid) + food[1]) >= 400) then doPlayerSendCancel(cid, "You are full.") return true end doPlayerFeed(cid, food[1] * 4) doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1) doRemoveItem(item.uid, 1) return true end edite aqui:
    [2667] = {12, "Munch."},
     
    assim:
    [iDDOITEM] = {CORDOTEXTO, "PALAVRAQUANDOCOME."},
     
    esse script ja tem no seu server e so ir em data/actions/scripts e procurar por food.lua (a maioria das vezes ta em other).
  22. Upvote
    Zaruss recebeu reputação de Roksas em Colocar dano   
    Duvida sanada.
    Reportado para moverem.
  23. Upvote
    Zaruss recebeu reputação de SkyDarkyes em [Resolvido] Dar items ao NPC   
    Entao a sua duvida foi sanada?
  24. Upvote
    Zaruss recebeu reputação de Roksas em [Resolvido] Colocar dano   
    local combat = createCombatObject() setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE) setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA) setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY) setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1) function onCastSpell(cid, var) local jogadorpos = getCreaturePosition(cid) local target = getCreatureTarget(cid) local position1 = {x=getThingPosition(getCreatureTarget(cid)).x+1, y=getThingPosition(getCreatureTarget(cid)).y+1, z=getThingPosition(getCreatureTarget(cid)).z} local monsterpos = getCreaturePosition(target) if target == isMonster or isCreature then doTeleportThing(cid,monsterpos) doSendMagicEffect(jogadorpos, 229) doSendMagicEffect(position1, 31) else doPlayerSendTextMessage(cid,20,'Precisa Selecionar um Alvo') end end
  25. Upvote
    Zaruss deu reputação a Oneshot em Fábrica de Scripts   
    local PETS = { ["Rat"] = {0, 250}, } function onUse(cid, item, fromPosition, itemEx, toPosition) if getTileInfo(getCreaturePosition(cid)).protection then return doPlayerSendCancel(cid, "Você não pode invocar dentro de zonas de proteção.") end if getCreatureStorage(cid, 11548) > os.time() then return doPlayerSendCancel(cid, "A energia espiritual não é suficiente. Aguarde ".. getCreatureStorage(cid, 11548) - os.time() .." segundos.") end local summons = getConfigValue("maxPlayerSummons") if #getCreatureSummons(cid) > summons then return doPlayerSendCancel(cid, "Você já invocou criaturas o bastante.") end local tmp = nil for _, uid in ipairs(getCreatureSummons(cid)) do if PETS[getCreatureName(uid)] then tmp = uid end end if tmp then return doPlayerSendCancel(cid, "Sua criatura já foi invocada.") end for name, level in pairs(PETS) do if getPlayerLevel(cid) > level[1] and getPlayerLevel(cid) <= level[2] then local monster = doCreateMonster(name, getCreaturePosition(cid)) if doConvinceCreature(cid, monster) then doCreatureSay(cid, "Go, " .. name .. "!", TALKTYPE_ORANGE_1) doCreatureSetStorage(cid, 11548, os.time() + 30) doSendMagicEffect(getCreaturePosition(monster), 2) end break end end return true end Alguém pediu algo sobre summon, sem a função do summon voltar, eu fiz um do zero, identado e funcional.
     
    Abraços.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...