diff --git a/data-canary/scripts/actions/worldboard.lua b/data-canary/scripts/actions/objects/world_board.lua similarity index 100% rename from data-canary/scripts/actions/worldboard.lua rename to data-canary/scripts/actions/objects/world_board.lua diff --git a/data-canary/scripts/bestiary/charms.lua b/data-canary/scripts/bestiary/charms.lua deleted file mode 100644 index b6263e05572..00000000000 --- a/data-canary/scripts/bestiary/charms.lua +++ /dev/null @@ -1,285 +0,0 @@ -local charms = { - -- Wound charm - [1] = { - name = "Wound", - description = "Triggers on a creature with a certain chance and deals 5% \z - of its initial hit points as physical damage once.", - type = CHARM_OFFENSIVE, - damageType = COMBAT_PHYSICALDAMAGE, - percent = 5, - chance = 10, - messageCancel = "You wounded the monster.", - messageServerLog = "[Wound charm]", - effect = CONST_ME_HITAREA, - points = 600, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_BRUTAL_STRIKE, - }, - }, - -- Enflame charm - [2] = { - name = "Enflame", - description = "Triggers on a creature with a certain chance and deals 5% \z - of its initial hit points as fire damage once.", - type = CHARM_OFFENSIVE, - damageType = COMBAT_FIREDAMAGE, - percent = 5, - chance = 10, - messageCancel = "You enflamed the monster.", - messageServerLog = "[Enflame charm]", - effect = CONST_ME_HITBYFIRE, - points = 1000, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_FLAME_STRIKE, - }, - }, - -- Poison charm - [3] = { - name = "Poison", - description = "Triggers on a creature with a certain chance and deals 5% \z - of its initial hit points as earth damage once.", - type = CHARM_OFFENSIVE, - damageType = COMBAT_EARTHDAMAGE, - percent = 5, - chance = 10, - messageCancel = "You poisoned the monster.", - messageServerLog = "[Poison charm]", - effect = CONST_ME_GREEN_RINGS, - points = 600, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_TERRA_STRIKE, - }, - }, - -- Freeze charm - [4] = { - name = "Freeze", - description = "Triggers on a creature with a certain chance and deals 5% \z - of its initial hit points as ice damage once.", - type = CHARM_OFFENSIVE, - damageType = COMBAT_ICEDAMAGE, - percent = 5, - chance = 10, - messageCancel = "You frozen the monster.", - messageServerLog = "[Freeze charm]", - effect = CONST_ME_ICEATTACK, - points = 800, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_ICE_STRIKE, - }, - }, - --Zap charm - [5] = { - name = "Zap", - description = "Triggers on a creature with a certain chance and deals 5% \z - of its initial hit points as energy damage once.", - type = CHARM_OFFENSIVE, - damageType = COMBAT_ENERGYDAMAGE, - percent = 5, - chance = 10, - messageCancel = "You eletrocuted the monster.", - messageServerLog = "[Zap charm]", - effect = CONST_ME_ENERGYHIT, - points = 800, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_ENERGY_STRIKE, - }, - }, - --Curse charm - [6] = { - name = "Curse", - description = "Triggers on a creature with a certain chance and deals 5% \z - of its initial hit points as death damage once.", - type = CHARM_OFFENSIVE, - damageType = COMBAT_DEATHDAMAGE, - percent = 5, - chance = 10, - messageCancel = "You curse the monster.", - messageServerLog = "[Curse charm]", - effect = CONST_ME_SMALLCLOUDS, - points = 900, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_DEATH_STRIKE, - }, - }, - -- Cripple charm - [7] = { - name = "Cripple", - description = "Cripples the creature with a certain chance and paralyzes it for 10 seconds.", - type = CHARM_OFFENSIVE, - chance = 10, - messageCancel = "You cripple the monster.", - points = 500, - }, - -- Parry charm - [8] = { - name = "Parry", - description = "Any damage taken is reflected to the aggressor with a certain chance.", - type = CHARM_DEFENSIVE, - damageType = COMBAT_PHYSICALDAMAGE, - chance = 10, - messageCancel = "You parry the attack.", - messageServerLog = "[Parry charm]", - effect = CONST_ME_EXPLOSIONAREA, - points = 1000, - }, - -- Dodge charm - [9] = { - name = "Dodge", - description = "Dodges an attack with a certain chance without taking any damage at all.", - type = CHARM_DEFENSIVE, - chance = 10, - messageCancel = "You dodge the attack.", - effect = CONST_ME_POFF, - points = 600, - }, - -- Adrenaline burst charm - [10] = { - name = "Adrenaline Burst", - description = "Bursts of adrenaline enhance your reflexes with a certain chance \z - after you get hit and let you move faster for 10 seconds.", - type = CHARM_DEFENSIVE, - chance = 10, - messageCancel = "Your movements where bursted.", - points = 500, - }, - -- Numb charm - [11] = { - name = "Numb", - description = "Numbs the creature with a certain chance after its attack and paralyzes the creature for 10 seconds.", - type = CHARM_DEFENSIVE, - chance = 10, - messageCancel = "You numb the monster.", - points = 500, - }, - -- Cleanse charm - [12] = { - name = "Cleanse", - description = "Cleanses you from within with a certain chance after you get hit and \z - removes one random active negative status effect and temporarily makes you immune against it.", - type = CHARM_DEFENSIVE, - chance = 10, - messageCancel = "You purified the attack.", - points = 700, - }, - -- Bless charm - [13] = { - name = "Bless", - description = "Blesses you and reduces skill and xp loss by 10% when killed by the chosen creature.", - type = CHARM_PASSIVE, - percent = 10, - chance = 100, - points = 800, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_BRUTAL_STRIKE, - }, - }, - -- Scavenge charm - [14] = { - name = "Scavenge", - description = "Enhances your chances to successfully skin/dust a skinnable/dustable creature.", - type = CHARM_PASSIVE, - percent = 25, - points = 800, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_BRUTAL_STRIKE, - }, - }, - -- Gut charm - [15] = { - name = "Gut", - description = "Gutting the creature yields 20% more creature products.", - type = CHARM_PASSIVE, - percent = 20, - chance = 100, - points = 800, - }, - -- Low blow charm - [16] = { - name = "Low Blow", - description = "Adds 8% critical hit chance to attacks with critical hit weapons.", - type = CHARM_PASSIVE, - percent = 8, - chance = 100, - points = 2000, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_BRUTAL_STRIKE, - }, - }, - -- Divine wrath charm - [17] = { - name = "Divine Wrath", - description = "Triggers on a creature with a certain chance and deals 5% \z - of its initial hit points as holy damage once.", - type = CHARM_OFFENSIVE, - damageType = COMBAT_HOLYDAMAGE, - percent = 5, - chance = 10, - messageCancel = "You divine the monster.", - messageServerLog = "[Divine charm]", - effect = CONST_ME_HOLYDAMAGE, - points = 1500, - sounds = { - castSound = SOUND_EFFECT_TYPE_SPELL_HOLY_FLASH, - }, - }, - -- Vampiric embrace charm - [18] = { - name = "Vampiric Embrace", - description = "Adds 4% Life Leech to attacks if wearing equipment that provides life leech.", - type = CHARM_PASSIVE, - percent = 4, - chance = 100, - points = 1500, - }, - -- Void's call charm - [19] = { - name = "Void's Call", - description = "Adds 2% Mana Leech to attacks if wearing equipment that provides mana leech.", - type = CHARM_PASSIVE, - percent = 2, - chance = 100, - points = 1500, - }, -} - -for charmId, chamsTable in ipairs(charms) do - local charm = Game.createBestiaryCharm(charmId - 1) - local charmConfig = {} - - if chamsTable.name then - charmConfig.name = chamsTable.name - end - if chamsTable.description then - charmConfig.description = chamsTable.description - end - if chamsTable.sounds then - charmConfig.sounds = chamsTable.sounds - end - if chamsTable.type then - charmConfig.type = chamsTable.type - end - if chamsTable.damageType then - charmConfig.damageType = chamsTable.damageType - end - if chamsTable.percent then - charmConfig.percent = chamsTable.percent - end - if chamsTable.chance then - charmConfig.chance = chamsTable.chance - end - if chamsTable.messageCancel then - charmConfig.messageCancel = chamsTable.messageCancel - end - if chamsTable.messageServerLog then - charmConfig.messageServerLog = chamsTable.messageServerLog - end - if chamsTable.effect then - charmConfig.effect = chamsTable.effect - end - if chamsTable.points then - charmConfig.points = chamsTable.points - end - - -- Create charm and egister charmConfig table - charm:register(charmConfig) -end diff --git a/data-canary/scripts/item_classification/item_tiers.lua b/data-canary/scripts/item_classification/item_tiers.lua deleted file mode 100644 index 2eb0d08bb23..00000000000 --- a/data-canary/scripts/item_classification/item_tiers.lua +++ /dev/null @@ -1,111 +0,0 @@ -local itemTierClassifications = { - -- Upgrade classification 1 - [1] = { - -- Update tier 0 - [1] = { - regular = 25000, - core = 1, - }, - }, - -- Upgrade classification 2 - [2] = { - -- Update tier 0 - [1] = { - regular = 750000, - core = 1, - }, - -- Update tier 1 - [2] = { - regular = 5000000, - core = 1, - }, - }, - -- Upgrade classification 3 - [3] = { - [1] = { - regular = 4000000, - core = 1, - }, - [2] = { - regular = 10000000, - core = 1, - }, - [3] = { - regular = 20000000, - core = 2, - }, - }, - -- Upgrade classification 4 - [4] = { - [1] = { - regular = 8000000, - core = 1, - convergence = { fusion = { price = 55000000 }, transfer = { price = 65000000 } }, - }, - [2] = { - regular = 20000000, - core = 2, - convergence = { fusion = { price = 110000000 }, transfer = { price = 165000000 } }, - }, - [3] = { - regular = 40000000, - core = 5, - convergence = { fusion = { price = 170000000 }, transfer = { price = 375000000 } }, - }, - [4] = { - regular = 65000000, - core = 10, - convergence = { fusion = { price = 300000000 }, transfer = { price = 800000000 } }, - }, - [5] = { - regular = 100000000, - core = 15, - convergence = { fusion = { price = 875000000 }, transfer = { price = 2000000000 } }, - }, - [6] = { - regular = 250000000, - core = 25, - convergence = { fusion = { price = 2350000000 }, transfer = { price = 5250000000 } }, - }, - [7] = { - regular = 750000000, - core = 35, - convergence = { fusion = { price = 6950000000 }, transfer = { price = 14500000000 } }, - }, - [8] = { - regular = 2500000000, - core = 50, - convergence = { fusion = { price = 21250000000 }, transfer = { price = 42500000000 } }, - }, - [9] = { - regular = 8000000000, - core = 60, - convergence = { fusion = { price = 50000000000 }, transfer = { price = 100000000000 } }, - }, - [10] = { - regular = 15000000000, - core = 85, - convergence = { fusion = { price = 125000000000 }, transfer = { price = 300000000000 } }, - }, - }, -} - --- Item tier with gold price for uprading it -for classificationId, classificationTable in ipairs(itemTierClassifications) do - local itemClassification = Game.createItemClassification(classificationId) - local classification = {} - - -- Registers table for register_item_tier.lua interface - classification.Upgrades = {} - for tierId, tierTable in ipairs(classificationTable) do - table.insert(classification.Upgrades, { - TierId = tierId, - Core = tierTable.core, - RegularPrice = tierTable.regular, - ConvergenceFustionPrice = tierTable.convergence and tierTable.convergence.fusion.price or 0, - ConvergenceTransferPrice = tierTable.convergence and tierTable.convergence.transfer.price or 0, - }) - end - -- Create item classification and register classification table - itemClassification:register(classification) -end diff --git a/data-canary/scripts/reward_chest/reward_chest.lua b/data-canary/scripts/reward_chest/reward_chest.lua deleted file mode 100644 index d7724ca0b32..00000000000 --- a/data-canary/scripts/reward_chest/reward_chest.lua +++ /dev/null @@ -1,8 +0,0 @@ -local chest = Action() - -function chest.onUse(player, item, fromPosition, target, toPosition, isHotkey) end - --- Create reward chest in the Montag temple -chest:position({ x = 5003, y = 4996, z = 7 }, 19250) - -chest:register() diff --git a/data-otservbr-global/scripts/creaturescripts/familiar/on_advance.lua b/data-otservbr-global/scripts/creaturescripts/familiar/on_advance.lua deleted file mode 100644 index 59ede1e0b12..00000000000 --- a/data-otservbr-global/scripts/creaturescripts/familiar/on_advance.lua +++ /dev/null @@ -1,16 +0,0 @@ -local familiarOnAdvance = CreatureEvent("FamiliarAdvance") - -function familiarOnAdvance.onAdvance(player, skill, oldLevel, newLevel) - local vocation = FAMILIAR_ID[player:getVocation():getBaseId()] - if vocation and newLevel >= 200 and isPremium(player) then - if player:getFamiliarLooktype() == 0 then - player:setFamiliarLooktype(vocation.id) - end - if not player:hasFamiliar(vocation.id) then - player:addFamiliar(vocation.id) - end - end - return true -end - -familiarOnAdvance:register() diff --git a/data-otservbr-global/scripts/creaturescripts/familiar/on_death.lua b/data-otservbr-global/scripts/creaturescripts/familiar/on_death.lua deleted file mode 100644 index 47d3ba81839..00000000000 --- a/data-otservbr-global/scripts/creaturescripts/familiar/on_death.lua +++ /dev/null @@ -1,21 +0,0 @@ -local familiarOnDeath = CreatureEvent("FamiliarDeath") - -function familiarOnDeath.onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified) - local player = creature:getMaster() - if not player then - return false - end - - local vocation = FAMILIAR_ID[player:getVocation():getBaseId()] - - if table.contains(vocation, creature:getName()) then - player:kv():set("familiar-summon-time", os.time()) - for sendMessage = 1, #FAMILIAR_TIMER do - stopEvent(player:getStorageValue(FAMILIAR_TIMER[sendMessage].storage)) - player:setStorageValue(FAMILIAR_TIMER[sendMessage].storage, -1) - end - end - return true -end - -familiarOnDeath:register() diff --git a/data-otservbr-global/scripts/creaturescripts/familiar/on_login.lua b/data-otservbr-global/scripts/creaturescripts/familiar/on_login.lua deleted file mode 100644 index e264040dbf9..00000000000 --- a/data-otservbr-global/scripts/creaturescripts/familiar/on_login.lua +++ /dev/null @@ -1,37 +0,0 @@ -local familiarOnLogin = CreatureEvent("FamiliarLogin") - -function familiarOnLogin.onLogin(player) - if not player then - return false - end - - local vocation = FAMILIAR_ID[player:getVocation():getBaseId()] - - local familiarName - local familiarSummonTime = player:kv():get("familiar-summon-time") or 0 - local familiarTimeLeft = familiarSummonTime - player:getLastLogout() - - if vocation then - if (not player:isPremium() and player:hasFamiliar(vocation.id)) or player:getLevel() < 200 then - player:removeFamiliar(vocation.id) - elseif player:isPremium() and player:getLevel() >= 200 then - if familiarTimeLeft > 0 then - familiarName = vocation.name - end - if player:getFamiliarLooktype() == 0 then - player:setFamiliarLooktype(vocation.id) - end - if not player:hasFamiliar(vocation.id) then - player:addFamiliar(vocation.id) - end - end - end - - if not familiarName then - return true - end - player:createFamiliar(familiarName, familiarTimeLeft) - return true -end - -familiarOnLogin:register() diff --git a/data-otservbr-global/scripts/exaltation_forge/exaltation_forge.lua b/data-otservbr-global/scripts/exaltation_forge/exaltation_forge.lua deleted file mode 100644 index fe3e1de952d..00000000000 --- a/data-otservbr-global/scripts/exaltation_forge/exaltation_forge.lua +++ /dev/null @@ -1,9 +0,0 @@ -local forge = Action() - -function forge.onUse(player, item, fromPosition, target, toPosition, isHotkey) - player:openForge() - return true -end - -forge:id(37122, 37128, 37129, 37131, 37132, 37133, 37153, 37157) -forge:register() diff --git a/data-otservbr-global/scripts/modal_window/#example.lua b/data-otservbr-global/scripts/modal_window/#example.lua deleted file mode 100644 index 7d252a1433e..00000000000 --- a/data-otservbr-global/scripts/modal_window/#example.lua +++ /dev/null @@ -1,32 +0,0 @@ -local config = { - { name = "Hunts", position = Position(1054, 1040, 7) }, - { name = "Trainer", position = Position(1116, 1094, 7) }, - { name = "Temple", position = Position(32369, 32241, 7) }, -} - -local modalTeleport = TalkAction("!teleport") - -function modalTeleport.onSay(player, words, param) - local menu = ModalWindow({ - title = "Teleport Modal", - message = "Locations", - }) - - for i, info in pairs(config) do - menu:addChoice(string.format("%s", info.name), function(player, button, choice) - if button.name ~= "Select" then - return - end - - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You were teleported to " .. info.name) - player:teleportTo(info.position) - end) - end - - menu:addButton("Select") - menu:addButton("Close") - menu:sendToPlayer(player) - return false -end - -modalTeleport:register() diff --git a/data-otservbr-global/scripts/hazard/primal.lua b/data-otservbr-global/scripts/systems/hazard_primal.lua similarity index 100% rename from data-otservbr-global/scripts/hazard/primal.lua rename to data-otservbr-global/scripts/systems/hazard_primal.lua diff --git a/data-canary/scripts/exaltation_forge/exaltation_forge.lua b/data/scripts/actions/objects/exaltation_forge.lua similarity index 100% rename from data-canary/scripts/exaltation_forge/exaltation_forge.lua rename to data/scripts/actions/objects/exaltation_forge.lua diff --git a/data-canary/scripts/creaturescripts/familiar/on_advance.lua b/data/scripts/creaturescripts/familiar/on_advance.lua similarity index 100% rename from data-canary/scripts/creaturescripts/familiar/on_advance.lua rename to data/scripts/creaturescripts/familiar/on_advance.lua diff --git a/data-canary/scripts/creaturescripts/familiar/on_death.lua b/data/scripts/creaturescripts/familiar/on_death.lua similarity index 100% rename from data-canary/scripts/creaturescripts/familiar/on_death.lua rename to data/scripts/creaturescripts/familiar/on_death.lua diff --git a/data-canary/scripts/creaturescripts/familiar/on_login.lua b/data/scripts/creaturescripts/familiar/on_login.lua similarity index 100% rename from data-canary/scripts/creaturescripts/familiar/on_login.lua rename to data/scripts/creaturescripts/familiar/on_login.lua diff --git a/data/scripts/reward_chest/boss_health_change.lua b/data/scripts/reward_chest/boss_health_change.lua deleted file mode 100644 index 037d6aa567a..00000000000 --- a/data/scripts/reward_chest/boss_health_change.lua +++ /dev/null @@ -1,44 +0,0 @@ -local bossParticipation = CreatureEvent("BossParticipation") - -function bossParticipation.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) - if not next(_G.GlobalBosses) then - return primaryDamage, primaryType, secondaryDamage, secondaryType - end - - if not creature or not attacker then - return primaryDamage, primaryType, secondaryDamage, secondaryType - end - - local stats = creature:inBossFight() - if not stats then - return primaryDamage, primaryType, secondaryDamage, secondaryType - end - - local creatureId, attackerId = creature:getId(), attacker:getId() - -- Update player id - stats.playerId = creatureId - - -- Account for healing of others active in the boss fight - if primaryType == COMBAT_HEALING and attacker:isPlayer() and attackerId ~= creatureId then - local healerStats = GetPlayerStats(stats.bossId, attacker:getGuid(), true) - healerStats.active = true - -- Update player id - healerStats.playerId = attackerId - healerStats.healing = healerStats.healing + primaryDamage - elseif stats.bossId == attackerId then - -- Account for damage taken from the boss - stats.damageIn = stats.damageIn + primaryDamage - end - return primaryDamage, primaryType, secondaryDamage, secondaryType -end - -bossParticipation:register() - -local loginBossPlayer = CreatureEvent("LoginBossPlayer") - -function loginBossPlayer.onLogin(player) - player:registerEvent("BossDeath") - return true -end - -loginBossPlayer:register() diff --git a/data/scripts/reward_chest/boss_think.lua b/data/scripts/reward_chest/boss_think.lua deleted file mode 100644 index 9029c88da41..00000000000 --- a/data/scripts/reward_chest/boss_think.lua +++ /dev/null @@ -1,11 +0,0 @@ -local bossThink = CreatureEvent("BossThink") - -function bossThink.onThink(creature, interval) - if not creature then - return true - end - - ResetAndSetTargetList(creature) -end - -bossThink:register() diff --git a/data-otservbr-global/scripts/bestiary/charms.lua b/data/scripts/systems/bestiary_charms.lua similarity index 100% rename from data-otservbr-global/scripts/bestiary/charms.lua rename to data/scripts/systems/bestiary_charms.lua diff --git a/data/scripts/discord_webhook/discord_webhook.lua b/data/scripts/systems/discord_webhook.lua similarity index 100% rename from data/scripts/discord_webhook/discord_webhook.lua rename to data/scripts/systems/discord_webhook.lua diff --git a/data-otservbr-global/scripts/item_classification/item_tiers.lua b/data/scripts/systems/item_tiers.lua similarity index 100% rename from data-otservbr-global/scripts/item_classification/item_tiers.lua rename to data/scripts/systems/item_tiers.lua diff --git a/data/scripts/reward_chest/boss_death.lua b/data/scripts/systems/reward_chest.lua similarity index 73% rename from data/scripts/reward_chest/boss_death.lua rename to data/scripts/systems/reward_chest.lua index 900d8538d01..2ee8e297b2a 100644 --- a/data/scripts/reward_chest/boss_death.lua +++ b/data/scripts/systems/reward_chest.lua @@ -131,3 +131,60 @@ function bossDeath.onDeath(creature, corpse, killer, mostDamageKiller, lastHitUn end bossDeath:register() + +local bossParticipation = CreatureEvent("BossParticipation") + +function bossParticipation.onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin) + if not next(_G.GlobalBosses) then + return primaryDamage, primaryType, secondaryDamage, secondaryType + end + + if not creature or not attacker then + return primaryDamage, primaryType, secondaryDamage, secondaryType + end + + local stats = creature:inBossFight() + if not stats then + return primaryDamage, primaryType, secondaryDamage, secondaryType + end + + local creatureId, attackerId = creature:getId(), attacker:getId() + -- Update player id + stats.playerId = creatureId + + -- Account for healing of others active in the boss fight + if primaryType == COMBAT_HEALING and attacker:isPlayer() and attackerId ~= creatureId then + local healerStats = GetPlayerStats(stats.bossId, attacker:getGuid(), true) + healerStats.active = true + -- Update player id + healerStats.playerId = attackerId + healerStats.healing = healerStats.healing + primaryDamage + elseif stats.bossId == attackerId then + -- Account for damage taken from the boss + stats.damageIn = stats.damageIn + primaryDamage + end + return primaryDamage, primaryType, secondaryDamage, secondaryType +end + +bossParticipation:register() + +local loginBossPlayer = CreatureEvent("LoginBossPlayer") + +function loginBossPlayer.onLogin(player) + player:registerEvent("BossDeath") + return true +end + +loginBossPlayer:register() + +local bossThink = CreatureEvent("BossThink") + +function bossThink.onThink(creature, interval) + if not creature then + return true + end + + ResetAndSetTargetList(creature) +end + +bossThink:register()