diff --git a/data-canary/scripts/actions/other/christmas_bundle.lua b/data-canary/scripts/actions/other/christmas_bundle.lua deleted file mode 100644 index 3c74fa30a4d..00000000000 --- a/data-canary/scripts/actions/other/christmas_bundle.lua +++ /dev/null @@ -1,72 +0,0 @@ -local setting = { -- [christmas bundle item id] = {{reward item id, count}, ...} - [6506] = { -- red bundle - { 6569, 15 }, -- candy - { 3585, 5 }, -- red apple - { 3586, 10 }, -- orange - { 3598, 20 }, -- cookie - { 3599, 10 }, -- candy cane - 6500, -- gingerbreadman - 6501, -- christmas wreath - 6489, -- christmas branch - 6503, -- red christmas garland - 6387, -- christmas card - }, - [6507] = { -- blue bundle - { 6569, 15 }, -- candy - { 3585, 5 }, -- red apple - { 3586, 10 }, -- orange - { 3598, 20 }, -- cookie - { 3599, 10 }, -- candy cane - 6500, -- gingerbreadman - 6501, -- christmas wreath - 6489, -- christmas branch - 6505, -- blue christmas garland - 6387, -- christmas card - }, - [6508] = { -- green bundle - { 6569, 15 }, -- candy - { 3585, 5 }, -- red apple - { 3586, 10 }, -- orange - { 3598, 20 }, -- cookie - { 3599, 10 }, -- candy cane - 6500, -- gingerbreadman - 6501, -- christmas wreath - 6489, -- christmas branch - 6502, -- christmas garland - 6387, -- christmas card - }, -} - -local christmasBundle = Action() - -function christmasBundle.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local targetItem = setting[item.itemid] - if not targetItem then - return true - end - - local rewards = {} - while #rewards < 7 do - local count = 1 - local rand = math.random(#targetItem) - local gift = targetItem[rand] - if type(gift) == "table" then - gift, count = unpack(gift) - end - rewards[#rewards + 1] = { gift, count } - table.remove(targetItem, rand) - end - - for i = 1, #rewards do - player:addItem(unpack(rewards[i])) - end - item:remove(1) - player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS) - return true -end - -for index, value in pairs(setting) do - christmasBundle:id(index) -end - -christmasBundle:register() diff --git a/data-canary/scripts/actions/other/ferumbras_amulet.lua b/data-canary/scripts/actions/other/ferumbras_amulet.lua deleted file mode 100644 index 01f1ca7a502..00000000000 --- a/data-canary/scripts/actions/other/ferumbras_amulet.lua +++ /dev/null @@ -1,17 +0,0 @@ -local ferumbrasAmulet = Action() - -function ferumbrasAmulet.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if math.random(2) == 1 then - player:addMana(1000) - else - player:addHealth(1000) - end - item:transform(22768) - item:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - item:decay() - player:say("Magical sparks whirl around the amulet and you suddenly feel refreshed.", TALKTYPE_MONSTER_SAY) - return true -end - -ferumbrasAmulet:id(22767) -ferumbrasAmulet:register() diff --git a/data-canary/scripts/actions/other/ferumbras_mana_keg.lua b/data-canary/scripts/actions/other/ferumbras_mana_keg.lua deleted file mode 100644 index c1400379d6d..00000000000 --- a/data-canary/scripts/actions/other/ferumbras_mana_keg.lua +++ /dev/null @@ -1,13 +0,0 @@ -local ferumbrasManaKeg = Action() - -function ferumbrasManaKeg.onUse(player, item, fromPosition, target, toPosition, isHotkey) - player:addItem(238, 10) - item:transform(22770) - item:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - item:decay() - player:say("Magical sparks whirl around the keg as you open the spigot and you fill ten empty vials with mana fluid.", TALKTYPE_MONSTER_SAY) - return true -end - -ferumbrasManaKeg:id(22769) -ferumbrasManaKeg:register() diff --git a/data-canary/scripts/actions/other/ferumbras_staff.lua b/data-canary/scripts/actions/other/ferumbras_staff.lua deleted file mode 100644 index f2f897f2c3f..00000000000 --- a/data-canary/scripts/actions/other/ferumbras_staff.lua +++ /dev/null @@ -1,16 +0,0 @@ -local ferumbrasStaff = Action() - -function ferumbrasStaff.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if math.random(100) > 20 then - item:transform(22767) - else - item:transform(22766) - end - item:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED) - item:decay() - player:say("Magical sparks whirl around the staff and suddenly it changes its appearance.", TALKTYPE_MONSTER_SAY) - return ActionsLib.destroyItem(player, target, toPosition) -end - -ferumbrasStaff:id(22764) -ferumbrasStaff:register() diff --git a/data-canary/scripts/actions/other/music.lua b/data-canary/scripts/actions/other/music.lua index eb44c56aeed..589723a1f89 100644 --- a/data-canary/scripts/actions/other/music.lua +++ b/data-canary/scripts/actions/other/music.lua @@ -27,8 +27,6 @@ local setting = { [2966] = { effect = CONST_ME_SOUND_RED }, -- war drum [3103] = { effect = CONST_ME_SOUND_YELLOW, itemId = 3592, itemCount = 10, chance = 80, remove = true }, -- cornucopia [5786] = { effects = { failure = CONST_ME_SOUND_RED, success = CONST_ME_SOUND_YELLOW }, monster = "war wolf", chance = 60, remove = true }, -- wooden whistle - [6572] = { effect = CONST_ME_SOUND_GREEN, text = "TOOOOOOT", transformId = 6573, decayId = 6572 }, -- party trumpet - [6573] = { effect = CONST_ME_SOUND_GREEN, text = "TOOOOOOT", transformId = 6572, decayId = 6573 }, -- party trumpet [12602] = { effect = CONST_ME_SOUND_BLUE }, -- small whistle (actual effect is unknown) [23725] = { effect = CONST_ME_SOUND_WHITE }, -- small crystal bell } diff --git a/data-canary/scripts/actions/other/surprise_bag.lua b/data-canary/scripts/actions/other/surprise_bag.lua deleted file mode 100644 index be59af96267..00000000000 --- a/data-canary/scripts/actions/other/surprise_bag.lua +++ /dev/null @@ -1,62 +0,0 @@ -local setting = { - -- Blue present - [6570] = { - { 3598, 10 }, - { 6393, 3 }, - 2995, - 6569, - 6572, - 6574, - 6575, - 6576, - 6577, - 6578, - 6279, - }, - -- Red present - [6571] = { - { 3035, 10 }, - { 3035, 10 }, - { 3035, 10 }, - { 2995, 3 }, - { 6392, 2 }, - { 6574, 2 }, - { 6576, 2 }, - { 6578, 2 }, - 2993, - 3036, - 3079, - 3386, - 3420, - 5944, - 6566, - 6568, - }, -} - -local surpriseBag = Action() - -function surpriseBag.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local count = 1 - local targetItem = setting[item.itemid] - if not targetItem then - return true - end - - local gift = targetItem[math.random(#targetItem)] - if type(gift) == "table" then - gift = gift[1] - count = gift[2] - end - - player:addItem(gift, count) - item:remove(1) - fromPosition:sendMagicEffect(CONST_ME_GIFT_WRAPS) - return true -end - -for index, value in pairs(setting) do - surpriseBag:id(index) -end - -surpriseBag:register() diff --git a/data-canary/scripts/creaturescripts/#modal_window_example.lua b/data-canary/scripts/creaturescripts/#modal_window_example.lua deleted file mode 100644 index e2de4a9e474..00000000000 --- a/data-canary/scripts/creaturescripts/#modal_window_example.lua +++ /dev/null @@ -1,63 +0,0 @@ ---[[ - ModalWindowHelper Example -]] --- - -local moveDirectionTest = { - ["Right"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_EAST) - player:teleportTo(pos, true) - end, - ["Left"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_WEST) - player:teleportTo(pos, true) - end, - ["Up"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_NORTH) - player:teleportTo(pos, true) - end, - ["Down"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_SOUTH) - player:teleportTo(pos, true) - end, -} - -local talkAction = TalkAction("!modalTest") - -function talkAction.onSay(player, words, param, type) - local modalWindow = ModalWindow({ - title = "Modal Window Helper Example", - message = "This is an example of ModalWindowHelper.", - }) - if param == "choices" then - for text, callback in pairs(moveDirectionTest) do - modalWindow:addChoice(text, function(player, button, choice) - if button.name == "Select" then - callback(player) - modalWindow:sendToPlayer(player) - end - end) - end - - modalWindow:addButton("Select") - modalWindow:addButton("Cancel") - elseif param == "buttons" then - for direction, callback in pairs(moveDirectionTest) do - modalWindow:addButton(direction, function(player, button, choice) - callback(player) - modalWindow:sendToPlayer(player) - end) - end - end - modalWindow:sendToPlayer(player) - return false -end - ---talkAction:accountType(ACCOUNT_TYPE_GOD) ---talkAction:access(true) -talkAction:separator(" ") -talkAction:register() diff --git a/data-canary/scripts/creaturescripts/monster.lua b/data-canary/scripts/creaturescripts/monster.lua deleted file mode 100644 index abbdae1aea4..00000000000 --- a/data-canary/scripts/creaturescripts/monster.lua +++ /dev/null @@ -1,24 +0,0 @@ -local monsterDeath = CreatureEvent("monsterDeath") -function monsterDeath.onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified) - if creature:isMonster() then - local self = creature:getStorageValue(MonsterStorage.Spawn.monster_spawn_object) - self:executeFunctionMonster("onDeath", creature) - self:deleteMonster(creature) - return true - end - return true -end - -local monsterDeathBoss = CreatureEvent("monsterDeathBoss") -function monsterDeathBoss.onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified) - if creature:isMonster() then - local self = creature:getStorageValue(MonsterStorage.Spawn.monster_spawn_object) - self:removeSpawn() - self:removeMonsters() - return true - end - return true -end - -monsterDeathBoss:register() -monsterDeath:register() diff --git a/data-otservbr-global/lib/others/fragment_gems.lua b/data-otservbr-global/lib/others/fragment_gems.lua deleted file mode 100644 index cb82b9e951e..00000000000 --- a/data-otservbr-global/lib/others/fragment_gems.lua +++ /dev/null @@ -1,16 +0,0 @@ -MAX_GEM_BREAK = 10 - -FRAGMENT_GEMS = { - small = { ids = { 44602, 44605, 44608, 44611 }, fragment = 46625, range = { 1, 4 } }, - medium = { ids = { 44603, 44606, 44609, 44612 }, fragment = 46625, range = { 2, 8 } }, - great = { ids = { 44604, 44607, 44610, 44613 }, fragment = 46626, range = { 1, 4 } }, -} - -function getGemData(id) - for _, gem in pairs(FRAGMENT_GEMS) do - if table.contains(gem.ids, id) then - return gem.fragment, gem.range - end - end - return nil -end diff --git a/data-otservbr-global/lib/others/load.lua b/data-otservbr-global/lib/others/load.lua index 3d7da57cc77..031c8fb2026 100644 --- a/data-otservbr-global/lib/others/load.lua +++ b/data-otservbr-global/lib/others/load.lua @@ -1,2 +1 @@ dofile(DATA_DIRECTORY .. "/lib/others/dawnport.lua") -dofile(DATA_DIRECTORY .. "/lib/others/fragment_gems.lua") diff --git a/data-otservbr-global/scripts/actions/other/bed_modification_kits.lua b/data-otservbr-global/scripts/actions/other/bed_modification_kits.lua deleted file mode 100644 index 4dd68ff834d..00000000000 --- a/data-otservbr-global/scripts/actions/other/bed_modification_kits.lua +++ /dev/null @@ -1,54 +0,0 @@ -local beds = { - [831] = { { 734, 735 }, { 736, 737 } }, -- green kit - [832] = { { 742, 743 }, { 744, 745 } }, -- yellow kit - [833] = { { 738, 739 }, { 740, 741 } }, -- red kit - [834] = { { 2487, 2488 }, { 2493, 2494 } }, -- removal kit - [17972] = { { 17917, 17918 }, { 17919, 17920 } }, -- canopy kit -} - -local function internalBedTransform(item, target, toPosition, itemArray) - target:transform(itemArray[1]) - target:getPosition():sendMagicEffect(CONST_ME_POFF) - - toPosition:getTile():getItemByType(ITEM_TYPE_BED):transform(itemArray[2]) - toPosition:sendMagicEffect(CONST_ME_POFF) - - item:remove() -end - -local bedModificationKits = Action() - -function bedModificationKits.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local newBed = beds[item.itemid] - if not newBed then - return false - end - - local tile = toPosition:getTile() - if not tile or not tile:getHouse() then - return false - end - - if target.itemid == newBed[1][1] or target.itemid == newBed[2][1] then - player:sendTextMessage(MESSAGE_FAILURE, "You already have this bed modification.") - return true - end - - for kit, bed in pairs(beds) do - if bed[1][1] == target.itemid or table.contains({ 2491, 5501, 15506 }, target.itemid) then - toPosition:sendMagicEffect(CONST_ME_POFF) - toPosition.y = toPosition.y + 1 - internalBedTransform(item, target, toPosition, newBed[1]) - break - elseif bed[2][1] == target.itemid or table.contains({ 2489, 5499, 15508 }, target.itemid) then - toPosition:sendMagicEffect(CONST_ME_POFF) - toPosition.x = toPosition.x + 1 - internalBedTransform(item, target, toPosition, newBed[2]) - break - end - end - return true -end - -bedModificationKits:id(831, 832, 833, 834, 17972) -bedModificationKits:register() diff --git a/data-otservbr-global/scripts/actions/other/dolls.lua b/data-otservbr-global/scripts/actions/other/dolls.lua deleted file mode 100644 index 32864dcd109..00000000000 --- a/data-otservbr-global/scripts/actions/other/dolls.lua +++ /dev/null @@ -1,106 +0,0 @@ -local dolls = { - [5080] = { "Hug me." }, - [5668] = { - "It's not winning that matters, but winning in style.", - "Today's your lucky day. Probably.", - "Do not meddle in the affairs of dragons, for you are crunchy and taste good with ketchup.", - "That is one stupid question.", - "You'll need more rum for that.", - "Do or do not. There is no try.", - "You should do something you always wanted to.", - "If you walk under a ladder and it falls down on you it probably means bad luck.", - "Never say 'oops'. Always say 'Ah, interesting!'", - "Five steps east, fourteen steps south, two steps north and seventeen steps west!", - }, - [6566] = { - "Fchhhhhh!", - "Zchhhhhh!", - "Grooaaaaar*cough*", - "Aaa... CHOO!", - "You... will.... burn!!", - }, - [6387] = { "Merry Christmas |PLAYERNAME|." }, - [6511] = { - "Ho ho ho", - "Jingle bells, jingle bells...", - "Have you been naughty?", - "Have you been nice?", - "Merry Christmas!", - "Can you stop squeezing me now... I'm starting to feel a little sick.", - }, - [8146] = { "ARE YOU PREPARED TO FACE YOUR DESTINY?" }, - [8149] = { - "Weirdo, you're a weirdo! Actually all of you are!", - "Pie for breakfast, pie for lunch and pie for dinner!", - "All hail the control panel!", - "I own, Tibiacity owns, perfect match!", - "Hug me! Feed me! Hail me!", - }, - [8153] = { - "It's news to me.", - "News, updated as infrequently as possible!", - "Extra! Extra! Read all about it!", - "Fresh off the press!", - }, - [8154] = { - "Hail TibiaNordic!", - "So cold..", - "Run, mammoth!", - }, - [21435] = { - "I can hear their whisperings... Revenge!", - "You shall feel pain and terror, |PLAYERNAME|", - "I do not need a sword to slaughter you", - "My sword is broken, but my spirit is not dead", - "I can say 469 and more...", - "My dark magic lies on tibialatina.wikia.com", - }, - [21962] = { "Hail Tibia Brasileiros! (União&Força)" }, - [32918] = { - "COME HERE! FREE ITEMS FOR EVERYONE!", - "DON'T BE AFRAID! I AM COMING IN PEACE!", - "BOW TO THE POWER OF THE RUTHLESS SEVEN!", - "Slay your friends and I will spare you!", - }, -} - -local doll = Action() - -function doll.onUse(player, item, fromPosition, target, toPosition, isHotkey) - local sounds = dolls[item.itemid] - if not sounds then - return false - end - - if fromPosition.x == CONTAINER_POSITION then - fromPosition = player:getPosition() - end - - local random = math.random(#sounds) - local sound = sounds[random] - if item.itemid == 6566 then - if random == 3 then - fromPosition:sendMagicEffect(CONST_ME_POFF) - elseif random == 4 then - fromPosition:sendMagicEffect(CONST_ME_FIREAREA) - elseif random == 5 then - doTargetCombatHealth(0, player, COMBAT_PHYSICALDAMAGE, -1, -1, CONST_ME_EXPLOSIONHIT) - end - elseif item.itemid == 5668 then - fromPosition:sendMagicEffect(CONST_ME_MAGIC_RED) - item:transform(item.itemid + 1) - item:decay() - elseif item.itemid == 6387 then - fromPosition:sendMagicEffect(CONST_ME_SOUND_YELLOW) - end - - sound = sound:gsub("|PLAYERNAME|", player:getName()) - player:say(sound, TALKTYPE_MONSTER_SAY, false, 0, fromPosition) - return true -end - -for index, value in pairs(dolls) do - doll:id(index) -end - -doll:register() diff --git a/data-otservbr-global/scripts/actions/other/surprise_bag.lua b/data-otservbr-global/scripts/actions/other/surprise_bag.lua deleted file mode 100644 index 052fc987c61..00000000000 --- a/data-otservbr-global/scripts/actions/other/surprise_bag.lua +++ /dev/null @@ -1,103 +0,0 @@ -local config = { - [6570] = { -- bluePresent - { 3598, 10 }, - { 6393, 3 }, - 6279, - 6574, - 6578, - 6575, - 6577, - 6569, - 6576, - 6572, - 2995, - 14027, - 14681, - }, - [6571] = { -- redPresent - 6574, - 3079, - 6393, - 6576, - 6578, - 2995, - 14027, - 3036, - 5944, - 3386, - 3420, - 3039, - 5080, - 2993, - 3392, - 3057, - 5791, - }, - [8853] = { -- surpriseBag - { 3031, 10 }, - 123, - 2995, - 2397, - 651, - 3218, - 6574, - 6393, - 7377, - 3578, - 8778, - }, - [14751] = { -- surpriseBag - { 9642, 15 }, - { 3581, 15 }, - 5917, - 3273, - 10302, - 9019, - 5928, - 5926, - 5927, - 6095, - 5918, - 6097, - 6098, - 5461, - 5090, - }, - [14759] = { -- surpriseBag - { 6569, 10 }, - { 6541, 10 }, - { 6542, 10 }, - { 6543, 10 }, - { 6544, 10 }, - { 6545, 10 }, - 6574, - 4839, - 6570, - 6571, - 3215, - }, -} - -local surpriseBag = Action() - -function surpriseBag.onUse(cid, item, fromPosition, itemEx, toPosition) - local present = config[item.itemid] - if not present then - return false - end - - local count = 1 - local gift = present[math.random(1, #present)] - if type(gift) == "table" then - count = math.random(1, gift[2]) - gift = gift[1] - end - - Player(cid):addItem(gift, count) - Item(item.uid):remove(1) - fromPosition:sendMagicEffect(CONST_ME_GIFT_WRAPS) - return true -end - -surpriseBag:id(6570, 6571, 8853, 14751, 14759) -surpriseBag:register() diff --git a/data-otservbr-global/scripts/actions/other/surprise_box.lua b/data-otservbr-global/scripts/actions/other/surprise_box.lua deleted file mode 100644 index 94fdb95eb2d..00000000000 --- a/data-otservbr-global/scripts/actions/other/surprise_box.lua +++ /dev/null @@ -1,31 +0,0 @@ -local prize = { - [1] = { chance = 1, id = 3246, amount = 1 }, - [2] = { chance = 2, id = 10227, amount = 1 }, - [3] = { chance = 3, id = 11588, amount = 1 }, - [4] = { chance = 4, id = 3549, amount = 1 }, - [5] = { chance = 5, id = 3420, amount = 1 }, - [6] = { chance = 10, id = ITEM_CRYSTAL_COIN, amount = 17 }, - [7] = { chance = 20, id = ITEM_GOLD_COIN, amount = 1 }, - [8] = { chance = 30, id = ITEM_CRYSTAL_COIN, amount = 1 }, - [9] = { chance = 40, id = ITEM_GOLD_COIN, amount = 50 }, - [10] = { chance = 50, id = ITEM_PLATINUM_COIN, amount = 15 }, - [11] = { chance = 90, id = ITEM_GOLD_COIN, amount = 80 }, -} - -local surpriseBox = Action() - -function surpriseBox.onUse(player, item, fromPosition, target, toPosition, isHotkey) - for i = 1, #prize do - local number = math.random() * 100 - if prize[i].chance > 100 - number then - player:getPosition():sendMagicEffect(CONST_ME_POFF) - player:addItem(prize[i].id, prize[i].amount) - item:remove() - break - end - end - return true -end - -surpriseBox:id(12045) -surpriseBox:register() diff --git a/data-otservbr-global/scripts/actions/other/transform_to.lua b/data-otservbr-global/scripts/actions/other/transform_to.lua deleted file mode 100644 index 5257544eb60..00000000000 --- a/data-otservbr-global/scripts/actions/other/transform_to.lua +++ /dev/null @@ -1,484 +0,0 @@ -local voices = { - [23708] = "Au au!", - [23443] = "Grooaarr!", -} - -local transformItems = { - [2062] = 2063, - [2063] = 2062, -- sacred statue - [2064] = 2065, - [2065] = 2064, -- sacred statue - [2108] = 2109, - [2109] = 2108, -- street lamp - [2334] = 2335, - [2335] = 2334, -- table - [2336] = 2337, - [2337] = 2336, -- table - [2338] = 2339, - [2339] = 2338, -- table - [2340] = 2341, - [2341] = 2340, -- table - [2535] = 2536, - [2536] = 2535, -- oven - [2537] = 2538, - [2538] = 2537, -- oven - [2539] = 2540, - [2540] = 2539, -- oven - [2541] = 2542, - [2542] = 2541, -- oven - [2660] = 2661, - [2661] = 2660, -- cuckoo clock - [2662] = 2663, - [2663] = 2662, -- cuckoo clock - [2772] = 2773, - [2773] = 2772, -- lever - [2911] = 2912, - [2912] = 2911, -- candelabrum - [2914] = 2915, - [2915] = 2914, -- lamp - [2917] = 2918, - [2918] = 2917, -- candlestick - [2920] = 2921, - [2921] = 2920, -- torch - [2922] = 2923, - [2923] = 2922, -- torch - [2924] = 2925, - [2925] = 2924, -- torch - [2928] = 2929, - [2929] = 2928, -- torch bearer - [2930] = 2931, - [2931] = 2930, -- torch bearer - [2934] = 2935, - [2935] = 2934, -- table lamp - [2977] = 2978, - [2978] = 2977, -- pumpkinhead - [3046] = 3047, - [3047] = 3046, -- magic light wand - [3481] = 3482, -- closed trap - [5812] = 5813, - [5813] = 5812, -- skull candle - [6488] = 6489, - [6489] = 6488, -- christmas branch - [7058] = 7059, - [7059] = 7058, -- skull pillar - [7856] = 7857, - [7857] = 7856, -- chimney - [7858] = 7859, - [7859] = 7858, -- chimney - [7860] = 7861, - [7861] = 7860, -- chimney - [7862] = 7863, - [7863] = 7862, -- chimney - [8659] = 8660, - [8660] = 8659, -- street lamp - [8661] = 8662, - [8662] = 8661, -- street lamp - [8663] = 8664, - [8664] = 8663, -- street lamp - [8665] = 8666, - [8666] = 8665, -- street lamp - [8832] = 8833, - [8833] = 8832, -- wall lamp - [8834] = 8835, - [8835] = 8834, -- wall lamp - [17411] = 17412, - [17412] = 17411, -- street lamp - [20280] = 20281, - [20281] = 20280, -- beacon - [20498] = 20497, - [20497] = 20498, -- street lamp - [20500] = 20499, - [20499] = 20500, -- street lamp - [20501] = 20502, - [20502] = 20501, -- candle - [20503] = 20504, - [20504] = 20503, -- candle - [22153] = 22154, - [22154] = 22153, -- skull - [22764] = 22765, - [22765] = 22764, -- ferumbras staff - [23434] = 23436, - [23436] = 23434, -- predador lamp - [23435] = 23437, - [23437] = 23435, -- predador lamp - [23438] = 23440, - [23440] = 23438, -- protectress lamp - [23439] = 23441, - [23441] = 23439, -- protectress lamp - [23442] = 23443, - [23443] = 23442, -- baby dragon - [23444] = 23445, - [23445] = 23444, -- hamster wheel - [23451] = 23452, - [23452] = 23451, -- cat in a basket - [23485] = 23486, - [23486] = 23485, -- barrel - [23708] = 23709, - [23709] = 23708, -- dog house - [24432] = 24433, - [24433] = 24432, -- parrot - [24434] = 24436, - [24435] = 24434, -- skull lamp - [25212] = 25210, - [25211] = 25212, -- vengothic lamp - [26078] = 26079, -- spider terrarium - [26081] = 26083, - [26083] = 26081, -- hrodmiran weapons rack - [26084] = 26082, - [26082] = 26084, -- hrodmiran weapons rack side - [26171] = 26169, - [26172] = 26170, -- snake terrarium - [26173] = 26175, - [26174] = 26176, -- demon pet - [27667] = 27668, -- light of change empty to red - [27668] = 27669, -- light of change red to green - [27669] = 27670, -- light of change green to blue - [27670] = 27667, -- light of change blue to empty - [27671] = 27673, -- torch of change empty to red - [27673] = 27674, -- torch of change red to green - [27674] = 27675, -- torch of change green to blue - [27675] = 27671, -- torch of change blue to empty - [27683] = 27685, - [27684] = 27686, -- alchemistic scales - [27687] = 27688, - [27688] = 27687, -- pile of alchemistic books - [27691] = 27692, - [27692] = 27691, -- ferumbras bust - [27693] = 27694, - [27694] = 27693, -- ferumbras bust - [27986] = 27988, - [27988] = 27986, -- bonelord statue - [27987] = 27989, - [27989] = 27987, -- bonelord statue - [27996] = 27998, - [27998] = 27996, -- scholar bust - [27997] = 27999, - [27999] = 27997, -- scholar bust - [28000] = 28002, - [28002] = 28000, -- scholar bust - [28001] = 28003, - [28003] = 28001, -- scholar bust - [28674] = 28675, - [28675] = 28674, -- anglerfish lamp - [28690] = 28691, - [28692] = 28693, -- baby rotworm - [28694] = 28695, --fennec - [28915] = 28916, - [28917] = 28918, -- adamant shield - [28920] = 28921, - [28921] = 28920, -- fluorescent fungi - [28922] = 28923, - [28923] = 28922, -- luminescent fungi - [28924] = 28925, - [28925] = 28924, -- glowing sulphur fungi - [28926] = 28927, - [28927] = 28926, -- gloomy poisonous fungi - [30229] = 30230, - [30230] = 30231, -- festive table - [30231] = 30229, -- festive table - [30233] = 30234, - [30234] = 30233, -- festive fireplace - [30235] = 30236, - [30236] = 30235, -- festive fireplace - [30237] = 30238, - [30238] = 30237, -- festive tree - [30248] = 30249, - [30249] = 30248, -- festive pyramid - [30362] = 30365, -- Badbara - [30363] = 30366, -- Tearesa - [30364] = 30367, -- Cryana - [31196] = 31197, - [31197] = 31196, -- crystal lamp - [31213] = 31215, - [31215] = 31213, -- idol lamp - [31214] = 31216, - [31216] = 31214, -- idol lamp side - [31462] = 31463, - [31464] = 31465, -- jousting eagle baby - [31674] = 31675, -- omniscient owl - [31681] = 31682, -- hedgehog - [31683] = 31684, - [31684] = 31683, -- exalted sarcophagus - [31695] = 31696, - [31696] = 31695, -- curly hortensis lamp - [31697] = 31698, - [31698] = 31697, -- little big flower lamp - [31703] = 31704, -- baby unicorn - [32760] = 32758, - [32761] = 32759, -- mini NaBbot - [32784] = 32785, - [32785] = 32784, -- ice chandelier - [32788] = 32789, -- baby seal - [32790] = 32791, - [32792] = 32793, -- baby polar bear - [32897] = 32899, - [32899] = 32897, -- wall lamp - [32900] = 32901, - [32901] = 32900, -- torch bearer - [32902] = 32903, - [32903] = 32902, -- bamboo wall lamp - [32904] = 32905, - [32905] = 32904, -- wall candle - [32907] = 32910, -- guzzlemaw grub - [32908] = 32911, -- baby vulcongra - [32909] = 32912, -- baby brain squid - [33026] = 33047, - [33027] = 33026, -- heart lamp - [33028] = 33048, - [33029] = 33028, -- heart lamp (flower) - [33030] = 33049, - [33031] = 33030, -- heart lamp (small flower) - [33040] = 33042, -- bat - [33331] = 33332, - [33333] = 33334, -- bard doll - [34026] = 34027, -- baby bonelord - [34030] = 34031, - [34031] = 34030, -- artist shelf - [34032] = 34033, - [34033] = 34032, -- artist shelf - [34034] = 34035, - [34035] = 34034, -- artist table - [34044] = 34045, - [34045] = 34044, -- sculptor shelf - [34046] = 34047, - [34047] = 34046, -- sculptor shelf - [34048] = 34049, - [34049] = 34048, -- sculptor table - [34064] = 34065, - [34065] = 34066, -- sculpture of a noblewoman - [34066] = 34067, - [34067] = 34064, -- sculpture of a noblewoman - [34068] = 34069, - [34069] = 34070, -- sculpture of a noblewoman - [34070] = 34071, - [34071] = 34068, -- sculpture of a noblewoman - [34264] = 34265, - [34266] = 34267, -- Tibiapedia - [34268] = 34269, - [34269] = 34268, -- Baby Munster - [34270] = 34271, - [34271] = 34270, -- glowworms - [34272] = 34273, - [34273] = 34272, -- oven - [34274] = 34275, - [34275] = 34274, -- oven - [34284] = 34285, - [34285] = 34284, -- kitchen table (empty) - [34287] = 34288, - [34288] = 34287, -- kitchen table (empty) - [34286] = 34290, - [34290] = 34286, -- kitchen table - [34289] = 34291, - [34291] = 34289, -- kitchen table - [34300] = 34301, - [34301] = 34300, -- barrel - [34304] = 34305, - [34305] = 34304, -- kitchen lamp - [34326] = 34327, -- wicked witch - [35153] = 35154, -- baby elephant - [35155] = 35157, - [35157] = 35159, -- forge - [35159] = 35155, - [35156] = 35158, -- forge - [35158] = 35160, - [35160] = 35156, -- forge - [35161] = 35162, - [35162] = 35161, -- metal wall lamp - [35163] = 35165, - [35165] = 35163, -- workbench - [35164] = 35166, - [35166] = 35164, -- workbench - [35177] = 35180, - [35180] = 35177, -- grinding wheel - [35178] = 35179, - [35179] = 35178, -- grinding wheel - [35181] = 35183, - [35183] = 35181, -- pair of bellows - [35182] = 35184, - [35184] = 35182, -- pair of bellows - [35185] = 35186, - [35186] = 35185, -- anvil - [35187] = 35188, - [35188] = 35187, -- water bucket - [35909] = 35910, -- chaos critical dice - [36019] = 36020, -- white lion doll - [36478] = 36479, - [36480] = 36481, -- banor doll - [36618] = 36619, - [36619] = 36618, -- volcanic basin - [36620] = 36621, - [36621] = 36620, -- volcanic sphere - [36622] = 36623, - [36623] = 36622, -- volcanic spire - [36624] = 36625, - [36625] = 36624, -- volcanic bulb - [36626] = 36628, - [36628] = 36626, -- volcanic mirror - [36627] = 36629, - [36629] = 36627, -- volcanic mirror - [36638] = 36639, - [36639] = 36638, -- volcanic table - [36640] = 36642, - [36642] = 36644, -- volcanic shelf - [36644] = 36640, - [36641] = 36643, -- volcanic shelf - [36643] = 36645, - [36645] = 36641, -- volcanic shelf - [36646] = 36649, - [36647] = 36650, -- demon baller - [36648] = 36651, - [36653] = 36652, -- demon baller - [36654] = 36646, -- demon baller - [36750] = 36751, - [36754] = 36752, -- falcon pet - [36756] = 36753, -- falcon pet - [36959] = 36960, -- megasylvan plant - [36978] = 36979, - [36979] = 36978, -- magic hat - [36996] = 36997, - [36998] = 36999, -- Luna - [37015] = 37016, - [37016] = 37015, -- yellow shroom lamp - [37017] = 37018, - [37018] = 37017, -- pink shroom lamp - [37021] = 37022, -- dragon plant - [37052] = 37053, - [37053] = 37052, -- bonelord tome - [37054] = 37055, - [37056] = 37057, -- Bella Bonecrusher's doll - [37061] = 37062, - [37063] = 37064, -- Evora - [37111] = 37112, - [37113] = 37114, -- armillary sphere - [37185] = 37186, - [37186] = 37700, -- kraken watcher lamp - [37700] = 37185, -- kraken watcher lamp - [37187] = 37519, - [37519] = 37187, -- kraken buoy lamp - [37188] = 37520, - [37520] = 37188, -- kraken tentacle lamp - [37189] = 37191, - [37191] = 37189, -- kraken shelf - [37190] = 37192, - [37192] = 37190, -- kraken shelf - [37205] = 37206, - [37206] = 37207, -- sculpture of an octoputz - [37207] = 37205, - [37208] = 37209, -- sculpture of an octoputz - [37209] = 37210, - [37210] = 37208, -- sculpture of an octoputz - [37211] = 37212, - [37212] = 37211, -- octoputz - [37543] = 37580, - [37580] = 37543, -- string of fairy lights RYG - [37544] = 37581, - [37581] = 37544, -- string of fairy lights BRG - [37545] = 37582, - [37582] = 37545, -- string of fairy lights BGY - [37557] = 37558, - [37559] = 37560, -- dragon pinata - [37743] = 37744, - [37745] = 37746, -- draptor doll - [37749] = 37750, - [37750] = 37749, -- dark oracle - [37806] = 37807, - [37807] = 37806, -- zaoan wall lamp - [37808] = 37809, - [37809] = 37808, -- zaoan wall lamps - [37811] = 37813, - [37812] = 37814, -- sculpture of a fox - [38522] = 38524, - [38524] = 38522, -- naga lamp - [38523] = 38525, - [38525] = 38523, -- naga lamp - [38526] = 38528, - [38528] = 38526, -- basin with a glowing flower - [38677] = 38680, - [38704] = 38705, -- beaver of wisdom - [38827] = 38828, - [38828] = 38827, -- wall lamp - [39423] = 39425, - [39425] = 39423, -- knightly table - [39424] = 39426, - [39426] = 39424, -- knightly table - [39427] = 39428, - [39428] = 39427, -- knightly chess table - [39443] = 39444, - [39444] = 39445, -- knightly fire bowl - [39445] = 39443, -- knightly fire bowl - [39498] = 39499, - [39499] = 39498, -- knightly candelabra - [39500] = 39501, - [39501] = 39500, -- knightly candle holder - [39508] = 39509, - [39668] = 39510, -- knightly guard - [39694] = 39696, -- lucky dragon - [39697] = 39698, - [39698] = 39697, -- rainbow torch - [39699] = 39700, - [39700] = 39699, -- rainbow torch - [39701] = 39702, - [39702] = 39701, -- rainbow torch - [39757] = 39758, -- yeti doll - [39759] = 39760, - [39761] = 39762, -- the gods' twilight doll - [39772] = 39773, - [39773] = 39774, -- flower table - [39774] = 39772, -- flower table - [39793] = 39794, - [39794] = 39793, -- turquoise flower lamp - [39795] = 39796, - [39796] = 39795, -- purple flower lamp - [39801] = 39802, - [39802] = 39801, -- wall leaves - [39803] = 39804, - [39804] = 39803, -- tendrils - [39805] = 39806, - [39807] = 39808, -- water nymph - [39810] = 39809, -- water nymph - [42271] = 42272, - [42272] = 42271, -- seafarer table - [42291] = 42292, - [42292] = 42291, -- seashell lamp - [42293] = 42294, - [42294] = 42293, -- seashell lamp - [42295] = 42296, - [42296] = 42295, -- tentacle lamp - [42297] = 42298, - [42298] = 42297, -- tentacle lamp - [42299] = 42300, - [42300] = 42299, -- sea-devil wall lamp - [42301] = 42302, - [42302] = 42301, -- seafood bucket - [42324] = 42326, - [42326] = 42324, -- opulent table - [42325] = 42327, - [42327] = 42325, -- opulent table - [42346] = 42347, - [42347] = 42346, -- opulent floor lamp - [42348] = 42349, - [42349] = 42348, -- opulent floor lamp - [42363] = 42364, -- djinn lamp - [42365] = 42366, -- djinn lamp -} - -local transformTo = Action() - -function transformTo.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if voices[item:getId()] then - local spectators = Game.getSpectators(fromPosition, false, true, 3, 3) - for i = 1, #spectators do - player:say(voices[item:getId()], TALKTYPE_MONSTER_SAY, false, spectators[i], fromPosition) - end - end - - item:transform(transformItems[item.itemid]) - item:decay() - return true -end - -for index, value in pairs(transformItems) do - transformTo:id(index) -end - -transformTo:register() diff --git a/data-otservbr-global/scripts/actions/other/vessels.lua b/data-otservbr-global/scripts/actions/other/vessels.lua deleted file mode 100644 index b1f0701becb..00000000000 --- a/data-otservbr-global/scripts/actions/other/vessels.lua +++ /dev/null @@ -1,30 +0,0 @@ -local config = { - [37572] = CONST_ME_GAZHARAGOTH, -- vessel of Gaz'haragoth - [37573] = CONST_ME_FERUMBRAS_1, -- vessel of Ferumbras - [37574] = CONST_ME_MAD_MAGE, -- vessel of the Mad Mage - [37575] = CONST_ME_HORESTIS, -- vessel of Horestis - [37576] = CONST_ME_DEVOVORGA, -- vessel of Devovorga -} - -local vessels = Action() - -function vessels.onUse(player, item, fromPosition, itemEx, toPosition) - local vessel = config[item.itemid] - local tile = toPosition:getTile() - if not vessel or not player then - return false - end - if not tile:isWalkable() then - player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM) - else - item:remove(1) - toPosition:sendMagicEffect(vessel) - end - return true -end - -for index, value in pairs(config) do - vessels:id(index) -end -vessels:allowFarUse(true) -vessels:register() diff --git a/data-otservbr-global/scripts/actions/tools/amber_crusher.lua b/data-otservbr-global/scripts/actions/tools/amber_crusher.lua deleted file mode 100644 index d9c3edc4ce8..00000000000 --- a/data-otservbr-global/scripts/actions/tools/amber_crusher.lua +++ /dev/null @@ -1,31 +0,0 @@ -local amberCrusher = Action() - -function amberCrusher.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if not target or not target:isItem() or target:getId() == item:getId() or player:getItemCount(target:getId()) <= 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use the crusher on a valid gem in your inventory.") - return false - end - - local fragmentType, fragmentRange = getGemData(target:getId()) - if not fragmentType then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This item can't be broken into fragments.") - return false - end - - if target:getCount() >= MAX_GEM_BREAK then - target:remove(MAX_GEM_BREAK) - for i = 1, MAX_GEM_BREAK, 1 do - player:addItem(fragmentType, math.random(fragmentRange[1], fragmentRange[2])) - end - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have broken the gems into fragments.") - else - target:remove(1) - player:addItem(fragmentType, math.random(fragmentRange[1], fragmentRange[2])) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have broken the gem into fragments.") - end - - return true -end - -amberCrusher:id(46628) -amberCrusher:register() diff --git a/data-otservbr-global/scripts/actions/tools/crusher.lua b/data-otservbr-global/scripts/actions/tools/crusher.lua deleted file mode 100644 index 8daa9f2771b..00000000000 --- a/data-otservbr-global/scripts/actions/tools/crusher.lua +++ /dev/null @@ -1,42 +0,0 @@ -local crusher = Action() - -function crusher.onUse(player, item, fromPosition, target, toPosition, isHotkey) - if not target or not target:isItem() or target:getId() == item:getId() or player:getItemCount(target:getId()) <= 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use the crusher on a valid gem in your inventory.") - return false - end - - local fragmentType, fragmentRange = getGemData(target:getId()) - if not fragmentType then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This item can't be broken into fragments.") - return false - end - - local crusherCharges = item:getAttribute(ITEM_ATTRIBUTE_CHARGES) - if not crusherCharges or crusherCharges <= 0 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your crusher has no more charges.") - return false - end - - target:remove(1) - - player:addItem(fragmentType, math.random(fragmentRange[1], fragmentRange[2])) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have broken the gem into fragments.") - - crusherCharges = crusherCharges - 1 - if crusherCharges > 0 then - local container = item:getParent() - item:setAttribute(ITEM_ATTRIBUTE_CHARGES, crusherCharges) - if container:isContainer() then - player:sendUpdateContainer(container) - end - else - item:remove() - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your crusher has been consumed.") - end - - return true -end - -crusher:id(46627) -crusher:register() diff --git a/data-otservbr-global/scripts/creaturescripts/others/#modal_window_example.lua b/data-otservbr-global/scripts/creaturescripts/others/#modal_window_example.lua deleted file mode 100644 index e2de4a9e474..00000000000 --- a/data-otservbr-global/scripts/creaturescripts/others/#modal_window_example.lua +++ /dev/null @@ -1,63 +0,0 @@ ---[[ - ModalWindowHelper Example -]] --- - -local moveDirectionTest = { - ["Right"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_EAST) - player:teleportTo(pos, true) - end, - ["Left"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_WEST) - player:teleportTo(pos, true) - end, - ["Up"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_NORTH) - player:teleportTo(pos, true) - end, - ["Down"] = function(player) - local pos = player:getPosition() - pos:getNextPosition(DIRECTION_SOUTH) - player:teleportTo(pos, true) - end, -} - -local talkAction = TalkAction("!modalTest") - -function talkAction.onSay(player, words, param, type) - local modalWindow = ModalWindow({ - title = "Modal Window Helper Example", - message = "This is an example of ModalWindowHelper.", - }) - if param == "choices" then - for text, callback in pairs(moveDirectionTest) do - modalWindow:addChoice(text, function(player, button, choice) - if button.name == "Select" then - callback(player) - modalWindow:sendToPlayer(player) - end - end) - end - - modalWindow:addButton("Select") - modalWindow:addButton("Cancel") - elseif param == "buttons" then - for direction, callback in pairs(moveDirectionTest) do - modalWindow:addButton(direction, function(player, button, choice) - callback(player) - modalWindow:sendToPlayer(player) - end) - end - end - modalWindow:sendToPlayer(player) - return false -end - ---talkAction:accountType(ACCOUNT_TYPE_GOD) ---talkAction:access(true) -talkAction:separator(" ") -talkAction:register() diff --git a/data-otservbr-global/scripts/globalevents/others/guild_war.lua b/data-otservbr-global/scripts/globalevents/others/guild_war.lua deleted file mode 100644 index 41238755494..00000000000 --- a/data-otservbr-global/scripts/globalevents/others/guild_war.lua +++ /dev/null @@ -1,10 +0,0 @@ -local guildWar = GlobalEvent("guildwar") - -function guildWar.onThink(interval) - local time = os.time() - db.query("UPDATE `guild_wars` SET `status` = 4, `ended` = " .. time .. " WHERE `status` = 1 AND `ended` != 0 AND `ended` < " .. time) - return true -end - -guildWar:interval(60000) -guildWar:register() diff --git a/data/libs/functions/player.lua b/data/libs/functions/player.lua index 3f7c8e17b75..0350310e397 100644 --- a/data/libs/functions/player.lua +++ b/data/libs/functions/player.lua @@ -459,17 +459,6 @@ function Player.getSubjectVerb(self, past) return Pronouns.getPlayerSubjectVerb(self:getPronoun(), past) end -function Player.findItemInInbox(self, itemId) - local inbox = self:getStoreInbox() - local items = inbox:getItems() - for _, item in pairs(items) do - if item:getId() == itemId then - return item - end - end - return nil -end - function Player.updateHazard(self) local zones = self:getZones() if not zones or #zones == 0 then @@ -618,28 +607,6 @@ function Player:setFiendish() return false end -function Player:findItemInInbox(itemId, name) - local inbox = self:getStoreInbox() - local items = inbox:getItems() - for _, item in pairs(items) do - if item:getId() == itemId and (not name or item:getName() == name) then - return item - end - end - return nil -end - -function Player:sendColoredMessage(message) - local grey = 3003 - local blue = 3043 - local green = 3415 - local purple = 36792 - local yellow = 34021 - - local msg = message:gsub("{grey|", "{" .. grey .. "|"):gsub("{blue|", "{" .. blue .. "|"):gsub("{green|", "{" .. green .. "|"):gsub("{purple|", "{" .. purple .. "|"):gsub("{yellow|", "{" .. yellow .. "|") - return self:sendTextMessage(MESSAGE_LOOT, msg) -end - function Player:showInfoModal(title, message, buttonText) local modal = ModalWindow({ title = title, @@ -746,15 +713,6 @@ function Player.getNextRewardTime(self) return math.max(self:getStorageValue(DailyReward.storages.nextRewardTime), 0) end -function Player.isRestingAreaBonusActive(self) - local levelStreak = self:getStreakLevel() - if levelStreak > 1 then - return true - else - return false - end -end - function Player.getActiveDailyRewardBonusesName(self) local msg = "" local streakLevel = self:getStreakLevel() @@ -846,45 +804,6 @@ function Player.inBossFight(self) return false end --- For use of data/events/scripts/player.lua -function Player:executeRewardEvents(item, toPosition) - if toPosition.x == CONTAINER_POSITION then - local containerId = toPosition.y - 64 - local container = self:getContainerById(containerId) - if not container then - return true - end - - -- Do not let the player insert items into either the Reward Container or the Reward Chest - local itemId = container:getId() - if itemId == ITEM_REWARD_CONTAINER or itemId == ITEM_REWARD_CHEST then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - return false - end - - -- The player also shouldn't be able to insert items into the boss corpse - local tileCorpse = Tile(container:getPosition()) - for index, value in ipairs(tileCorpse:getItems() or {}) do - if value:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2 ^ 31 - 1 and value:getName() == container:getName() then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - return false - end - end - end - -- Do not let the player move the boss corpse. - if item:getAttribute(ITEM_ATTRIBUTE_CORPSEOWNER) == 2 ^ 31 - 1 then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - return false - end - -- Players cannot throw items on reward chest - local tileChest = Tile(toPosition) - if tileChest and tileChest:getItemById(ITEM_REWARD_CHEST) then - self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - self:getPosition():sendMagicEffect(CONST_ME_POFF) - return false - end -end - do local loyaltySystem = { enable = configManager.getBoolean(configKeys.LOYALTY_ENABLED), @@ -1009,3 +928,15 @@ function Player.getMarkdownLink(self) return string.format("**[%s](%s)** %s [_%s_]", self:getName(), playerURL, emoji, vocation) end + +function Player.findItemInInbox(self, itemId, name) + local inbox = self:getStoreInbox() + local items = inbox:getItems() + + for _, item in pairs(items) do + if item:getId() == itemId and (not name or item:getName() == name) then + return item + end + end + return nil +end diff --git a/data/libs/systems/vip.lua b/data/libs/systems/vip.lua index 9e76fd8ad80..49ef7bcf8cc 100644 --- a/data/libs/systems/vip.lua +++ b/data/libs/systems/vip.lua @@ -45,17 +45,17 @@ function Player.onAddVip(self, days, silent) self:kv():scoped("account"):set("vip-system", true) end -function CheckPremiumAndPrint(player, msgType) - if player:getVipDays() == 0xFFFF then - player:sendTextMessage(msgType, "You have an unlimited VIP status.") +function Player.sendVipStatus(self) + if self:getVipDays() == 0xFFFF then + self:sendTextMessage(MESSAGE_LOGIN, "You have unlimited VIP status.") return true end - local playerVipTime = player:getVipTime() + local playerVipTime = self:getVipTime() if playerVipTime < os.time() then - player:sendTextMessage(msgType, "Your VIP status is currently inactive.") + self:sendTextMessage(MESSAGE_STATUS, "Your VIP status is currently inactive.") return true end - player:sendTextMessage(msgType, string.format("You have %s of VIP time remaining.", getFormattedTimeRemaining(playerVipTime))) + self:sendTextMessage(MESSAGE_LOGIN, string.format("You have %s of VIP time remaining.", getFormattedTimeRemaining(playerVipTime))) end diff --git a/data-otservbr-global/scripts/actions/other/balloons.lua b/data/scripts/actions/items/anniversary_balloons.lua similarity index 79% rename from data-otservbr-global/scripts/actions/other/balloons.lua rename to data/scripts/actions/items/anniversary_balloons.lua index 35e84eec531..8fbeecee110 100644 --- a/data-otservbr-global/scripts/actions/other/balloons.lua +++ b/data/scripts/actions/items/anniversary_balloons.lua @@ -1,4 +1,4 @@ -local balloonItems = { +local settings = { [37471] = 37414, [37414] = 37471, -- blue balloon [37472] = 37416, @@ -77,32 +77,28 @@ local balloonItems = { [39692] = 39680, -- balloon no.9 } -local balloons = Action() +local anniversaryBalloons = Action() -function balloons.onUse(player, item, fp, target, toPosition, isHotkey) - local balloon = balloonItems[item.itemid] +function anniversaryBalloons.onUse(player, item, fromPosition, target, toPosition, isHotkey) + local balloon = settings[item.itemid] if not balloon then - return false + return true end local fromPosition = item:getPosition() local tile = Tile(fromPosition) - if not fromPosition:getTile():getHouse() then + + if not tile:getHouse() then player:sendTextMessage(MESSAGE_FAILURE, "You may use this only inside a house.") - elseif tile:getItemCountById(item.itemid) == 1 then - for index, value in pairs(balloonItems) do - if tile:getItemCountById(index) > 0 and index ~= item.itemid then - player:sendCancelMessage(Game.getReturnMessage(RETURNVALUE_NOTPOSSIBLE)) - return true - end - end - item:transform(balloon) + return true end + + item:transform(balloon, 1) return true end -for index, value in pairs(balloonItems) do - balloons:id(index) +for itemId in pairs(settings) do + anniversaryBalloons:id(itemId) end -balloons:register() +anniversaryBalloons:register() diff --git a/data-canary/scripts/actions/other/bed_modification_kits.lua b/data/scripts/actions/items/bed_modification_kits.lua similarity index 90% rename from data-canary/scripts/actions/other/bed_modification_kits.lua rename to data/scripts/actions/items/bed_modification_kits.lua index 431e3cef5eb..a406f7fd5b2 100644 --- a/data-canary/scripts/actions/other/bed_modification_kits.lua +++ b/data/scripts/actions/items/bed_modification_kits.lua @@ -20,7 +20,7 @@ local bedModificationKits = Action() function bedModificationKits.onUse(player, item, fromPosition, target, toPosition, isHotkey) local newBed = setting[item:getId()] - if not newBed or type(target) ~= "userdata" or not target:isItem() then + if not newBed or not target or not target:isItem() then return false end @@ -35,7 +35,7 @@ function bedModificationKits.onUse(player, item, fromPosition, target, toPositio return true end - for index, value in pairs(setting) do + for _, value in pairs(setting) do if value[1][1] == targetItemId or table.contains({ 2491, 5501, 15506 }, targetItemId) then toPosition:sendMagicEffect(CONST_ME_POFF) toPosition.y = toPosition.y + 1 @@ -51,8 +51,8 @@ function bedModificationKits.onUse(player, item, fromPosition, target, toPositio return true end -for index, value in pairs(setting) do - bedModificationKits:id(index) +for id in pairs(setting) do + bedModificationKits:id(id) end bedModificationKits:register() diff --git a/data/scripts/actions/items/christmas_bundle.lua b/data/scripts/actions/items/christmas_bundle.lua new file mode 100644 index 00000000000..d0a56f6d050 --- /dev/null +++ b/data/scripts/actions/items/christmas_bundle.lua @@ -0,0 +1,42 @@ +local setting = { + [6506] = { { 6569, 15 }, { 3585, 5 }, { 3586, 10 }, { 3598, 20 }, { 3599, 10 }, 6500, 6501, 6489, 6503, 6387 }, -- red bundle + [6507] = { { 6569, 15 }, { 3585, 5 }, { 3586, 10 }, { 3598, 20 }, { 3599, 10 }, 6500, 6501, 6489, 6505, 6387 }, -- blue bundle + [6508] = { { 6569, 15 }, { 3585, 5 }, { 3586, 10 }, { 3598, 20 }, { 3599, 10 }, 6500, 6501, 6489, 6502, 6387 }, -- green bundle +} + +local christmasBundle = Action() + +function christmasBundle.onUse(player, item, fromPosition, target, toPosition, isHotkey) + local targetItem = setting[item.itemid] + if not targetItem then + return true + end + + local rewards = {} + while #rewards < 7 do + local randIndex = math.random(#targetItem) + local gift = targetItem[randIndex] + + local count = 1 + if type(gift) == "table" then + gift, count = unpack(gift) + end + + rewards[#rewards + 1] = { gift, count } + table.remove(targetItem, randIndex) + end + + for _, reward in ipairs(rewards) do + player:addItem(unpack(reward)) + end + + player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS) + item:remove(1) + return true +end + +for itemId in pairs(setting) do + christmasBundle:id(itemId) +end + +christmasBundle:register() diff --git a/data-canary/scripts/actions/other/decay_to.lua b/data/scripts/actions/items/decay_to.lua similarity index 87% rename from data-canary/scripts/actions/other/decay_to.lua rename to data/scripts/actions/items/decay_to.lua index bfceedb288e..bb68e346e1f 100644 --- a/data-canary/scripts/actions/other/decay_to.lua +++ b/data/scripts/actions/items/decay_to.lua @@ -1,5 +1,9 @@ -local setting = { - --[itemid] = decayto +local voices = { + [23708] = "Au au!", + [23443] = "Grooaarr!", +} + +local transformItems = { [2062] = 2063, [2063] = 2062, -- sacred statue [2064] = 2065, @@ -439,16 +443,69 @@ local setting = { [39700] = 39699, -- rainbow torch [39701] = 39702, [39702] = 39701, -- rainbow torch + [39757] = 39758, -- yeti doll + [39759] = 39760, + [39761] = 39762, -- the gods' twilight doll + [39772] = 39773, + [39773] = 39774, -- flower table + [39774] = 39772, -- flower table + [39793] = 39794, + [39794] = 39793, -- turquoise flower lamp + [39795] = 39796, + [39796] = 39795, -- purple flower lamp + [39801] = 39802, + [39802] = 39801, -- wall leaves + [39803] = 39804, + [39804] = 39803, -- tendrils + [39805] = 39806, + [39807] = 39808, -- water nymph + [39810] = 39809, -- water nymph + [42271] = 42272, + [42272] = 42271, -- seafarer table + [42291] = 42292, + [42292] = 42291, -- seashell lamp + [42293] = 42294, + [42294] = 42293, -- seashell lamp + [42295] = 42296, + [42296] = 42295, -- tentacle lamp + [42297] = 42298, + [42298] = 42297, -- tentacle lamp + [42299] = 42300, + [42300] = 42299, -- sea-devil wall lamp + [42301] = 42302, + [42302] = 42301, -- seafood bucket + [42324] = 42326, + [42326] = 42324, -- opulent table + [42325] = 42327, + [42327] = 42325, -- opulent table + [42346] = 42347, + [42347] = 42346, -- opulent floor lamp + [42348] = 42349, + [42349] = 42348, -- opulent floor lamp + [42363] = 42364, -- djinn lamp + [42365] = 42366, -- djinn lamp } local decayTo = Action() function decayTo.onUse(player, item, fromPosition, target, toPosition, isHotkey) - item:transform(setting[item.itemid]) + local itemId = item:getId() + if voices[itemId] then + local spectators = Game.getSpectators(fromPosition, false, true, 3, 3) + for _, spectator in ipairs(spectators) do + player:say(voices[itemId], TALKTYPE_MONSTER_SAY, false, spectator, fromPosition) + end + end + + local newItemId = transformItems[itemId] + if newItemId then + item:transform(newItemId) + item:decay() + end return true end -for index, value in pairs(setting) do +for index in pairs(transformItems) do decayTo:id(index) end diff --git a/data-canary/scripts/actions/other/dolls.lua b/data/scripts/actions/items/dolls.lua similarity index 100% rename from data-canary/scripts/actions/other/dolls.lua rename to data/scripts/actions/items/dolls.lua diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_amulet.lua b/data/scripts/actions/items/ferumbras_amulet.lua similarity index 95% rename from data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_amulet.lua rename to data/scripts/actions/items/ferumbras_amulet.lua index d92c496e165..dee32339a46 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_amulet.lua +++ b/data/scripts/actions/items/ferumbras_amulet.lua @@ -1,10 +1,12 @@ local ferumbrasAscendantAmulet = Action() + function ferumbrasAscendantAmulet.onUse(player, item, fromPosition, target, toPosition, isHotkey) local amulet = player:getSlotItem(CONST_SLOT_NECKLACE) - if amulet ~= item or amulet ~= item then + if amulet ~= item then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to equip the amulet to try use it.") return true end + if item.itemid == 22767 then if math.random(2) == 1 then player:addHealth(1000, true, true) @@ -13,10 +15,10 @@ function ferumbrasAscendantAmulet.onUse(player, item, fromPosition, target, toPo player:addMana(1000, true, true) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Magical sparks whirl around the amulet as you use it and you was restored.") end + item:transform(22768) item:decay() player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) - return true elseif item.itemid == 22768 then player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You are tired of the last use of the amulet, you must wait for the recharge.") end diff --git a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_mana_keg.lua b/data/scripts/actions/items/ferumbras_mana_keg.lua similarity index 99% rename from data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_mana_keg.lua rename to data/scripts/actions/items/ferumbras_mana_keg.lua index 8ece01ed6e8..04bbc7b6e50 100644 --- a/data-otservbr-global/scripts/quests/ferumbras_ascension/actions_ferumbras_mana_keg.lua +++ b/data/scripts/actions/items/ferumbras_mana_keg.lua @@ -1,4 +1,5 @@ local ferumbrasAscendantManaKeg = Action() + function ferumbrasAscendantManaKeg.onUse(player, item, fromPosition, target, toPosition, isHotkey) if item.itemid == 22769 then player:addItem("ultimate mana potion", 10) diff --git a/data-otservbr-global/scripts/actions/other/party_trumpet.lua b/data/scripts/actions/items/party_trumpet.lua similarity index 100% rename from data-otservbr-global/scripts/actions/other/party_trumpet.lua rename to data/scripts/actions/items/party_trumpet.lua index 71ee617ec69..a1cb77bf56d 100644 --- a/data-otservbr-global/scripts/actions/other/party_trumpet.lua +++ b/data/scripts/actions/items/party_trumpet.lua @@ -1,10 +1,10 @@ local partyTrumpet = Action() function partyTrumpet.onUse(player, item, fromPosition, target, toPosition, isHotkey) - item:transform(6573) - item:decay() player:say("TOOOOOOT!", TALKTYPE_MONSTER_SAY) fromPosition:sendMagicEffect(CONST_ME_SOUND_BLUE) + item:transform(6573) + item:decay() return true end diff --git a/data-otservbr-global/scripts/actions/other/roasted_meat.lua b/data/scripts/actions/items/roasted_meat.lua similarity index 100% rename from data-otservbr-global/scripts/actions/other/roasted_meat.lua rename to data/scripts/actions/items/roasted_meat.lua diff --git a/data/scripts/actions/items/surprise_bags.lua b/data/scripts/actions/items/surprise_bags.lua new file mode 100644 index 00000000000..09c03e516db --- /dev/null +++ b/data/scripts/actions/items/surprise_bags.lua @@ -0,0 +1,32 @@ +local settings = { + [6570] = { { 3598, 10 }, 6393, 6279, 6574, 6578, 6575, 6577, 6569, 6576, 6572, 2995, 14027, 14681 }, -- blue present + [6571] = { 6574, 3079, 6393, 6576, 6578, 2995, 14027, 3036, 5944, 3386, 3420, 3039, 5080, 2993, 3392, 3057, 5791 }, -- red present + [8853] = { { 3031, 10 }, 123, 2995, 2397, 651, 3218, 6574, 6393, 7377, 3578, 8778 }, -- surprise bag + [14751] = { { 9642, 15 }, { 3581, 15 }, 5917, 3273, 10302, 9019, 5928, 5926, 5927, 6095, 5918, 6097, 6098, 5461, 5090 }, -- surprise bag + [14759] = { { 6569, 10 }, { 6541, 10 }, { 6542, 10 }, { 6543, 10 }, { 6544, 10 }, { 6545, 10 }, 6574, 4839, 6570, 6571, 3215 }, -- surprise bag +} + +local surpriseBag = Action() + +function surpriseBag.onUse(player, item, fromPosition) + local present = settings[item.itemid] + if not present then + return true + end + + local gift = present[math.random(#present)] + local count = 1 + + if type(gift) == "table" then + count = math.random(gift[2]) + gift = gift[1] + end + + player:addItem(gift, count) + fromPosition:sendMagicEffect(CONST_ME_GIFT_WRAPS) + item:remove(1) + return true +end + +surpriseBag:id(6570, 6571, 8853, 14751, 14759) +surpriseBag:register() diff --git a/data/scripts/actions/items/surprise_music_box.lua b/data/scripts/actions/items/surprise_music_box.lua new file mode 100644 index 00000000000..05abbac3d08 --- /dev/null +++ b/data/scripts/actions/items/surprise_music_box.lua @@ -0,0 +1,34 @@ +local prize = { + { chance = 1, id = 3246, amount = 1 }, + { chance = 2, id = 10227, amount = 1 }, + { chance = 3, id = 11588, amount = 1 }, + { chance = 4, id = 3549, amount = 1 }, + { chance = 5, id = 3420, amount = 1 }, + { chance = 10, id = ITEM_CRYSTAL_COIN, amount = 17 }, + { chance = 20, id = ITEM_GOLD_COIN, amount = 1 }, + { chance = 30, id = ITEM_CRYSTAL_COIN, amount = 1 }, + { chance = 40, id = ITEM_GOLD_COIN, amount = 50 }, + { chance = 50, id = ITEM_PLATINUM_COIN, amount = 15 }, + { chance = 90, id = ITEM_GOLD_COIN, amount = 80 }, +} + +local surpriseBox = Action() + +function surpriseBox.onUse(player, item, fromPosition, target, toPosition, isHotkey) + local number = math.random(1, 100) + local cumulativeChance = 0 + + for _, prizeEntry in ipairs(prize) do + cumulativeChance = cumulativeChance + prizeEntry.chance + if number <= cumulativeChance then + player:getPosition():sendMagicEffect(CONST_ME_POFF) + player:addItem(prizeEntry.id, prizeEntry.amount) + item:remove() + break + end + end + return true +end + +surpriseBox:id(12045) +surpriseBox:register() diff --git a/data/scripts/actions/items/vessels.lua b/data/scripts/actions/items/vessels.lua new file mode 100644 index 00000000000..2d6fe19bf00 --- /dev/null +++ b/data/scripts/actions/items/vessels.lua @@ -0,0 +1,26 @@ +local config = { + [37572] = CONST_ME_GAZHARAGOTH, + [37573] = CONST_ME_FERUMBRAS_1, + [37574] = CONST_ME_MAD_MAGE, + [37575] = CONST_ME_HORESTIS, + [37576] = CONST_ME_DEVOVORGA, +} + +local vessels = Action() + +function vessels.onUse(player, item, fromPosition, target, toPosition, isHotkey) + local vessel = config[item.itemid] + if not vessel or not target:isPlayer() then + return true + end + + toPosition:sendMagicEffect(vessel) + item:remove(1) + return true +end + +for index in pairs(config) do + vessels:id(index) +end + +vessels:register() diff --git a/data-otservbr-global/scripts/actions/other/bath_tub.lua b/data/scripts/actions/objects/bath_tub_drain.lua similarity index 99% rename from data-otservbr-global/scripts/actions/other/bath_tub.lua rename to data/scripts/actions/objects/bath_tub_drain.lua index cd1b3238ca6..a09886a2ad1 100644 --- a/data-otservbr-global/scripts/actions/other/bath_tub.lua +++ b/data/scripts/actions/objects/bath_tub_drain.lua @@ -1,4 +1,5 @@ local bathtubDrain = Action() + function bathtubDrain.onUse(player, item, fromPosition, itemEx, toPosition) local tile = Tile(fromPosition) if tile:getTopCreature() then diff --git a/data/scripts/actions/tools/crushers.lua b/data/scripts/actions/tools/crushers.lua new file mode 100644 index 00000000000..99c3102616d --- /dev/null +++ b/data/scripts/actions/tools/crushers.lua @@ -0,0 +1,86 @@ +local config = { + maxGemBreak = 10, + fragmentGems = { + small = { ids = { 44602, 44605, 44608, 44611 }, fragment = 46625, range = { 1, 4 } }, + medium = { ids = { 44603, 44606, 44609, 44612 }, fragment = 46625, range = { 2, 8 } }, + great = { ids = { 44604, 44607, 44610, 44613 }, fragment = 46626, range = { 1, 4 } }, + }, +} + +local function getGemData(gemId) + for _, gemData in pairs(config.fragmentGems) do + if table.contains(gemData.ids, gemId) then + return gemData.fragment, gemData.range + end + end + return nil +end + +local amberCrusher = Action() + +function amberCrusher.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if not target or not target:isItem() or target:getId() == item:getId() or player:getItemCount(target:getId()) <= 0 then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use the crusher on a valid gem in your inventory.") + return true + end + + local fragmentType, fragmentRange = getGemData(target:getId()) + if not fragmentType then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This item can't be broken into fragments.") + return true + end + + local breakAmount = (target:getCount() >= config.maxGemBreak) and config.maxGemBreak or 1 + target:remove(breakAmount) + + for _ = 1, breakAmount do + player:addItem(fragmentType, math.random(fragmentRange[1], fragmentRange[2])) + end + + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have broken the gem into fragments.") + return true +end + +amberCrusher:id(46628) +amberCrusher:register() + +local crusher = Action() + +function crusher.onUse(player, item, fromPosition, target, toPosition, isHotkey) + if not target or not target:isItem() or target:getId() == item:getId() or player:getItemCount(target:getId()) <= 0 then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only use the crusher on a valid gem in your inventory.") + return true + end + + local fragmentType, fragmentRange = getGemData(target:getId()) + if not fragmentType then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "This item can't be broken into fragments.") + return true + end + + local crusherCharges = item:getAttribute(ITEM_ATTRIBUTE_CHARGES) + if not crusherCharges or crusherCharges <= 0 then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your crusher has no more charges.") + return true + end + + target:remove(1) + player:addItem(fragmentType, math.random(fragmentRange[1], fragmentRange[2])) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You have broken the gem into fragments.") + + crusherCharges = crusherCharges - 1 + if crusherCharges > 0 then + local container = item:getParent() + item:setAttribute(ITEM_ATTRIBUTE_CHARGES, crusherCharges) + if container:isContainer() then + player:sendUpdateContainer(container) + end + else + item:remove() + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your crusher has been consumed.") + end + return true +end + +crusher:id(46627) +crusher:register() diff --git a/data-otservbr-global/scripts/creaturescripts/monster/spawn_system.lua b/data/scripts/creaturescripts/monster/spawn_system.lua similarity index 99% rename from data-otservbr-global/scripts/creaturescripts/monster/spawn_system.lua rename to data/scripts/creaturescripts/monster/spawn_system.lua index 580dba6d07c..710585cced3 100644 --- a/data-otservbr-global/scripts/creaturescripts/monster/spawn_system.lua +++ b/data/scripts/creaturescripts/monster/spawn_system.lua @@ -1,4 +1,5 @@ local monsterDeath = CreatureEvent("monsterDeath") + function monsterDeath.onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamageUnjustified) if creature and creature:isMonster() then local self = creature:getStorageValue(MonsterStorage.Spawn.monster_spawn_object) @@ -12,6 +13,7 @@ end monsterDeath:register() local monsterDeathBoss = CreatureEvent("monsterDeathBoss") + function monsterDeathBoss.onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamageUnjustified) if creature and creature:isMonster() then local self = creature:getStorageValue(MonsterStorage.Spawn.monster_spawn_object) diff --git a/data-canary/scripts/creaturescripts/extended_opcode.lua b/data/scripts/creaturescripts/others/#extended_opcode.lua similarity index 100% rename from data-canary/scripts/creaturescripts/extended_opcode.lua rename to data/scripts/creaturescripts/others/#extended_opcode.lua diff --git a/data/scripts/creaturescripts/player/login.lua b/data/scripts/creaturescripts/player/login.lua index 5f9f0e695f4..20049d87621 100644 --- a/data/scripts/creaturescripts/player/login.lua +++ b/data/scripts/creaturescripts/player/login.lua @@ -118,19 +118,19 @@ function playerLoginGlobal.onLogin(player) -- Updates the player's VIP status and executes corresponding actions if applicable. if configManager.getBoolean(configKeys.VIP_SYSTEM_ENABLED) then - local isVipNow = player:isVip() - local wasVip = player:kv():scoped("account"):get("vip-system") or false + local isCurrentlyVip = player:isVip() + local hadVipStatus = player:kv():scoped("account"):get("vip-system") or false - if wasVip ~= isVipNow then - if wasVip then + if hadVipStatus ~= isCurrentlyVip then + if hadVipStatus then player:onRemoveVip() else player:onAddVip(player:getVipDays()) end end - if isVipNow then - CheckPremiumAndPrint(player, MESSAGE_LOGIN) + if isCurrentlyVip then + player:sendVipStatus() end end diff --git a/data/scripts/globalevents/update_guild_war_status.lua b/data/scripts/globalevents/update_guild_war_status.lua new file mode 100644 index 00000000000..2ede80428ef --- /dev/null +++ b/data/scripts/globalevents/update_guild_war_status.lua @@ -0,0 +1,10 @@ +local updateGuildWarStatus = GlobalEvent("UpdateGuildWarStatus") + +function updateGuildWarStatus.onThink(interval) + local currentTime = os.time() + db.query("UPDATE `guild_wars` SET `status` = 4, `ended` = %d WHERE `status` = 1 AND `ended` != 0 AND `ended` < %d", currentTime, currentTime) + return true +end + +updateGuildWarStatus:interval(60000) +updateGuildWarStatus:register() diff --git a/data-otservbr-global/scripts/movements/others/bath_tub.lua b/data/scripts/movements/bath_tub.lua similarity index 64% rename from data-otservbr-global/scripts/movements/others/bath_tub.lua rename to data/scripts/movements/bath_tub.lua index 7ff7d1fe841..258efae4bb7 100644 --- a/data-otservbr-global/scripts/movements/others/bath_tub.lua +++ b/data/scripts/movements/bath_tub.lua @@ -1,35 +1,38 @@ -local playerBathTub = 26087 - local bathtubEnter = MoveEvent() function bathtubEnter.onStepIn(creature, item, position, fromPosition) - if not creature:isPlayer() then - return false + local player = creature:getPlayer() + if not player then + return true end local condition = Condition(CONDITION_OUTFIT) - condition:setOutfit({ lookTypeEx = playerBathTub }) + condition:setOutfit({ lookTypeEx = 26087 }) condition:setTicks(-1) position:sendMagicEffect(CONST_ME_WATERSPLASH) item:transform(BATHTUB_FILLED_NOTMOVABLE) - creature:addCondition(condition) + player:addCondition(condition) return true end +bathtubEnter:type("stepin") bathtubEnter:id(BATHTUB_FILLED) bathtubEnter:register() local bathtubExit = MoveEvent() + function bathtubExit.onStepOut(creature, item, position, fromPosition) - if not creature:isPlayer() then - return false + local player = creature:getPlayer() + if not player then + return true end item:transform(BATHTUB_FILLED) - creature:removeCondition(CONDITION_OUTFIT) + player:removeCondition(CONDITION_OUTFIT) return true end +bathtubExit:type("stepout") bathtubExit:id(BATHTUB_FILLED_NOTMOVABLE) bathtubExit:register() diff --git a/data/scripts/talkactions/gm/gold_highscore.lua b/data/scripts/talkactions/gm/gold_highscore.lua index de923712887..a68df6900a5 100644 --- a/data/scripts/talkactions/gm/gold_highscore.lua +++ b/data/scripts/talkactions/gm/gold_highscore.lua @@ -1,28 +1,33 @@ -local gold_rank = TalkAction("/goldrank") +local goldRank = TalkAction("/goldrank") -function gold_rank.onSay(player, words, param) +function goldRank.onSay(player, words, param) -- create log logCommand(player, words, param) - local resultId = db.storeQuery("SELECT `balance`, `name` FROM `players` WHERE group_id < 3 ORDER BY balance DESC LIMIT 10") - if resultId ~= false then - local str = "" - local x = 0 - repeat - x = x + 1 - str = str .. "\n" .. x .. "- " .. Result.getString(resultId, "name") .. " (" .. Result.getNumber(resultId, "balance") .. ")." - until not Result.next(resultId) - Result.free(resultId) - if str == "" then - str = "No highscore to show." - end - player:popupFYI("Current gold highscore for this server:\n" .. str) - else + local highscoreQuery = db.storeQuery("SELECT `balance`, `name` FROM `players` WHERE group_id < 3 ORDER BY balance DESC LIMIT 10") + if not highscoreQuery then player:sendCancelMessage("No highscore to show.") + return true end + + local highscoreList = "" + local rank = 0 + repeat + rank = rank + 1 + local playerName = Result.getString(highscoreQuery, "name") + local playerBalance = FormatNumber(Result.getNumber(highscoreQuery, "balance")) + highscoreList = highscoreList .. "\n" .. rank .. "- " .. playerName .. " (" .. playerBalance .. ")." + until not Result.next(highscoreQuery) + + Result.free(highscoreQuery) + if highscoreList == "" then + highscoreList = "No highscore to show." + end + + player:popupFYI("Current gold highscore for this server:\n" .. highscoreList) return true end -gold_rank:separator(" ") -gold_rank:groupType("gamemaster") -gold_rank:register() +goldRank:separator(" ") +goldRank:groupType("gamemaster") +goldRank:register() diff --git a/data/scripts/talkactions/god/add_addon.lua b/data/scripts/talkactions/god/add_addon.lua index 026336e270e..bbcd21c94fa 100644 --- a/data/scripts/talkactions/god/add_addon.lua +++ b/data/scripts/talkactions/god/add_addon.lua @@ -1,45 +1,305 @@ -local addons = TalkAction("/addaddon") +local addaddon = TalkAction("/addaddon") -function addons.onSay(player, words, param) - -- create log - logCommand(player, words, param) +local looktypes = { + -- Female Outfits + 136, + 137, + 138, + 139, + 140, + 141, + 142, + 147, + 148, + 149, + 150, + 155, + 156, + 157, + 158, + 252, + 269, + 270, + 279, + 288, + 324, + 329, + 336, + 366, + 431, + 433, + 464, + 466, + 471, + 513, + 514, + 542, + 575, + 578, + 618, + 620, + 632, + 635, + 636, + 664, + 666, + 683, + 694, + 696, + 698, + 724, + 732, + 745, + 749, + 759, + 845, + 852, + 874, + 885, + 900, + 909, + 929, + 956, + 958, + 963, + 965, + 967, + 969, + 971, + 973, + 975, + 1020, + 1024, + 1043, + 1050, + 1057, + 1070, + 1095, + 1103, + 1128, + 1147, + 1162, + 1174, + 1187, + 1203, + 1205, + 1207, + 1211, + 1244, + 1246, + 1252, + 1271, + 1280, + 1283, + 1289, + 1293, + 1323, + 1332, + 1339, + 1372, + 1383, + 1385, + 1387, + 1416, + 1437, + 1445, + 1450, + 1456, + 1461, + 1490, + 1501, + 1569, + 1576, + 1582, + 1598, + 1613, + 1619, + 1663, + 1676, + 1681, - local target - local split = param:split(",") - local name = split[1] + -- Male Outfits + 1714, + 1723, + 1726, + 1746, + 1775, + 1777, + 128, + 129, + 130, + 131, + 132, + 133, + 134, + 143, + 144, + 145, + 146, + 151, + 152, + 153, + 154, + 251, + 268, + 273, + 278, + 289, + 325, + 328, + 335, + 367, + 430, + 432, + 463, + 465, + 472, + 512, + 516, + 541, + 574, + 577, + 610, + 619, + 633, + 634, + 637, + 665, + 667, + 684, + 695, + 697, + 699, + 725, + 733, + 746, + 750, + 760, + 846, + 853, + 873, + 884, + 899, + 908, + 931, + 955, + 957, + 962, + 964, + 966, + 968, + 970, + 972, + 974, + 1021, + 1023, + 1042, + 1051, + 1056, + 1069, + 1094, + 1102, + 1127, + 1146, + 1161, + 1173, + 1186, + 1202, + 1204, + 1206, + 1210, + 1243, + 1245, + 1251, + 1270, + 1279, + 1282, + 1288, + 1292, + 1322, + 1331, + 1338, + 1371, + 1382, + 1384, + 1386, + 1415, + 1436, + 1444, + 1449, + 1457, + 1460, + 1489, + 1500, + 1568, + 1575, + 1581, + 1597, + 1612, + 1618, + 1662, + 1675, + 1680, + 1713, + 1722, + 1725, + 1745, + 1774, + 1776, +} + +function addaddon.onSay(player, words, param) + -- Create log + logCommand(player, words, param) if param == "" then - target = player:getTarget() - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Gives players the ability to wear addon for a specific outfit. Usage: /addaddon , ") - return true - end - else - target = Player(name) + player:sendCancelMessage("Command param required.") + return true end - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. name .. " is currently not online.") + local split = param:split(",") + if #split < 3 then + player:sendCancelMessage("Usage: /addaddon , , ") return true end - local looktype = tonumber(split[2]) - if not looktype then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Invalid looktype.") + local playerName = split[1] + local target = Player(playerName) + + if not target then + player:sendCancelMessage("Player not found.") return true end - local addons = tonumber(split[3]) - if not addons or addons < 0 or addons > 3 then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Invalid addon.") + local addonParam = string.trim(split[2]) + local addonValue = tonumber(string.trim(split[3])) + + if not addonValue or addonValue < 0 or addonValue > 3 then + player:sendCancelMessage("Invalid addon value. It should be between 0 and 3.") return true end - target:addOutfitAddon(looktype, addons) - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Addon for looktype " .. looktype .. "a for " .. target:getName() .. " set to " .. addons .. ".") + if addonParam == "all" then + for _, looktype in ipairs(looktypes) do + target:addOutfitAddon(looktype, addonValue) + end + + target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added addon %d to all your looktypes.", player:getName(), addonValue)) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added addon %d to all looktypes of player %s.", addonValue, target:getName())) + else + local looktype = tonumber(addonParam) + if not looktype then + player:sendCancelMessage("Invalid looktype.") + return true + end + + target:addOutfitAddon(looktype, addonValue) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("Addon %d for looktype %d set for player %s.", addonValue, looktype, target:getName())) + target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added addon %d for looktype %d to you.", player:getName(), addonValue, looktype)) + end return true end -addons:separator(" ") -addons:groupType("god") -addons:register() +addaddon:separator(" ") +addaddon:groupType("god") +addaddon:register() diff --git a/data/scripts/talkactions/god/add_addons.lua b/data/scripts/talkactions/god/add_addons.lua deleted file mode 100644 index 5498ae1e11b..00000000000 --- a/data/scripts/talkactions/god/add_addons.lua +++ /dev/null @@ -1,277 +0,0 @@ --- /addaddons playername - -local addons = TalkAction("/addaddons") -local looktypes = { - - -- Female Outfits - 136, - 137, - 138, - 139, - 140, - 141, - 142, - 147, - 148, - 149, - 150, - 155, - 156, - 157, - 158, - 252, - 269, - 270, - 279, - 288, - 324, - 329, - 336, - 366, - 431, - 433, - 464, - 466, - 471, - 513, - 514, - 542, - 575, - 578, - 618, - 620, - 632, - 635, - 636, - 664, - 666, - 683, - 694, - 696, - 698, - 724, - 732, - 745, - 749, - 759, - 845, - 852, - 874, - 885, - 900, - 909, - 929, - 956, - 958, - 963, - 965, - 967, - 969, - 971, - 973, - 975, - 1020, - 1024, - 1043, - 1050, - 1057, - 1070, - 1095, - 1103, - 1128, - 1147, - 1162, - 1174, - 1187, - 1203, - 1205, - 1207, - 1211, - 1244, - 1246, - 1252, - 1271, - 1280, - 1283, - 1289, - 1293, - 1323, - 1332, - 1339, - 1372, - 1383, - 1385, - 1387, - 1416, - 1437, - 1445, - 1450, - 1456, - 1461, - 1490, - 1501, - 1569, - 1576, - 1582, - 1598, - 1613, - 1619, - 1663, - 1676, - 1681, - - -- Male Outfits - 128, - 129, - 130, - 131, - 132, - 133, - 134, - 143, - 144, - 145, - 146, - 151, - 152, - 153, - 154, - 251, - 268, - 273, - 278, - 289, - 325, - 328, - 335, - 367, - 430, - 432, - 463, - 465, - 472, - 512, - 516, - 541, - 574, - 577, - 610, - 619, - 633, - 634, - 637, - 665, - 667, - 684, - 695, - 697, - 699, - 725, - 733, - 746, - 750, - 760, - 846, - 853, - 873, - 884, - 899, - 908, - 931, - 955, - 957, - 962, - 964, - 966, - 968, - 970, - 972, - 974, - 1021, - 1023, - 1042, - 1051, - 1056, - 1069, - 1094, - 1102, - 1127, - 1146, - 1161, - 1173, - 1186, - 1202, - 1204, - 1206, - 1210, - 1243, - 1245, - 1251, - 1270, - 1279, - 1282, - 1288, - 1292, - 1322, - 1331, - 1338, - 1371, - 1382, - 1384, - 1386, - 1415, - 1436, - 1444, - 1449, - 1457, - 1460, - 1489, - 1500, - 1568, - 1575, - 1581, - 1597, - 1612, - 1618, - 1662, - 1675, - 1680, -} - -function addons.onSay(player, words, param) - -- create log - logCommand(player, words, param) - - local target - if param == "" then - target = player:getTarget() - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Gives players the ability to wear all addons. Usage: /addaddons ") - return true - end - else - target = Player(param) - end - - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. param .. " is currently not online.") - return true - end - - if player:getAccountType() < ACCOUNT_TYPE_GOD then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Cannot perform action.") - return true - end - - for i = 1, #looktypes do - target:addOutfitAddon(looktypes[i], 3) - end - - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All addons unlocked for " .. target:getName() .. ".") - target:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All of your addons have been unlocked!") - return true -end - -addons:separator(" ") -addons:groupType("god") -addons:register() diff --git a/data/scripts/talkactions/god/add_mount.lua b/data/scripts/talkactions/god/add_mount.lua index b8b2f00dda1..5dc8c9a97fb 100644 --- a/data/scripts/talkactions/god/add_mount.lua +++ b/data/scripts/talkactions/god/add_mount.lua @@ -1,13 +1,7 @@ ---[[ - /addmount playername, mount -]] +local addmount = TalkAction("/addmount") -local printConsole = true - -local addOutfit = TalkAction("/addmount") - -function addOutfit.onSay(player, words, param) - -- create log +function addmount.onSay(player, words, param) + -- Create log logCommand(player, words, param) if param == "" then @@ -16,23 +10,41 @@ function addOutfit.onSay(player, words, param) end local split = param:split(",") - local name = split[1] - - local target = Player(name) - if target then - local mount = tonumber(split[2]) - target:addMount(mount) - target:sendTextMessage(MESSAGE_ADMINISTRATOR, "" .. player:getName() .. " has been added a new mount for you.") - player:sendTextMessage(MESSAGE_ADMINISTRATOR, "You have sucessfull added mount " .. mount .. " to the player " .. target:getName() .. ".") - if printConsole then - logger.info("[addOutfit.onSay] - Player: {} has been added mount: {} to the player: {}", player:getName(), lookType, target:getName()) - end + if #split < 2 then + player:sendCancelMessage("Usage: /addmount , ") + return true + end + + local playerName = split[1] + local target = Player(playerName) + + if not target then + player:sendCancelMessage("Player not found.") return true end - player:sendCancelMessage("Player not found.") + + local mountParam = string.trim(split[2]) + if mountParam == "all" then + for mountId = 1, 231 do + target:addMount(mountId) + end + + target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added all mounts to you.", player:getName())) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added all mounts to player %s.", target:getName())) + else + local mountId = tonumber(mountParam) + if not mountId then + player:sendCancelMessage("Invalid mount ID.") + return true + end + + target:addMount(mountId) + target:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added a new mount for you.", player:getName())) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added mount %d to player %s.", mountId, target:getName())) + end return true end -addOutfit:separator(" ") -addOutfit:groupType("god") -addOutfit:register() +addmount:separator(" ") +addmount:groupType("god") +addmount:register() diff --git a/data/scripts/talkactions/god/add_mounts.lua b/data/scripts/talkactions/god/add_mounts.lua deleted file mode 100644 index 3de09916505..00000000000 --- a/data/scripts/talkactions/god/add_mounts.lua +++ /dev/null @@ -1,32 +0,0 @@ --- /addmounts playername - -local mounts = TalkAction("/addmounts") -function mounts.onSay(player, words, param) - local target - if param == "" then - target = player:getTarget() - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Unlocks all mounts for certain player. Usage: /mounts ") - return true - end - else - target = Player(param) - end - - if not target then - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Player " .. param .. " is not currently online.") - return true - end - - for i = 1, 221 do - target:addMount(i) - end - - player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All mounts unlocked for: " .. target:getName()) - target:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All of your mounts have been unlocked!") - return true -end - -mounts:separator(" ") -mounts:groupType("god") -mounts:register() diff --git a/data/scripts/talkactions/god/add_outfit.lua b/data/scripts/talkactions/god/add_outfit.lua deleted file mode 100644 index a27fb4f8a18..00000000000 --- a/data/scripts/talkactions/god/add_outfit.lua +++ /dev/null @@ -1,42 +0,0 @@ ---[[ - /addoutfit playername, looktype - make sure you’re adding a male outfit to a male character - if you try to add a female outfit to a male character, it won’t work -]] - -local printConsole = true - -local addOutfit = TalkAction("/addoutfit") - -function addOutfit.onSay(player, words, param) - -- create log - logCommand(player, words, param) - - if param == "" then - player:sendCancelMessage("Command param required.") - return true - end - - local split = param:split(",") - local name = split[1] - - local target = Player(name) - if target then - local lookType = tonumber(split[2]) - target:addOutfit(lookType) - target:sendTextMessage(MESSAGE_ADMINISTRATOR, "" .. player:getName() .. " has been added a new outfit for you.") - player:sendTextMessage(MESSAGE_ADMINISTRATOR, "You have sucessfull added looktype " .. lookType .. " to the player " .. target:getName() .. ".") - if printConsole then - logger.info("[addOutfit.onSay] - Player: {} has been added looktype: {} to the player: {}", player:getName(), lookType, target:getName()) - end - return true - else - player:sendCancelMessage("Player not found.") - return true - end - return true -end - -addOutfit:separator(" ") -addOutfit:groupType("god") -addOutfit:register() diff --git a/data/scripts/talkactions/god/add_skill.lua b/data/scripts/talkactions/god/add_skill.lua index 09d240ece4d..3d082f656af 100644 --- a/data/scripts/talkactions/god/add_skill.lua +++ b/data/scripts/talkactions/god/add_skill.lua @@ -1,25 +1,20 @@ +local skillMap = { + club = SKILL_CLUB, + sword = SKILL_SWORD, + axe = SKILL_AXE, + dist = SKILL_DISTANCE, + shield = SKILL_SHIELD, + fish = SKILL_FISHING, +} + local function getSkillId(skillName) - if skillName == "club" then - return SKILL_CLUB - elseif skillName == "sword" then - return SKILL_SWORD - elseif skillName == "axe" then - return SKILL_AXE - elseif skillName:sub(1, 4) == "dist" then - return SKILL_DISTANCE - elseif skillName:sub(1, 6) == "shield" then - return SKILL_SHIELD - elseif skillName:sub(1, 4) == "fish" then - return SKILL_FISHING - else - return SKILL_FIST - end + return skillMap[skillName:match("^%a+")] or SKILL_FIST end local addSkill = TalkAction("/addskill") function addSkill.onSay(player, words, param) - -- create log + -- Create log logCommand(player, words, param) if param == "" then @@ -28,39 +23,51 @@ function addSkill.onSay(player, words, param) end local split = param:split(",") - if not split[2] then - player:sendCancelMessage("Insufficient parameters.") + if #split < 2 then + player:sendCancelMessage("Usage: /addskill , , [amount]") return true end - local target = Player(split[1]) - if not target then - player:sendCancelMessage("A player with that name is not online.") + local targetPlayerName = split[1]:trim() + local targetPlayer = Player(targetPlayerName) + + if not targetPlayer then + player:sendCancelMessage("Player not found.") return true end - split[2] = split[2]:trimSpace() + local skillParam = split[2]:trim() + local skillIncreaseAmount = tonumber(split[3]) or 1 + local skillPrefix = skillParam:sub(1, 1) - local count = 1 - if split[3] then - count = tonumber(split[3]) - end + if skillPrefix == "l" then + local targetNewLevel = targetPlayer:getLevel() + skillIncreaseAmount + local targetNewExp = Game.getExperienceForLevel(targetNewLevel) + local experienceToAdd = targetNewExp - targetPlayer:getExperience() + local levelText = (skillIncreaseAmount > 1) and "levels" or "level" - local ch = split[2]:sub(1, 1) - if ch == "l" or ch == "e" then - targetLevel = target:getLevel() + count - targetExp = Game.getExperienceForLevel(targetLevel) - addExp = targetExp - target:getExperience() - target:addExperience(addExp, false) - elseif ch == "m" then - for i = 1, count do - target:addManaSpent(target:getVocation():getRequiredManaSpent(target:getBaseMagicLevel() + 1) - target:getManaSpent(), true) + targetPlayer:addExperience(experienceToAdd, false) + targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added %d %s to you.", player:getName(), skillIncreaseAmount, levelText)) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added %d %s to player %s.", skillIncreaseAmount, levelText, targetPlayer:getName())) + elseif skillPrefix == "m" then + for _ = 1, skillIncreaseAmount do + local requiredManaSpent = targetPlayer:getVocation():getRequiredManaSpent(targetPlayer:getBaseMagicLevel() + 1) + targetPlayer:addManaSpent(requiredManaSpent - targetPlayer:getManaSpent(), true) end + + local magicText = (skillIncreaseAmount > 1) and "magic levels" or "magic level" + targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added %d %s to you.", player:getName(), skillIncreaseAmount, magicText)) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added %d %s to player %s.", skillIncreaseAmount, magicText, targetPlayer:getName())) else - local skillId = getSkillId(split[2]) - for i = 1, count do - target:addSkillTries(skillId, target:getVocation():getRequiredSkillTries(skillId, target:getSkillLevel(skillId) + 1) - target:getSkillTries(skillId), true) + local skillId = getSkillId(skillParam) + for _ = 1, skillIncreaseAmount do + local requiredSkillTries = targetPlayer:getVocation():getRequiredSkillTries(skillId, targetPlayer:getSkillLevel(skillId) + 1) + targetPlayer:addSkillTries(skillId, requiredSkillTries - targetPlayer:getSkillTries(skillId), true) end + + local skillText = (skillIncreaseAmount > 1) and "skill levels" or "skill level" + targetPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("%s has added %d %s %s to you.", player:getName(), skillIncreaseAmount, skillParam, skillText)) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("You have successfully added %d %s %s to player %s.", skillIncreaseAmount, skillParam, skillText, targetPlayer:getName())) end return true end diff --git a/data/scripts/talkactions/god/manage_monster.lua b/data/scripts/talkactions/god/manage_monster.lua index da110d59265..106acefa078 100644 --- a/data/scripts/talkactions/god/manage_monster.lua +++ b/data/scripts/talkactions/god/manage_monster.lua @@ -1,37 +1,38 @@ -local function createCreaturesAround(player, maxRadius, creatureName, creatureCount, creatureForge, boolForceCreate) - local position = player:getPosition() - local createdCount = 0 +local function createCreaturesAround(player, maxRadius, creatureName, creatureCount, creatureForge, forceCreateMonsters) + local playerPosition = player:getPosition() + local createdCreatureCount = 0 local sendMessage = false local canSetFiendish, canSetInfluenced, influencedLevel = CheckDustLevel(creatureForge, player) + for radius = 1, maxRadius do - if createdCount >= creatureCount then + if createdCreatureCount >= creatureCount then break end - local minX = position.x - radius - local maxX = position.x + radius - local minY = position.y - radius - local maxY = position.y + radius + local minX, maxX = playerPosition.x - radius, playerPosition.x + radius + local minY, maxY = playerPosition.y - radius, playerPosition.y + radius for dx = minX, maxX do for dy = minY, maxY do - if (dx == minX or dx == maxX or dy == minY or dy == maxY) and createdCount < creatureCount then - local checkPosition = Position(dx, dy, position.z) + if (dx == minX or dx == maxX or dy == minY or dy == maxY) and createdCreatureCount < creatureCount then + local checkPosition = Position(dx, dy, playerPosition.z) local tile = Tile(checkPosition) if tile and not tile:hasProperty(CONST_PROP_IMMOVABLEBLOCKSOLID) then - local monster = Game.createMonster(creatureName, checkPosition, false, boolForceCreate) + local monster = Game.createMonster(creatureName, checkPosition, false, forceCreateMonsters) if monster then - createdCount = createdCount + 1 + createdCreatureCount = createdCreatureCount + 1 monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT) - position:sendMagicEffect(CONST_ME_MAGIC_RED) - if creatureForge ~= nil and monster:isForgeable() then + playerPosition:sendMagicEffect(CONST_ME_MAGIC_RED) + + if creatureForge and monster:isForgeable() then local monsterType = monster:getType() if canSetFiendish then - SetFiendish(monsterType, position, player, monster) + SetFiendish(monsterType, playerPosition, player, monster) end + if canSetInfluenced then SetInfluenced(monsterType, monster, player, influencedLevel) end - elseif notSendMessage then + elseif not sendMessage then sendMessage = true end end @@ -40,86 +41,58 @@ local function createCreaturesAround(player, maxRadius, creatureName, creatureCo end end end - if sendMessage == true then + + if sendMessage then player:sendCancelMessage("Only allowed monsters can be fiendish or influenced.") end - - logger.info("Player {} created '{}' monsters", player:getName(), createdCount) end local createMonster = TalkAction("/m") --- @function createMonster.onSay --- @desc TalkAction to create monsters with multiple options. --- @param player: The player executing the command. --- @param words: Command words. --- @param param: String containing the command parameters. --- Format: "/m monstername, monstercount, [fiendish/influenced level], spawnRadius, [forceCreate]" --- Example: "/m rat, 10, fiendish, 5, true" --- @param: the last param is by default "false", if add "," or any value it's set to true --- @return true if the command is executed successfully, false otherwise. function createMonster.onSay(player, words, param) -- create log logCommand(player, words, param) + if param == "" then player:sendCancelMessage("Monster name param required.") - logger.error("[createMonster.onSay] - Monster name param not found.") return true end - local position = player:getPosition() - - local split = param:split(",") - local monsterName = split[1] - local monsterCount = 0 - if split[2] then - split[2] = split[2]:trimSpace() - monsterCount = tonumber(split[2]) - end - - local monsterForge = nil - if split[3] then - split[3] = split[3]:trimSpace() - monsterForge = split[3] - end + local playerPosition = player:getPosition() + local splitParams = param:split(",") + local monsterName = splitParams[1] + local monsterCount = tonumber(splitParams[2] or 1) + local monsterForge = splitParams[3] and splitParams[3]:trimSpace() or nil + local spawnRadius = tonumber(splitParams[4] or 5) + local forceCreate = splitParams[5] and true or false if monsterCount > 1 then - local spawnRadius = 5 - if split[4] then - split[4] = split[4]:trimSpace() - spawnRadius = split[4] - print(spawnRadius) - end - - local forceCreate = false - if split[5] then - forceCreate = true - end - createCreaturesAround(player, spawnRadius, monsterName, monsterCount, monsterForge, forceCreate) return true end - local monster = Game.createMonster(monsterName, position) + local monster = Game.createMonster(monsterName, playerPosition) if monster then local canSetFiendish, canSetInfluenced, influencedLevel = CheckDustLevel(monsterForge, player) monster:getPosition():sendMagicEffect(CONST_ME_TELEPORT) - position:sendMagicEffect(CONST_ME_MAGIC_RED) - if monsterForge ~= nil and not monster:isForgeable() then + playerPosition:sendMagicEffect(CONST_ME_MAGIC_RED) + + if monsterForge and not monster:isForgeable() then player:sendCancelMessage("Only allowed monsters can be fiendish or influenced.") return true end local monsterType = monster:getType() if canSetFiendish then - SetFiendish(monsterType, position, player, monster) + SetFiendish(monsterType, playerPosition, player, monster) end + if canSetInfluenced then SetInfluenced(monsterType, monster, player, influencedLevel) end else player:sendCancelMessage("There is not enough room.") - position:sendMagicEffect(CONST_ME_POFF) + playerPosition:sendMagicEffect(CONST_ME_POFF) end return true end @@ -128,29 +101,27 @@ createMonster:separator(" ") createMonster:groupType("god") createMonster:register() ------------------ Rename monster name ----------------- local setMonsterName = TalkAction("/setmonstername") --- @function setMonsterName.onSay --- @desc TalkAction to rename nearby monsters within a radius of 4 sqm. --- Format: "/setmonstername newName" function setMonsterName.onSay(player, words, param) + -- create log + logCommand(player, words, param) + if param == "" then player:sendCancelMessage("Command param required.") return true end - local split = param:split(",") - local monsterNewName = split[1] - + local splitParams = param:split(",") + local newMonsterName = splitParams[1] local spectators, spectator = Game.getSpectators(player:getPosition(), false, false, 4, 4, 4, 4) + for i = 1, #spectators do spectator = spectators[i] if spectator:isMonster() then - spectator:setName(monsterNewName) + spectator:setName(newMonsterName) end end - return true end diff --git a/data/scripts/talkactions/player/vip.lua b/data/scripts/talkactions/player/vip.lua index 65ca4be99f8..a80f6dd54dc 100644 --- a/data/scripts/talkactions/player/vip.lua +++ b/data/scripts/talkactions/player/vip.lua @@ -1,12 +1,10 @@ local vip = TalkAction("!checkvip", "!vip") function vip.onSay(player, words, param) - if not player:isVip() then - local msg = "You do not have VIP on your account." - player:sendCancelMessage(msg) - player:sendTextMessage(MESSAGE_STATUS, msg) + if player:isVip() then + player:sendVipStatus() else - CheckPremiumAndPrint(player, MESSAGE_STATUS) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You do not have VIP on your account.") end return true end