diff --git a/config.lua.dist b/config.lua.dist index 88d0eff156c..a9dd892269b 100644 --- a/config.lua.dist +++ b/config.lua.dist @@ -24,6 +24,8 @@ maintainModeMessage = "" -- Combat settings -- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced" +-- NOTE: removeBeginningWeaponAmmunition: spears, arrows, bolt have endless ammo (allows training for paladins) +-- NOTE: refundManaOnBeginningWeapons: wand of vortex and snakebite refund mana used (allows training for mages) worldType = "pvp" hotkeyAimbotEnabled = true protectionLevel = 7 @@ -32,6 +34,8 @@ removeChargesFromRunes = true removeChargesFromPotions = true removeWeaponAmmunition = true removeWeaponCharges = true +removeBeginningWeaponAmmunition = true +refundBeginningWeaponMana = false timeToDecreaseFrags = 24 * 60 * 60 * 1000 whiteSkullTime = 15 * 60 * 1000 stairJumpExhaustion = 2 * 1000 diff --git a/data-otservbr-global/lib/core/storages.lua b/data-otservbr-global/lib/core/storages.lua index bd0a1c135f5..93e2bf9364d 100644 --- a/data-otservbr-global/lib/core/storages.lua +++ b/data-otservbr-global/lib/core/storages.lua @@ -2767,6 +2767,7 @@ Storage = { GoshnarMegalomaniaKilled = 47222, QuestReward = 47223, OutfitReward = 47224, + MountReward = 47225, }, }, U12_60 = { -- update 12.60 - Reserved Storages 47501 - 47600 diff --git a/data-otservbr-global/monster/demons/vexclaw.lua b/data-otservbr-global/monster/demons/vexclaw.lua index 9a6e1666209..d13f5a5087d 100644 --- a/data-otservbr-global/monster/demons/vexclaw.lua +++ b/data-otservbr-global/monster/demons/vexclaw.lua @@ -107,7 +107,11 @@ monster.loot = { { name = "platinum amulet", chance = 940 }, { name = "devil helmet", chance = 520 }, { name = "rift crossbow", chance = 370 }, + { name = "rift bow", chance = 370 }, + { name = "rift shield", chance = 370 }, + { name = "demon shield", chance = 370 }, { name = "magic plate armor", chance = 70 }, + { name = "golden legs", chance = 50 }, { name = "demonrage sword", chance = 30 }, } diff --git a/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua b/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua index c422f817bb2..1f3f3ba37b4 100644 --- a/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua +++ b/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua @@ -14,7 +14,7 @@ monster.outfit = { } monster.events = { - "VesperothDeath", + "VersperothDeath", } monster.health = 100000 @@ -84,16 +84,16 @@ monster.defenses = { } monster.elements = { - { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, - { type = COMBAT_ENERGYDAMAGE, percent = 0 }, + { type = COMBAT_PHYSICALDAMAGE, percent = 30 }, + { type = COMBAT_ENERGYDAMAGE, percent = 45 }, { type = COMBAT_EARTHDAMAGE, percent = 0 }, - { type = COMBAT_FIREDAMAGE, percent = 90 }, + { type = COMBAT_FIREDAMAGE, percent = 50 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 0 }, - { type = COMBAT_HOLYDAMAGE, percent = 0 }, - { type = COMBAT_DEATHDAMAGE, percent = 0 }, + { type = COMBAT_ICEDAMAGE, percent = 45 }, + { type = COMBAT_HOLYDAMAGE, percent = 40 }, + { type = COMBAT_DEATHDAMAGE, percent = 55 }, } monster.immunities = { diff --git a/data-otservbr-global/monster/quests/feaster_of_souls/the_pale_worm.lua b/data-otservbr-global/monster/quests/feaster_of_souls/the_pale_worm.lua index bde610ee680..a2d99ab1f13 100644 --- a/data-otservbr-global/monster/quests/feaster_of_souls/the_pale_worm.lua +++ b/data-otservbr-global/monster/quests/feaster_of_souls/the_pale_worm.lua @@ -125,16 +125,16 @@ monster.defenses = { } monster.elements = { - { type = COMBAT_PHYSICALDAMAGE, percent = 90 }, - { type = COMBAT_ENERGYDAMAGE, percent = 90 }, - { type = COMBAT_EARTHDAMAGE, percent = 90 }, - { type = COMBAT_FIREDAMAGE, percent = 90 }, + { type = COMBAT_PHYSICALDAMAGE, percent = 5 }, + { type = COMBAT_ENERGYDAMAGE, percent = 5 }, + { type = COMBAT_EARTHDAMAGE, percent = 5 }, + { type = COMBAT_FIREDAMAGE, percent = 5 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 90 }, - { type = COMBAT_HOLYDAMAGE, percent = 90 }, - { type = COMBAT_DEATHDAMAGE, percent = 90 }, + { type = COMBAT_ICEDAMAGE, percent = 5 }, + { type = COMBAT_HOLYDAMAGE, percent = 5 }, + { type = COMBAT_DEATHDAMAGE, percent = 5 }, } monster.immunities = { diff --git a/data-otservbr-global/monster/quests/primal_ordeal_quest/the_end_of_days.lua b/data-otservbr-global/monster/quests/primal_ordeal_quest/the_end_of_days.lua index c81c27b95a9..8674c4e2bac 100644 --- a/data-otservbr-global/monster/quests/primal_ordeal_quest/the_end_of_days.lua +++ b/data-otservbr-global/monster/quests/primal_ordeal_quest/the_end_of_days.lua @@ -98,18 +98,4 @@ monster.immunities = { { type = "bleed", condition = false }, } -mType.onThink = function(monster, interval) end - -mType.onAppear = function(monster, creature) - if monster:getType():isRewardBoss() then - monster:setReward(true) - end -end - -mType.onDisappear = function(monster, creature) end - -mType.onMove = function(monster, creature, fromPosition, toPosition) end - -mType.onSay = function(monster, creature, type, message) end - mType:register(monster) diff --git a/data-otservbr-global/monster/quests/wrath_of_the_emperor/lizard_abomination.lua b/data-otservbr-global/monster/quests/wrath_of_the_emperor/lizard_abomination.lua index 9b0e18c6cc3..35d07338d44 100644 --- a/data-otservbr-global/monster/quests/wrath_of_the_emperor/lizard_abomination.lua +++ b/data-otservbr-global/monster/quests/wrath_of_the_emperor/lizard_abomination.lua @@ -42,7 +42,7 @@ monster.flags = { hostile = true, convinceable = false, pushable = false, - rewardBoss = true, + rewardBoss = false, illusionable = false, canPushItems = true, canPushCreatures = true, diff --git a/data-otservbr-global/monster/raids/ferumbras.lua b/data-otservbr-global/monster/raids/ferumbras.lua index fa2f348d871..40df72b86a9 100644 --- a/data-otservbr-global/monster/raids/ferumbras.lua +++ b/data-otservbr-global/monster/raids/ferumbras.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Ferumbras") local monster = {} monster.description = "Ferumbras" -monster.experience = 35000 +monster.experience = 12000 monster.outfit = { lookType = 229, lookHead = 0, diff --git a/data-otservbr-global/monster/trainers/training_machine.lua b/data-otservbr-global/monster/trainers/training_machine.lua index c5a98a9ce28..cb50c0a4532 100644 --- a/data-otservbr-global/monster/trainers/training_machine.lua +++ b/data-otservbr-global/monster/trainers/training_machine.lua @@ -14,7 +14,7 @@ monster.corpse = 0 monster.speed = 0 monster.changeTarget = { - interval = 1 * 1000, + interval = 1000, chance = 0, } @@ -49,13 +49,13 @@ monster.voices = { monster.loot = {} monster.attacks = { - { name = "melee", attack = 130, interval = 2 * 1000, minDamage = -1, maxDamage = -2 }, + { name = "melee", interval = 2000, chance = 100, minDamage = -2, maxDamage = -7, attack = 130 }, } monster.defenses = { - defense = 1, - armor = 1, - { name = "combat", type = COMBAT_HEALING, chance = 15, interval = 2 * 1000, minDamage = 10000, maxDamage = 50000, effect = CONST_ME_MAGIC_BLUE }, + defense = 10, + armor = 7, + { name = "combat", type = COMBAT_HEALING, chance = 15, interval = 2000, minDamage = 10000, maxDamage = 50000, effect = CONST_ME_MAGIC_BLUE }, } monster.elements = {} diff --git a/data-otservbr-global/npc/battlemart.lua b/data-otservbr-global/npc/battlemart.lua index 2461fc91129..b4b99993411 100644 --- a/data-otservbr-global/npc/battlemart.lua +++ b/data-otservbr-global/npc/battlemart.lua @@ -50,137 +50,173 @@ npcType.onCloseChannel = function(npc, creature) npcHandler:onCloseChannel(npc, creature) end -npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) - -npcConfig.shop = { - { itemName = "animate dead rune", clientId = 3203, buy = 375 }, - { itemName = "arrow", clientId = 3447, buy = 3 }, - { itemName = "assassin star", clientId = 7368, buy = 100 }, - { itemName = "avalanche rune", clientId = 3161, buy = 57 }, - { itemName = "backpack", clientId = 2854, buy = 20 }, - { itemName = "blank rune", clientId = 3147, buy = 10 }, - { itemName = "blue quiver", clientId = 35848, buy = 400 }, - { itemName = "bolt", clientId = 3446, buy = 4 }, - { itemName = "bow", clientId = 3350, buy = 400 }, - { itemName = "brown mushroom", clientId = 3725, buy = 10 }, - { itemName = "chameleon rune", clientId = 3178, buy = 210 }, - { itemName = "collar of blue plasma", clientId = 23542, buy = 60000 }, - { itemName = "collar of green plasma", clientId = 23543, buy = 60000 }, - { itemName = "collar of red plasma", clientId = 23544, buy = 60000 }, - { itemName = "convince creature rune", clientId = 3177, buy = 80 }, - { itemName = "crowbar", clientId = 3304, buy = 260 }, - { itemName = "crystalline arrow", clientId = 15793, buy = 20 }, - { itemName = "cure poison rune", clientId = 3153, buy = 65 }, - { itemName = "desintegrate rune", clientId = 3197, buy = 26 }, - { itemName = "destroy field rune", clientId = 3148, buy = 15 }, - { itemName = "diamond arrow", clientId = 35901, buy = 100 }, - { itemName = "drill bolt", clientId = 16142, buy = 12 }, - { itemName = "dwarven ring", clientId = 3097, buy = 2000 }, - { itemName = "earth arrow", clientId = 774, buy = 5 }, - { itemName = "enchanted spear", clientId = 7367, buy = 30 }, - { itemName = "energy bomb rune", clientId = 3149, buy = 203 }, - { itemName = "energy field rune", clientId = 3164, buy = 38 }, - { itemName = "energy ring", clientId = 3051, buy = 2000 }, - { itemName = "energy wall rune", clientId = 3166, buy = 85 }, - { itemName = "enhanced exercise axe", clientId = 35280, buy = 2340000 }, - { itemName = "enhanced exercise bow", clientId = 35282, buy = 2340000 }, - { itemName = "enhanced exercise club", clientId = 35281, buy = 2340000 }, - { itemName = "enhanced exercise rod", clientId = 35283, buy = 2340000 }, - { itemName = "enhanced exercise shield", clientId = 44066, buy = 2340000 }, - { itemName = "enhanced exercise sword", clientId = 35279, buy = 2340000 }, - { itemName = "enhanced exercise wand", clientId = 35284, buy = 2340000 }, - { itemName = "envenomed arrow", clientId = 16143, buy = 12 }, - { itemName = "exercise axe", clientId = 28553, buy = 1800000 }, - { itemName = "exercise bow", clientId = 28555, buy = 1800000 }, - { itemName = "exercise club", clientId = 28554, buy = 1800000 }, - { itemName = "exercise rod", clientId = 28556, buy = 1800000 }, - { itemName = "exercise sword", clientId = 28552, buy = 1800000 }, - { itemName = "exercise wand", clientId = 28557, buy = 1800000 }, - { itemName = "explosion rune", clientId = 3200, buy = 31 }, - { itemName = "fire bomb rune", clientId = 3192, buy = 147 }, - { itemName = "fire field rune", clientId = 3188, buy = 28 }, - { itemName = "fire mushroom", clientId = 3731, buy = 300 }, - { itemName = "fire wall rune", clientId = 3190, buy = 61 }, - { itemName = "fireball rune", clientId = 3189, buy = 30 }, - { itemName = "fishing rod", clientId = 3483, buy = 150 }, - { itemName = "flaming arrow", clientId = 763, buy = 5 }, - { itemName = "flash arrow", clientId = 761, buy = 5 }, - { itemName = "flask of rust remover", clientId = 9016, buy = 50 }, - { itemName = "gill necklace", clientId = 16108, buy = 20000 }, - { itemName = "glacier amulet", clientId = 815, buy = 15000 }, - { itemName = "great fireball rune", clientId = 3191, buy = 57 }, - { itemName = "great health potion", clientId = 239, buy = 225 }, - { itemName = "great mana potion", clientId = 238, buy = 144 }, - { itemName = "great spirit potion", clientId = 7642, buy = 228 }, - { itemName = "health potion", clientId = 266, buy = 50 }, - { itemName = "heavy magic missile rune", clientId = 3198, buy = 12 }, - { itemName = "holy missile rune", clientId = 3182, buy = 16 }, - { itemName = "hunting spear", clientId = 3347, buy = 25 }, - { itemName = "icicle rune", clientId = 3158, buy = 30 }, - { itemName = "intense healing rune", clientId = 3152, buy = 95 }, - { itemName = "leviathan's amulet", clientId = 9303, buy = 30000 }, - { itemName = "life ring", clientId = 3052, buy = 900 }, - { itemName = "light magic missile rune", clientId = 3174, buy = 4 }, - { itemName = "lightning pendant", clientId = 816, buy = 15000 }, - { itemName = "magic wall rune", clientId = 3180, buy = 116 }, - { itemName = "magma amulet", clientId = 817, buy = 15000 }, - { itemName = "mana potion", clientId = 268, buy = 56 }, - { itemName = "mana shield potion", clientId = 35563, buy = 200000 }, - { itemName = "masterful exercise axe", clientId = 35286, buy = 2700000 }, - { itemName = "masterful exercise bow", clientId = 35288, buy = 2700000 }, - { itemName = "masterful exercise club", clientId = 35287, buy = 2700000 }, - { itemName = "masterful exercise rod", clientId = 35289, buy = 2700000 }, - { itemName = "masterful exercise shield", clientId = 44067, buy = 2700000 }, - { itemName = "masterful exercise sword", clientId = 35285, buy = 2700000 }, - { itemName = "masterful exercise wand", clientId = 35290, buy = 2700000 }, - { itemName = "might ring", clientId = 3048, buy = 5000 }, - { itemName = "onyx arrow", clientId = 7365, buy = 7 }, - { itemName = "paralyze rune", clientId = 3165, buy = 700 }, - { itemName = "piercing bolt", clientId = 7363, buy = 5 }, - { itemName = "poison bomb rune", clientId = 3173, buy = 85 }, - { itemName = "poison field rune", clientId = 3172, buy = 21 }, - { itemName = "poison wall rune", clientId = 3176, buy = 52 }, - { itemName = "power bolt", clientId = 3450, buy = 7 }, - { itemName = "prismatic bolt", clientId = 16141, buy = 20 }, - { itemName = "prismatic necklace", clientId = 16113, buy = 20000 }, - { itemName = "prismatic ring", clientId = 16114, buy = 100000 }, - { itemName = "quiver", clientId = 35562, buy = 400 }, - { itemName = "red quiver", clientId = 35849, buy = 400 }, - { itemName = "ring of blue plasma", clientId = 23529, buy = 80000 }, - { itemName = "ring of green plasma", clientId = 23531, buy = 80000 }, - { itemName = "ring of healing", clientId = 3098, buy = 2000 }, - { itemName = "ring of red plasma", clientId = 23533, buy = 80000 }, - { itemName = "royal star", clientId = 25759, buy = 110 }, - { itemName = "sacred tree amulet", clientId = 9302, buy = 30000 }, - { itemName = "shiver arrow", clientId = 762, buy = 5 }, - { itemName = "shockwave amulet", clientId = 9304, buy = 30000 }, - { itemName = "sniper arrow", clientId = 7364, buy = 5 }, - { itemName = "soulfire rune", clientId = 3195, buy = 46 }, - { itemName = "spear", clientId = 3277, buy = 5 }, - { itemName = "spectral bolt", clientId = 35902, buy = 70 }, - { itemName = "stalagmite rune", clientId = 3179, buy = 12 }, - { itemName = "stealth ring", clientId = 3049, buy = 5000 }, - { itemName = "stone shower rune", clientId = 3175, buy = 37 }, - { itemName = "stone skin amulet", clientId = 3081, buy = 5000 }, - { itemName = "strong health potion", clientId = 236, buy = 115 }, - { itemName = "strong mana potion", clientId = 237, buy = 93 }, - { itemName = "sudden death rune", clientId = 3155, buy = 135 }, - { itemName = "supreme health potion", clientId = 23375, buy = 625 }, - { itemName = "tarsal arrow", clientId = 14251, buy = 6 }, - { itemName = "terra amulet", clientId = 814, buy = 15000 }, - { itemName = "throwing star", clientId = 3287, buy = 42 }, - { itemName = "thunderstorm rune", clientId = 3202, buy = 47 }, - { itemName = "time ring", clientId = 3053, buy = 2000 }, - { itemName = "torch", clientId = 2920, buy = 2 }, - { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, - { itemName = "ultimate health potion", clientId = 7643, buy = 379 }, - { itemName = "ultimate mana potion", clientId = 23373, buy = 438 }, - { itemName = "ultimate spirit potion", clientId = 23374, buy = 438 }, - { itemName = "vortex bolt", clientId = 14252, buy = 6 }, - { itemName = "wild growth rune", clientId = 3156, buy = 160 }, - { itemName = "worm", clientId = 3492, buy = 1 }, +local itemsTable = { + ["foods"] = { + { itemName = "brown mushroom", clientId = 3725, buy = 10 }, + { itemName = "fire mushroom", clientId = 3731, buy = 300 }, + }, + ["exercise weapons"] = { + { itemName = "enhanced exercise axe", clientId = 35280, buy = 2340000 }, + { itemName = "enhanced exercise bow", clientId = 35282, buy = 2340000 }, + { itemName = "enhanced exercise club", clientId = 35281, buy = 2340000 }, + { itemName = "enhanced exercise rod", clientId = 35283, buy = 2340000 }, + { itemName = "enhanced exercise shield", clientId = 44066, buy = 2340000 }, + { itemName = "enhanced exercise sword", clientId = 35279, buy = 2340000 }, + { itemName = "enhanced exercise wand", clientId = 35284, buy = 2340000 }, + { itemName = "exercise axe", clientId = 28553, buy = 1800000 }, + { itemName = "exercise bow", clientId = 28555, buy = 1800000 }, + { itemName = "exercise club", clientId = 28554, buy = 1800000 }, + { itemName = "exercise rod", clientId = 28556, buy = 1800000 }, + { itemName = "exercise sword", clientId = 28552, buy = 1800000 }, + { itemName = "exercise wand", clientId = 28557, buy = 1800000 }, + { itemName = "masterful exercise axe", clientId = 35286, buy = 2700000 }, + { itemName = "masterful exercise bow", clientId = 35288, buy = 2700000 }, + { itemName = "masterful exercise club", clientId = 35287, buy = 2700000 }, + { itemName = "masterful exercise rod", clientId = 35289, buy = 2700000 }, + { itemName = "masterful exercise shield", clientId = 44067, buy = 2700000 }, + { itemName = "masterful exercise sword", clientId = 35285, buy = 2700000 }, + { itemName = "masterful exercise wand", clientId = 35290, buy = 2700000 }, + }, + ["distance equipments"] = { + { itemName = "envenomed arrow", clientId = 16143, buy = 12 }, + { itemName = "diamond arrow", clientId = 35901, buy = 100 }, + { itemName = "drill bolt", clientId = 16142, buy = 12 }, + { itemName = "crystalline arrow", clientId = 15793, buy = 20 }, + { itemName = "blue quiver", clientId = 35848, buy = 400 }, + { itemName = "bolt", clientId = 3446, buy = 4 }, + { itemName = "bow", clientId = 3350, buy = 400 }, + { itemName = "arrow", clientId = 3447, buy = 3 }, + { itemName = "assassin star", clientId = 7368, buy = 100 }, + { itemName = "earth arrow", clientId = 774, buy = 5 }, + { itemName = "enchanted spear", clientId = 7367, buy = 30 }, + { itemName = "flaming arrow", clientId = 763, buy = 5 }, + { itemName = "flash arrow", clientId = 761, buy = 5 }, + { itemName = "royal star", clientId = 25759, buy = 110 }, + { itemName = "quiver", clientId = 35562, buy = 400 }, + { itemName = "red quiver", clientId = 35849, buy = 400 }, + { itemName = "power bolt", clientId = 3450, buy = 7 }, + { itemName = "piercing bolt", clientId = 7363, buy = 5 }, + { itemName = "onyx arrow", clientId = 7365, buy = 7 }, + { itemName = "prismatic bolt", clientId = 16141, buy = 20 }, + { itemName = "shiver arrow", clientId = 762, buy = 5 }, + { itemName = "sniper arrow", clientId = 7364, buy = 5 }, + { itemName = "spear", clientId = 3277, buy = 5 }, + { itemName = "spectral bolt", clientId = 35902, buy = 70 }, + { itemName = "throwing star", clientId = 3287, buy = 42 }, + { itemName = "tarsal arrow", clientId = 14251, buy = 6 }, + { itemName = "vortex bolt", clientId = 14252, buy = 6 }, + { itemName = "hunting spear", clientId = 3347, buy = 25 }, + }, + ["runes"] = { + { itemName = "avalanche rune", clientId = 3161, buy = 57 }, + { itemName = "blank rune", clientId = 3147, buy = 10 }, + { itemName = "chameleon rune", clientId = 3178, buy = 210 }, + { itemName = "animate dead rune", clientId = 3203, buy = 375 }, + { itemName = "convince creature rune", clientId = 3177, buy = 80 }, + { itemName = "cure poison rune", clientId = 3153, buy = 65 }, + { itemName = "desintegrate rune", clientId = 3197, buy = 26 }, + { itemName = "destroy field rune", clientId = 3148, buy = 15 }, + { itemName = "energy wall rune", clientId = 3166, buy = 85 }, + { itemName = "energy bomb rune", clientId = 3149, buy = 203 }, + { itemName = "energy field rune", clientId = 3164, buy = 38 }, + { itemName = "explosion rune", clientId = 3200, buy = 31 }, + { itemName = "fire bomb rune", clientId = 3192, buy = 147 }, + { itemName = "fire field rune", clientId = 3188, buy = 28 }, + { itemName = "fire wall rune", clientId = 3190, buy = 61 }, + { itemName = "fireball rune", clientId = 3189, buy = 30 }, + { itemName = "great fireball rune", clientId = 3191, buy = 57 }, + { itemName = "heavy magic missile rune", clientId = 3198, buy = 12 }, + { itemName = "holy missile rune", clientId = 3182, buy = 16 }, + { itemName = "icicle rune", clientId = 3158, buy = 30 }, + { itemName = "intense healing rune", clientId = 3152, buy = 95 }, + { itemName = "light magic missile rune", clientId = 3174, buy = 4 }, + { itemName = "magic wall rune", clientId = 3180, buy = 116 }, + { itemName = "paralyze rune", clientId = 3165, buy = 700 }, + { itemName = "poison bomb rune", clientId = 3173, buy = 85 }, + { itemName = "poison field rune", clientId = 3172, buy = 21 }, + { itemName = "poison wall rune", clientId = 3176, buy = 52 }, + { itemName = "stone shower rune", clientId = 3175, buy = 37 }, + { itemName = "stalagmite rune", clientId = 3179, buy = 12 }, + { itemName = "sudden death rune", clientId = 3155, buy = 135 }, + { itemName = "soulfire rune", clientId = 3195, buy = 46 }, + { itemName = "thunderstorm rune", clientId = 3202, buy = 47 }, + { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, + { itemName = "wild growth rune", clientId = 3156, buy = 160 }, + }, + ["tools"] = { + { itemName = "fishing rod", clientId = 3483, buy = 150 }, + { itemName = "flask of rust remover", clientId = 9016, buy = 50 }, + { itemName = "torch", clientId = 2920, buy = 2 }, + { itemName = "worm", clientId = 3492, buy = 1 }, + { itemName = "crowbar", clientId = 3304, buy = 260 }, + { itemName = "backpack", clientId = 2854, buy = 20 }, + }, + ["amulets"] = { + { itemName = "gill necklace", clientId = 16108, buy = 20000 }, + { itemName = "glacier amulet", clientId = 815, buy = 15000 }, + { itemName = "leviathan's amulet", clientId = 9303, buy = 30000 }, + { itemName = "magma amulet", clientId = 817, buy = 15000 }, + { itemName = "lightning pendant", clientId = 816, buy = 15000 }, + { itemName = "prismatic necklace", clientId = 16113, buy = 20000 }, + { itemName = "sacred tree amulet", clientId = 9302, buy = 30000 }, + { itemName = "shockwave amulet", clientId = 9304, buy = 30000 }, + { itemName = "stone skin amulet", clientId = 3081, buy = 5000 }, + { itemName = "collar of blue plasma", clientId = 23542, buy = 60000 }, + { itemName = "collar of green plasma", clientId = 23543, buy = 60000 }, + { itemName = "collar of red plasma", clientId = 23544, buy = 60000 }, + { itemName = "terra amulet", clientId = 814, buy = 15000 }, + }, + ["rings"] = { + { itemName = "life ring", clientId = 3052, buy = 900 }, + { itemName = "might ring", clientId = 3048, buy = 5000 }, + { itemName = "ring of blue plasma", clientId = 23529, buy = 80000 }, + { itemName = "ring of green plasma", clientId = 23531, buy = 80000 }, + { itemName = "ring of healing", clientId = 3098, buy = 2000 }, + { itemName = "prismatic ring", clientId = 16114, buy = 100000 }, + { itemName = "ring of red plasma", clientId = 23533, buy = 80000 }, + { itemName = "stealth ring", clientId = 3049, buy = 5000 }, + { itemName = "time ring", clientId = 3053, buy = 2000 }, + { itemName = "dwarven ring", clientId = 3097, buy = 2000 }, + { itemName = "energy ring", clientId = 3051, buy = 2000 }, + }, + ["potions"] = { + { itemName = "great health potion", clientId = 239, buy = 225 }, + { itemName = "great mana potion", clientId = 238, buy = 144 }, + { itemName = "great spirit potion", clientId = 7642, buy = 228 }, + { itemName = "health potion", clientId = 266, buy = 50 }, + { itemName = "mana potion", clientId = 268, buy = 56 }, + { itemName = "mana shield potion", clientId = 35563, buy = 200000 }, + { itemName = "ultimate health potion", clientId = 7643, buy = 379 }, + { itemName = "ultimate mana potion", clientId = 23373, buy = 438 }, + { itemName = "ultimate spirit potion", clientId = 23374, buy = 438 }, + { itemName = "supreme health potion", clientId = 23375, buy = 625 }, + { itemName = "strong health potion", clientId = 236, buy = 115 }, + { itemName = "strong mana potion", clientId = 237, buy = 93 }, + }, } +local function creatureSayCallback(npc, player, type, message) + local formattedCategoryNames = {} + for categoryName, _ in pairs(itemsTable) do + table.insert(formattedCategoryNames, "{" .. categoryName .. "}") + end + + local categoryTable = itemsTable[message:lower()] + if MsgContains(message, "shop options") then + npcHandler:say("I sell a selection of " .. table.concat(formattedCategoryNames, ", "), npc, player) + elseif categoryTable then + npcHandler:say("Here are the items for the category " .. message, npc, player) + npc:openShopWindowTable(player, categoryTable) + end +end + +npcHandler:setMessage(MESSAGE_GREET, "It is good to see you. I'm always at your {shop options}") +npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell, |PLAYERNAME|, I'll be here if you need me again.") +npcHandler:setMessage(MESSAGE_WALKAWAY, "Come back soon!") + +npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback) +npcHandler:addModule(FocusModule:new(), npcConfig.name, true, true, true) + -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) npc:sellItem(player, itemId, amount, subType, 0, ignore, inBackpacks) diff --git a/data-otservbr-global/npc/hireling.lua b/data-otservbr-global/npc/hireling.lua index 519ff32773a..11757bff0a5 100644 --- a/data-otservbr-global/npc/hireling.lua +++ b/data-otservbr-global/npc/hireling.lua @@ -30,300 +30,336 @@ function createHirelingType(HirelingName) floorchange = false, } - npcConfig.shop = { - { itemName = "amphora", clientId = 2893, buy = 4 }, - { itemName = "animate dead rune", clientId = 3203, buy = 377 }, - { itemName = "armor rack kit", clientId = 6111, buy = 90 }, - { itemName = "arrow", clientId = 3447, buy = 2 }, - { itemName = "avalanche rune", clientId = 3161, buy = 57 }, - { itemName = "axe", clientId = 3274, sell = 7 }, - { itemName = "bamboo drawer kit", clientId = 2465, buy = 20 }, - { itemName = "bamboo table kit", clientId = 2350, buy = 25 }, - { itemName = "barrel kit", clientId = 2523, buy = 12 }, - { itemName = "basket", clientId = 2855, buy = 6 }, - { itemName = "battle axe", clientId = 3266, sell = 80 }, - { itemName = "battle hammer", clientId = 3305, sell = 120 }, - { itemName = "big table kit", clientId = 2314, buy = 30 }, - { itemName = "birdcage kit", clientId = 2976, buy = 50 }, - { itemName = "blank rune", clientId = 3147, buy = 10 }, - { itemName = "blue footboard", clientId = 32482, buy = 40 }, - { itemName = "blue headboard", clientId = 32473, buy = 40 }, - { itemName = "blue pillow", clientId = 2394, buy = 25 }, - { itemName = "blue quiver", clientId = 35848, buy = 400 }, - { itemName = "blue tapestry", clientId = 2659, buy = 25 }, - { itemName = "bolt", clientId = 3446, buy = 4 }, - { itemName = "bone sword", clientId = 3338, sell = 20 }, - { itemName = "bookcase kit", clientId = 6370, buy = 70 }, - { itemName = "bottle", clientId = 2875, buy = 3 }, - { itemName = "bow", clientId = 3350, sell = 100 }, - { itemName = "box", clientId = 2469, buy = 10 }, - { itemName = "brass armor", clientId = 3359, sell = 150 }, - { itemName = "brass helmet", clientId = 3354, sell = 30 }, - { itemName = "brass legs", clientId = 3372, sell = 49 }, - { itemName = "brass shield", clientId = 3411, sell = 25 }, - { itemName = "brown mushroom", clientId = 3725, buy = 10 }, - { itemName = "bucket", clientId = 2873, buy = 4 }, - { itemName = "candelabrum", clientId = 2911, buy = 8 }, - { itemName = "candlestick", clientId = 2917, buy = 2 }, - { itemName = "canopy footboard", clientId = 32490, buy = 40 }, - { itemName = "canopy headboard", clientId = 32481, buy = 40 }, - { itemName = "carlin sword", clientId = 3283, sell = 118 }, - { itemName = "chain armor", clientId = 3358, sell = 70 }, - { itemName = "chain helmet", clientId = 3352, sell = 17 }, - { itemName = "chain legs", clientId = 3558, sell = 25 }, - { itemName = "chameleon rune", clientId = 3178, buy = 210 }, - { itemName = "chest of drawers", clientId = 2433, buy = 18 }, - { itemName = "chest", clientId = 2472, buy = 10 }, - { itemName = "chimney kit", clientId = 7860, buy = 200 }, - { itemName = "closed trap", clientId = 3481, sell = 75 }, - { itemName = "club", clientId = 3270, sell = 1 }, - { itemName = "coal basin kit", clientId = 3513, buy = 25 }, - { itemName = "coat", clientId = 3562, sell = 1 }, - { itemName = "convince creature rune", clientId = 3177, buy = 80 }, - { itemName = "cookie", clientId = 3598, buy = 2 }, - { itemName = "cot footboard", clientId = 32486, buy = 40 }, - { itemName = "cot headboard", clientId = 32477, buy = 40 }, - { itemName = "crate", clientId = 2471, buy = 10 }, - { itemName = "crossbow", clientId = 3349, sell = 120 }, - { itemName = "crowbar", clientId = 3304, sell = 50 }, - { itemName = "crystalline arrow", clientId = 15793, buy = 20 }, - { itemName = "cuckoo clock", clientId = 2664, buy = 40 }, - { itemName = "cure poison rune", clientId = 3153, buy = 65 }, - { itemName = "dagger", clientId = 3267, sell = 2 }, - { itemName = "destroy field rune", clientId = 3148, buy = 15 }, - { itemName = "diamond arrow", clientId = 35901, buy = 100 }, - { itemName = "disintegrate rune", clientId = 3197, buy = 26 }, - { itemName = "doublet", clientId = 3379, sell = 3 }, - { itemName = "dresser kit", clientId = 2441, buy = 25 }, - { itemName = "drill bolt", clientId = 16142, buy = 12 }, - { itemName = "dwarven shield", clientId = 3425, sell = 100 }, - { itemName = "earth arrow", clientId = 774, buy = 5 }, - { itemName = "empty potion flask", clientId = 283, sell = 5 }, - { itemName = "empty potion flask", clientId = 284, sell = 5 }, - { itemName = "empty potion flask", clientId = 285, sell = 5 }, - { itemName = "energy bomb rune", clientId = 3149, buy = 203 }, - { itemName = "energy field rune", clientId = 3164, buy = 38 }, - { itemName = "energy wall rune", clientId = 3166, buy = 85 }, - { itemName = "envenomed arrow", clientId = 16143, buy = 12 }, - { itemName = "exercise axe", clientId = 28553, buy = 262500 }, - { itemName = "exercise bow", clientId = 28555, buy = 262500 }, - { itemName = "exercise club", clientId = 28554, buy = 262500 }, - { itemName = "exercise rod", clientId = 28556, buy = 262500 }, - { itemName = "exercise shield", clientId = 44065, buy = 262500 }, - { itemName = "exercise sword", clientId = 28552, buy = 262500 }, - { itemName = "exercise wand", clientId = 28557, buy = 262500 }, - { itemName = "durable exercise axe", clientId = 35280, buy = 945000 }, - { itemName = "durable exercise bow", clientId = 35282, buy = 945000 }, - { itemName = "durable exercise club", clientId = 35281, buy = 945000 }, - { itemName = "durable exercise rod", clientId = 35283, buy = 945000 }, - { itemName = "durable exercise shield", clientId = 44066, buy = 945000 }, - { itemName = "durable exercise sword", clientId = 35279, buy = 945000 }, - { itemName = "durable exercise wand", clientId = 35284, buy = 945000 }, - { itemName = "lasting exercise axe", clientId = 35286, buy = 7560000 }, - { itemName = "lasting exercise bow", clientId = 35288, buy = 7560000 }, - { itemName = "lasting exercise club", clientId = 35287, buy = 7560000 }, - { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000 }, - { itemName = "lasting exercise shield", clientId = 44067, buy = 7560000 }, - { itemName = "lasting exercise sword", clientId = 35285, buy = 7560000 }, - { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000 }, - { itemName = "explosion rune", clientId = 3200, buy = 31 }, - { itemName = "fire bomb rune", clientId = 3192, buy = 147 }, - { itemName = "fire field rune", clientId = 3188, buy = 28 }, - { itemName = "fire wall rune", clientId = 3190, buy = 61 }, - { itemName = "fireball rune", clientId = 3189, buy = 30 }, - { itemName = "fireworks rocket", clientId = 6576, buy = 100 }, - { itemName = "fishing rod", clientId = 3483, sell = 40 }, - { itemName = "flaming arrow", clientId = 763, buy = 5 }, - { itemName = "flash arrow", clientId = 761, buy = 5 }, - { itemName = "flower bowl", clientId = 2983, buy = 6 }, - { itemName = "globe", clientId = 2979, buy = 50 }, - { itemName = "goblin statue kit", clientId = 2030, buy = 50 }, - { itemName = "god flowers", clientId = 2981, buy = 5 }, - { itemName = "goldfish bowl", clientId = 5928, buy = 50 }, - { itemName = "great fireball rune", clientId = 3191, buy = 57 }, - { itemName = "great health potion", clientId = 239, buy = 225 }, - { itemName = "great mana potion", clientId = 238, buy = 144 }, - { itemName = "great spirit potion", clientId = 7642, buy = 228 }, - { itemName = "green balloons", clientId = 6577, buy = 500 }, - { itemName = "green cushioned chair kit", clientId = 2378, buy = 40 }, - { itemName = "green footboard", clientId = 32483, buy = 40 }, - { itemName = "green headboard", clientId = 32474, buy = 40 }, - { itemName = "green pillow", clientId = 2396, buy = 25 }, - { itemName = "green tapestry", clientId = 2647, buy = 25 }, - { itemName = "hailstorm rod", clientId = 3067, buy = 13526 }, - { itemName = "ham", clientId = 3582, buy = 10 }, - { itemName = "hammock foot section", clientId = 32487, buy = 40 }, - { itemName = "hammock head section", clientId = 32478, buy = 40 }, - { itemName = "hand axe", clientId = 3268, sell = 4 }, - { itemName = "harp kit", clientId = 2963, buy = 50 }, - { itemName = "health potion", clientId = 266, buy = 50 }, - { itemName = "heart pillow", clientId = 2393, buy = 30 }, - { itemName = "heavy magic missile rune", clientId = 3198, buy = 12 }, - { itemName = "holy missile rune", clientId = 3182, buy = 16 }, - { itemName = "honey flower", clientId = 2984, buy = 5 }, - { itemName = "icicle rune", clientId = 3158, buy = 30 }, - { itemName = "indoor plant kit", clientId = 2982, buy = 8 }, - { itemName = "intense healing rune", clientId = 3152, buy = 95 }, - { itemName = "iron helmet", clientId = 3353, sell = 150 }, - { itemName = "ivory chair kit", clientId = 2422, buy = 25 }, - { itemName = "jacket", clientId = 3561, sell = 1 }, - { itemName = "knight statue kit", clientId = 2025, buy = 50 }, - { itemName = "label", clientId = 3507, buy = 1 }, - { itemName = "large amphora kit", clientId = 2904, buy = 50 }, - { itemName = "large trunk", clientId = 2483, buy = 10 }, - { itemName = "leather armor", clientId = 3361, sell = 12 }, - { itemName = "leather boots", clientId = 3552, sell = 2 }, - { itemName = "leather helmet", clientId = 3355, sell = 4 }, - { itemName = "leather legs", clientId = 3559, sell = 9 }, - { itemName = "letter", clientId = 3505, buy = 8 }, - { itemName = "light magic missile rune", clientId = 3174, buy = 4 }, - { itemName = "locker kit", clientId = 2449, buy = 30 }, - { itemName = "longsword", clientId = 3285, sell = 51 }, - { itemName = "mace", clientId = 3286, sell = 30 }, - { itemName = "machete", clientId = 3308, sell = 6 }, - { itemName = "magic wall rune", clientId = 3180, buy = 116 }, - { itemName = "mana potion", clientId = 268, buy = 56 }, - { itemName = "meat", clientId = 3577, buy = 5 }, - { itemName = "minotaur statue kit", clientId = 2029, buy = 50 }, - { itemName = "moonlight rod", clientId = 3070, buy = 1245 }, - { itemName = "morning star", clientId = 3282, sell = 100 }, - { itemName = "necrotic rod", clientId = 3069, buy = 4999 }, - { itemName = "northwind rod", clientId = 8083, buy = 7500 }, - { itemName = "onyx arrow", clientId = 7365, buy = 7 }, - { itemName = "orange tapestry", clientId = 2653, buy = 25 }, - { itemName = "oven kit", clientId = 6355, buy = 80 }, - { itemName = "paralyse rune", clientId = 3165, buy = 700 }, - { itemName = "parcel", clientId = 3503, buy = 15 }, - { itemName = "party hat", clientId = 6578, buy = 800 }, - { itemName = "party trumpet", clientId = 6572, buy = 500 }, - { itemName = "pendulum clock kit", clientId = 2445, buy = 75 }, - { itemName = "piano kit", clientId = 2959, buy = 200 }, - { itemName = "pick", clientId = 3456, sell = 15 }, - { itemName = "piercing bolt", clientId = 7363, buy = 5 }, - { itemName = "plate armor", clientId = 3357, sell = 400 }, - { itemName = "plate shield", clientId = 3410, sell = 45 }, - { itemName = "poison bomb rune", clientId = 3173, buy = 85 }, - { itemName = "poison field rune", clientId = 3172, buy = 21 }, - { itemName = "poison wall rune", clientId = 3176, buy = 52 }, - { itemName = "potted flower", clientId = 2985, buy = 5 }, - { itemName = "power bolt", clientId = 3450, buy = 7 }, - { itemName = "present", clientId = 2856, buy = 10 }, - { itemName = "prismatic bolt", clientId = 16141, buy = 20 }, - { itemName = "purple tapestry", clientId = 2644, buy = 25 }, - { itemName = "quiver", clientId = 35562, buy = 400 }, - { itemName = "rapier", clientId = 3272, sell = 5 }, - { itemName = "red balloons", clientId = 6575, buy = 500 }, - { itemName = "red cushioned chair kit", clientId = 2374, buy = 40 }, - { itemName = "red footboard", clientId = 32484, buy = 40 }, - { itemName = "red headboard", clientId = 32475, buy = 40 }, - { itemName = "red pillow", clientId = 2395, buy = 25 }, - { itemName = "red quiver", clientId = 35849, buy = 400 }, - { itemName = "red tapestry", clientId = 2656, buy = 25 }, - { itemName = "rocking horse", clientId = 2998, buy = 30 }, - { itemName = "rope", clientId = 3003, sell = 15 }, - { itemName = "round blue pillow", clientId = 2398, buy = 25 }, - { itemName = "round purple pillow", clientId = 2400, buy = 25 }, - { itemName = "round red pillow", clientId = 2399, buy = 25 }, - { itemName = "round turquoise pillow", clientId = 2401, buy = 25 }, - { itemName = "royal spear", clientId = 7378, buy = 15 }, - { itemName = "sabre", clientId = 3273, sell = 12 }, - { itemName = "scale armor", clientId = 3377, sell = 75 }, - { itemName = "scythe", clientId = 3453, sell = 10 }, - { itemName = "shiver arrow", clientId = 762, buy = 5 }, - { itemName = "short sword", clientId = 3294, sell = 10 }, - { itemName = "shovel", clientId = 3457, sell = 8 }, - { itemName = "sickle", clientId = 3293, sell = 3 }, - { itemName = "simple footboard", clientId = 32488, buy = 40 }, - { itemName = "simple headboard", clientId = 32479, buy = 40 }, - { itemName = "small blue pillow", clientId = 2389, buy = 20 }, - { itemName = "small green pillow", clientId = 2387, buy = 20 }, - { itemName = "small ice statue", clientId = 7448, buy = 50 }, - { itemName = "small orange pillow", clientId = 2390, buy = 20 }, - { itemName = "small purple pillow", clientId = 2386, buy = 20 }, - { itemName = "small red pillow", clientId = 2388, buy = 20 }, - { itemName = "small round table", clientId = 2316, buy = 25 }, - { itemName = "small table kit", clientId = 2319, buy = 20 }, - { itemName = "small trunk", clientId = 2426, buy = 20 }, - { itemName = "small turquoise pillow", clientId = 2391, buy = 20 }, - { itemName = "small white pillow", clientId = 2392, buy = 20 }, - { itemName = "snakebite rod", clientId = 3066, buy = 500 }, - { itemName = "sniper arrow", clientId = 7364, buy = 5 }, - { itemName = "sofa chair kit", clientId = 2366, buy = 55 }, - { itemName = "soldier helmet", clientId = 3375, sell = 16 }, - { itemName = "soulfire rune", clientId = 3195, buy = 46 }, - { itemName = "spear", clientId = 3277, sell = 3 }, - { itemName = "spectral bolt", clientId = 35902, buy = 70 }, - { itemName = "spellwand", clientId = 651, sell = 299 }, - { itemName = "spike sword", clientId = 3271, sell = 240 }, - { itemName = "springsprout rod", clientId = 8084, buy = 15468 }, - { itemName = "square table kit", clientId = 2315, buy = 25 }, - { itemName = "stalagmite rune", clientId = 3179, buy = 12 }, - { itemName = "steel helmet", clientId = 3351, sell = 293 }, - { itemName = "steel shield", clientId = 3409, sell = 80 }, - { itemName = "stone shower rune", clientId = 3175, buy = 37 }, - { itemName = "stone table kit", clientId = 2347, buy = 30 }, - { itemName = "straw mat foot section", clientId = 32489, buy = 40 }, - { itemName = "straw mat head section", clientId = 32480, buy = 40 }, - { itemName = "strong health potion", clientId = 236, buy = 115 }, - { itemName = "strong mana potion", clientId = 237, buy = 93 }, - { itemName = "studded armor", clientId = 3378, sell = 25 }, - { itemName = "studded helmet", clientId = 3376, sell = 20 }, - { itemName = "studded legs", clientId = 3362, sell = 15 }, - { itemName = "studded shield", clientId = 3426, sell = 16 }, - { itemName = "sudden death rune", clientId = 3155, buy = 135 }, - { itemName = "supreme health potion", clientId = 23375, buy = 625 }, - { itemName = "sword", clientId = 3264, sell = 25 }, - { itemName = "table lamp kit", clientId = 2934, buy = 35 }, - { itemName = "tarsal arrow", clientId = 14251, buy = 6 }, - { itemName = "telescope kit", clientId = 3485, buy = 70 }, - { itemName = "terra rod", clientId = 3065, buy = 10000 }, - { itemName = "thick trunk", clientId = 2352, buy = 20 }, - { itemName = "throwing knife", clientId = 3298, sell = 2 }, - { itemName = "throwing star", clientId = 3287, buy = 42 }, - { itemName = "thunderstorm rune", clientId = 3202, buy = 47 }, - { itemName = "torch", clientId = 2920, buy = 2 }, - { itemName = "treasure chest", clientId = 2478, buy = 1245 }, - { itemName = "trophy stand", clientId = 872, buy = 50 }, - { itemName = "trough kit", clientId = 2524, buy = 7 }, - { itemName = "tusk chair kit", clientId = 2418, buy = 25 }, - { itemName = "tusk table kit", clientId = 2348, buy = 25 }, - { itemName = "two handed sword", clientId = 3265, sell = 456 }, - { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, - { itemName = "ultimate health potion", clientId = 7643, buy = 381 }, - { itemName = "ultimate mana potion", clientId = 23373, buy = 443 }, - { itemName = "ultimate spirit potion", clientId = 23374, buy = 443 }, - { itemName = "underworld rod", clientId = 8082, buy = 19666 }, - { itemName = "vase", clientId = 2876, buy = 3 }, - { itemName = "venorean cabinet", clientId = 18015, buy = 90 }, - { itemName = "venorean drawer", clientId = 18019, buy = 40 }, - { itemName = "venorean wardrobe", clientId = 18017, buy = 50 }, - { itemName = "vial", clientId = 2874, sell = 5 }, - { itemName = "viking helmet", clientId = 3367, sell = 66 }, - { itemName = "viking shield", clientId = 3431, sell = 85 }, - { itemName = "vortex bolt", clientId = 14252, buy = 6 }, - { itemName = "wall mirror", clientId = 2632, buy = 40 }, - { itemName = "wand of cosmic energy", clientId = 3073, buy = 9087 }, - { itemName = "wand of decay", clientId = 3072, buy = 4999 }, - { itemName = "wand of draconia", clientId = 8093, buy = 7500 }, - { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, - { itemName = "wand of inferno", clientId = 3071, buy = 13526 }, - { itemName = "wand of starstorm", clientId = 8092, buy = 15468 }, - { itemName = "wand of voodoo", clientId = 8094, buy = 19666 }, - { itemName = "wand of vortex", clientId = 3074, buy = 500 }, - { itemName = "war hammer", clientId = 3279, sell = 595 }, - { itemName = "watch", clientId = 2906, sell = 6 }, - { itemName = "water pipe", clientId = 2980, buy = 40 }, - { itemName = "weapon rack kit", clientId = 6109, buy = 90 }, - { itemName = "white tapestry", clientId = 2667, buy = 25 }, - { itemName = "wild growth rune", clientId = 3156, buy = 160 }, - { itemName = "wooden chair kit", clientId = 2360, buy = 15 }, - { itemName = "wooden shield", clientId = 3412, sell = 5 }, - { itemName = "worm", clientId = 3492, buy = 1 }, - { itemName = "yellow footboard", clientId = 32485, buy = 40 }, - { itemName = "yellow headboard", clientId = 32476, buy = 40 }, - { itemName = "yellow pillow", clientId = 900, buy = 25 }, - { itemName = "yellow tapestry", clientId = 2650, buy = 25 }, + local itemsTable = { + ["various"] = { + { itemName = "blue footboard", clientId = 32482, buy = 40 }, + { itemName = "blue headboard", clientId = 32473, buy = 40 }, + { itemName = "cot footboard", clientId = 32486, buy = 40 }, + { itemName = "cot headboard", clientId = 32477, buy = 40 }, + { itemName = "green footboard", clientId = 32483, buy = 40 }, + { itemName = "green headboard", clientId = 32474, buy = 40 }, + { itemName = "hammock foot section", clientId = 32487, buy = 40 }, + { itemName = "hammock head section", clientId = 32478, buy = 40 }, + { itemName = "red footboard", clientId = 32484, buy = 40 }, + { itemName = "red headboard", clientId = 32475, buy = 40 }, + { itemName = "simple footboard", clientId = 32488, buy = 40 }, + { itemName = "simple headboard", clientId = 32479, buy = 40 }, + { itemName = "straw mat foot section", clientId = 32489, buy = 40 }, + { itemName = "straw mat head section", clientId = 32480, buy = 40 }, + { itemName = "yellow footboard", clientId = 32485, buy = 40 }, + { itemName = "yellow headboard", clientId = 32476, buy = 40 }, + { itemName = "amphora", clientId = 2893, buy = 4 }, + { itemName = "armor rack kit", clientId = 6114, buy = 90 }, + { itemName = "bamboo drawer kit", clientId = 2795, buy = 20 }, + { itemName = "bamboo table kit", clientId = 2788, buy = 25 }, + { itemName = "barrel kit", clientId = 2793, buy = 12 }, + { itemName = "big table kit", clientId = 2785, buy = 30 }, + { itemName = "birdcage kit", clientId = 2796, buy = 50 }, + { itemName = "blue pillow", clientId = 2394, buy = 25 }, + { itemName = "blue tapestry", clientId = 2659, buy = 25 }, + { itemName = "bookcase kit", clientId = 6372, buy = 70 }, + { itemName = "box", clientId = 2469, buy = 10 }, + { itemName = "chest", clientId = 2472, buy = 10 }, + { itemName = "chest of drawers", clientId = 2789, buy = 18 }, + { itemName = "chimney kit", clientId = 7864, buy = 200 }, + { itemName = "coal basin kit", clientId = 2806, buy = 25 }, + { itemName = "cookie", clientId = 3598, buy = 2 }, + { itemName = "crate", clientId = 2471, buy = 10 }, + { itemName = "cuckoo clock", clientId = 2664, buy = 40 }, + { itemName = "dresser kit", clientId = 2790, buy = 25 }, + { itemName = "goldfish bowl", clientId = 5928, buy = 50 }, + { itemName = "fireworks rocket", clientId = 6576, buy = 100 }, + { itemName = "flower bowl", clientId = 2983, buy = 6 }, + { itemName = "globe", clientId = 2797, buy = 50 }, + { itemName = "goblin statue kit", clientId = 2804, buy = 50 }, + { itemName = "god flowers", clientId = 2981, buy = 5 }, + { itemName = "green balloons", clientId = 6577, buy = 500 }, + { itemName = "green cushioned chair kit", clientId = 2776, buy = 40 }, + { itemName = "green pillow", clientId = 2396, buy = 25 }, + { itemName = "green tapestry", clientId = 2647, buy = 25 }, + { itemName = "harp kit", clientId = 2808, buy = 50 }, + { itemName = "heart pillow", clientId = 2393, buy = 30 }, + { itemName = "honey flower", clientId = 2984, buy = 5 }, + { itemName = "indoor plant kit", clientId = 2811, buy = 8 }, + { itemName = "ivory chair kit", clientId = 2781, buy = 25 }, + { itemName = "knight statue kit", clientId = 2802, buy = 50 }, + { itemName = "large amphora kit", clientId = 2805, buy = 50 }, + { itemName = "large trunk", clientId = 2794, buy = 10 }, + { itemName = "locker kit", clientId = 2791, buy = 30 }, + { itemName = "minotaur statue kit", clientId = 2803, buy = 50 }, + { itemName = "orange tapestry", clientId = 2653, buy = 25 }, + { itemName = "oven kit", clientId = 6371, buy = 80 }, + { itemName = "party hat", clientId = 6578, buy = 800 }, + { itemName = "party trumpet", clientId = 6572, buy = 500 }, + { itemName = "pendulum clock kit", clientId = 2801, buy = 75 }, + { itemName = "piano kit", clientId = 2807, buy = 200 }, + { itemName = "potted flower", clientId = 2985, buy = 5 }, + { itemName = "present", clientId = 2856, buy = 10 }, + { itemName = "purple tapestry", clientId = 2644, buy = 25 }, + { itemName = "red balloons", clientId = 6575, buy = 500 }, + { itemName = "red cushioned chair kit", clientId = 2775, buy = 40 }, + { itemName = "red pillow", clientId = 2395, buy = 25 }, + { itemName = "red tapestry", clientId = 2656, buy = 25 }, + { itemName = "rocking horse", clientId = 2800, buy = 30 }, + { itemName = "round blue pillow", clientId = 2398, buy = 25 }, + { itemName = "round purple pillow", clientId = 2400, buy = 25 }, + { itemName = "round red pillow", clientId = 2399, buy = 25 }, + { itemName = "round turquoise pillow", clientId = 2401, buy = 25 }, + { itemName = "small blue pillow", clientId = 2389, buy = 20 }, + { itemName = "small green pillow", clientId = 2387, buy = 20 }, + { itemName = "small ice statue", clientId = 7447, buy = 50 }, + { itemName = "small ice statue", clientId = 7448, buy = 50 }, + { itemName = "small orange pillow", clientId = 2390, buy = 20 }, + { itemName = "small purple pillow", clientId = 2386, buy = 20 }, + { itemName = "small red pillow", clientId = 2388, buy = 20 }, + { itemName = "small round table", clientId = 2783, buy = 25 }, + { itemName = "small table kit", clientId = 2782, buy = 20 }, + { itemName = "small trunk", clientId = 2426, buy = 20 }, + { itemName = "small turquoise pillow", clientId = 2391, buy = 20 }, + { itemName = "small white pillow", clientId = 2392, buy = 20 }, + { itemName = "sofa chair kit", clientId = 2779, buy = 55 }, + { itemName = "square table kit", clientId = 2784, buy = 25 }, + { itemName = "stone table kit", clientId = 2786, buy = 30 }, + { itemName = "table lamp kit", clientId = 2798, buy = 35 }, + { itemName = "telescope kit", clientId = 2799, buy = 70 }, + { itemName = "thick trunk", clientId = 2352, buy = 20 }, + { itemName = "treasure chest", clientId = 2478, buy = 1000 }, + { itemName = "trophy stand", clientId = 872, buy = 50 }, + { itemName = "trough kit", clientId = 2792, buy = 7 }, + { itemName = "tusk chair kit", clientId = 2780, buy = 25 }, + { itemName = "tusk table kit", clientId = 2787, buy = 25 }, + { itemName = "vase", clientId = 2876, buy = 3 }, + { itemName = "venorean cabinet", clientId = 17974, buy = 90 }, + { itemName = "venorean drawer", clientId = 17977, buy = 40 }, + { itemName = "venorean wardrobe", clientId = 17975, buy = 50 }, + { itemName = "wall mirror", clientId = 2638, buy = 40 }, + { itemName = "wall mirror", clientId = 2635, buy = 40 }, + { itemName = "wall mirror", clientId = 2632, buy = 40 }, + { itemName = "water pipe", clientId = 2980, buy = 40 }, + { itemName = "weapon rack kit", clientId = 6115, buy = 90 }, + { itemName = "white tapestry", clientId = 2667, buy = 25 }, + { itemName = "wooden chair kit", clientId = 2777, buy = 15 }, + { itemName = "yellow pillow", clientId = 900, buy = 25 }, + { itemName = "yellow tapestry", clientId = 2650, buy = 25 }, + { itemName = "exercise axe", clientId = 28553, buy = 262500, subType = 500 }, + { itemName = "exercise bow", clientId = 28555, buy = 262500, subType = 500 }, + { itemName = "exercise club", clientId = 28554, buy = 262500, subType = 500 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, subType = 500 }, + { itemName = "exercise sword", clientId = 28552, buy = 262500, subType = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, subType = 500 }, + { itemName = "durable exercise axe", clientId = 35280, buy = 945000, subType = 1800 }, + { itemName = "durable exercise bow", clientId = 35282, buy = 945000, subType = 1800 }, + { itemName = "durable exercise club", clientId = 35281, buy = 945000, subType = 1800 }, + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, subType = 1800 }, + { itemName = "durable exercise sword", clientId = 35279, buy = 945000, subType = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, subType = 1800 }, + }, + ["exercise weapons"] = { + { itemName = "exercise axe", clientId = 28553, buy = 262500, subType = 500 }, + { itemName = "exercise bow", clientId = 28555, buy = 262500, subType = 500 }, + { itemName = "exercise club", clientId = 28554, buy = 262500, subType = 500 }, + { itemName = "exercise rod", clientId = 28556, buy = 262500, subType = 500 }, + { itemName = "exercise sword", clientId = 28552, buy = 262500, subType = 500 }, + { itemName = "exercise wand", clientId = 28557, buy = 262500, subType = 500 }, + { itemName = "durable exercise axe", clientId = 35280, buy = 945000, subType = 1800 }, + { itemName = "durable exercise bow", clientId = 35282, buy = 945000, subType = 1800 }, + { itemName = "durable exercise club", clientId = 35281, buy = 945000, subType = 1800 }, + { itemName = "durable exercise rod", clientId = 35283, buy = 945000, subType = 1800 }, + { itemName = "durable exercise sword", clientId = 35279, buy = 945000, subType = 1800 }, + { itemName = "durable exercise wand", clientId = 35284, buy = 945000, subType = 1800 }, + { itemName = "lasting exercise axe", clientId = 35286, buy = 7560000, subType = 14400 }, + { itemName = "lasting exercise bow", clientId = 35288, buy = 7560000, subType = 14400 }, + { itemName = "lasting exercise club", clientId = 35287, buy = 7560000, subType = 14400 }, + { itemName = "lasting exercise rod", clientId = 35289, buy = 7560000, subType = 14400 }, + { itemName = "lasting exercise sword", clientId = 35285, buy = 7560000, subType = 14400 }, + { itemName = "lasting exercise wand", clientId = 35290, buy = 7560000, subType = 14400 }, + }, + ["equipment"] = { + { itemName = "axe", clientId = 3274, buy = 20, sell = 7 }, + { itemName = "battle axe", clientId = 3266, buy = 235, sell = 80 }, + { itemName = "battle hammer", clientId = 3305, buy = 350, sell = 120 }, + { itemName = "bone sword", clientId = 3338, buy = 75, sell = 20 }, + { itemName = "brass armor", clientId = 3359, buy = 450, sell = 150 }, + { itemName = "brass helmet", clientId = 3354, buy = 120, sell = 30 }, + { itemName = "brass legs", clientId = 3372, buy = 195, sell = 49 }, + { itemName = "brass shield", clientId = 3411, buy = 65, sell = 25 }, + { itemName = "carlin sword", clientId = 3283, buy = 473, sell = 118 }, + { itemName = "chain armor", clientId = 3358, buy = 200, sell = 70 }, + { itemName = "chain helmet", clientId = 3352, buy = 52, sell = 17 }, + { itemName = "chain legs", clientId = 3558, buy = 80, sell = 25 }, + { itemName = "club", clientId = 3270, buy = 5, sell = 1 }, + { itemName = "coat", clientId = 3562, buy = 8, sell = 1 }, + { itemName = "crowbar", clientId = 3304, buy = 260, sell = 50 }, + { itemName = "dagger", clientId = 3267, buy = 5, sell = 2 }, + { itemName = "doublet", clientId = 3379, buy = 16, sell = 3 }, + { itemName = "dwarven shield", clientId = 3425, buy = 500, sell = 100 }, + { itemName = "hand axe", clientId = 3268, buy = 8, sell = 4 }, + { itemName = "iron helmet", clientId = 3353, buy = 390, sell = 150 }, + { itemName = "jacket", clientId = 3561, buy = 12, sell = 1 }, + { itemName = "leather armor", clientId = 3361, buy = 35, sell = 12 }, + { itemName = "leather boots", clientId = 3552, buy = 10, sell = 2 }, + { itemName = "leather helmet", clientId = 3355, buy = 12, sell = 4 }, + { itemName = "leather legs", clientId = 3559, buy = 10, sell = 9 }, + { itemName = "longsword", clientId = 3285, buy = 160, sell = 51 }, + { itemName = "mace", clientId = 3286, buy = 90, sell = 30 }, + { itemName = "morning star", clientId = 3282, buy = 430, sell = 100 }, + { itemName = "plate armor", clientId = 3357, buy = 1200, sell = 400 }, + { itemName = "plate shield", clientId = 3410, buy = 125, sell = 45 }, + { itemName = "rapier", clientId = 3272, buy = 15, sell = 5 }, + { itemName = "sabre", clientId = 3273, buy = 35, sell = 12 }, + { itemName = "scale armor", clientId = 3377, buy = 260, sell = 75 }, + { itemName = "short sword", clientId = 3294, buy = 26, sell = 10 }, + { itemName = "sickle", clientId = 3293, buy = 7, sell = 3 }, + { itemName = "soldier helmet", clientId = 3375, buy = 110, sell = 16 }, + { itemName = "spike sword", clientId = 3271, buy = 8000, sell = 240 }, + { itemName = "steel helmet", clientId = 3351, buy = 580, sell = 293 }, + { itemName = "steel shield", clientId = 3409, buy = 240, sell = 80 }, + { itemName = "studded armor", clientId = 3378, buy = 90, sell = 25 }, + { itemName = "studded helmet", clientId = 3376, buy = 63, sell = 20 }, + { itemName = "studded legs", clientId = 3362, buy = 50, sell = 15 }, + { itemName = "studded shield", clientId = 3426, buy = 50, sell = 16 }, + { itemName = "sword", clientId = 3264, buy = 85, sell = 25 }, + { itemName = "throwing knife", clientId = 3298, buy = 25, sell = 2 }, + { itemName = "two handed sword", clientId = 3265, buy = 950, sell = 450 }, + { itemName = "viking helmet", clientId = 3367, buy = 265, sell = 66 }, + { itemName = "viking shield", clientId = 3431, buy = 260, sell = 85 }, + { itemName = "war hammer", clientId = 3279, buy = 10000, sell = 470 }, + { itemName = "wooden shield", clientId = 3412, buy = 15, sell = 5 }, + }, + ["distance"] = { + { itemName = "arrow", clientId = 3447, buy = 2 }, + { itemName = "bolt", clientId = 3483, buy = 4 }, + { itemName = "bow", clientId = 3350, buy = 400, sell = 100 }, + { itemName = "crossbow", clientId = 3349, buy = 500, sell = 120 }, + { itemName = "crystalline arrow", clientId = 15793, buy = 450 }, + { itemName = "drill bolt", clientId = 16142, buy = 12 }, + { itemName = "diamond arrow", clientId = 35901, buy = 100 }, + { itemName = "earth arrow", clientId = 774, buy = 5 }, + { itemName = "envenomed arrow", clientId = 16143, buy = 12 }, + { itemName = "flaming arrow", clientId = 763, buy = 5 }, + { itemName = "flash arrow", clientId = 761, buy = 5 }, + { itemName = "onyx arrow", clientId = 7365, buy = 7 }, + { itemName = "piercing bolt", clientId = 7363, buy = 5 }, + { itemName = "power bolt", clientId = 3450, buy = 7 }, + { itemName = "prismatic bolt", clientId = 16141, buy = 20 }, + { itemName = "quiver", clientId = 35562, buy = 400 }, + { itemName = "royal spear", clientId = 7378, buy = 15 }, + { itemName = "shiver arrow", clientId = 762, buy = 5 }, + { itemName = "sniper arrow", clientId = 7364, buy = 5 }, + { itemName = "spear", clientId = 3277, buy = 9, sell = 3 }, + { itemName = "spectral bolt", clientId = 35902, buy = 70 }, + { itemName = "tarsal arrow", clientId = 14251, buy = 6 }, + { itemName = "throwing star", clientId = 3287, buy = 42 }, + { itemName = "vortex bolt", clientId = 14252, buy = 6 }, + }, + ["rods"] = { + { itemName = "exercise rod", clientId = 28556, buy = 236250, subType = 500 }, + { itemName = "hailstorm rod", clientId = 3067, buy = 15000 }, + { itemName = "moonlight rod", clientId = 3070, buy = 1000 }, + { itemName = "necrotic rod", clientId = 3069, buy = 5000 }, + { itemName = "northwind rod", clientId = 8083, buy = 7500 }, + { itemName = "snakebite rod", clientId = 3066, buy = 500 }, + { itemName = "springsprout rod", clientId = 8084, buy = 18000 }, + { itemName = "terra rod", clientId = 3065, buy = 10000 }, + { itemName = "underworld rod", clientId = 8082, buy = 22000 }, + }, + ["wands"] = { + { itemName = "exercise wand", clientId = 28557, buy = 236250, subType = 500 }, + { itemName = "wand of cosmic energy", clientId = 3073, buy = 10000 }, + { itemName = "wand of decay", clientId = 3072, buy = 5000 }, + { itemName = "wand of draconia", clientId = 8093, buy = 7500 }, + { itemName = "wand of dragonbreath", clientId = 3075, buy = 1000 }, + { itemName = "wand of inferno", clientId = 3071, buy = 15000 }, + { itemName = "wand of starstorm", clientId = 8092, buy = 18000 }, + { itemName = "wand of voodoo", clientId = 8094, buy = 22000 }, + { itemName = "wand of vortex", clientId = 3074, buy = 500 }, + }, + ["potions"] = { + { itemName = "great health potion", clientId = 239, buy = 225 }, + { itemName = "great mana potion", clientId = 238, buy = 144 }, + { itemName = "great spirit potion", clientId = 7642, buy = 228 }, + { itemName = "health potion", clientId = 266, buy = 50 }, + { itemName = "mana potion", clientId = 268, buy = 56 }, + { itemName = "strong health potion", clientId = 236, buy = 115 }, + { itemName = "strong mana potion", clientId = 237, buy = 93 }, + { itemName = "supreme health potion", clientId = 23375, buy = 625 }, + { itemName = "ultimate health potion", clientId = 7643, buy = 379 }, + { itemName = "ultimate mana potion", clientId = 23373, buy = 438 }, + { itemName = "ultimate spirit potion", clientId = 23374, buy = 438 }, + { itemName = "empty potion flask", clientId = 283, sell = 5 }, + { itemName = "empty potion flask", clientId = 284, sell = 5 }, + { itemName = "empty potion flask", clientId = 285, sell = 5 }, + { itemName = "vial", clientId = 2874, sell = 5 }, + }, + ["runes"] = { + { itemName = "animate dead rune", clientId = 3203, buy = 375 }, + { itemName = "avalanche rune", clientId = 3161, buy = 57 }, + { itemName = "blank rune", clientId = 3147, buy = 10 }, + { itemName = "chameleon rune", clientId = 3178, buy = 210 }, + { itemName = "convince creature rune", clientId = 3177, buy = 80 }, + { itemName = "cure poison rune", clientId = 3153, buy = 65 }, + { itemName = "destroy field rune", clientId = 3148, buy = 15 }, + { itemName = "disintegrate rune", clientId = 3197, buy = 26 }, + { itemName = "energy bomb rune", clientId = 3149, buy = 203 }, + { itemName = "energy field rune", clientId = 3164, buy = 38 }, + { itemName = "energy wall rune", clientId = 3166, buy = 85 }, + { itemName = "explosion rune", clientId = 3200, buy = 31 }, + { itemName = "fire bomb rune", clientId = 3192, buy = 147 }, + { itemName = "fire field rune", clientId = 3188, buy = 28 }, + { itemName = "fire wall rune", clientId = 3190, buy = 61 }, + { itemName = "fireball rune", clientId = 3189, buy = 30 }, + { itemName = "great fireball rune", clientId = 3191, buy = 57 }, + { itemName = "heavy magic missile rune", clientId = 3198, buy = 12 }, + { itemName = "holy missile rune", clientId = 3182, buy = 16 }, + { itemName = "icicle rune", clientId = 3158, buy = 30 }, + { itemName = "intense healing rune", clientId = 3152, buy = 95 }, + { itemName = "light magic missile rune", clientId = 3174, buy = 4 }, + { itemName = "magic wall rune", clientId = 3180, buy = 116 }, + { itemName = "paralyse rune", clientId = 3165, buy = 700 }, + { itemName = "poison bomb rune", clientId = 3173, buy = 85 }, + { itemName = "poison field rune", clientId = 3172, buy = 21 }, + { itemName = "poison wall rune", clientId = 3176, buy = 52 }, + { itemName = "soulfire rune", clientId = 3195, buy = 46 }, + { itemName = "stalagmite rune", clientId = 3179, buy = 12 }, + { itemName = "stone shower rune", clientId = 3175, buy = 37 }, + { itemName = "sudden death rune", clientId = 3155, buy = 135 }, + { itemName = "thunderstorm rune", clientId = 3202, buy = 47 }, + { itemName = "ultimate healing rune", clientId = 3160, buy = 175 }, + { itemName = "wild growth rune", clientId = 3156, buy = 160 }, + }, + ["supplies"] = { + { itemName = "brown mushroom", clientId = 3725, buy = 10 }, + { itemName = "ham", clientId = 3582, buy = 10 }, + { itemName = "meat", clientId = 3577, buy = 5 }, + { itemName = "shapeshifter ring", clientId = 907, buy = 5500, subType = 15 }, + }, + ["tools"] = { + { itemName = "basket", clientId = 2855, buy = 6 }, + { itemName = "bottle", clientId = 2875, buy = 3 }, + { itemName = "bucket", clientId = 2873, buy = 4 }, + { itemName = "candelabrum", clientId = 2911, buy = 8 }, + { itemName = "candlestick", clientId = 2917, buy = 2 }, + { itemName = "closed trap", clientId = 3481, buy = 280, sell = 75 }, + { itemName = "crowbar", clientId = 3304, buy = 260, sell = 50 }, + { itemName = "fishing rod", clientId = 3483, buy = 150, sell = 40 }, + { itemName = "machete", clientId = 3308, buy = 35, sell = 6 }, + { itemName = "pick", clientId = 3456, buy = 50, sell = 15 }, + { itemName = "rope", clientId = 3003, buy = 50, sell = 15 }, + { itemName = "scythe", clientId = 3453, buy = 50, sell = 10 }, + { itemName = "shovel", clientId = 3457, buy = 50, sell = 8 }, + { itemName = "spellwand", clientId = 651, sell = 299 }, + { itemName = "torch", clientId = 2920, buy = 2 }, + { itemName = "watch", clientId = 2906, buy = 20, sell = 6 }, + { itemName = "worm", clientId = 3492, buy = 1 }, + { itemName = "spellwand", clientId = 651, sell = 299 }, + }, + ["postal"] = { + { itemName = "label", clientId = 3507, buy = 1 }, + { itemName = "letter", clientId = 3505, buy = 8 }, + { itemName = "parcel", clientId = 3503, buy = 15 }, + }, } + -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) npc:sellItem(player, itemId, amount, subType, 0, ignore, inBackpacks) @@ -394,14 +430,14 @@ function createHirelingType(HirelingName) local function getHirelingSkills() local skills = {} - if hireling:hasSkill(HIRELING_SKILLS.BANKER) then - table.insert(skills, HIRELING_SKILLS.BANKER) + if hireling:hasSkill(HIRELING_SKILLS.BANKER[2]) then + table.insert(skills, HIRELING_SKILLS.BANKER[1]) end - if hireling:hasSkill(HIRELING_SKILLS.COOKING) then - table.insert(skills, HIRELING_SKILLS.COOKING) + if hireling:hasSkill(HIRELING_SKILLS.COOKING[2]) then + table.insert(skills, HIRELING_SKILLS.COOKING[1]) end - if hireling:hasSkill(HIRELING_SKILLS.STEWARD) then - table.insert(skills, HIRELING_SKILLS.STEWARD) + if hireling:hasSkill(HIRELING_SKILLS.STEWARD[2]) then + table.insert(skills, HIRELING_SKILLS.STEWARD[1]) end -- ignoring trader skills as it shows the same message about {goods} return skills @@ -418,11 +454,11 @@ function createHirelingType(HirelingName) str = str .. ", " end - if skills[i] == HIRELING_SKILLS.BANKER then + if skills[i] == HIRELING_SKILLS.BANKER[1] then str = str .. "to access your {bank} account" -- TODO: this setence is not official - elseif skills[i] == HIRELING_SKILLS.COOKING then + elseif skills[i] == HIRELING_SKILLS.COOKING[1] then str = str .. "to order {food}" - elseif skills[i] == HIRELING_SKILLS.STEWARD then + elseif skills[i] == HIRELING_SKILLS.STEWARD[1] then str = str .. "to open your {stash}" end end @@ -436,21 +472,10 @@ function createHirelingType(HirelingName) return str end - local function sendSkillNotLearned(npc, creature, SKILL) + local function sendSkillNotLearned(npc, creature, skillName) local message = "Sorry, but I do not have mastery in this skill yet." - local profession - if SKILL == HIRELING_SKILLS.BANKER then - profession = "banker" - elseif SKILL == HIRELING_SKILLS.COOKING then - profession = "cooker" - elseif SKILL == HIRELING_SKILLS.STEWARD then - profession = "steward" - elseif SKILL == HIRELING_SKILLS.TRADER then - profession = "trader" - end - - if profession then - message = string.format("I'm not a %s and would not know how to help you with that, sorry. I can start a %s apprenticeship if you buy it for me in the store!", profession, profession) + if skillName then + message = string.format("I'm not a %s and would not know how to help you with that, sorry. I can start a %s apprenticeship if you buy it for me in the store!", skillName, skillName) end npcHandler:say(message, npc, creature) @@ -517,7 +542,7 @@ function createHirelingType(HirelingName) npcHandler:setTopic(playerId, TOPIC_FOOD.SKILL_CHOOSE) npcHandler:say("Yay! I have the ingredients to make a skill boost dish. Would you rather like to boost your {magic}, {melee}, {shielding} or {distance} skill?", npc, creature) else -- deliver the random generated index - deliverFood(npc, creature, HIRELING_FOODS[random]) + deliverFood(npc, creature, HIRELING_FOODS_IDS[random]) end end @@ -572,45 +597,55 @@ function createHirelingType(HirelingName) npcHandler:say(servicesMsg, npc, creature) elseif npcHandler:getTopic(playerId) == TOPIC.SERVICES then if MsgContains(message, "bank") then - if hireling:hasSkill(HIRELING_SKILLS.BANKER) then + local bankerSkillName = HIRELING_SKILLS.BANKER[2] + if hireling:hasSkill(bankerSkillName) then npcHandler:setTopic(playerId, TOPIC.BANK) count[playerId], transfer[playerId] = nil, nil npcHandler:say(GREETINGS.BANK, npc, creature) else - sendSkillNotLearned(npc, creature, HIRELING_SKILLS.BANKER) + sendSkillNotLearned(npc, creature, bankerSkillName) end elseif MsgContains(message, "food") then - if hireling:hasSkill(HIRELING_SKILLS.COOKING) then + local bankerSkillName = HIRELING_SKILLS.COOKING[2] + if hireling:hasSkill(bankerSkillName) then npcHandler:setTopic(playerId, TOPIC.FOOD) npcHandler:say(GREETINGS.FOOD, npc, creature) else - sendSkillNotLearned(npc, creature, HIRELING_SKILLS.COOKING) + sendSkillNotLearned(npc, creature, bankerSkillName) end elseif MsgContains(message, "stash") then - if hireling:hasSkill(HIRELING_SKILLS.STEWARD) then + local bankerSkillName = HIRELING_SKILLS.STEWARD[2] + if hireling:hasSkill(bankerSkillName) then npcHandler:say(GREETINGS.STASH, npc, creature) player:setSpecialContainersAvailable(true) player:openStash(true) player:sendTextMessage(MESSAGE_FAILURE, "Your supply stash contains " .. player:getStashCount() .. " item" .. (player:getStashCount() > 1 and "s." or ".")) else - sendSkillNotLearned(npc, creature, HIRELING_SKILLS.STEWARD) + sendSkillNotLearned(npc, creature, bankerSkillName) end elseif MsgContains(message, "goods") then - npcHandler:say("I sell a selection of various items. Just ask {trade}!", npc, creature) + local string + if not hireling:hasSkill(HIRELING_SKILLS.TRADER[2]) then + string = "While I'm not a trader, I still have a collection of {various} items to sell if you like!" + else + string = "I sell a selection of {various} items, {exercise weapons}, {equipment}, " .. "{distance} weapons, {wands} and {rods}, {potions}, {runes}, " .. "{supplies}, {tools} and {postal} goods. Just ask!" + end + npcHandler:setTopic(playerId, TOPIC.GOODS) + npcHandler:say(string, npc, creature) elseif MsgContains(message, "lamp") then npcHandler:setTopic(playerId, TOPIC.LAMP) - if player:getGuid() == hireling:getOwnerId() then - npcHandler:say("Are you sure you want me to go back to my lamp?", npc, creature) - else + if player:getGuid() ~= hireling:getOwnerId() then return false end + + npcHandler:say("Are you sure you want me to go back to my lamp?", npc, creature) elseif MsgContains(message, "outfit") then - if player:getGuid() == hireling:getOwnerId() then - hireling:requestOutfitChange() - npcHandler:say("As you wish!", npc, creature) - else + if player:getGuid() ~= hireling:getOwnerId() then return false end + + hireling:requestOutfitChange() + npcHandler:say("As you wish!", npc, creature) end elseif npcHandler:getTopic(playerId) == TOPIC.LAMP then if MsgContains(message, "yes") then @@ -621,8 +656,27 @@ function createHirelingType(HirelingName) end elseif npcHandler:getTopic(playerId) == TOPIC.BANK then enableBankSystem[playerId] = true - elseif npcHandler:getTopic(playerId) >= TOPIC.FOOD and npcHandler:getTopic(playerId) < TOPIC.GOODS then + elseif npcHandler:getTopic(playerId) == TOPIC.FOOD then handleFoodActions(npc, creature, message) + elseif npcHandler:getTopic(playerId) == TOPIC.GOODS then + -- Ensures players cannot access other shop categories + if not hireling:hasSkill(HIRELING_SKILLS.TRADER[2]) then + if not MsgContains(message, "various") then + local text = "While I'm not a trader, I still have a collection of {various} items to sell if you like!" + npcHandler:say(text, npc, creature) + return + end + + npcHandler:say("Here are the items for the category various.", npc, creature) + npc:openShopWindowTable(player, itemsTable["various"]) + return + end + + local categoryTable = itemsTable[message:lower()] + if categoryTable then + npcHandler:say("Here are the items for the category " .. message .. ".", npc, creature) + npc:openShopWindowTable(player, categoryTable) + end end if enableBankSystem[playerId] then -- Parse bank @@ -635,7 +689,7 @@ function createHirelingType(HirelingName) return true end - npcHandler:setMessage(MESSAGE_GREET, "It is good to see you. I'm always at your {service}") + npcHandler:setMessage(MESSAGE_GREET, "It is good to see you. I'm always at your {service}.") npcHandler:setMessage(MESSAGE_FAREWELL, "Farewell, |PLAYERNAME|, I'll be here if you need me again.") npcHandler:setMessage(MESSAGE_WALKAWAY, "Come back soon!") diff --git a/data-otservbr-global/scripts/actions/farmine/oberon_lever.lua b/data-otservbr-global/scripts/actions/farmine/oberon_lever.lua index c45451965ca..0ec20531e46 100644 --- a/data-otservbr-global/scripts/actions/farmine/oberon_lever.lua +++ b/data-otservbr-global/scripts/actions/farmine/oberon_lever.lua @@ -3,7 +3,6 @@ local config = { name = "Grand Master Oberon", position = Position(33364, 31317, 9), }, - timeAfterKill = 60, playerPositions = { { pos = Position(33362, 31344, 9), teleport = Position(33364, 31322, 9) }, { pos = Position(33363, 31344, 9), teleport = Position(33364, 31322, 9) }, diff --git a/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua b/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua index 2997a8df514..f9bc313df12 100644 --- a/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua +++ b/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua @@ -3,7 +3,7 @@ local chayenneLever = Action() function chayenneLever.onUse(player, item, fromPosition, itemEx, toPosition) if item.itemid == 2772 then if Game.getStorageValue(Storage.ChayenneKeyTime) > os.time() then - player:sendTendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait few minutes to use again.") + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait few minutes to use again.") return true end diff --git a/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua b/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua index 53dbb4f669d..8a25b60c3d1 100644 --- a/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua +++ b/data-otservbr-global/scripts/actions/quests/grave_danger/cobra_bastion/scarlett.lua @@ -18,7 +18,6 @@ local config = { return scarlett end, }, - timeAfterKill = 60, playerPositions = { { pos = Position(33395, 32661, 6), teleport = Position(33396, 32651, 6) }, { pos = Position(33394, 32662, 6), teleport = Position(33396, 32651, 6) }, diff --git a/data-otservbr-global/scripts/actions/quests/ice_islands/yakchal.lua b/data-otservbr-global/scripts/actions/quests/ice_islands/yakchal.lua index 47dfafd807a..db81c1606c2 100644 --- a/data-otservbr-global/scripts/actions/quests/ice_islands/yakchal.lua +++ b/data-otservbr-global/scripts/actions/quests/ice_islands/yakchal.lua @@ -13,7 +13,7 @@ end local iceYakchal = Action() function iceYakchal.onUse(player, item, fromPosition, target, toPosition, isHotkey) local sarcophagus = Position(32205, 31002, 14) - if toPosition.x == sarcophagus.x and toPosition.y == sarcophagus.y and toPosition.z == sarcophagus.z and target.itemid == 7362 and item.itemid == 2361 then + if toPosition.x == sarcophagus.x and toPosition.y == sarcophagus.y and toPosition.z == sarcophagus.z and target.itemid == 7362 and item.itemid == 3249 then if Game.getStorageValue(GlobalStorage.Yakchal) < os.time() then Game.setStorageValue(GlobalStorage.Yakchal, os.time() + 24 * 60 * 60) if math.random(2) == 2 then diff --git a/data-otservbr-global/scripts/creaturescripts/others/hireling_logout.lua b/data-otservbr-global/scripts/creaturescripts/others/hireling_logout.lua deleted file mode 100644 index ccf9701424b..00000000000 --- a/data-otservbr-global/scripts/creaturescripts/others/hireling_logout.lua +++ /dev/null @@ -1,7 +0,0 @@ -local hirelingLogoutPlayer = CreatureEvent("HirelingLogoutPlayer") -function hirelingLogoutPlayer.onLogout(player) - player:copyHirelingStorageToCache() - return true -end - -hirelingLogoutPlayer:register() diff --git a/data-otservbr-global/scripts/globalevents/game_migrations/20231128213358_move_hireling_data_to_kv.lua b/data-otservbr-global/scripts/globalevents/game_migrations/20231128213358_move_hireling_data_to_kv.lua new file mode 100644 index 00000000000..b30eeb1c790 --- /dev/null +++ b/data-otservbr-global/scripts/globalevents/game_migrations/20231128213358_move_hireling_data_to_kv.lua @@ -0,0 +1,101 @@ +local old_hirelingSkills = { + BANKER = 1, -- 1<<0 + COOKING = 2, -- 1<<1 + STEWARD = 4, -- 1<<2 + TRADER = 8, -- 1<<3 +} + +local old_hirelingOutfits = { + BANKER = 1, -- 1<<0 + COOKING = 2, -- 1<<1 + STEWARD = 4, -- 1<<2 + TRADER = 8, -- 1<<3 ... + SERVANT = 16, + HYDRA = 32, + FERUMBRAS = 64, + BONELORD = 128, + DRAGON = 256, +} + +local old_hirelingStorage = { + SKILL = 28800, + OUTFIT = 28900, +} + +local function getOutfits(player) + local flags = player:getStorageValue(old_hirelingStorage.OUTFIT) + local outfits = {} + if flags <= 0 then + return outfits + end + for key, value in pairs(old_hirelingOutfits) do + if hasBitSet(value, flags) then + table.insert(outfits, key) + end + end + return outfits +end + +local function getSkills(player) + local flags = player:getStorageValue(old_hirelingStorage.SKILL) + local skills = {} + if flags <= 0 then + return skills + end + for key, value in pairs(old_hirelingSkills) do + if hasBitSet(value, flags) then + table.insert(skills, key) + end + end + return skills +end + +local function migrateHirelingData(player) + if not player then + return false + end + + local outfits = getOutfits(player) + local skills = getSkills(player) + if #outfits == 0 and #skills == 0 then + return true + end + logger.info("Migrating hireling data for player {}", player:getName()) + for _, outfit in pairs(outfits) do + logger.debug("Enabling hireling outfit: {}", outfit) + local outfit = HIRELING_OUTFITS[outfit] + if outfit then + local name = outfit[2] + if name then + player:enableHirelingOutfit(name) + else + logger.error("Invalid hireling outfit name: {}", outfit[1]) + end + else + logger.error("Invalid hireling outfit: {}", outfit) + end + end + + for _, skill in pairs(skills) do + logger.debug("Enabling hireling skill: {}", skill) + local skill = HIRELING_SKILLS[skill] + if skill then + local name = skill[2] + if name then + player:enableHirelingSkill(name) + else + logger.error("Invalid hireling skill name: {}", skill[1]) + end + else + logger.error("Invalid hireling skill: {}", skill) + end + end +end + +local migration = Migration("20231128213158_move_hireling_data_to_kv") + +function migration:onExecute() + self:forEachPlayer(migrateHirelingData) +end + +migration:register() diff --git a/data-otservbr-global/scripts/globalevents/others/bosslever_death.lua b/data-otservbr-global/scripts/globalevents/others/bosslever_death.lua index e31c8609afd..9538fe15eb7 100644 --- a/data-otservbr-global/scripts/globalevents/others/bosslever_death.lua +++ b/data-otservbr-global/scripts/globalevents/others/bosslever_death.lua @@ -19,9 +19,9 @@ function onBossDeath.onDeath(creature) end if bossLever.timeAfterKill > 0 then zone:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The " .. name .. " has been defeated. You have " .. bossLever.timeAfterKill .. " seconds to leave the room.") - bossLever.timeoutEvent = addEvent(function(zone) - zone:refresh() - zone:removePlayers() + bossLever.timeoutEvent = addEvent(function(zn) + zn:refresh() + zn:removePlayers() end, bossLever.timeAfterKill * 1000, zone) end return true diff --git a/data-otservbr-global/scripts/globalevents/vip/online_coins.lua b/data-otservbr-global/scripts/globalevents/vip/online_coins.lua index 75ef27dc2fa..e75f23bde7a 100644 --- a/data-otservbr-global/scripts/globalevents/vip/online_coins.lua +++ b/data-otservbr-global/scripts/globalevents/vip/online_coins.lua @@ -31,7 +31,7 @@ function onlineCoinsEvent.onThink(interval) local checkIp = {} for _, player in pairs(players) do - if player:getGroup():getId() > GROUP_TYPE_SENIORTUTOR then + if player:getGroup():getId() > GROUP_TYPE_SENIORTUTOR or (config.coinsPerHour.free < 1 and not player:isVip()) then goto continue end diff --git a/data-otservbr-global/scripts/lib/register_migrations.lua b/data-otservbr-global/scripts/lib/register_migrations.lua new file mode 100644 index 00000000000..5a2734dfc51 --- /dev/null +++ b/data-otservbr-global/scripts/lib/register_migrations.lua @@ -0,0 +1,90 @@ +Migration = { + registry = {}, +} + +setmetatable(Migration, { + ---@param self Migration + __call = function(self, name) + return setmetatable({ + name = name, + executed = KV.scoped("migrations"):get(name) or false, + }, { __index = Migration }) + end, +}) + +function Migration:forEachPlayer(callback, main) + local rows = db.storeQuery("SELECT `id` FROM `players`") + if rows then + repeat + local playerId = Result.getNumber(rows, "id") + local player = Game.getOfflinePlayer(playerId) + if player then + callback(player) + player:save() + end + until not Result.next(rows) + Result.free(rows) + end +end + +function Migration:execute() + if self.executed then + return + end + + if self.onExecute then + self:onExecute() + end + + self.executed = true + KV.scoped("migrations"):set(self.name, true) +end + +function Migration:register() + if self.executed then + return + end + if not self:_validateName() then + error("Invalid migration name: " .. self.name .. ". Migration names must be in the format: _. Example: 20231128213149_add_new_monsters") + end + + table.insert(Migration.registry, self) +end + +function Migration:_validateName() + local timestampString = string.match(self.name, "^(%d+)_") + + if not timestampString or #timestampString ~= 14 then + return false + end + + local year, month, day, hour, min, sec = timestampString:match("(%d%d%d%d)(%d%d)(%d%d)(%d%d)(%d%d)(%d%d)") + local timestamp = os.time({ year = tonumber(year), month = tonumber(month), day = tonumber(day), hour = tonumber(hour), min = tonumber(min), sec = tonumber(sec) }) + + local minTimestamp = os.time({ year = 2023, month = 11, day = 28, hour = 0, min = 0, sec = 0 }) + + if timestamp < minTimestamp then + return false + end + + return true +end + +local serverstartup = GlobalEvent("GameMigrations") +function serverstartup.onStartup() + if #Migration.registry > 0 then + table.sort(Migration.registry, function(a, b) + return a.name < b.name + end) + logger.info("[migration] === Executing game migrations ===") + local start = os.time() + for _, migration in ipairs(Migration.registry) do + logger.info("[migration] Executing game migration {}", migration.name) + migration:execute() + end + logger.info("[migration] === Game migrations executed in {}s ===", os.time() - start) + else + end +end + +serverstartup:register() diff --git a/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_fight.lua b/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_fight.lua index 91f57104d85..7f05611cbc0 100644 --- a/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_fight.lua +++ b/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_fight.lua @@ -1,7 +1,11 @@ -local magicFieldId = 39232 -local chargedFlameId = 39230 -local heatedCrystalId = 39168 -local cooledCrystalId = 39169 +local config = { + magicFieldId = 39232, + chargedFlameId = 39230, + heatedCrystalId = 39168, + cooledCrystalId = 39169, + bossPos = Position(33654, 32909, 15), + timeToLeftAfterKill = 60, +} local overheatedZone = Zone("fight.magma-bubble.overheated") local bossZone = Zone("boss.magma-bubble") @@ -30,6 +34,11 @@ local encounter = Encounter("Magma Bubble", { function encounter:onReset(position) encounter:removeMonsters() + bossZone:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format("The Magma Bubble has been defeated. You have %i seconds to leave the room.", config.timeToLeftAfterKill)) + addEvent(function(zn) + zn:refresh() + zn:removePlayers() + end, config.timeToLeftAfterKill * 1000, bossZone) end encounter:addRemoveMonsters():autoAdvance() @@ -71,9 +80,7 @@ encounter { name = "Magma Bubble", event = "fight.magma-bubble.MagmaBubbleDeath", - positions = { - Position(33654, 32909, 15), - }, + positions = { config.bossPos }, }, }) :autoAdvance("10s") @@ -151,32 +158,32 @@ function crystalsCycle.onThink(interval, lastExecution) local minCooled = 2 local crystals = {} for _, item in ipairs(zoneItems) do - if item:getId() == cooledCrystalId or item:getId() == heatedCrystalId then + if item:getId() == config.cooledCrystalId or item:getId() == config.heatedCrystalId then table.insert(crystals, item) end end local shouldChange = math.random(1, 100) <= 50 if shouldChange and #crystals > 0 then local item = crystals[math.random(1, #crystals)] - local newItemId = item:getId() == cooledCrystalId and heatedCrystalId or cooledCrystalId + local newItemId = item:getId() == config.cooledCrystalId and config.heatedCrystalId or config.cooledCrystalId item:transform(newItemId) end local cooledCount = 0 - local heatedCyrstas = {} + local heatedCrystals = {} for _, item in ipairs(zoneItems) do - if item:getId() == cooledCrystalId then + if item:getId() == config.cooledCrystalId then cooledCount = cooledCount + 1 - elseif item:getId() == heatedCrystalId then - table.insert(heatedCyrstas, item) + elseif item:getId() == config.heatedCrystalId then + table.insert(heatedCrystals, item) end end if cooledCount < minCooled then for _ = 1, minCooled - cooledCount do - local index = math.random(1, #heatedCyrstas) - local item = heatedCyrstas[index] + local index = math.random(1, #heatedCrystals) + local item = heatedCrystals[index] if item then - table.remove(heatedCyrstas, index) - item:transform(cooledCrystalId) + table.remove(heatedCrystals, index) + item:transform(config.cooledCrystalId) end end end @@ -204,10 +211,10 @@ function chargedFlameAction.onUse(player, item, fromPosition, target, toPosition if not target or not target:isItem() then return false end - if target:getId() ~= cooledCrystalId then + if target:getId() ~= config.cooledCrystalId then return false end - target:transform(heatedCrystalId) + target:transform(config.heatedCrystalId) local positions = { Position(toPosition.x - 1, toPosition.y, toPosition.z), Position(toPosition.x + 1, toPosition.y, toPosition.z), @@ -220,12 +227,12 @@ function chargedFlameAction.onUse(player, item, fromPosition, target, toPosition } local position = randomPosition(positions) position:sendMagicEffect(CONST_ME_FIREAREA) - local field = Game.createItem(magicFieldId, 1, position) + local field = Game.createItem(config.magicFieldId, 1, position) field:decay() item:remove() end -chargedFlameAction:id(chargedFlameId) +chargedFlameAction:id(config.chargedFlameId) chargedFlameAction:register() local shieldField = MoveEvent() @@ -242,7 +249,7 @@ function shieldField.onStepIn(creature, item, position, fromPosition) end shieldField:type("stepin") -shieldField:id(magicFieldId) +shieldField:id(config.magicFieldId) shieldField:register() local theEndOfDaysHealth = CreatureEvent("fight.magma-bubble.TheEndOfDaysHealth") diff --git a/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_lever.lua b/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_lever.lua index 68d2cbd6f56..04849ab49b7 100644 --- a/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_lever.lua +++ b/data-otservbr-global/scripts/quests/primal_ordeal_quest/magma_bubble_lever.lua @@ -2,7 +2,6 @@ local config = { boss = { name = "Magma Bubble" }, encounter = "Magma Bubble", requiredLevel = 500, - playerPositions = { { pos = Position(33669, 32926, 15), teleport = Position(33655, 32917, 15), effect = CONST_ME_TELEPORT }, { pos = Position(33669, 32927, 15), teleport = Position(33655, 32917, 15), effect = CONST_ME_TELEPORT }, @@ -18,8 +17,8 @@ local config = { } local lever = BossLever(config) -lever:position({ x = 33669, y = 32925, z = 15 }) +lever:position(Position(33669, 32925, 15)) lever:register() local zone = lever:getZone() -zone:addArea({ x = 33633, y = 32915, z = 15 }, { x = 33649, y = 32928, z = 15 }) +zone:addArea(Position(33633, 32915, 15), Position(33649, 32928, 15)) diff --git a/data/libs/functions/bosslever.lua b/data/libs/functions/bosslever.lua index 648c25bed63..257e9eb4eae 100644 --- a/data/libs/functions/bosslever.lua +++ b/data/libs/functions/bosslever.lua @@ -61,7 +61,7 @@ setmetatable(BossLever, { bossPosition = boss.position, timeToFightAgain = config.timeToFightAgain or configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_FIGHT_AGAIN), timeToDefeat = config.timeToDefeat or configManager.getNumber(configKeys.BOSS_DEFAULT_TIME_TO_DEFEAT), - timeAfterKill = config.timeAfterKill or 0, + timeAfterKill = config.timeAfterKill or 60, requiredLevel = config.requiredLevel or 0, createBoss = boss.createFunction, disabled = config.disabled, @@ -214,9 +214,9 @@ function BossLever:onUse(player) stopEvent(self.timeoutEvent) self.timeoutEvent = nil end - self.timeoutEvent = addEvent(function(zone) - zone:refresh() - zone:removePlayers() + self.timeoutEvent = addEvent(function(zn) + zn:refresh() + zn:removePlayers() end, self.timeToDefeat * 1000, zone) end return true diff --git a/data/libs/functions/functions.lua b/data/libs/functions/functions.lua index 95e6ccb3e3a..c39a10de451 100644 --- a/data/libs/functions/functions.lua +++ b/data/libs/functions/functions.lua @@ -266,7 +266,7 @@ function clearBossRoom(playerId, centerPosition, onlyPlayers, rangeX, rangeY, ex local spectators, spectator = Game.getSpectators(centerPosition, false, onlyPlayers, rangeX, rangeX, rangeY, rangeY) for i = 1, #spectators do spectator = spectators[i] - if spectator:isPlayer() and spectator.uid == playerId then + if spectator:isPlayer() and ((playerId ~= nil and spectator.uid == playerId) or playerId == nil) then spectator:teleportTo(exitPosition) exitPosition:sendMagicEffect(CONST_ME_TELEPORT) end diff --git a/data/libs/hireling_lib.lua b/data/libs/hireling_lib.lua index beadcdb6cf1..92c5436e15d 100644 --- a/data/libs/hireling_lib.lua +++ b/data/libs/hireling_lib.lua @@ -1,39 +1,25 @@ -HIRELING_CREDITS = { - Developer = 'Leonardo "Leu" Pereira (jlcvp)', - Version = "1.0-CoronaVaires", - Date = "29/04/2020", -} - -local DEBUG = true -- print debug to console - -HIRELING_CACHE_STORAGE = {} HIRELINGS = {} PLAYER_HIRELINGS = {} HIRELING_OUTFIT_CHANGING = {} -function DebugPrint(str) - if DEBUG == true then - logger.debug(str) - end -end - -function printTable(t) - local str = "{" - - for k, v in pairs(t) do - str = str .. string.format("\n %s = %s", tostring(k), tostring(v)) - end - str = str .. "\n}" - logger.debug(str) -end - --- [[ Constants and ENUMS ]] - +-- This is for server registration only, high ids to avoid conflicting with the gamestore subaction HIRELING_SKILLS = { - BANKER = 1, -- 1<<0 - COOKING = 2, -- 1<<1 - STEWARD = 4, -- 1<<2 - TRADER = 8, -- 1<<3 + BANKER = { 1001, "banker" }, + COOKING = { 1002, "cooker" }, + STEWARD = { 1003, "steward" }, + TRADER = { 1004, "trader" }, +} + +HIRELING_OUTFITS = { + BANKER = { 2001, "banker" }, + COOKING = { 2002, "cooker" }, + STEWARD = { 2003, "steward" }, + TRADER = { 2004, "trader" }, + SERVANT = { 2005, "servant" }, + HYDRA = { 2006, "hydra" }, + FERUMBRAS = { 2007, "ferumbras" }, + BONELORD = { 2008, "bonelord" }, + DRAGON = { 2009, "dragon" }, } HIRELING_SEX = { @@ -43,18 +29,6 @@ HIRELING_SEX = { HIRELING_OUTFIT_DEFAULT = { name = "Citizen", female = 1107, male = 1108 } -HIRELING_OUTFITS = { - BANKER = 1, -- 1<<0 - COOKING = 2, -- 1<<1 - STEWARD = 4, -- 1<<2 - TRADER = 8, -- 1<<3 ... - SERVANT = 16, - HYDRA = 32, - FERUMBRAS = 64, - BONELORD = 128, - DRAGON = 256, -} - HIRELING_OUTFITS_TABLE = { BANKER = { name = "Banker Dress", female = 1109, male = 1110 }, BONELORD = { name = "Bonelord Dress", female = 1123, male = 1124 }, @@ -67,11 +41,6 @@ HIRELING_OUTFITS_TABLE = { TRADER = { name = "Trader Dress", female = 1111, male = 1112 }, } -HIRELING_STORAGE = { - SKILL = 28800, - OUTFIT = 28900, -} - HIRELING_FOODS_BOOST = { MAGIC = 29410, MELEE = 29411, @@ -79,7 +48,7 @@ HIRELING_FOODS_BOOST = { DISTANCE = 35173, } -HIRELING_FOODS = { -- only the non-skill ones +HIRELING_FOODS_IDS = { 29412, 29413, 29414, @@ -87,10 +56,18 @@ HIRELING_FOODS = { -- only the non-skill ones 29416, } --- [[ LOCAL FUNCTIONS AND UTILS ]] +local function printTable(t) + local str = "{" + + for k, v in pairs(t) do + str = str .. string.format("\n %s = %s", tostring(k), tostring(v)) + end + str = str .. "\n}" + logger.debug(str) +end local function checkHouseAccess(hireling) - --check if owner still have access to the house + -- Check if owner still have access to the house if not hireling or hireling.active == 0 then return false end @@ -99,6 +76,7 @@ local function checkHouseAccess(hireling) if not tile then return false end + local house = tile:getHouse() if not house then return false @@ -112,13 +90,20 @@ local function checkHouseAccess(hireling) return true end - -- player is not invited anymore, return to lamp - logger.info("Returning Hireling: {} to owner Inbox", hireling:getName()) + -- Player is not invited anymore, return to lamp + logger.debug("Returning Hireling: {} to owner '{}' Inbox", hireling:getName(), player:getName()) local inbox = player:getSlotItem(CONST_SLOT_STORE_INBOX) + if not inbox then + return false + end + -- Using FLAG_NOLIMIT to avoid losing the hireling after being kicked out of the house and having no slots available in the store inbox local lamp = inbox:addItem(HIRELING_LAMP, 1, INDEX_WHEREEVER, FLAG_NOLIMIT) - lamp:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "This mysterious lamp summons your very own personal hireling.\nThis item cannot be traded.\nThis magic lamp is the home of " .. hireling:getName() .. ".") - lamp:setCustomAttribute("Hireling", hireling:getId()) --save hirelingId on item + if lamp then + lamp:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "This mysterious lamp summons your very own personal hireling.\nThis item cannot be traded.\nThis magic lamp is the home of " .. hireling:getName() .. ".") + lamp:setCustomAttribute("Hireling", hireling:getId()) + end + player:save() hireling.active = 0 hireling.cid = -1 @@ -137,41 +122,6 @@ local function spawnNPCs() end end -local function addStorageCacheValue(player_id, storage, value) - if not HIRELING_CACHE_STORAGE[player_id] then - HIRELING_CACHE_STORAGE[player_id] = {} - end - HIRELING_CACHE_STORAGE[player_id][storage] = value -end - -local function initStorageCache() - local sql = string.format("SELECT `player_id`, `key`, `value` FROM `player_storage` " .. "WHERE `key` IN (%d,%d)", HIRELING_STORAGE.SKILL, HIRELING_STORAGE.OUTFIT) - - local resultId = db.storeQuery(sql) - if resultId ~= false then - local player_id, key, value - repeat - player_id = Result.getNumber(resultId, "player_id") - key = Result.getNumber(resultId, "key") - value = Result.getNumber(resultId, "value") - - addStorageCacheValue(player_id, key, value) - until not Result.next(resultId) - Result.free(resultId) - end -end - -local function getStorageForPlayer(player_id, storage) - local player = Player(player_id) - if player then - return player:getStorageValue(storage) - else - return HIRELING_CACHE_STORAGE[player_id] and HIRELING_CACHE_STORAGE[player_id][storage] or -1 - end -end - --- [[ DEFINING HIRELING CLASS ]] - Hireling = { id = -1, player_id = -1, @@ -253,26 +203,28 @@ function Hireling:getOutfit() end function Hireling:getAvailableOutfits() - local flags = getStorageForPlayer(self:getOwnerId(), HIRELING_STORAGE.OUTFIT) - local sex = (self.sex == HIRELING_SEX.FEMALE) and "female" or "male" + local player = Player(self:getOwnerId()) + if not player then + return + end - local outfits = {} - -- add default outfit - table.insert(outfits, { name = HIRELING_OUTFIT_DEFAULT.name, lookType = HIRELING_OUTFIT_DEFAULT[sex] }) - if flags > 0 then - local outfit - for key, value in pairs(HIRELING_OUTFITS) do - if hasBitSet(value, flags) then - outfit = { - name = HIRELING_OUTFITS_TABLE[key].name, - lookType = HIRELING_OUTFITS_TABLE[key][sex], - } - table.insert(outfits, outfit) - end + local outfitsAvailable = {} + local sex = (self.sex == HIRELING_SEX.FEMALE) and "female" or "male" + -- Add default outfit + table.insert(outfitsAvailable, { name = HIRELING_OUTFIT_DEFAULT.name, lookType = HIRELING_OUTFIT_DEFAULT[sex] }) + for key, outfit in pairs(HIRELING_OUTFITS) do + local outfitName = outfit[2] + local haveOutfit = player:kv():scoped("hireling-outfits"):get(outfitName) + if haveOutfit == true then + logger.debug("[getAvailableOutfits] found outfit {}", outfitName) + tempOutfit = { + name = HIRELING_OUTFITS_TABLE[key].name, + lookType = HIRELING_OUTFITS_TABLE[key][sex], + } + table.insert(outfitsAvailable, tempOutfit) end end - - return outfits + return outfitsAvailable end function Hireling:requestOutfitChange() @@ -317,13 +269,27 @@ function Hireling:changeOutfit(outfit) self:setOutfit(outfit) end -function Hireling:hasSkill(SKILL) - local skills = getStorageForPlayer(self:getOwnerId(), HIRELING_STORAGE.SKILL) - if skills <= 0 then +function Hireling:hasSkill(skillName) + local function hasSkillFromPlayer(player) + if player then + return player:kv():scoped("hireling-skills"):get(skillName) or false + end + end + + local player = Player(self:getOwnerId()) or Game.getOfflinePlayer(self:getOwnerId()) + return hasSkillFromPlayer(player) +end + +function Hireling:hasSkill(skillName) + local function hasSkillFromPlayer(player) + if player then + return player:kv():scoped("hireling-skills"):get(skillName) or false + end + return false - else - return hasBitSet(SKILL, skills) end + local player = Player(self:getOwnerId()) or Game.getOfflinePlayer(self:getOwnerId()) + return hasSkillFromPlayer(player) end function Hireling:setCreature(cid) @@ -446,18 +412,39 @@ function getHirelingByPosition(position) return nil end +function GetHirelingSkillNameById(id) + for _, skill in pairs(HIRELING_SKILLS) do + if skill[1] == id then + return skill[2] + end + end + return nil +end + +function GetHirelingOutfitNameById(id) + local outfitName = nil + for _, outfit in pairs(HIRELING_OUTFITS) do + if outfit[1] == id then + logger.debug("[GetHirelingOutfitNameById] returning outfit name {}", outfit[2]) + outfitName = outfit[2] + break + end + end + + return outfitName +end + function HirelingsInit() local rows = db.storeQuery("SELECT * FROM `player_hirelings`") - if rows then + local player_id, hireling repeat - local player_id = Result.getNumber(rows, "player_id") - + player_id = Result.getNumber(rows, "player_id") if not PLAYER_HIRELINGS[player_id] then PLAYER_HIRELINGS[player_id] = {} end - local hireling = Hireling:new() + hireling = Hireling:new() hireling.id = Result.getNumber(rows, "id") hireling.player_id = player_id hireling.name = Result.getString(rows, "name") @@ -478,7 +465,6 @@ function HirelingsInit() Result.free(rows) spawnNPCs() - initStorageCache() end end @@ -521,9 +507,6 @@ function PersistHireling(hireling) end end --- [[ END GLOBAL FUNCTIONS ]] - --- [[ Player extension ]] function Player:getHirelings() return PLAYER_HIRELINGS[self:getGuid()] or {} end @@ -538,15 +521,17 @@ function Player:addNewHireling(name, sex) hireling.name = name hireling.player_id = self:getGuid() if sex == HIRELING_SEX.FEMALE then - hireling.looktype = 136 -- citizen female + -- Citizen female + hireling.looktype = 136 hireling.sex = HIRELING_SEX.FEMALE else - hireling.looktype = 128 -- citizen male + -- Citizen male + hireling.looktype = 128 hireling.sex = HIRELING_SEX.MALE end local lampType = ItemType(HIRELING_LAMP) - if self:getFreeCapacity() < lampType:getWeight(1) then + if not lampType or self:getFreeCapacity() < lampType:getWeight(1) then self:getPosition():sendMagicEffect(CONST_ME_POFF) self:sendTextMessage(MESSAGE_FAILURE, "You do not have enough capacity.") return false @@ -561,20 +546,26 @@ function Player:addNewHireling(name, sex) local saved = PersistHireling(hireling) if not saved then - DebugPrint("Error saving Hireling:" .. name .. " - player:" .. self:getName()) + logger.error("[Player:addNewHireling] error to saving Hireling '{}' for player '{}'", name, self:getName()) return false - else - if not PLAYER_HIRELINGS[self:getGuid()] then - PLAYER_HIRELINGS[self:getGuid()] = {} - end - table.insert(PLAYER_HIRELINGS[self:getGuid()], hireling) - table.insert(HIRELINGS, hireling) - local lamp = inbox:addItem(HIRELING_LAMP, 1, INDEX_WHEREEVER, FLAG_NOLIMIT) - lamp:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "This mysterious lamp summons your very own personal hireling.\nThis item cannot be traded.\nThis magic lamp is the home of " .. hireling:getName() .. ".") - lamp:setCustomAttribute("Hireling", hireling:getId()) --save hirelingId on item - hireling.active = 0 - return hireling end + + local lamp = inbox:addItem(HIRELING_LAMP, 1, INDEX_WHEREEVER, FLAG_NOLIMIT) + if not lamp then + logger.error("[Player:addNewHireling] error to add hireling lamp '{}' for player {}", name, self:getName()) + return false + end + + if not PLAYER_HIRELINGS[self:getGuid()] then + PLAYER_HIRELINGS[self:getGuid()] = {} + end + table.insert(PLAYER_HIRELINGS[self:getGuid()], hireling) + table.insert(HIRELINGS, hireling) + + lamp:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "This mysterious lamp summons your very own personal hireling.\nThis item cannot be traded.\nThis magic lamp is the home of " .. hireling:getName() .. ".") + lamp:setCustomAttribute("Hireling", hireling:getId()) + hireling.active = 0 + return hireling end function Player:isChangingHirelingOutfit() @@ -593,7 +584,8 @@ end function Player:sendHirelingOutfitWindow(hireling) local outfit = hireling:getOutfit() local msg = NetworkMessage() - msg:addByte(0xC8) -- 'ProtocolGame::sendOutfitWindow()'' header + -- 'ProtocolGame::sendOutfitWindow()' header + msg:addByte(0xC8) msg:addU16(outfit.lookType) if outfit.lookType == 0 then @@ -635,15 +627,6 @@ function Player:hasHirelings() return PLAYER_HIRELINGS[self:getGuid()] and #PLAYER_HIRELINGS[self:getGuid()] > 0 or false end -function Player:copyHirelingStorageToCache() - if self:hasHirelings() then - local storageSkill = self:getStorageValue(HIRELING_STORAGE.SKILL) - local storageOutfit = self:getStorageValue(HIRELING_STORAGE.OUTFIT) - addStorageCacheValue(self:getGuid(), HIRELING_STORAGE.SKILL, storageSkill) - addStorageCacheValue(self:getGuid(), HIRELING_STORAGE.OUTFIT, storageOutfit) - end -end - function Player:findHirelingLamp(hirelingId) local inbox = self:getSlotItem(CONST_SLOT_STORE_INBOX) if not inbox then @@ -705,42 +688,46 @@ function Player:showInfoModal(title, message, buttonText) modal:sendToPlayer(self) end -function Player:hasHirelingSkill(SKILL) - local skills = self:getStorageValue(HIRELING_STORAGE.SKILL) - if skills <= 0 then - return false - else - return hasBitSet(SKILL, skills) - end +function Player:hasHirelingSkill(skillName) + return self:kv():scoped("hireling-skills"):get(skillName) end -function Player:enableHirelingSkill(SKILL) - local skills = self:getStorageValue(HIRELING_STORAGE.SKILL) - if skills < 0 then - skills = 0 +function Player:enableHirelingSkill(skillName) + local skillScoped = self:kv():scoped("hireling-skills") + if skillScoped:get(skillName) then + logger.debug("Player '{}' already have hireling skill name '{}'", self:getName(), skillName) + return end - skills = setFlag(SKILL, skills) - self:setStorageValue(HIRELING_STORAGE.SKILL, skills) - self:copyHirelingStorageToCache() + + skillScoped:set(skillName, true) end -function Player:hasHirelingOutfit(OUTFIT) - local outfits = self:getStorageValue(HIRELING_STORAGE.OUTFIT) - if outfits <= 0 then - return false - else - return hasBitSet(OUTFIT, outfits) - end +function Player:hasHirelingOutfit(outfitName) + return self:kv():scoped("hireling-outfits"):get(outfitName) end -function Player:enableHirelingOutfit(OUTFIT) - local outfits = self:getStorageValue(HIRELING_STORAGE.OUTFIT) - if outfits < 0 then - outfits = 0 +function Player:enableHirelingOutfit(outfitName) + local outfitScoped = self:kv():scoped("hireling-outfits") + if outfitScoped:get(outfitName) then + logger.debug("Player '{}' already have hireling outfit name '{}'", self:getName(), outfitName) + return end - outfits = setFlag(OUTFIT, outfits) - self:setStorageValue(HIRELING_STORAGE.OUTFIT, outfits) - self:copyHirelingStorageToCache() + + outfitScoped:set(outfitName, true) end --- [[ END PLAYER EXTENSION ]] +function Player:clearAllHirelingStats() + local skillsScoped = self:kv():scoped("hireling-skills") + for key, skills in pairs(HIRELING_SKILLS) do + if skillsScoped:get(skills[2]) then + skillsScoped:set(skills[2], false) + end + end + + local outfitsScoped = self:kv():scoped("hireling-outfits") + for key, outfits in pairs(HIRELING_OUTFITS) do + if outfitsScoped:get(outfits[2]) then + outfitsScoped:set(outfits[2], false) + end + end +end diff --git a/data/modules/scripts/gamestore/gamestore.lua b/data/modules/scripts/gamestore/gamestore.lua index cfef21f6468..4559bd0f96d 100644 --- a/data/modules/scripts/gamestore/gamestore.lua +++ b/data/modules/scripts/gamestore/gamestore.lua @@ -6169,7 +6169,7 @@ GameStore.Categories = { icons = { "Hireling_Cook.png" }, name = "Hireling Cook", price = 900, - id = HIRELING_STORAGE.SKILL + HIRELING_SKILLS.COOKING, + id = HIRELING_SKILLS.COOKING[1], count = 1, number = 1, description = "{info} Give your hirelings the ability to cook exclusive status enhancement and instant recovery meals!", @@ -6179,7 +6179,7 @@ GameStore.Categories = { icons = { "Hireling_Trader.png" }, name = "Hireling Trader", price = 250, - id = HIRELING_STORAGE.SKILL + HIRELING_SKILLS.TRADER, + id = HIRELING_SKILLS.TRADER[1], count = 1, number = 1, description = "{info} Give your hirelings the ability of trading several types of items, including equipment, tools, potions, runes, wands and rods.", @@ -6189,7 +6189,7 @@ GameStore.Categories = { icons = { "Hireling_Steward.png" }, name = "Hireling Steward", price = 250, - id = HIRELING_STORAGE.SKILL + HIRELING_SKILLS.STEWARD, + id = HIRELING_SKILLS.STEWARD[1], count = 1, number = 1, description = "{info} Give your hirelings the ability to access and manage your stash at the confort of your from home", @@ -6199,7 +6199,7 @@ GameStore.Categories = { icons = { "Hireling_Banker.png" }, name = "Hireling Banker", price = 250, - id = HIRELING_STORAGE.SKILL + HIRELING_SKILLS.BANKER, + id = HIRELING_SKILLS.BANKER[1], count = 1, number = 1, description = "{info} Give your hirelings the ability of managing your banking business.", @@ -6219,7 +6219,7 @@ GameStore.Categories = { icons = { "Hireling_Banker.png" }, name = "Banker Dress", price = 500, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.BANKER, + id = HIRELING_OUTFITS.BANKER[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} colours can be changed using the Outfit dialog\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6229,7 +6229,7 @@ GameStore.Categories = { icons = { "Hireling_Trader.png" }, name = "Trader Dress", price = 500, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.TRADER, + id = HIRELING_OUTFITS.TRADER[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} colours can be changed using the Outfit dialog\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6239,7 +6239,7 @@ GameStore.Categories = { icons = { "Hireling_Cook.png" }, name = "Cook Dress", price = 500, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.COOKING, + id = HIRELING_OUTFITS.COOKING[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} colours can be changed using the Outfit dialog\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6249,7 +6249,7 @@ GameStore.Categories = { icons = { "Hireling_Steward.png" }, name = "Steward Dress", price = 500, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.STEWARD, + id = HIRELING_OUTFITS.STEWARD[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} colours can be changed using the Outfit dialog\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6259,7 +6259,7 @@ GameStore.Categories = { icons = { "Hireling_Servant.png" }, name = "Servant Dress", price = 300, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.SERVANT, + id = HIRELING_OUTFITS.SERVANT[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} colours can be changed using the Outfit dialog\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6269,7 +6269,7 @@ GameStore.Categories = { icons = { "Hireling_Hydra.png" }, name = "Hydra Dress", price = 900, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.HYDRA, + id = HIRELING_OUTFITS.HYDRA[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6279,7 +6279,7 @@ GameStore.Categories = { icons = { "Hireling_Ferumbras.png" }, name = "Ferumbras Dress", price = 900, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.FERUMBRAS, + id = HIRELING_OUTFITS.FERUMBRAS[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6289,7 +6289,7 @@ GameStore.Categories = { icons = { "Hireling_Bonelord.png" }, name = "Bonelord Dress", price = 900, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.BONELORD, + id = HIRELING_OUTFITS.BONELORD[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} number that can be purchased depends on the amount of hirelings you own", @@ -6299,7 +6299,7 @@ GameStore.Categories = { icons = { "Hireling_Dragon.png" }, name = "Dragon Dress", price = 900, - id = HIRELING_STORAGE.OUTFIT + HIRELING_OUTFITS.DRAGON, + id = HIRELING_OUTFITS.DRAGON[1], count = 1, number = 1, description = "{info} can only be used for hirelings of the purchasing character\n{activated}\n{info} the purchased dress can be used by all hirelings, however, how many hirelings can wear this outfit at the same time depends on the number of dresses you own\n{info} number that can be purchased depends on the amount of hirelings you own", diff --git a/data/modules/scripts/gamestore/init.lua b/data/modules/scripts/gamestore/init.lua index 1d80111fcbd..d905f8f876f 100644 --- a/data/modules/scripts/gamestore/init.lua +++ b/data/modules/scripts/gamestore/init.lua @@ -734,8 +734,7 @@ function Player.canBuyOffer(self, offer) disabledReason = "You already have bought the maximum number of allowed hirelings." end elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_HIRELING_SKILL then - local skill = (HIRELING_STORAGE.SKILL + offer.id) - if self:hasHirelingSkill(skill) then + if self:hasHirelingSkill(GetHirelingSkillNameById(offer.id)) then disabled = 1 disabledReason = "This skill is already unlocked." end @@ -744,8 +743,7 @@ function Player.canBuyOffer(self, offer) disabledReason = "You need to have a hireling." end elseif offer.type == GameStore.OfferTypes.OFFER_TYPE_HIRELING_OUTFIT then - local outfit = offer.id - HIRELING_STORAGE.OUTFIT - if self:hasHirelingOutfit(outfit) then + if self:hasHirelingOutfit(GetHirelingOutfitNameById(offer.id)) then disabled = 1 disabledReason = "This hireling outfit is already unlocked." end @@ -1872,8 +1870,7 @@ function GameStore.processHirelingSkillPurchase(player, offer) end player:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE) - local skill = offer.id - HIRELING_STORAGE.SKILL - player:enableHirelingSkill(skill) + player:enableHirelingSkill(GetHirelingSkillNameById(offer.id)) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A new hireling skill has been added to all your hirelings") end @@ -1882,9 +1879,10 @@ function GameStore.processHirelingOutfitPurchase(player, offer) return error({ code = 1, message = "You cannot buy hireling outfit on client 10, please relog on client 12 and try again." }) end + local outfitName = GetHirelingOutfitNameById(offer.id) + logger.debug("Processing hireling outfit purchase name {}", outfitName) player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) - local outfit = offer.id - HIRELING_STORAGE.OUTFIT - player:enableHirelingOutfit(outfit) + player:enableHirelingOutfit(outfitName) player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A new hireling outfit has been added to all your hirelings") end diff --git a/data/npclib/npc_system/modules.lua b/data/npclib/npc_system/modules.lua index 896fba8eccd..c8f2847c84f 100644 --- a/data/npclib/npc_system/modules.lua +++ b/data/npclib/npc_system/modules.lua @@ -106,6 +106,7 @@ if Modules == nil then else npcHandler:say(parameters.text, npc, player) player:setVocation(promotion) + player:kv():set("promoted", true) end else npcHandler:say("You need a premium account in order to get promoted.", npc, player) diff --git a/data/scripts/talkactions/god/hireling_clear_stats.lua b/data/scripts/talkactions/god/hireling_clear_stats.lua new file mode 100644 index 00000000000..0da98747f24 --- /dev/null +++ b/data/scripts/talkactions/god/hireling_clear_stats.lua @@ -0,0 +1,23 @@ +-- Very useful for testing environments +local talk = TalkAction("/clearhirelingstas") + +function talk.onSay(player, words, param) + -- create log + logCommand(player, words, param) + + local split = param:split(",") + local name = split[1] ~= "" and split[1] + local target = Player(name) + if target then + target:clearAllHirelingStats() + else + player:clearAllHirelingStats() + end + + player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN) + return true +end + +talk:separator(" ") +talk:groupType("god") +talk:register() diff --git a/data/scripts/talkactions/god/create_hirelinglamp.lua b/data/scripts/talkactions/god/hireling_create_lamp.lua similarity index 100% rename from data/scripts/talkactions/god/create_hirelinglamp.lua rename to data/scripts/talkactions/god/hireling_create_lamp.lua diff --git a/src/config/config_definitions.hpp b/src/config/config_definitions.hpp index 0aa8b0cd770..4983109c5b8 100644 --- a/src/config/config_definitions.hpp +++ b/src/config/config_definitions.hpp @@ -28,6 +28,8 @@ enum ConfigKey_t : uint16_t { CLASSIC_ATTACK_SPEED, SCRIPTS_CONSOLE_LOGS, REMOVE_WEAPON_AMMO, + REMOVE_BEGINNING_WEAPON_AMMO, + REFUND_BEGINNING_WEAPON_MANA, REMOVE_WEAPON_CHARGES, REMOVE_POTION_CHARGES, GLOBAL_SERVER_SAVE_NOTIFY_MESSAGE, diff --git a/src/config/configmanager.cpp b/src/config/configmanager.cpp index c4f0f140d62..fea78c8fec9 100644 --- a/src/config/configmanager.cpp +++ b/src/config/configmanager.cpp @@ -102,6 +102,8 @@ bool ConfigManager::load() { loadBoolConfig(L, ALLOW_BLOCK_SPAWN, "allowBlockSpawn", true); loadBoolConfig(L, REMOVE_WEAPON_AMMO, "removeWeaponAmmunition", true); loadBoolConfig(L, REMOVE_WEAPON_CHARGES, "removeWeaponCharges", true); + loadBoolConfig(L, REMOVE_BEGINNING_WEAPON_AMMO, "removeBeginningWeaponAmmunition", true); + loadBoolConfig(L, REFUND_BEGINNING_WEAPON_MANA, "refundBeginningWeaponMana", false); loadBoolConfig(L, REMOVE_POTION_CHARGES, "removeChargesFromPotions", true); loadBoolConfig(L, GLOBAL_SERVER_SAVE_NOTIFY_MESSAGE, "globalServerSaveNotifyMessage", true); loadBoolConfig(L, GLOBAL_SERVER_SAVE_CLEAN_MAP, "globalServerSaveCleanMap", false); diff --git a/src/core.hpp b/src/core.hpp index aea1993b262..67262257a32 100644 --- a/src/core.hpp +++ b/src/core.hpp @@ -14,7 +14,7 @@ static constexpr auto AUTHENTICATOR_PERIOD = 30U; // SERVER_MAJOR_VERSION is the actual full version of the server, including minor and patch numbers. // This is intended for internal use to identify the exact state of the server (release) software. -static constexpr auto SERVER_RELEASE_VERSION = "3.1.1"; +static constexpr auto SERVER_RELEASE_VERSION = "3.1.2"; static constexpr auto CLIENT_VERSION = 1321; #define CLIENT_VERSION_UPPER (CLIENT_VERSION / 100) diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index 648ce4da4c2..3991d01c1c1 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -261,7 +261,7 @@ void Npc::onPlayerBuyItem(std::shared_ptr player, uint16_t itemId, uint8 } uint32_t buyPrice = 0; - const std::vector &shopVector = getShopItemVector(); + const std::vector &shopVector = getShopItemVector(player->getGUID()); for (ShopBlock shopBlock : shopVector) { if (itemType.id == shopBlock.itemId && shopBlock.itemBuyPrice != 0) { buyPrice = shopBlock.itemBuyPrice; @@ -370,7 +370,7 @@ void Npc::onPlayerSellItem(std::shared_ptr player, uint16_t itemId, uint uint32_t sellPrice = 0; const ItemType &itemType = Item::items[itemId]; - const std::vector &shopVector = getShopItemVector(); + const std::vector &shopVector = getShopItemVector(player->getGUID()); for (ShopBlock shopBlock : shopVector) { if (itemType.id == shopBlock.itemId && shopBlock.itemSellPrice != 0) { sellPrice = shopBlock.itemSellPrice; @@ -642,23 +642,25 @@ bool Npc::getRandomStep(Direction &moveDirection) { return false; } -void Npc::addShopPlayer(const std::shared_ptr &player) { +void Npc::addShopPlayer(const std::shared_ptr &player, const std::vector &shopItems /* = {}*/) { if (!player) { return; } - shopPlayerMap.try_emplace(player->getID(), player); + + shopPlayerMap.try_emplace(player->getGUID(), shopItems); } void Npc::removeShopPlayer(const std::shared_ptr &player) { if (!player) { return; } - shopPlayerMap.erase(player->getID()); + + shopPlayerMap.erase(player->getGUID()); } void Npc::closeAllShopWindows() { - for (auto &[_, playerPtr] : shopPlayerMap) { - auto shopPlayer = playerPtr.lock(); + for (const auto &[playerGUID, playerPtr] : shopPlayerMap) { + auto shopPlayer = g_game().getPlayerByGUID(playerGUID); if (shopPlayer) { shopPlayer->closeShopWindow(); } diff --git a/src/creatures/npcs/npc.hpp b/src/creatures/npcs/npc.hpp index 5f118360528..393b24867a1 100644 --- a/src/creatures/npcs/npc.hpp +++ b/src/creatures/npcs/npc.hpp @@ -96,7 +96,14 @@ class Npc final : public Creature { npcType->info.currencyId = currency; } - std::vector getShopItemVector() { + std::vector getShopItemVector(uint32_t playerGUID) { + if (playerGUID != 0) { + auto it = shopPlayerMap.find(playerGUID); + if (it != shopPlayerMap.end() && !it->second.empty()) { + return it->second; + } + } + return npcType->info.shopItemVector; } @@ -159,7 +166,7 @@ class Npc final : public Creature { internalLight = npcType->info.light; } - void addShopPlayer(const std::shared_ptr &player); + void addShopPlayer(const std::shared_ptr &player, const std::vector &shopItems = {}); void removeShopPlayer(const std::shared_ptr &player); void closeAllShopWindows(); @@ -178,7 +185,7 @@ class Npc final : public Creature { std::map playerInteractions; - phmap::flat_hash_map> shopPlayerMap; + phmap::flat_hash_map> shopPlayerMap; std::shared_ptr npcType; std::shared_ptr spawnNpc; diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 44bf33d09b1..0c68ec3a659 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -1474,7 +1474,7 @@ void Player::openImbuementWindow(std::shared_ptr item) { void Player::sendSaleItemList(const std::map &inventoryMap) const { if (client && shopOwner) { - client->sendSaleItemList(shopOwner->getShopItemVector(), inventoryMap); + client->sendSaleItemList(shopOwner->getShopItemVector(getGUID()), inventoryMap); } } @@ -1781,7 +1781,6 @@ bool Player::openShopWindow(std::shared_ptr npc) { } setShopOwner(npc); - npc->addShopPlayer(static_self_cast()); sendShop(npc); std::map inventoryMap; @@ -4130,7 +4129,7 @@ bool Player::hasShopItemForSale(uint16_t itemId, uint8_t subType) const { } const ItemType &itemType = Item::items[itemId]; - std::vector shoplist = shopOwner->getShopItemVector(); + std::vector shoplist = shopOwner->getShopItemVector(getGUID()); return std::any_of(shoplist.begin(), shoplist.end(), [&](const ShopBlock &shopBlock) { return shopBlock.itemId == itemId && shopBlock.itemBuyPrice != 0 && (!itemType.isFluidContainer() || shopBlock.itemSubType == subType); }); diff --git a/src/game/game.cpp b/src/game/game.cpp index a9a2786de1a..5dcba79adc1 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -7223,7 +7223,13 @@ bool Game::combatChangeMana(std::shared_ptr attacker, std::shared_ptr< } target->drainMana(attacker, manaLoss); - + if (targetPlayer) { + std::string cause = "(other)"; + if (attacker) { + cause = attacker->getName(); + } + targetPlayer->updateInputAnalyzer(damage.primary.type, damage.primary.value * -1, cause); + } std::stringstream ss; std::string damageString = std::to_string(manaLoss); diff --git a/src/items/weapons/weapons.cpp b/src/items/weapons/weapons.cpp index 0e5d1e949bb..796aea212a6 100644 --- a/src/items/weapons/weapons.cpp +++ b/src/items/weapons/weapons.cpp @@ -252,6 +252,10 @@ void Weapon::onUsedWeapon(std::shared_ptr player, std::shared_ptr if (manaCost != 0) { player->addManaSpent(manaCost); player->changeMana(-static_cast(manaCost)); + + if (g_configManager().getBoolean(REFUND_BEGINNING_WEAPON_MANA, __FUNCTION__) && (item->getName() == "wand of vortex" || item->getName() == "snakebite rod")) { + player->changeMana(static_cast(manaCost)); + } } uint32_t healthCost = getHealthCost(player); @@ -263,7 +267,8 @@ void Weapon::onUsedWeapon(std::shared_ptr player, std::shared_ptr player->changeSoul(-static_cast(soul)); } - if (breakChance != 0 && uniform_random(1, 100) <= breakChance) { + bool skipRemoveBeginningWeaponAmmo = !g_configManager().getBoolean(REMOVE_BEGINNING_WEAPON_AMMO, __FUNCTION__) && (item->getName() == "arrow" || item->getName() == "bolt" || item->getName() == "spear"); + if (!skipRemoveBeginningWeaponAmmo && breakChance != 0 && uniform_random(1, 100) <= breakChance) { Weapon::decrementItemCount(item); player->updateSupplyTracker(item); return; @@ -271,7 +276,7 @@ void Weapon::onUsedWeapon(std::shared_ptr player, std::shared_ptr switch (action) { case WEAPONACTION_REMOVECOUNT: - if (g_configManager().getBoolean(REMOVE_WEAPON_AMMO, __FUNCTION__)) { + if (!skipRemoveBeginningWeaponAmmo && g_configManager().getBoolean(REMOVE_WEAPON_AMMO, __FUNCTION__)) { Weapon::decrementItemCount(item); player->updateSupplyTracker(item); } diff --git a/src/lua/functions/creatures/monster/monster_functions.cpp b/src/lua/functions/creatures/monster/monster_functions.cpp index e0f702f249e..5e32115a21c 100644 --- a/src/lua/functions/creatures/monster/monster_functions.cpp +++ b/src/lua/functions/creatures/monster/monster_functions.cpp @@ -15,6 +15,7 @@ #include "creatures/monsters/monsters.hpp" #include "lua/functions/creatures/monster/monster_functions.hpp" #include "map/spectators.hpp" +#include "game/scheduling/events_scheduler.hpp" int MonsterFunctions::luaMonsterCreate(lua_State* L) { // Monster(id or userdata) @@ -350,19 +351,22 @@ int MonsterFunctions::luaMonsterSearchTarget(lua_State* L) { } int MonsterFunctions::luaMonsterSetSpawnPosition(lua_State* L) { - // monster:setSpawnPosition() + // monster:setSpawnPosition(interval) std::shared_ptr monster = getUserdataShared(L, 1); if (!monster) { lua_pushnil(L); return 1; } + uint32_t eventschedule = g_eventsScheduler().getSpawnMonsterSchedule(); + const Position &pos = monster->getPosition(); monster->setMasterPos(pos); g_game().map.spawnsMonster.getspawnMonsterList().emplace_front(pos, 5); SpawnMonster &spawnMonster = g_game().map.spawnsMonster.getspawnMonsterList().front(); - spawnMonster.addMonster(monster->mType->name, pos, DIRECTION_NORTH, 60000); + uint32_t interval = getNumber(L, 2, 90) * 1000 * 100 / std::max((uint32_t)1, (g_configManager().getNumber(RATE_SPAWN, __FUNCTION__) * eventschedule)); + spawnMonster.addMonster(monster->mType->typeName, pos, DIRECTION_NORTH, static_cast(interval)); spawnMonster.startSpawnMonsterCheck(); pushBoolean(L, true); diff --git a/src/lua/functions/creatures/npc/npc_functions.cpp b/src/lua/functions/creatures/npc/npc_functions.cpp index d24ed978ac8..0df0b55041a 100644 --- a/src/lua/functions/creatures/npc/npc_functions.cpp +++ b/src/lua/functions/creatures/npc/npc_functions.cpp @@ -354,6 +354,60 @@ int NpcFunctions::luaNpcOpenShopWindow(lua_State* L) { return 1; } + npc->addShopPlayer(player); + pushBoolean(L, player->openShopWindow(npc)); + return 1; +} + +int NpcFunctions::luaNpcOpenShopWindowTable(lua_State* L) { + // npc:openShopWindowTable(player, items) + const auto &npc = getUserdataShared(L, 1); + if (!npc) { + reportErrorFunc(getErrorDesc(LUA_ERROR_NPC_NOT_FOUND)); + pushBoolean(L, false); + return 1; + } + + const auto &player = getUserdataShared(L, 2); + if (!player) { + reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND)); + return 1; + } + + if (lua_istable(L, 3) == 0) { + reportError(__FUNCTION__, "item list is not a table."); + pushBoolean(L, false); + return 1; + } + + std::vector items; + lua_pushnil(L); + while (lua_next(L, 3) != 0) { + const auto tableIndex = lua_gettop(L); + ShopBlock item; + + auto itemId = getField(L, tableIndex, "clientId"); + auto subType = getField(L, tableIndex, "subType"); + if (subType == 0) { + subType = getField(L, tableIndex, "subtype"); + lua_pop(L, 1); + } + + auto buyPrice = getField(L, tableIndex, "buy"); + auto sellPrice = getField(L, tableIndex, "sell"); + auto storageKey = getField(L, tableIndex, "storageKey"); + auto storageValue = getField(L, tableIndex, "storageValue"); + auto realName = getFieldString(L, tableIndex, "name"); + g_logger().debug("[{}] item '{}' sell price '{}', buyprice '{}'", __FUNCTION__, realName, sellPrice, buyPrice); + + items.emplace_back(itemId, subType, buyPrice, sellPrice, storageKey, storageValue, std::move(realName)); + lua_pop(L, 8); + } + lua_pop(L, 3); + + // Close any eventual other shop window currently open. + player->closeShopWindow(true); + npc->addShopPlayer(player, items); pushBoolean(L, player->openShopWindow(npc)); return 1; } @@ -391,8 +445,8 @@ int NpcFunctions::luaNpcIsMerchant(lua_State* L) { return 1; } - const std::vector shopItems = npc->getShopItemVector(); - + auto playerGUID = getNumber(L, 2, 0); + const auto &shopItems = npc->getShopItemVector(playerGUID); if (shopItems.empty()) { pushBoolean(L, false); return 1; @@ -411,8 +465,9 @@ int NpcFunctions::luaNpcGetShopItem(lua_State* L) { return 1; } - const std::vector &shopVector = npc->getShopItemVector(); - for (ShopBlock shopBlock : shopVector) { + auto playerGUID = getNumber(L, 2, 0); + const auto &shopItems = npc->getShopItemVector(playerGUID); + for (ShopBlock shopBlock : shopItems) { setField(L, "id", shopBlock.itemId); setField(L, "name", shopBlock.itemName); setField(L, "subType", shopBlock.itemSubType); @@ -522,7 +577,7 @@ int NpcFunctions::luaNpcSellItem(lua_State* L) { } uint64_t pricePerUnit = 0; - const std::vector &shopVector = npc->getShopItemVector(); + const std::vector &shopVector = npc->getShopItemVector(player->getGUID()); for (ShopBlock shopBlock : shopVector) { if (itemId == shopBlock.itemId && shopBlock.itemBuyPrice != 0) { pricePerUnit = shopBlock.itemBuyPrice; diff --git a/src/lua/functions/creatures/npc/npc_functions.hpp b/src/lua/functions/creatures/npc/npc_functions.hpp index 7671780e720..ef3371a54fb 100644 --- a/src/lua/functions/creatures/npc/npc_functions.hpp +++ b/src/lua/functions/creatures/npc/npc_functions.hpp @@ -36,6 +36,7 @@ class NpcFunctions final : LuaScriptInterface { registerMethod(L, "Npc", "isInTalkRange", NpcFunctions::luaNpcIsInTalkRange); registerMethod(L, "Npc", "isPlayerInteractingOnTopic", NpcFunctions::luaNpcIsPlayerInteractingOnTopic); registerMethod(L, "Npc", "openShopWindow", NpcFunctions::luaNpcOpenShopWindow); + registerMethod(L, "Npc", "openShopWindowTable", NpcFunctions::luaNpcOpenShopWindowTable); registerMethod(L, "Npc", "closeShopWindow", NpcFunctions::luaNpcCloseShopWindow); registerMethod(L, "Npc", "getShopItem", NpcFunctions::luaNpcGetShopItem); registerMethod(L, "Npc", "isMerchant", NpcFunctions::luaNpcIsMerchant); @@ -73,6 +74,7 @@ class NpcFunctions final : LuaScriptInterface { static int luaNpcIsInTalkRange(lua_State* L); static int luaNpcIsPlayerInteractingOnTopic(lua_State* L); static int luaNpcOpenShopWindow(lua_State* L); + static int luaNpcOpenShopWindowTable(lua_State* L); static int luaNpcCloseShopWindow(lua_State* L); static int luaNpcGetShopItem(lua_State* L); static int luaNpcIsMerchant(lua_State* L); diff --git a/src/lua/functions/lua_functions_loader.hpp b/src/lua/functions/lua_functions_loader.hpp index 90285daffa1..17495cd2e63 100644 --- a/src/lua/functions/lua_functions_loader.hpp +++ b/src/lua/functions/lua_functions_loader.hpp @@ -68,7 +68,7 @@ class LuaFunctionsLoader { // If there is overflow, we return the value 0 if constexpr (std::is_integral_v && std::is_unsigned_v) { if (number < 0) { - g_logger().warn("[{}] overflow, setting to default signed value (0)", __FUNCTION__); + g_logger().debug("[{}] overflow, setting to default signed value (0)", __FUNCTION__); number = T(0); } } diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 38014a3a511..958d19f2a71 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -4360,7 +4360,7 @@ void ProtocolGame::sendShop(std::shared_ptr npc) { msg.addString(std::string()); // Currency name } - std::vector shoplist = npc->getShopItemVector(); + std::vector shoplist = npc->getShopItemVector(player->getGUID()); uint16_t itemsToSend = std::min(shoplist.size(), std::numeric_limits::max()); msg.add(itemsToSend);