From 8af607bdf87ab8004ed01e9557175f2d33116eec Mon Sep 17 00:00:00 2001 From: Paulo Henrique Lisboa Date: Tue, 11 Jun 2024 10:05:04 -0300 Subject: [PATCH 01/17] fix: docker ubuntu package and start.sh permission (#2681) --- docker/Dockerfile.dev | 6 +++--- docker/data/start.sh | 4 ++-- docker/docker-compose.yml | 2 -- start.sh | 0 4 files changed, 5 insertions(+), 7 deletions(-) mode change 100644 => 100755 start.sh diff --git a/docker/Dockerfile.dev b/docker/Dockerfile.dev index 161a80a2e21..4cd63334d5e 100644 --- a/docker/Dockerfile.dev +++ b/docker/Dockerfile.dev @@ -1,10 +1,10 @@ # Stage 1: Download all dependencies -FROM ubuntu:23.04 AS dependencies +FROM ubuntu:24.04 AS dependencies RUN --mount=type=cache,target=/var/cache/apt \ apt-get update && apt-get install -y --no-install-recommends cmake git \ unzip build-essential ca-certificates curl zip unzip tar \ - pkg-config ninja-build autoconf automake libtool \ + pkg-config ninja-build autoconf automake libtool glibc-tools \ python3 \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* @@ -32,7 +32,7 @@ COPY recompile.sh CMakeLists.txt CMakePresets.json vcpkg.json ./ RUN ./recompile.sh "/opt" # Stage 3: execute -FROM ubuntu:23.04 AS prod +FROM ubuntu:24.04 AS prod COPY --from=build /srv/build/build/linux-release/bin/canary /bin/canary WORKDIR /srv/canary ENTRYPOINT ["/srv/canary/start.sh", "canary"] diff --git a/docker/data/start.sh b/docker/data/start.sh index db688b488d0..c7d10fa0fdb 100755 --- a/docker/data/start.sh +++ b/docker/data/start.sh @@ -10,8 +10,8 @@ OT_SERVER_LOGIN_PORT="${OT_SERVER_LOGIN_PORT:-7171}" OT_SERVER_GAME_PORT="${OT_SERVER_GAME_PORT:-7172}" OT_SERVER_STATUS_PORT="${OT_SERVER_STATUS_PORT:-7171}" OT_SERVER_TEST_ACCOUNTS="${OT_SERVER_TEST_ACCOUNTS:-false}" -OT_SERVER_DATA="${OT_SERVER_DATA:-data-canary}" -OT_SERVER_MAP="${OT_SERVER_MAP:-https://github.com/opentibiabr/otservbr-global/releases/download/v1.5.0/otservbr.otbm}" +OT_SERVER_DATA="${OT_SERVER_DATA:-data-otservbr-global}" +OT_SERVER_MAP="${OT_SERVER_MAP:-https://github.com/opentibiabr/canary/releases/download/v3.1.0/otservbr.otbm}" echo "" echo "===== Print Variables =====" diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 46a2fb619b2..88fd938e500 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -1,5 +1,3 @@ ---- -version: '3.8' name: otbr services: database: diff --git a/start.sh b/start.sh old mode 100644 new mode 100755 From ede4b035bcb3c664bd42c757f1d4466b8d7b5c43 Mon Sep 17 00:00:00 2001 From: Felipe Paluco <87909998+FelipePaluco@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:05:20 -0300 Subject: [PATCH 02/17] feat: rebalancing monsters (#2683) --- data-canary/monster/demons/fury.lua | 2 +- data-canary/monster/demons/juggernaut.lua | 4 ++-- .../monster/aquatics/quara_constrictor.lua | 2 +- .../monster/aquatics/quara_hydromancer.lua | 2 +- .../monster/aquatics/quara_mantassin.lua | 2 +- .../monster/aquatics/quara_pincher.lua | 2 +- .../monster/aquatics/quara_predator.lua | 2 +- data-otservbr-global/monster/bosses/splasher.lua | 2 +- .../monster/constructs/clay_guardian.lua | 2 +- .../monster/constructs/infected_weeper.lua | 2 +- .../monster/constructs/lava_golem.lua | 3 +-- .../monster/constructs/magma_crawler.lua | 8 ++++---- .../monster/constructs/orewalker.lua | 3 +-- .../monster/constructs/stone_devourer.lua | 2 +- data-otservbr-global/monster/constructs/weeper.lua | 6 +++--- .../monster/demons/hellfire_fighter.lua | 2 +- .../monster/elementals/cliff_strider.lua | 6 +++--- .../monster/elementals/earth_elemental.lua | 4 ++-- .../monster/elementals/high_voltage_elemental.lua | 2 +- .../monster/elementals/ironblight.lua | 2 +- .../monster/elementals/massive_earth_elemental.lua | 4 ++-- .../monster/elementals/sulphur_spouter.lua | 2 +- .../monster/humanoids/lost_basher.lua | 6 +++--- .../monster/humanoids/lost_berserker.lua | 12 +++++------- .../monster/humanoids/lost_husher.lua | 9 ++++----- .../monster/humanoids/lost_thrower.lua | 6 +++--- data-otservbr-global/monster/magicals/armadile.lua | 13 +++++-------- .../monster/magicals/choking_fear.lua | 2 +- data-otservbr-global/monster/magicals/phantasm.lua | 2 +- .../monster/magicals/retching_horror.lua | 2 +- .../monster/mammals/mutated_bat.lua | 2 +- .../monster/plants/hideous_fungus.lua | 13 ++++++------- .../monster/plants/humongous_fungus.lua | 7 +++---- .../quests/bigfoots_burden/bosses/abyssador.lua | 2 +- .../quests/bigfoots_burden/bosses/gnomevil.lua | 2 +- .../quests/bigfoots_burden/humorless_fungus.lua | 9 +++------ .../bosses/the_count_of_the_core.lua | 2 +- .../bosses/the_duke_of_the_depths.lua | 2 +- .../bosses/ferumbras_mortal_shell.lua | 2 +- .../quests/ferumbras_ascendant/bosses/mazoran.lua | 2 +- .../quests/ferumbras_ascendant/bosses/plagirath.lua | 2 +- .../quests/ferumbras_ascendant/bosses/ragiaz.lua | 2 +- .../quests/ferumbras_ascendant/bosses/razzagorn.lua | 2 +- .../quests/ferumbras_ascendant/bosses/shulgrax.lua | 2 +- .../quests/ferumbras_ascendant/bosses/tarbaz.lua | 2 +- .../quests/ferumbras_ascendant/bosses/zamulosh.lua | 2 +- .../monster/quests/in_service_of_yalahar/inky.lua | 2 +- .../quests/in_service_of_yalahar/sharptooth.lua | 2 +- .../monster/reptiles/seacrest_serpent.lua | 2 +- .../monster/reptiles/young_sea_serpent.lua | 2 +- .../monster/undeads/betrayed_wraith.lua | 2 +- .../monster/undeads/blightwalker.lua | 7 +++---- .../monster/undeads/crypt_warrior.lua | 2 +- .../monster/undeads/falcon_knight.lua | 2 +- .../monster/undeads/falcon_paladin.lua | 2 +- .../monster/undeads/hand_of_cursed_fate.lua | 4 ++-- .../monster/undeads/skeleton_elite_warrior.lua | 2 +- .../monster/undeads/undead_dragon.lua | 2 +- .../monster/undeads/undead_elite_gladiator.lua | 2 +- .../monster/vermins/cave_devourer.lua | 4 ++-- .../monster/vermins/chasm_spawn.lua | 4 ++-- data-otservbr-global/monster/vermins/deepworm.lua | 2 +- data-otservbr-global/monster/vermins/diremaw.lua | 2 +- data-otservbr-global/monster/vermins/drillworm.lua | 2 +- .../monster/vermins/tunnel_tyrant.lua | 4 ++-- ...d_,master_oberon.lua => grand_master_oberon.lua} | 0 66 files changed, 105 insertions(+), 119 deletions(-) rename data-otservbr-global/scripts/actions/bosses_levers/{grand_,master_oberon.lua => grand_master_oberon.lua} (100%) diff --git a/data-canary/monster/demons/fury.lua b/data-canary/monster/demons/fury.lua index 3835050ce67..a01553afeed 100644 --- a/data-canary/monster/demons/fury.lua +++ b/data-canary/monster/demons/fury.lua @@ -125,7 +125,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 30 }, + { type = COMBAT_ICEDAMAGE, percent = 5 }, { type = COMBAT_HOLYDAMAGE, percent = 30 }, { type = COMBAT_DEATHDAMAGE, percent = -10 }, } diff --git a/data-canary/monster/demons/juggernaut.lua b/data-canary/monster/demons/juggernaut.lua index 7b3e3d1795b..704ce847f13 100644 --- a/data-canary/monster/demons/juggernaut.lua +++ b/data-canary/monster/demons/juggernaut.lua @@ -27,8 +27,8 @@ monster.Bestiary = { The Blood Halls, The Vats, The Hive, The Shadow Nexus, a room deep in Formorgar Mines, Roshamuul Prison, Oramond Dungeon, Grounds of Destruction.", } -monster.health = 20000 -monster.maxHealth = 20000 +monster.health = 18000 +monster.maxHealth = 18000 monster.race = "blood" monster.corpse = 6335 monster.speed = 170 diff --git a/data-otservbr-global/monster/aquatics/quara_constrictor.lua b/data-otservbr-global/monster/aquatics/quara_constrictor.lua index 02b4877620e..c04460f1f50 100644 --- a/data-otservbr-global/monster/aquatics/quara_constrictor.lua +++ b/data-otservbr-global/monster/aquatics/quara_constrictor.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Quara Constrictor") local monster = {} monster.description = "a quara constrictor" -monster.experience = 250 +monster.experience = 380 monster.outfit = { lookType = 46, lookHead = 0, diff --git a/data-otservbr-global/monster/aquatics/quara_hydromancer.lua b/data-otservbr-global/monster/aquatics/quara_hydromancer.lua index 4129dcfe81c..07c3ffbfda3 100644 --- a/data-otservbr-global/monster/aquatics/quara_hydromancer.lua +++ b/data-otservbr-global/monster/aquatics/quara_hydromancer.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Quara Hydromancer") local monster = {} monster.description = "a quara hydromancer" -monster.experience = 800 +monster.experience = 950 monster.outfit = { lookType = 47, lookHead = 0, diff --git a/data-otservbr-global/monster/aquatics/quara_mantassin.lua b/data-otservbr-global/monster/aquatics/quara_mantassin.lua index 53594881d50..3e857cab7f2 100644 --- a/data-otservbr-global/monster/aquatics/quara_mantassin.lua +++ b/data-otservbr-global/monster/aquatics/quara_mantassin.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Quara Mantassin") local monster = {} monster.description = "a quara mantassin" -monster.experience = 400 +monster.experience = 600 monster.outfit = { lookType = 72, lookHead = 0, diff --git a/data-otservbr-global/monster/aquatics/quara_pincher.lua b/data-otservbr-global/monster/aquatics/quara_pincher.lua index 200aed87628..09fea436314 100644 --- a/data-otservbr-global/monster/aquatics/quara_pincher.lua +++ b/data-otservbr-global/monster/aquatics/quara_pincher.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Quara Pincher") local monster = {} monster.description = "a quara pincher" -monster.experience = 1200 +monster.experience = 1500 monster.outfit = { lookType = 77, lookHead = 0, diff --git a/data-otservbr-global/monster/aquatics/quara_predator.lua b/data-otservbr-global/monster/aquatics/quara_predator.lua index e513aa5712c..b12719e26f8 100644 --- a/data-otservbr-global/monster/aquatics/quara_predator.lua +++ b/data-otservbr-global/monster/aquatics/quara_predator.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Quara Predator") local monster = {} monster.description = "a quara predator" -monster.experience = 1600 +monster.experience = 1850 monster.outfit = { lookType = 20, lookHead = 0, diff --git a/data-otservbr-global/monster/bosses/splasher.lua b/data-otservbr-global/monster/bosses/splasher.lua index 60b89710c4f..426d3be3c26 100644 --- a/data-otservbr-global/monster/bosses/splasher.lua +++ b/data-otservbr-global/monster/bosses/splasher.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Splasher") local monster = {} monster.description = "Splasher" -monster.experience = 500 +monster.experience = 1500 monster.outfit = { lookType = 47, lookHead = 0, diff --git a/data-otservbr-global/monster/constructs/clay_guardian.lua b/data-otservbr-global/monster/constructs/clay_guardian.lua index 804d671bdf9..fb28abe50c3 100644 --- a/data-otservbr-global/monster/constructs/clay_guardian.lua +++ b/data-otservbr-global/monster/constructs/clay_guardian.lua @@ -107,7 +107,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 35 }, + { type = COMBAT_ICEDAMAGE, percent = 20 }, { type = COMBAT_HOLYDAMAGE, percent = 0 }, { type = COMBAT_DEATHDAMAGE, percent = 40 }, } diff --git a/data-otservbr-global/monster/constructs/infected_weeper.lua b/data-otservbr-global/monster/constructs/infected_weeper.lua index e302618f3eb..2b7d97f0479 100644 --- a/data-otservbr-global/monster/constructs/infected_weeper.lua +++ b/data-otservbr-global/monster/constructs/infected_weeper.lua @@ -105,7 +105,7 @@ monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 50 }, { type = COMBAT_ENERGYDAMAGE, percent = 25 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, - { type = COMBAT_FIREDAMAGE, percent = 100 }, + { type = COMBAT_FIREDAMAGE, percent = -100 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, diff --git a/data-otservbr-global/monster/constructs/lava_golem.lua b/data-otservbr-global/monster/constructs/lava_golem.lua index aed9ad864c0..5c3f695cf32 100644 --- a/data-otservbr-global/monster/constructs/lava_golem.lua +++ b/data-otservbr-global/monster/constructs/lava_golem.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Lava Golem") local monster = {} monster.description = "a lava golem" -monster.experience = 6200 +monster.experience = 7900 monster.outfit = { lookType = 491, lookHead = 0, @@ -109,7 +109,6 @@ monster.loot = { monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -400 }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_FIREDAMAGE, minDamage = -350, maxDamage = -700, length = 8, spread = 0, effect = CONST_ME_FIREATTACK, target = false }, - { name = "combat", interval = 2000, chance = 10, type = COMBAT_MANADRAIN, minDamage = -600, maxDamage = -1300, length = 8, spread = 3, effect = CONST_ME_MORTAREA, target = false }, { name = "lava golem soulfire", interval = 2000, chance = 15, target = false }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_FIREDAMAGE, minDamage = -220, maxDamage = -350, radius = 4, effect = CONST_ME_FIREAREA, target = true }, { name = "speed", interval = 2000, chance = 10, speedChange = -800, length = 5, spread = 3, effect = CONST_ME_BLOCKHIT, target = false, duration = 30000 }, diff --git a/data-otservbr-global/monster/constructs/magma_crawler.lua b/data-otservbr-global/monster/constructs/magma_crawler.lua index 39c58ab8838..bf5f7ac4feb 100644 --- a/data-otservbr-global/monster/constructs/magma_crawler.lua +++ b/data-otservbr-global/monster/constructs/magma_crawler.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Magma Crawler") local monster = {} monster.description = "a magma crawler" -monster.experience = 2700 +monster.experience = 3900 monster.outfit = { lookType = 492, lookHead = 0, @@ -35,7 +35,7 @@ monster.manaCost = 0 monster.changeTarget = { interval = 4000, - chance = 10, + chance = 5, } monster.strategiesTarget = { @@ -118,7 +118,7 @@ monster.defenses = { defense = 45, armor = 84, mitigation = 2.51, - { name = "invisible", interval = 2000, chance = 10, effect = CONST_ME_MAGIC_BLUE }, + { name = "invisible", interval = 2000, chance = 5, effect = CONST_ME_MAGIC_BLUE }, } monster.elements = { @@ -129,7 +129,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 10 }, + { type = COMBAT_ICEDAMAGE, percent = 0 }, { type = COMBAT_HOLYDAMAGE, percent = 0 }, { type = COMBAT_DEATHDAMAGE, percent = 25 }, } diff --git a/data-otservbr-global/monster/constructs/orewalker.lua b/data-otservbr-global/monster/constructs/orewalker.lua index 767b8a049ae..3e1dc4deedd 100644 --- a/data-otservbr-global/monster/constructs/orewalker.lua +++ b/data-otservbr-global/monster/constructs/orewalker.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Orewalker") local monster = {} monster.description = "an orewalker" -monster.experience = 4800 +monster.experience = 5900 monster.outfit = { lookType = 490, lookHead = 0, @@ -112,7 +112,6 @@ monster.attacks = { { name = "combat", interval = 2000, chance = 10, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -1500, length = 6, spread = 3, effect = CONST_ME_GROUNDSHAKER, target = false }, -- poison { name = "condition", type = CONDITION_POISON, interval = 2000, chance = 10, minDamage = -800, maxDamage = -1080, radius = 3, shootEffect = CONST_ANI_SMALLEARTH, effect = CONST_ME_SMALLPLANTS, target = true }, - { name = "drunk", interval = 2000, chance = 15, radius = 4, effect = CONST_ME_SOUND_PURPLE, target = false, duration = 6000 }, { name = "speed", interval = 2000, chance = 15, speedChange = -800, radius = 2, effect = CONST_ME_MAGIC_RED, target = false, duration = 20000 }, } diff --git a/data-otservbr-global/monster/constructs/stone_devourer.lua b/data-otservbr-global/monster/constructs/stone_devourer.lua index 5a9174c3129..39c85402870 100644 --- a/data-otservbr-global/monster/constructs/stone_devourer.lua +++ b/data-otservbr-global/monster/constructs/stone_devourer.lua @@ -118,7 +118,7 @@ monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 10 }, { type = COMBAT_ENERGYDAMAGE, percent = 30 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, - { type = COMBAT_FIREDAMAGE, percent = 100 }, + { type = COMBAT_FIREDAMAGE, percent = -5 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, diff --git a/data-otservbr-global/monster/constructs/weeper.lua b/data-otservbr-global/monster/constructs/weeper.lua index 75a8d7ebb42..cfc7c6b0d68 100644 --- a/data-otservbr-global/monster/constructs/weeper.lua +++ b/data-otservbr-global/monster/constructs/weeper.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Weeper") local monster = {} monster.description = "a weeper" -monster.experience = 4800 +monster.experience = 5800 monster.outfit = { lookType = 489, lookHead = 0, @@ -55,7 +55,7 @@ monster.flags = { canPushCreatures = true, staticAttackChance = 70, targetDistance = 1, - runHealth = 570, + runHealth = 0, healthHidden = false, isBlockable = false, canWalkOnEnergy = false, @@ -101,7 +101,7 @@ monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -450 }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_FIREDAMAGE, minDamage = -400, maxDamage = -1000, length = 8, spread = 0, effect = CONST_ME_FIREATTACK, target = false }, { name = "combat", interval = 3000, chance = 100, type = COMBAT_FIREDAMAGE, minDamage = -80, maxDamage = -250, radius = 3, effect = CONST_ME_HITBYFIRE, target = false }, - { name = "speed", interval = 2000, chance = 10, speedChange = -800, length = 5, spread = 0, effect = CONST_ME_BLOCKHIT, target = false, duration = 30000 }, + { name = "speed", interval = 2000, chance = 10, speedChange = -600, length = 5, spread = 0, effect = CONST_ME_BLOCKHIT, target = false, duration = 30000 }, } monster.defenses = { diff --git a/data-otservbr-global/monster/demons/hellfire_fighter.lua b/data-otservbr-global/monster/demons/hellfire_fighter.lua index 6a90b5af06d..2ae5b00303a 100644 --- a/data-otservbr-global/monster/demons/hellfire_fighter.lua +++ b/data-otservbr-global/monster/demons/hellfire_fighter.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Hellfire Fighter") local monster = {} monster.description = "a hellfire fighter" -monster.experience = 3400 +monster.experience = 3800 monster.outfit = { lookType = 243, lookHead = 0, diff --git a/data-otservbr-global/monster/elementals/cliff_strider.lua b/data-otservbr-global/monster/elementals/cliff_strider.lua index 2690f356f23..2e143d42796 100644 --- a/data-otservbr-global/monster/elementals/cliff_strider.lua +++ b/data-otservbr-global/monster/elementals/cliff_strider.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Cliff Strider") local monster = {} monster.description = "a cliff strider" -monster.experience = 5700 +monster.experience = 7100 monster.outfit = { lookType = 497, lookHead = 0, @@ -119,7 +119,7 @@ monster.attacks = { { name = "cliff strider skill reducer", interval = 2000, chance = 10, target = false }, { name = "cliff strider electrify", interval = 2000, chance = 15, range = 1, target = false }, { name = "combat", interval = 2000, chance = 10, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -1000, length = 6, spread = 0, effect = CONST_ME_GROUNDSHAKER, target = false }, - { name = "combat", interval = 2000, chance = 15, type = COMBAT_MANADRAIN, minDamage = -100, maxDamage = -300, radius = 4, effect = CONST_ME_YELLOWENERGY, target = false }, + { name = "combat", interval = 2000, chance = 10, type = COMBAT_MANADRAIN, minDamage = -100, maxDamage = -300, radius = 4, effect = CONST_ME_YELLOWENERGY, target = false }, } monster.defenses = { @@ -130,7 +130,7 @@ monster.defenses = { monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 10 }, - { type = COMBAT_ENERGYDAMAGE, percent = 100 }, + { type = COMBAT_ENERGYDAMAGE, percent = 5 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, { type = COMBAT_FIREDAMAGE, percent = 20 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, diff --git a/data-otservbr-global/monster/elementals/earth_elemental.lua b/data-otservbr-global/monster/elementals/earth_elemental.lua index f71d6a7964d..4c3b3e11aa3 100644 --- a/data-otservbr-global/monster/elementals/earth_elemental.lua +++ b/data-otservbr-global/monster/elementals/earth_elemental.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Earth Elemental") local monster = {} monster.description = "an earth elemental" -monster.experience = 450 +monster.experience = 550 monster.outfit = { lookType = 301, lookHead = 0, @@ -117,7 +117,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 85 }, + { type = COMBAT_ICEDAMAGE, percent = 5 }, { type = COMBAT_HOLYDAMAGE, percent = 50 }, { type = COMBAT_DEATHDAMAGE, percent = 40 }, } diff --git a/data-otservbr-global/monster/elementals/high_voltage_elemental.lua b/data-otservbr-global/monster/elementals/high_voltage_elemental.lua index ca99e57527e..3d6806a707b 100644 --- a/data-otservbr-global/monster/elementals/high_voltage_elemental.lua +++ b/data-otservbr-global/monster/elementals/high_voltage_elemental.lua @@ -102,7 +102,7 @@ monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 35 }, { type = COMBAT_ENERGYDAMAGE, percent = 100 }, { type = COMBAT_EARTHDAMAGE, percent = -15 }, - { type = COMBAT_FIREDAMAGE, percent = 100 }, + { type = COMBAT_FIREDAMAGE, percent = -100 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, diff --git a/data-otservbr-global/monster/elementals/ironblight.lua b/data-otservbr-global/monster/elementals/ironblight.lua index 593069318ed..7cb7c7c58fc 100644 --- a/data-otservbr-global/monster/elementals/ironblight.lua +++ b/data-otservbr-global/monster/elementals/ironblight.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Ironblight") local monster = {} monster.description = "an ironblight" -monster.experience = 4400 +monster.experience = 5400 monster.outfit = { lookType = 498, lookHead = 0, diff --git a/data-otservbr-global/monster/elementals/massive_earth_elemental.lua b/data-otservbr-global/monster/elementals/massive_earth_elemental.lua index e894319b6ec..1b131e7c7ae 100644 --- a/data-otservbr-global/monster/elementals/massive_earth_elemental.lua +++ b/data-otservbr-global/monster/elementals/massive_earth_elemental.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Massive Earth Elemental") local monster = {} monster.description = "a massive earth elemental" -monster.experience = 950 +monster.experience = 1100 monster.outfit = { lookType = 285, lookHead = 0, @@ -119,7 +119,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 100 }, + { type = COMBAT_ICEDAMAGE, percent = 15 }, { type = COMBAT_HOLYDAMAGE, percent = 50 }, { type = COMBAT_DEATHDAMAGE, percent = 45 }, } diff --git a/data-otservbr-global/monster/elementals/sulphur_spouter.lua b/data-otservbr-global/monster/elementals/sulphur_spouter.lua index 6f574cc0a07..79ebcf8db4b 100644 --- a/data-otservbr-global/monster/elementals/sulphur_spouter.lua +++ b/data-otservbr-global/monster/elementals/sulphur_spouter.lua @@ -105,7 +105,7 @@ monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, { type = COMBAT_ENERGYDAMAGE, percent = 0 }, { type = COMBAT_EARTHDAMAGE, percent = 0 }, - { type = COMBAT_FIREDAMAGE, percent = 100 }, + { type = COMBAT_FIREDAMAGE, percent = 25 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, diff --git a/data-otservbr-global/monster/humanoids/lost_basher.lua b/data-otservbr-global/monster/humanoids/lost_basher.lua index e19aef97f78..f8866bdd177 100644 --- a/data-otservbr-global/monster/humanoids/lost_basher.lua +++ b/data-otservbr-global/monster/humanoids/lost_basher.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Lost Basher") local monster = {} monster.description = "a lost basher" -monster.experience = 1800 +monster.experience = 2300 monster.outfit = { lookType = 538, lookHead = 0, @@ -61,7 +61,7 @@ monster.flags = { healthHidden = false, isBlockable = false, canWalkOnEnergy = false, - canWalkOnFire = false, + canWalkOnFire = true, canWalkOnPoison = true, } @@ -126,7 +126,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 20 }, + { type = COMBAT_ICEDAMAGE, percent = 0 }, { type = COMBAT_HOLYDAMAGE, percent = 0 }, { type = COMBAT_DEATHDAMAGE, percent = 15 }, } diff --git a/data-otservbr-global/monster/humanoids/lost_berserker.lua b/data-otservbr-global/monster/humanoids/lost_berserker.lua index cd48787df95..cbc7012ff95 100644 --- a/data-otservbr-global/monster/humanoids/lost_berserker.lua +++ b/data-otservbr-global/monster/humanoids/lost_berserker.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Lost Berserker") local monster = {} monster.description = "a lost berserker" -monster.experience = 4400 +monster.experience = 4800 monster.outfit = { lookType = 496, lookHead = 0, @@ -111,27 +111,25 @@ monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -501 }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -300, range = 7, shootEffect = CONST_ANI_WHIRLWINDAXE, target = false }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_PHYSICALDAMAGE, minDamage = 0, maxDamage = -250, range = 7, radius = 3, shootEffect = CONST_ANI_EXPLOSION, effect = CONST_ME_EXPLOSIONAREA, target = true }, - { name = "combat", interval = 2000, chance = 10, type = COMBAT_MANADRAIN, minDamage = -150, maxDamage = -250, radius = 5, effect = CONST_ME_MAGIC_RED, target = false }, + { name = "combat", interval = 2000, chance = 10, type = COMBAT_MANADRAIN, minDamage = -50, maxDamage = -100, radius = 5, effect = CONST_ME_MAGIC_RED, target = false }, { name = "speed", interval = 2000, chance = 10, speedChange = -800, radius = 2, effect = CONST_ME_MAGIC_RED, target = false, duration = 20000 }, - { name = "drunk", interval = 2000, chance = 10, radius = 4, effect = CONST_ME_STUN, target = true, duration = 6000 }, } monster.defenses = { defense = 40, armor = 80, mitigation = 2.40, - { name = "invisible", interval = 2000, chance = 5, effect = CONST_ME_TELEPORT }, } monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 20 }, - { type = COMBAT_ENERGYDAMAGE, percent = 17 }, + { type = COMBAT_ENERGYDAMAGE, percent = 100 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, { type = COMBAT_FIREDAMAGE, percent = 10 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 40 }, + { type = COMBAT_ICEDAMAGE, percent = 10 }, { type = COMBAT_HOLYDAMAGE, percent = 0 }, { type = COMBAT_DEATHDAMAGE, percent = 15 }, } @@ -139,7 +137,7 @@ monster.elements = { monster.immunities = { { type = "paralyze", condition = true }, { type = "outfit", condition = false }, - { type = "invisible", condition = true }, + { type = "invisible", condition = false }, { type = "bleed", condition = false }, } diff --git a/data-otservbr-global/monster/humanoids/lost_husher.lua b/data-otservbr-global/monster/humanoids/lost_husher.lua index d8167f9710d..419bae1ab96 100644 --- a/data-otservbr-global/monster/humanoids/lost_husher.lua +++ b/data-otservbr-global/monster/humanoids/lost_husher.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Lost Husher") local monster = {} monster.description = "a lost husher" -monster.experience = 1800 +monster.experience = 1100 monster.outfit = { lookType = 537, lookHead = 0, @@ -61,7 +61,7 @@ monster.flags = { healthHidden = false, isBlockable = false, canWalkOnEnergy = false, - canWalkOnFire = false, + canWalkOnFire = true, canWalkOnPoison = true, } @@ -103,7 +103,6 @@ monster.loot = { monster.attacks = { { name = "combat", interval = 2000, chance = 10, type = COMBAT_DEATHDAMAGE, minDamage = -150, maxDamage = -300, length = 6, spread = 0, effect = CONST_ME_BLACKSMOKE, target = false }, - { name = "combat", interval = 2000, chance = 10, type = COMBAT_MANADRAIN, minDamage = -150, maxDamage = -250, radius = 5, effect = CONST_ME_BLACKSMOKE, target = false }, { name = "combat", interval = 2000, chance = 10, type = COMBAT_DEATHDAMAGE, minDamage = -150, maxDamage = -200, range = 7, shootEffect = CONST_ANI_SUDDENDEATH, effect = CONST_ME_MORTAREA, target = false }, { name = "combat", interval = 2000, chance = 10, type = COMBAT_EARTHDAMAGE, minDamage = -150, maxDamage = -250, range = 7, radius = 2, shootEffect = CONST_ANI_SMALLEARTH, effect = CONST_ME_MAGIC_GREEN, target = true }, { name = "drunk", interval = 2000, chance = 10, radius = 4, effect = CONST_ME_SOUND_RED, target = false, duration = 6000 }, @@ -125,7 +124,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 15 }, + { type = COMBAT_ICEDAMAGE, percent = 0 }, { type = COMBAT_HOLYDAMAGE, percent = -10 }, { type = COMBAT_DEATHDAMAGE, percent = 20 }, } @@ -133,7 +132,7 @@ monster.elements = { monster.immunities = { { type = "paralyze", condition = true }, { type = "outfit", condition = false }, - { type = "invisible", condition = true }, + { type = "invisible", condition = false }, { type = "bleed", condition = false }, } diff --git a/data-otservbr-global/monster/humanoids/lost_thrower.lua b/data-otservbr-global/monster/humanoids/lost_thrower.lua index c2a87f0d551..21a14bce085 100644 --- a/data-otservbr-global/monster/humanoids/lost_thrower.lua +++ b/data-otservbr-global/monster/humanoids/lost_thrower.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Lost Thrower") local monster = {} monster.description = "a lost thrower" -monster.experience = 1200 +monster.experience = 1500 monster.outfit = { lookType = 539, lookHead = 0, @@ -61,7 +61,7 @@ monster.flags = { healthHidden = false, isBlockable = false, canWalkOnEnergy = false, - canWalkOnFire = false, + canWalkOnFire = true, canWalkOnPoison = true, } @@ -117,7 +117,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 15 }, + { type = COMBAT_ICEDAMAGE, percent = -5 }, { type = COMBAT_HOLYDAMAGE, percent = 0 }, { type = COMBAT_DEATHDAMAGE, percent = 10 }, } diff --git a/data-otservbr-global/monster/magicals/armadile.lua b/data-otservbr-global/monster/magicals/armadile.lua index beca89510f4..98665845d28 100644 --- a/data-otservbr-global/monster/magicals/armadile.lua +++ b/data-otservbr-global/monster/magicals/armadile.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Armadile") local monster = {} monster.description = "an armadile" -monster.experience = 2900 +monster.experience = 3200 monster.outfit = { lookType = 487, lookHead = 0, @@ -56,8 +56,8 @@ monster.flags = { canPushItems = false, canPushCreatures = true, staticAttackChance = 90, - targetDistance = 4, - runHealth = 300, + targetDistance = 1, + runHealth = 0, healthHidden = false, isBlockable = false, canWalkOnEnergy = false, @@ -102,9 +102,7 @@ monster.loot = { monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -150 }, - { name = "drunk", interval = 2000, chance = 15, radius = 4, effect = CONST_ME_FIREAREA, target = true, duration = 5000 }, - { name = "combat", interval = 2000, chance = 15, type = COMBAT_MANADRAIN, minDamage = -430, maxDamage = -550, range = 7, effect = CONST_ME_MAGIC_BLUE, target = false }, - -- poison + { name = "drunk", interval = 2000, chance = 10, radius = 4, effect = CONST_ME_FIREAREA, target = true, duration = 5000 }, { name = "condition", type = CONDITION_POISON, interval = 2000, chance = 15, minDamage = -200, maxDamage = -400, radius = 4, effect = CONST_ME_POISONAREA, target = false }, } @@ -112,14 +110,13 @@ monster.defenses = { defense = 25, armor = 66, mitigation = 1.96, - { name = "invisible", interval = 2000, chance = 15, effect = CONST_ME_MAGIC_RED }, } monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 5 }, { type = COMBAT_ENERGYDAMAGE, percent = 15 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, - { type = COMBAT_FIREDAMAGE, percent = 20 }, + { type = COMBAT_FIREDAMAGE, percent = 0 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, diff --git a/data-otservbr-global/monster/magicals/choking_fear.lua b/data-otservbr-global/monster/magicals/choking_fear.lua index 16361bab0e9..604ca5cdaa6 100644 --- a/data-otservbr-global/monster/magicals/choking_fear.lua +++ b/data-otservbr-global/monster/magicals/choking_fear.lua @@ -124,7 +124,7 @@ monster.defenses = { monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 10 }, - { type = COMBAT_ENERGYDAMAGE, percent = 15 }, + { type = COMBAT_ENERGYDAMAGE, percent = 2 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, { type = COMBAT_FIREDAMAGE, percent = 100 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, diff --git a/data-otservbr-global/monster/magicals/phantasm.lua b/data-otservbr-global/monster/magicals/phantasm.lua index 9dc266f8bb3..36c0baed405 100644 --- a/data-otservbr-global/monster/magicals/phantasm.lua +++ b/data-otservbr-global/monster/magicals/phantasm.lua @@ -70,7 +70,7 @@ monster.light = { monster.summon = { maxSummons = 4, summons = { - { name = "Phantasm Summon", chance = 20, interval = 2000, count = 4 }, + { name = "Phantasm Summon", chance = 35, interval = 2000, count = 4 }, }, } diff --git a/data-otservbr-global/monster/magicals/retching_horror.lua b/data-otservbr-global/monster/magicals/retching_horror.lua index a6814343eaf..0479a7cb368 100644 --- a/data-otservbr-global/monster/magicals/retching_horror.lua +++ b/data-otservbr-global/monster/magicals/retching_horror.lua @@ -113,7 +113,7 @@ monster.defenses = { monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 5 }, - { type = COMBAT_ENERGYDAMAGE, percent = 10 }, + { type = COMBAT_ENERGYDAMAGE, percent = -3 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, { type = COMBAT_FIREDAMAGE, percent = 85 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, diff --git a/data-otservbr-global/monster/mammals/mutated_bat.lua b/data-otservbr-global/monster/mammals/mutated_bat.lua index 211ca62d2ad..dfea480341b 100644 --- a/data-otservbr-global/monster/mammals/mutated_bat.lua +++ b/data-otservbr-global/monster/mammals/mutated_bat.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Mutated Bat") local monster = {} monster.description = "a mutated bat" -monster.experience = 615 +monster.experience = 750 monster.outfit = { lookType = 307, lookHead = 0, diff --git a/data-otservbr-global/monster/plants/hideous_fungus.lua b/data-otservbr-global/monster/plants/hideous_fungus.lua index a80ba080fd7..275adb03b2f 100644 --- a/data-otservbr-global/monster/plants/hideous_fungus.lua +++ b/data-otservbr-global/monster/plants/hideous_fungus.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Hideous Fungus") local monster = {} monster.description = "a hideous fungus" -monster.experience = 2900 +monster.experience = 3700 monster.outfit = { lookType = 499, lookHead = 0, @@ -57,7 +57,7 @@ monster.flags = { canPushCreatures = true, staticAttackChance = 90, targetDistance = 4, - runHealth = 275, + runHealth = 0, healthHidden = false, isBlockable = false, canWalkOnEnergy = true, @@ -71,9 +71,9 @@ monster.light = { } monster.summon = { - maxSummons = 2, + maxSummons = 1, summons = { - { name = "humorless fungus", chance = 10, interval = 2000, count = 2 }, + { name = "humorless fungus", chance = 10, interval = 2000, count = 1 }, }, } @@ -110,7 +110,6 @@ monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -450 }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_EARTHDAMAGE, minDamage = -250, maxDamage = -430, range = 7, shootEffect = CONST_ANI_SMALLEARTH, effect = CONST_ME_SMALLPLANTS, target = false }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_ICEDAMAGE, minDamage = -250, maxDamage = -550, length = 8, spread = 0, shootEffect = CONST_ANI_SNOWBALL, effect = CONST_ME_ICEAREA, target = false }, - { name = "speed", interval = 2000, chance = 10, speedChange = -600, radius = 1, effect = CONST_ME_MAGIC_RED, target = true, duration = 60000 }, { name = "drunk", interval = 2000, chance = 10, range = 7, radius = 5, shootEffect = CONST_ANI_SMALLSTONE, effect = CONST_ME_STUN, target = true, duration = 4000 }, -- poison { name = "condition", type = CONDITION_POISON, interval = 2000, chance = 10, minDamage = -400, maxDamage = -640, range = 7, radius = 3, effect = CONST_ME_HITBYPOISON, target = false }, @@ -121,14 +120,14 @@ monster.defenses = { armor = 60, mitigation = 1.74, { name = "combat", interval = 2000, chance = 15, type = COMBAT_HEALING, minDamage = 275, maxDamage = 350, effect = CONST_ME_MAGIC_BLUE, target = false }, - { name = "invisible", interval = 2000, chance = 10, effect = CONST_ME_MAGIC_BLUE }, + { name = "invisible", interval = 2000, chance = 5, effect = CONST_ME_MAGIC_BLUE, duration = 2000 }, } monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, { type = COMBAT_ENERGYDAMAGE, percent = 15 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, - { type = COMBAT_FIREDAMAGE, percent = 5 }, + { type = COMBAT_FIREDAMAGE, percent = -5 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, diff --git a/data-otservbr-global/monster/plants/humongous_fungus.lua b/data-otservbr-global/monster/plants/humongous_fungus.lua index 942684e732c..09f301a6a59 100644 --- a/data-otservbr-global/monster/plants/humongous_fungus.lua +++ b/data-otservbr-global/monster/plants/humongous_fungus.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Humongous Fungus") local monster = {} monster.description = "a humongous fungus" -monster.experience = 2600 +monster.experience = 2900 monster.outfit = { lookType = 488, lookHead = 0, @@ -104,7 +104,7 @@ monster.loot = { monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -330 }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_EARTHDAMAGE, minDamage = -180, maxDamage = -350, range = 7, shootEffect = CONST_ANI_SMALLEARTH, effect = CONST_ME_SMALLPLANTS, target = false }, - { name = "poisonfield", interval = 2000, chance = 20, radius = 4, target = false }, + { name = "poisonfield", interval = 2000, chance = 10, radius = 4, target = false }, -- poison { name = "condition", type = CONDITION_POISON, interval = 2000, chance = 10, minDamage = -500, maxDamage = -1000, length = 8, spread = 0, effect = CONST_ME_GREEN_RINGS, target = false }, { name = "combat", interval = 2000, chance = 10, type = COMBAT_LIFEDRAIN, minDamage = -130, maxDamage = -260, length = 5, spread = 0, effect = CONST_ME_MAGIC_RED, target = false }, @@ -117,14 +117,13 @@ monster.defenses = { armor = 70, mitigation = 2.02, { name = "combat", interval = 2000, chance = 10, type = COMBAT_HEALING, minDamage = 225, maxDamage = 380, effect = CONST_ME_MAGIC_BLUE, target = false }, - { name = "invisible", interval = 2000, chance = 15, effect = CONST_ME_MAGIC_BLUE }, } monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, { type = COMBAT_ENERGYDAMAGE, percent = 15 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, - { type = COMBAT_FIREDAMAGE, percent = 5 }, + { type = COMBAT_FIREDAMAGE, percent = -10 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, diff --git a/data-otservbr-global/monster/quests/bigfoots_burden/bosses/abyssador.lua b/data-otservbr-global/monster/quests/bigfoots_burden/bosses/abyssador.lua index 24c993fda5b..1ca0ff1ca75 100644 --- a/data-otservbr-global/monster/quests/bigfoots_burden/bosses/abyssador.lua +++ b/data-otservbr-global/monster/quests/bigfoots_burden/bosses/abyssador.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Abyssador") local monster = {} monster.description = "Abyssador" -monster.experience = 50000 +monster.experience = 400000 monster.outfit = { lookType = 495, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/bigfoots_burden/bosses/gnomevil.lua b/data-otservbr-global/monster/quests/bigfoots_burden/bosses/gnomevil.lua index cd287d83709..8d410c85d26 100644 --- a/data-otservbr-global/monster/quests/bigfoots_burden/bosses/gnomevil.lua +++ b/data-otservbr-global/monster/quests/bigfoots_burden/bosses/gnomevil.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Gnomevil") local monster = {} monster.description = "Gnomevil" -monster.experience = 45000 +monster.experience = 400000 monster.outfit = { lookType = 504, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/bigfoots_burden/humorless_fungus.lua b/data-otservbr-global/monster/quests/bigfoots_burden/humorless_fungus.lua index 19ab3230231..ead6b096fbf 100644 --- a/data-otservbr-global/monster/quests/bigfoots_burden/humorless_fungus.lua +++ b/data-otservbr-global/monster/quests/bigfoots_burden/humorless_fungus.lua @@ -13,8 +13,8 @@ monster.outfit = { lookMount = 0, } -monster.health = 2500 -monster.maxHealth = 2500 +monster.health = 1600 +monster.maxHealth = 1600 monster.race = "venom" monster.corpse = 16083 monster.speed = 115 @@ -70,17 +70,14 @@ monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -475 }, { name = "combat", interval = 2000, chance = 10, type = COMBAT_EARTHDAMAGE, minDamage = -40, maxDamage = -197, range = 7, shootEffect = CONST_ANI_SMALLEARTH, effect = CONST_ME_SMALLPLANTS, target = true }, { name = "combat", interval = 2000, chance = 10, type = COMBAT_ICEDAMAGE, minDamage = 0, maxDamage = -525, range = 7, shootEffect = CONST_ANI_SNOWBALL, effect = CONST_ME_ICEAREA, target = true }, - -- poison { name = "condition", type = CONDITION_POISON, interval = 2000, chance = 10, minDamage = -400, maxDamage = -640, range = 7, radius = 3, effect = CONST_ME_HITBYPOISON, target = false }, - { name = "drunk", interval = 2000, chance = 10, range = 7, radius = 4, effect = CONST_ME_STUN, target = true, duration = 4000 }, } monster.defenses = { defense = 0, armor = 0, - -- mitigation = ???, { name = "combat", interval = 2000, chance = 5, type = COMBAT_HEALING, minDamage = 0, maxDamage = 230, effect = CONST_ME_MAGIC_BLUE, target = false }, - { name = "invisible", interval = 2000, chance = 10, effect = CONST_ME_MAGIC_BLUE }, + { name = "invisible", interval = 2000, chance = 5, effect = CONST_ME_MAGIC_BLUE }, } monster.elements = { diff --git a/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_count_of_the_core.lua b/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_count_of_the_core.lua index d611e78d84b..17cb6520d29 100644 --- a/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_count_of_the_core.lua +++ b/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_count_of_the_core.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("The Count of the Core") local monster = {} monster.description = "The Count Of The Core" -monster.experience = 40000 +monster.experience = 300000 monster.outfit = { lookType = 1046, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_duke_of_the_depths.lua b/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_duke_of_the_depths.lua index d654288c405..99053b93882 100644 --- a/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_duke_of_the_depths.lua +++ b/data-otservbr-global/monster/quests/dangerous_depth/bosses/the_duke_of_the_depths.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("The Duke of the Depths") local monster = {} monster.description = "The Duke Of The Depths" -monster.experience = 40000 +monster.experience = 300000 monster.outfit = { lookType = 1047, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ferumbras_mortal_shell.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ferumbras_mortal_shell.lua index 90b3124369a..7ad855bc88a 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ferumbras_mortal_shell.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ferumbras_mortal_shell.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Ferumbras Mortal Shell") local monster = {} monster.description = "Ferumbras Mortal Shell" -monster.experience = 500000 +monster.experience = 2000000 monster.outfit = { lookType = 229, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/mazoran.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/mazoran.lua index 0e0822e3d72..3f32bac95d4 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/mazoran.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/mazoran.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Mazoran") local monster = {} monster.description = "Mazoran" -monster.experience = 250000 +monster.experience = 500000 monster.outfit = { lookType = 842, lookHead = 77, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/plagirath.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/plagirath.lua index 625f10cf7fc..364b4f864a8 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/plagirath.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/plagirath.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Plagirath") local monster = {} monster.description = "Plagirath" -monster.experience = 250000 +monster.experience = 500000 monster.outfit = { lookType = 862, lookHead = 84, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ragiaz.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ragiaz.lua index 9701dc7d0f9..df016edfd84 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ragiaz.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/ragiaz.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Ragiaz") local monster = {} monster.description = "Ragiaz" -monster.experience = 250000 +monster.experience = 500000 monster.outfit = { lookType = 862, lookHead = 76, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/razzagorn.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/razzagorn.lua index 67d218c5ee0..066e22237c0 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/razzagorn.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/razzagorn.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Razzagorn") local monster = {} monster.description = "Razzagorn" -monster.experience = 250000 +monster.experience = 500000 monster.outfit = { lookType = 842, lookHead = 78, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/shulgrax.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/shulgrax.lua index c0de2c0c362..72c908104af 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/shulgrax.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/shulgrax.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Shulgrax") local monster = {} monster.description = "Shulgrax" -monster.experience = 250000 +monster.experience = 500000 monster.outfit = { lookType = 842, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/tarbaz.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/tarbaz.lua index 583167460e1..30b99353cdf 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/tarbaz.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/tarbaz.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Tarbaz") local monster = {} monster.description = "Tarbaz" -monster.experience = 250000 +monster.experience = 500000 monster.outfit = { lookType = 842, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/zamulosh.lua b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/zamulosh.lua index 5a441ff10f1..03fa92d3394 100644 --- a/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/zamulosh.lua +++ b/data-otservbr-global/monster/quests/ferumbras_ascendant/bosses/zamulosh.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Zamulosh") local monster = {} monster.description = "Zamulosh" -monster.experience = 250000 +monster.experience = 500000 monster.outfit = { lookType = 862, lookHead = 16, diff --git a/data-otservbr-global/monster/quests/in_service_of_yalahar/inky.lua b/data-otservbr-global/monster/quests/in_service_of_yalahar/inky.lua index 49025f4c6c4..bbc58881ee4 100644 --- a/data-otservbr-global/monster/quests/in_service_of_yalahar/inky.lua +++ b/data-otservbr-global/monster/quests/in_service_of_yalahar/inky.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Inky") local monster = {} monster.description = "Inky" -monster.experience = 250 +monster.experience = 700 monster.outfit = { lookType = 46, lookHead = 0, diff --git a/data-otservbr-global/monster/quests/in_service_of_yalahar/sharptooth.lua b/data-otservbr-global/monster/quests/in_service_of_yalahar/sharptooth.lua index 583df08b8b5..0325642344c 100644 --- a/data-otservbr-global/monster/quests/in_service_of_yalahar/sharptooth.lua +++ b/data-otservbr-global/monster/quests/in_service_of_yalahar/sharptooth.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Sharptooth") local monster = {} monster.description = "Sharptooth" -monster.experience = 1600 +monster.experience = 3000 monster.outfit = { lookType = 20, lookHead = 0, diff --git a/data-otservbr-global/monster/reptiles/seacrest_serpent.lua b/data-otservbr-global/monster/reptiles/seacrest_serpent.lua index 9be39aaa571..04b7dba7416 100644 --- a/data-otservbr-global/monster/reptiles/seacrest_serpent.lua +++ b/data-otservbr-global/monster/reptiles/seacrest_serpent.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Seacrest Serpent") local monster = {} monster.description = "a seacrest serpent" -monster.experience = 2600 +monster.experience = 2900 monster.outfit = { lookType = 675, lookHead = 0, diff --git a/data-otservbr-global/monster/reptiles/young_sea_serpent.lua b/data-otservbr-global/monster/reptiles/young_sea_serpent.lua index 961ff8204c6..98e8744b7b1 100644 --- a/data-otservbr-global/monster/reptiles/young_sea_serpent.lua +++ b/data-otservbr-global/monster/reptiles/young_sea_serpent.lua @@ -108,7 +108,7 @@ monster.defenses = { monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = -20 }, { type = COMBAT_ENERGYDAMAGE, percent = -10 }, - { type = COMBAT_EARTHDAMAGE, percent = 100 }, + { type = COMBAT_EARTHDAMAGE, percent = -5 }, { type = COMBAT_FIREDAMAGE, percent = 30 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, diff --git a/data-otservbr-global/monster/undeads/betrayed_wraith.lua b/data-otservbr-global/monster/undeads/betrayed_wraith.lua index 0c0648acda5..201887a7712 100644 --- a/data-otservbr-global/monster/undeads/betrayed_wraith.lua +++ b/data-otservbr-global/monster/undeads/betrayed_wraith.lua @@ -112,7 +112,7 @@ monster.defenses = { monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, - { type = COMBAT_ENERGYDAMAGE, percent = 100 }, + { type = COMBAT_ENERGYDAMAGE, percent = 10 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, { type = COMBAT_FIREDAMAGE, percent = 100 }, { type = COMBAT_LIFEDRAIN, percent = 100 }, diff --git a/data-otservbr-global/monster/undeads/blightwalker.lua b/data-otservbr-global/monster/undeads/blightwalker.lua index 28706adeb50..d900484b19f 100644 --- a/data-otservbr-global/monster/undeads/blightwalker.lua +++ b/data-otservbr-global/monster/undeads/blightwalker.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Blightwalker") local monster = {} monster.description = "a blightwalker" -monster.experience = 5850 +monster.experience = 6400 monster.outfit = { lookType = 246, lookHead = 0, @@ -108,9 +108,8 @@ monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -490 }, { name = "combat", interval = 2000, chance = 20, type = COMBAT_EARTHDAMAGE, minDamage = -220, maxDamage = -405, range = 7, radius = 1, shootEffect = CONST_ANI_POISON, target = true }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_LIFEDRAIN, minDamage = -65, maxDamage = -135, radius = 4, effect = CONST_ME_MAGIC_GREEN, target = false }, - { name = "drunk", interval = 2000, chance = 10, radius = 3, effect = CONST_ME_HITBYPOISON, target = false, duration = 5000 }, { name = "blightwalker curse", interval = 2000, chance = 15, target = false }, - { name = "speed", interval = 2000, chance = 15, speedChange = -300, range = 7, shootEffect = CONST_ANI_POISON, target = true, duration = 30000 }, + { name = "speed", interval = 2000, chance = 10, speedChange = -300, range = 7, shootEffect = CONST_ANI_POISON, target = true, duration = 15000 }, } monster.defenses = { @@ -127,7 +126,7 @@ monster.elements = { { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 50 }, + { type = COMBAT_ICEDAMAGE, percent = 15 }, { type = COMBAT_HOLYDAMAGE, percent = -30 }, { type = COMBAT_DEATHDAMAGE, percent = 100 }, } diff --git a/data-otservbr-global/monster/undeads/crypt_warrior.lua b/data-otservbr-global/monster/undeads/crypt_warrior.lua index 5de0ab637ba..dad0cbe7529 100644 --- a/data-otservbr-global/monster/undeads/crypt_warrior.lua +++ b/data-otservbr-global/monster/undeads/crypt_warrior.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Crypt Warrior") local monster = {} monster.description = "a crypt warrior" -monster.experience = 4200 +monster.experience = 6050 monster.outfit = { lookType = 298, lookHead = 0, diff --git a/data-otservbr-global/monster/undeads/falcon_knight.lua b/data-otservbr-global/monster/undeads/falcon_knight.lua index 54a23130758..2e2ac28a1fe 100644 --- a/data-otservbr-global/monster/undeads/falcon_knight.lua +++ b/data-otservbr-global/monster/undeads/falcon_knight.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Falcon Knight") local monster = {} monster.description = "a falcon knight" -monster.experience = 5985 +monster.experience = 6300 monster.outfit = { lookType = 1071, lookHead = 57, diff --git a/data-otservbr-global/monster/undeads/falcon_paladin.lua b/data-otservbr-global/monster/undeads/falcon_paladin.lua index 799143fe943..cc6a41571e4 100644 --- a/data-otservbr-global/monster/undeads/falcon_paladin.lua +++ b/data-otservbr-global/monster/undeads/falcon_paladin.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Falcon Paladin") local monster = {} monster.description = "a falcon paladin" -monster.experience = 6544 +monster.experience = 6900 monster.outfit = { lookType = 1071, lookHead = 57, diff --git a/data-otservbr-global/monster/undeads/hand_of_cursed_fate.lua b/data-otservbr-global/monster/undeads/hand_of_cursed_fate.lua index b1f76414dd4..527d0708730 100644 --- a/data-otservbr-global/monster/undeads/hand_of_cursed_fate.lua +++ b/data-otservbr-global/monster/undeads/hand_of_cursed_fate.lua @@ -108,7 +108,7 @@ monster.loot = { monster.attacks = { { name = "melee", interval = 2000, chance = 100, minDamage = 0, maxDamage = -520, condition = { type = CONDITION_POISON, totalDamage = 380, interval = 4000 } }, - { name = "combat", interval = 2000, chance = 15, type = COMBAT_MANADRAIN, minDamage = 0, maxDamage = -920, range = 1, target = false }, + { name = "combat", interval = 2000, chance = 15, type = COMBAT_MANADRAIN, minDamage = 0, maxDamage = -620, range = 1, target = false }, { name = "drunk", interval = 2000, chance = 10, radius = 4, effect = CONST_ME_SMALLCLOUDS, target = false, duration = 3000 }, { name = "combat", interval = 2000, chance = 15, type = COMBAT_LIFEDRAIN, minDamage = -220, maxDamage = -880, range = 1, effect = CONST_ME_SMALLCLOUDS, target = false }, } @@ -124,7 +124,7 @@ monster.defenses = { monster.elements = { { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, - { type = COMBAT_ENERGYDAMAGE, percent = 100 }, + { type = COMBAT_ENERGYDAMAGE, percent = 5 }, { type = COMBAT_EARTHDAMAGE, percent = 100 }, { type = COMBAT_FIREDAMAGE, percent = 100 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, diff --git a/data-otservbr-global/monster/undeads/skeleton_elite_warrior.lua b/data-otservbr-global/monster/undeads/skeleton_elite_warrior.lua index a0cc7545b99..25ebd9c1f6d 100644 --- a/data-otservbr-global/monster/undeads/skeleton_elite_warrior.lua +++ b/data-otservbr-global/monster/undeads/skeleton_elite_warrior.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Skeleton Elite Warrior") local monster = {} monster.description = "a skeleton elite warrior" -monster.experience = 4500 +monster.experience = 4800 monster.outfit = { lookType = 298, lookHead = 0, diff --git a/data-otservbr-global/monster/undeads/undead_dragon.lua b/data-otservbr-global/monster/undeads/undead_dragon.lua index 2ab63af8b77..b9039c5d914 100644 --- a/data-otservbr-global/monster/undeads/undead_dragon.lua +++ b/data-otservbr-global/monster/undeads/undead_dragon.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Undead Dragon") local monster = {} monster.description = "an undead dragon" -monster.experience = 7200 +monster.experience = 7500 monster.outfit = { lookType = 231, lookHead = 0, diff --git a/data-otservbr-global/monster/undeads/undead_elite_gladiator.lua b/data-otservbr-global/monster/undeads/undead_elite_gladiator.lua index 0f66c87cb21..10d1d5b08bc 100644 --- a/data-otservbr-global/monster/undeads/undead_elite_gladiator.lua +++ b/data-otservbr-global/monster/undeads/undead_elite_gladiator.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Undead Elite Gladiator") local monster = {} monster.description = "an undead elite gladiator" -monster.experience = 4740 +monster.experience = 5090 monster.outfit = { lookType = 306, lookHead = 0, diff --git a/data-otservbr-global/monster/vermins/cave_devourer.lua b/data-otservbr-global/monster/vermins/cave_devourer.lua index 1283ac20b81..17d89dfb176 100644 --- a/data-otservbr-global/monster/vermins/cave_devourer.lua +++ b/data-otservbr-global/monster/vermins/cave_devourer.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Cave Devourer") local monster = {} monster.description = "a cave devourer" -monster.experience = 2380 +monster.experience = 3380 monster.outfit = { lookType = 1036, lookHead = 0, @@ -88,7 +88,7 @@ monster.loot = { { name = "slime heart", chance = 13770, maxCount = 4 }, { name = "cave devourer legs", chance = 17160 }, { id = 3049, chance = 2540 }, -- stealth ring - { name = "suspicious device", chance = 420 }, + { name = "suspicious device", chance = 850 }, } monster.attacks = { diff --git a/data-otservbr-global/monster/vermins/chasm_spawn.lua b/data-otservbr-global/monster/vermins/chasm_spawn.lua index 0764367a1d0..9f27f57b006 100644 --- a/data-otservbr-global/monster/vermins/chasm_spawn.lua +++ b/data-otservbr-global/monster/vermins/chasm_spawn.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Chasm Spawn") local monster = {} monster.description = "a chasm spawn" -monster.experience = 2700 +monster.experience = 3600 monster.outfit = { lookType = 1037, lookHead = 0, @@ -89,7 +89,7 @@ monster.loot = { { name = "green crystal shard", chance = 7850 }, { name = "violet crystal shard", chance = 4690 }, { name = "mushroom backpack", chance = 610 }, - { name = "suspicious device", chance = 520 }, + { name = "suspicious device", chance = 850 }, } monster.attacks = { diff --git a/data-otservbr-global/monster/vermins/deepworm.lua b/data-otservbr-global/monster/vermins/deepworm.lua index 91b2ded8752..21775b2c673 100644 --- a/data-otservbr-global/monster/vermins/deepworm.lua +++ b/data-otservbr-global/monster/vermins/deepworm.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Deepworm") local monster = {} monster.description = "a deepworm" -monster.experience = 2300 +monster.experience = 2520 monster.outfit = { lookType = 1033, lookHead = 0, diff --git a/data-otservbr-global/monster/vermins/diremaw.lua b/data-otservbr-global/monster/vermins/diremaw.lua index b89c47c99e7..fd74c4e2be6 100644 --- a/data-otservbr-global/monster/vermins/diremaw.lua +++ b/data-otservbr-global/monster/vermins/diremaw.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Diremaw") local monster = {} monster.description = "a diremaw" -monster.experience = 2500 +monster.experience = 2770 monster.outfit = { lookType = 1034, lookHead = 0, diff --git a/data-otservbr-global/monster/vermins/drillworm.lua b/data-otservbr-global/monster/vermins/drillworm.lua index 3cf92fce18a..a435dc16ca3 100644 --- a/data-otservbr-global/monster/vermins/drillworm.lua +++ b/data-otservbr-global/monster/vermins/drillworm.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Drillworm") local monster = {} monster.description = "a drillworm" -monster.experience = 858 +monster.experience = 1200 monster.outfit = { lookType = 527, lookHead = 0, diff --git a/data-otservbr-global/monster/vermins/tunnel_tyrant.lua b/data-otservbr-global/monster/vermins/tunnel_tyrant.lua index f8e3b7bfb03..c2b8eb2df90 100644 --- a/data-otservbr-global/monster/vermins/tunnel_tyrant.lua +++ b/data-otservbr-global/monster/vermins/tunnel_tyrant.lua @@ -2,7 +2,7 @@ local mType = Game.createMonsterType("Tunnel Tyrant") local monster = {} monster.description = "a tunnel tyrant" -monster.experience = 3400 +monster.experience = 4420 monster.outfit = { lookType = 1035, lookHead = 0, @@ -87,7 +87,7 @@ monster.loot = { { name = "crystal mace", chance = 1580 }, { id = 23508, chance = 3010 }, -- energy vein { name = "crystalline armor", chance = 860 }, - { name = "suspicious device", chance = 1290 }, + { name = "suspicious device", chance = 1850 }, } monster.attacks = { diff --git a/data-otservbr-global/scripts/actions/bosses_levers/grand_,master_oberon.lua b/data-otservbr-global/scripts/actions/bosses_levers/grand_master_oberon.lua similarity index 100% rename from data-otservbr-global/scripts/actions/bosses_levers/grand_,master_oberon.lua rename to data-otservbr-global/scripts/actions/bosses_levers/grand_master_oberon.lua From f56af162772371b5a109e2514ff12341b7693148 Mon Sep 17 00:00:00 2001 From: Felipe Paluco <87909998+FelipePaluco@users.noreply.github.com> Date: Tue, 11 Jun 2024 10:37:27 -0300 Subject: [PATCH 03/17] fix: sam sellable missing items (#2685) --- data-otservbr-global/npc/sam.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/data-otservbr-global/npc/sam.lua b/data-otservbr-global/npc/sam.lua index cd3a517c147..fdca8c02f01 100644 --- a/data-otservbr-global/npc/sam.lua +++ b/data-otservbr-global/npc/sam.lua @@ -210,6 +210,7 @@ npcConfig.shop = { { itemName = "legion helmet", clientId = 3374, sell = 22 }, { itemName = "longsword", clientId = 3285, buy = 160, sell = 51 }, { itemName = "mace", clientId = 3286, buy = 90, sell = 30 }, + { itemName = "magic plate armor", clientId = 3366, sell = 6400 }, { itemName = "morning star", clientId = 3282, buy = 430, sell = 100 }, { itemName = "orcish axe", clientId = 3316, sell = 350 }, { itemName = "plate armor", clientId = 3357, buy = 1200, sell = 400 }, @@ -227,16 +228,16 @@ npcConfig.shop = { { itemName = "steel shield", clientId = 3409, buy = 240, sell = 80 }, { itemName = "studded armor", clientId = 3378, buy = 90, sell = 25 }, { itemName = "studded club", clientId = 3336, sell = 10 }, - { itemName = "studded helmet", clientId = 3376, buy = 63 }, - { itemName = "studded legs", clientId = 3362, buy = 50 }, - { itemName = "studded shield", clientId = 3426, buy = 50 }, - { itemName = "sword", clientId = 3264, buy = 85 }, - { itemName = "throwing knife", clientId = 3298, buy = 25 }, - { itemName = "two handed sword", clientId = 3265, buy = 950 }, - { itemName = "viking helmet", clientId = 3367, buy = 265 }, - { itemName = "viking shield", clientId = 3431, buy = 260 }, - { itemName = "war hammer", clientId = 3279, buy = 10000 }, - { itemName = "wooden shield", clientId = 3412, buy = 15 }, + { 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 }, } -- On buy npc shop message npcType.onBuyItem = function(npc, player, itemId, subType, amount, ignore, inBackpacks, totalCost) From 552eaefeca2530fee2194da37498fc21083ce2c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Lu=C3=ADs=20Lucarelo=20Lamonato?= Date: Tue, 11 Jun 2024 10:39:55 -0300 Subject: [PATCH 04/17] fix: mispelled storages in freequests.lua and add some quests (#2658) --- .../creaturescripts/customs/freequests.lua | 42 ++++++++++++------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua b/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua index ad0e8d49b73..6f7e00e77f6 100644 --- a/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua +++ b/data-otservbr-global/scripts/creaturescripts/customs/freequests.lua @@ -60,15 +60,15 @@ local questTable = { { storage = Storage.InServiceofYalahar.DoorToMatrix, storageValue = 1 }, { storage = Storage.InServiceofYalahar.DoorToQuara, storageValue = 1 }, { storage = Storage.CultsOfTibia.Questline, storageValue = 7 }, - { storage = Storage.CultsOfTibia.Minotaurs.jamesfrancisTask, storageValue = 1 }, + { storage = Storage.CultsOfTibia.Minotaurs.JamesfrancisTask, storageValue = 1 }, { storage = Storage.CultsOfTibia.Minotaurs.Mission, storageValue = 1 }, - { storage = Storage.CultsOfTibia.Minotaurs.bossTimer, storageValue = 1 }, + { storage = Storage.CultsOfTibia.Minotaurs.BossTimer, storageValue = 1 }, { storage = Storage.CultsOfTibia.MotA.Mission, storageValue = 1 }, - { storage = Storage.CultsOfTibia.MotA.Pedra1, storageValue = 1 }, - { storage = Storage.CultsOfTibia.MotA.Pedra2, storageValue = 1 }, - { storage = Storage.CultsOfTibia.MotA.Pedra3, storageValue = 1 }, - { storage = Storage.CultsOfTibia.MotA.Respostas, storageValue = 1 }, - { storage = Storage.CultsOfTibia.MotA.Perguntaid, storageValue = 1 }, + { storage = Storage.CultsOfTibia.MotA.Stone1, storageValue = 1 }, + { storage = Storage.CultsOfTibia.MotA.Stone2, storageValue = 1 }, + { storage = Storage.CultsOfTibia.MotA.Stone3, storageValue = 1 }, + { storage = Storage.CultsOfTibia.MotA.Answer, storageValue = 1 }, + { storage = Storage.CultsOfTibia.MotA.QuestionId, storageValue = 1 }, { storage = Storage.CultsOfTibia.Barkless.Mission, storageValue = 1 }, { storage = Storage.CultsOfTibia.Barkless.sulphur, storageValue = 4 }, { storage = Storage.CultsOfTibia.Barkless.Tar, storageValue = 3 }, @@ -76,19 +76,19 @@ local questTable = { { storage = Storage.CultsOfTibia.Barkless.Objects, storageValue = 1 }, { storage = Storage.CultsOfTibia.Barkless.Temp, storageValue = 1 }, { storage = Storage.CultsOfTibia.Orcs.Mission, storageValue = 1 }, - { storage = Storage.CultsOfTibia.Orcs.lookType, storageValue = 1 }, - { storage = Storage.CultsOfTibia.Orcs.bossTimer, storageValue = 1 }, + { storage = Storage.CultsOfTibia.Orcs.LookType, storageValue = 1 }, + { storage = Storage.CultsOfTibia.Orcs.BossTimer, storageValue = 1 }, { storage = Storage.CultsOfTibia.Life.Mission, storageValue = 7 }, - { storage = Storage.CultsOfTibia.Life.bossTimer, storageValue = 1 }, + { storage = Storage.CultsOfTibia.Life.BossTimer, storageValue = 1 }, { storage = Storage.CultsOfTibia.Humans.Mission, storageValue = 1 }, { storage = Storage.CultsOfTibia.Humans.Vaporized, storageValue = 1 }, { storage = Storage.CultsOfTibia.Humans.Decaying, storageValue = 1 }, - { storage = Storage.CultsOfTibia.Humans.bossTimer, storageValue = 1 }, + { storage = Storage.CultsOfTibia.Humans.BossTimer, storageValue = 1 }, { storage = Storage.CultsOfTibia.Misguided.Mission, storageValue = 1 }, { storage = Storage.CultsOfTibia.Misguided.Monsters, storageValue = 1 }, { storage = Storage.CultsOfTibia.Misguided.Exorcisms, storageValue = 1 }, { storage = Storage.CultsOfTibia.Misguided.Time, storageValue = 1 }, - { storage = Storage.CultsOfTibia.Misguided.bossTimer, storageValue = 1 }, + { storage = Storage.CultsOfTibia.Misguided.BossTimer, storageValue = 1 }, { storage = Storage.CultsOfTibia.Minotaurs.EntranceAccessDoor, storageValue = 1 }, { storage = Storage.CultsOfTibia.Minotaurs.AccessDoor, storageValue = 1 }, { storage = Storage.ExplorerSociety.QuestLine, storageValue = 1 }, @@ -119,6 +119,7 @@ local questTable = { { storage = Storage.ForgottenKnowledge.LloydKilled, storageValue = 1 }, { storage = Storage.ForgottenKnowledge.LadyTenebrisKilled, storageValue = 1 }, { storage = Storage.ForgottenKnowledge.AccessMachine, storageValue = 1 }, + { storage = Storage.ForgottenKnowledge.AccessLavaTeleport, storageValue = 1 }, { storage = Storage.BarbarianTest.Questline, storageValue = 8 }, { storage = Storage.BarbarianTest.Mission01, storageValue = 3 }, { storage = Storage.BarbarianTest.Mission02, storageValue = 3 }, @@ -146,8 +147,8 @@ local questTable = { { storage = Storage.DjinnWar.MaridFaction.Mission02, storageValue = 2 }, { storage = Storage.DjinnWar.MaridFaction.RataMari, storageValue = 2 }, { storage = Storage.DjinnWar.MaridFaction.Mission03, storageValue = 3 }, - { storage = Storage.TheWayToYalahar.Questline, storageValue = 1 }, - { storage = Storage.SearoutesAroundYalahar.TownsCounter, storageValue = 1 }, + { storage = Storage.TheWayToYalahar.QuestLine, storageValue = 1 }, + { storage = Storage.SearoutesAroundYalahar.TownsCounter, storageValue = 5 }, { storage = Storage.SearoutesAroundYalahar.AbDendriel, storageValue = 1 }, { storage = Storage.SearoutesAroundYalahar.Darashia, storageValue = 1 }, { storage = Storage.SearoutesAroundYalahar.Venore, storageValue = 1 }, @@ -205,7 +206,7 @@ local questTable = { { storage = Storage.Quest.U8_54.TheNewFrontier.Mission05.KingTibianus, storageValue = 1 }, { storage = Storage.Quest.U8_54.TheNewFrontier.Mission05.Leeland, storageValue = 1 }, { storage = Storage.Quest.U8_54.TheNewFrontier.Mission05.Angus, storageValue = 1 }, - { storage = Storage.Quest.U8_54.TheNewFrontier.Mission05.Wydrin, storageValue = 1 }, + { storage = Storage.Quest.U8_54.TheNewFrontier.Mission05.Wyrdin, storageValue = 1 }, { storage = Storage.Quest.U8_54.TheNewFrontier.Mission05.Telas, storageValue = 1 }, { storage = Storage.Quest.U8_54.TheNewFrontier.Mission05.Humgolf, storageValue = 1 }, { storage = Storage.TheShatteredIsles.DefaultStart, storageValue = 3 }, @@ -314,6 +315,7 @@ local questTable = { { storage = Storage.FerumbrasAscension.TarbazDoor, storageValue = 1 }, { storage = Storage.FerumbrasAscension.HabitatsAccess, storageValue = 1 }, { storage = Storage.FerumbrasAscension.TheLordOfTheLiceAccess, storageValue = 1 }, + { storage = Storage.FerumbrasAscension.Statue, storageValue = 1 }, { storage = Storage.Quest.U12_00.TheDreamCourts.AndrewDoor, storageValue = 1 }, @@ -372,11 +374,19 @@ local questTable = { { storage = Storage.OutfitQuest.DefaultStart, storageValue = 1 }, { storage = Storage.HeroRathleton.AccessDoor, storageValue = 1 }, - { storage = Storage.HeroRathleton.FastWay, storageValue = 1 }, + { storage = Storage.HeroRathleton.AccessTeleport1, storageValue = 1 }, + { storage = Storage.HeroRathleton.AccessTeleport2, storageValue = 1 }, + { storage = Storage.HeroRathleton.AccessTeleport3, storageValue = 1 }, -- Sea Serpent Quest { storage = Storage.Quest.U8_2.FishForASerpent.QuestLine, storageValue = 5 }, { storage = Storage.Quest.U8_2.TheHuntForTheSeaSerpent.QuestLine, storageValue = 2 }, + + --The White Raven Monastery + { storage = Storage.WhiteRavenMonastery.QuestLog, storageValue = 1 }, + { storage = Storage.WhiteRavenMonastery.Passage, storageValue = 1 }, + { storage = Storage.WhiteRavenMonastery.Diary, storageValue = 2 }, + { storage = Storage.WhiteRavenMonastery.Door, storageValue = 1 }, } -- from Position: (33201, 31762, 1) From 5d0d1c9e0947dee376461a51caa828c430521ca7 Mon Sep 17 00:00:00 2001 From: Karin Date: Wed, 12 Jun 2024 10:17:48 -0300 Subject: [PATCH 05/17] fix: prevent guests to rotate dummy (#2684) --- src/game/game.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/game/game.cpp b/src/game/game.cpp index 899a89549d9..fed3a3910a1 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -126,6 +126,10 @@ namespace InternalGame { if (isGuest && !isItemInGuestInventory && !item->isLadder() && !item->canBeUsedByGuests()) { return false; } + + if (isGuest && item->isDummy()) { + return false; + } } return true; From 201aa8cb940bab3c2db6779a0dee3be3ae218198 Mon Sep 17 00:00:00 2001 From: Beats Date: Wed, 12 Jun 2024 10:43:03 -0300 Subject: [PATCH 06/17] feat: shared_ptr: familiar, groups and reload: familiars, outfits (#2556) --- CMakePresets.json | 1 + data/scripts/talkactions/god/reload.lua | 3 + src/creatures/appearance/mounts/mounts.cpp | 2 +- src/creatures/appearance/outfit/outfit.cpp | 37 +++-- src/creatures/appearance/outfit/outfit.hpp | 14 +- src/creatures/players/grouping/familiars.cpp | 7 +- src/creatures/players/grouping/familiars.hpp | 5 +- src/creatures/players/grouping/groups.cpp | 4 +- src/creatures/players/grouping/groups.hpp | 4 +- src/creatures/players/player.cpp | 6 +- src/creatures/players/player.hpp | 11 +- src/game/functions/game_reload.cpp | 154 ++++++++++-------- src/game/functions/game_reload.hpp | 50 +++--- src/game/game.cpp | 4 +- src/game/game.hpp | 2 + src/io/functions/iologindata_load_player.cpp | 4 +- .../creatures/player/group_functions.cpp | 16 +- src/server/network/protocol/protocolgame.cpp | 2 +- 18 files changed, 184 insertions(+), 142 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 92ef2d33c6a..49f631e1921 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -54,6 +54,7 @@ "DEBUG_LOG": "ON", "ASAN_ENABLED": "OFF", "BUILD_STATIC_LIBRARY": "OFF", + "SPEED_UP_BUILD_UNITY": "OFF", "VCPKG_TARGET_TRIPLET": "x64-windows" } }, diff --git a/data/scripts/talkactions/god/reload.lua b/data/scripts/talkactions/god/reload.lua index 20b9431dbba..d0c0cdd45a8 100644 --- a/data/scripts/talkactions/god/reload.lua +++ b/data/scripts/talkactions/god/reload.lua @@ -7,6 +7,7 @@ local reloadTypes = { ["configuration"] = RELOAD_TYPE_CONFIG, ["core"] = RELOAD_TYPE_CORE, ["events"] = RELOAD_TYPE_EVENTS, + ["familiar"] = RELOAD_TYPE_FAMILIARS, ["global"] = RELOAD_TYPE_CORE, ["group"] = RELOAD_TYPE_GROUPS, ["groups"] = RELOAD_TYPE_GROUPS, @@ -20,6 +21,8 @@ local reloadTypes = { ["monsters"] = RELOAD_TYPE_MONSTERS, ["mount"] = RELOAD_TYPE_MOUNTS, ["mounts"] = RELOAD_TYPE_MOUNTS, + ["outfit"] = RELOAD_TYPE_OUTFITS, + ["outfits"] = RELOAD_TYPE_OUTFITS, ["npc"] = RELOAD_TYPE_NPCS, ["npcs"] = RELOAD_TYPE_NPCS, ["raid"] = RELOAD_TYPE_RAIDS, diff --git a/src/creatures/appearance/mounts/mounts.cpp b/src/creatures/appearance/mounts/mounts.cpp index 7051d04ddb8..7014d0b026b 100644 --- a/src/creatures/appearance/mounts/mounts.cpp +++ b/src/creatures/appearance/mounts/mounts.cpp @@ -29,7 +29,7 @@ bool Mounts::loadFromXml() { } for (auto mountNode : doc.child("mounts").children()) { - uint16_t lookType = pugi::cast(mountNode.attribute("clientid").value()); + auto lookType = pugi::cast(mountNode.attribute("clientid").value()); if (g_configManager().getBoolean(WARN_UNSAFE_SCRIPTS, __FUNCTION__) && lookType != 0 && !g_game().isLookTypeRegistered(lookType)) { g_logger().warn("{} - An unregistered creature mount with id '{}' was blocked to prevent client crash.", __FUNCTION__, lookType); continue; diff --git a/src/creatures/appearance/outfit/outfit.cpp b/src/creatures/appearance/outfit/outfit.cpp index 9e96c60e756..97120659333 100644 --- a/src/creatures/appearance/outfit/outfit.cpp +++ b/src/creatures/appearance/outfit/outfit.cpp @@ -14,6 +14,10 @@ #include "utils/tools.hpp" #include "game/game.hpp" +Outfits &Outfits::getInstance() { + return inject(); +} + bool Outfits::reload() { for (auto &outfitsVector : outfits) { outfitsVector.clear(); @@ -41,7 +45,7 @@ bool Outfits::loadFromXml() { continue; } - uint16_t type = pugi::cast(attr.value()); + auto type = pugi::cast(attr.value()); if (type > PLAYERSEX_LAST) { g_logger().warn("[Outfits::loadFromXml] - Invalid outfit type {}", type); continue; @@ -53,7 +57,7 @@ bool Outfits::loadFromXml() { continue; } - if (uint16_t lookType = pugi::cast(lookTypeAttribute.value()); + if (auto lookType = pugi::cast(lookTypeAttribute.value()); g_configManager().getBoolean(WARN_UNSAFE_SCRIPTS, __FUNCTION__) && lookType != 0 && !g_game().isLookTypeRegistered(lookType)) { g_logger().warn("[Outfits::loadFromXml] An unregistered creature looktype type with id '{}' was ignored to prevent client crash.", lookType); @@ -74,7 +78,22 @@ bool Outfits::loadFromXml() { return true; } -std::shared_ptr Outfits::getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const { +std::shared_ptr Outfits::getOutfitByLookType(const std::shared_ptr &player, uint16_t lookType, bool isOppositeOutfit) const { + if (!player) { + g_logger().error("[{}] - Player not found", __FUNCTION__); + return nullptr; + } + + auto sex = player->getSex(); + if (sex != PLAYERSEX_FEMALE && sex != PLAYERSEX_MALE) { + g_logger().error("[{}] - Sex invalid or player: {}", __FUNCTION__, player->getName()); + return nullptr; + } + + if (isOppositeOutfit) { + sex = (sex == PLAYERSEX_MALE) ? PLAYERSEX_FEMALE : PLAYERSEX_MALE; + } + auto it = std::ranges::find_if(outfits[sex], [&lookType](const auto &outfit) { return outfit->lookType == lookType; }); @@ -84,15 +103,3 @@ std::shared_ptr Outfits::getOutfitByLookType(PlayerSex_t sex, uint16_t l } return nullptr; } - -/** - * Get the oposite sex equivalent outfit - * @param sex current sex - * @param lookType current looktype - * @return const pointer to the outfit or nullptr if it could not be found. - */ - -std::shared_ptr Outfits::getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const { - PlayerSex_t searchSex = (sex == PLAYERSEX_MALE) ? PLAYERSEX_FEMALE : PLAYERSEX_MALE; - return getOutfitByLookType(searchSex, lookType); -} diff --git a/src/creatures/appearance/outfit/outfit.hpp b/src/creatures/appearance/outfit/outfit.hpp index 30b84d1aca2..0d89a2c932d 100644 --- a/src/creatures/appearance/outfit/outfit.hpp +++ b/src/creatures/appearance/outfit/outfit.hpp @@ -12,8 +12,10 @@ #include "declarations.hpp" #include "lib/di/container.hpp" +class Player; + struct OutfitEntry { - constexpr OutfitEntry(uint16_t initLookType, uint8_t initAddons) : + constexpr explicit OutfitEntry(uint16_t initLookType, uint8_t initAddons) : lookType(initLookType), addons(initAddons) { } uint16_t lookType; @@ -42,16 +44,12 @@ struct ProtocolOutfit { class Outfits { public: - static Outfits &getInstance() { - return inject(); - } - - std::shared_ptr getOpositeSexOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const; + static Outfits &getInstance(); - bool loadFromXml(); bool reload(); + bool loadFromXml(); - [[nodiscard]] std::shared_ptr getOutfitByLookType(PlayerSex_t sex, uint16_t lookType) const; + [[nodiscard]] std::shared_ptr getOutfitByLookType(const std::shared_ptr &player, uint16_t lookType, bool isOppositeOutfit = false) const; [[nodiscard]] const std::vector> &getOutfits(PlayerSex_t sex) const { return outfits[sex]; } diff --git a/src/creatures/players/grouping/familiars.cpp b/src/creatures/players/grouping/familiars.cpp index a922013f19b..6e923b823dc 100644 --- a/src/creatures/players/grouping/familiars.cpp +++ b/src/creatures/players/grouping/familiars.cpp @@ -10,10 +10,15 @@ #include "pch.hpp" #include "creatures/players/grouping/familiars.hpp" +#include "lib/di/container.hpp" #include "config/configmanager.hpp" #include "utils/pugicast.hpp" #include "utils/tools.hpp" +Familiars &Familiars::getInstance() { + return inject(); +} + bool Familiars::reload() { for (auto &familiarsVector : familiars) { familiarsVector.clear(); @@ -42,7 +47,7 @@ bool Familiars::loadFromXml() { continue; } - uint16_t vocation = pugi::cast(attr.value()); + auto vocation = pugi::cast(attr.value()); if (vocation > VOCATION_LAST) { g_logger().warn("[Familiars::loadFromXml] - Invalid familiar vocation {}", vocation); continue; diff --git a/src/creatures/players/grouping/familiars.hpp b/src/creatures/players/grouping/familiars.hpp index 8f553af9fbe..9eda7d95ba2 100644 --- a/src/creatures/players/grouping/familiars.hpp +++ b/src/creatures/players/grouping/familiars.hpp @@ -9,6 +9,7 @@ #pragma once +#include "declarations.hpp" #include "lib/di/container.hpp" struct FamiliarEntry { @@ -32,9 +33,7 @@ struct Familiar { class Familiars { public: - static Familiars &getInstance() { - return inject(); - } + static Familiars &getInstance(); bool loadFromXml(); bool reload(); diff --git a/src/creatures/players/grouping/groups.cpp b/src/creatures/players/grouping/groups.cpp index 27ae68d9fd4..937fa848f3f 100644 --- a/src/creatures/players/grouping/groups.cpp +++ b/src/creatures/players/grouping/groups.cpp @@ -43,7 +43,7 @@ PlayerFlags_t Groups::getFlagFromNumber(uint8_t value) { return magic_enum::enum_value(value); } -bool Groups::reload() const { +bool Groups::reload() { // Clear groups g_game().groups.getGroups().clear(); return g_game().groups.load(); @@ -99,7 +99,7 @@ bool Groups::load() { return true; } -std::shared_ptr Groups::getGroup(uint16_t id) { +std::shared_ptr Groups::getGroup(uint16_t id) const { if (auto it = std::find_if(groups_vector.begin(), groups_vector.end(), [id](auto group_it) { return group_it->id == id; }); diff --git a/src/creatures/players/grouping/groups.hpp b/src/creatures/players/grouping/groups.hpp index d76914e2632..af319e95772 100644 --- a/src/creatures/players/grouping/groups.hpp +++ b/src/creatures/players/grouping/groups.hpp @@ -24,9 +24,9 @@ class Groups { public: static uint8_t getFlagNumber(PlayerFlags_t playerFlags); static PlayerFlags_t getFlagFromNumber(uint8_t value); - bool reload() const; + static bool reload(); bool load(); - std::shared_ptr getGroup(uint16_t id); + [[nodiscard]] std::shared_ptr getGroup(uint16_t id) const; std::vector> &getGroups() { return groups_vector; } diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 4109eb77472..2b10c0f77ee 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -4914,7 +4914,7 @@ bool Player::canWear(uint16_t lookType, uint8_t addons) const { return true; } - const auto &outfit = Outfits::getInstance().getOutfitByLookType(sex, lookType); + const auto &outfit = Outfits::getInstance().getOutfitByLookType(getPlayer(), lookType); if (!outfit) { return false; } @@ -5001,7 +5001,7 @@ bool Player::removeOutfitAddon(uint16_t lookType, uint8_t addons) { return false; } -bool Player::getOutfitAddons(const std::shared_ptr outfit, uint8_t &addons) const { +bool Player::getOutfitAddons(const std::shared_ptr &outfit, uint8_t &addons) const { if (group->access) { addons = 3; return true; @@ -5826,7 +5826,7 @@ bool Player::toggleMount(bool mount) { return false; } - const auto &playerOutfit = Outfits::getInstance().getOutfitByLookType(getSex(), defaultOutfit.lookType); + const auto &playerOutfit = Outfits::getInstance().getOutfitByLookType(getPlayer(), defaultOutfit.lookType); if (!playerOutfit) { return false; } diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index c0761704db4..19e3af5ca9c 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -476,7 +476,12 @@ class Player final : public Creature, public Cylinder, public Bankable { return blessings[index - 1] != 0; } uint8_t getBlessingCount(uint8_t index) const { - return blessings[index - 1]; + if (index > 0 && index <= blessings.size()) { + return blessings[index - 1]; + } else { + g_logger().error("[{}] - index outside range 0-10.", __FUNCTION__); + return 0; + } } std::string getBlessingsName() const; @@ -1031,7 +1036,7 @@ class Player final : public Creature, public Cylinder, public Bankable { void addOutfit(uint16_t lookType, uint8_t addons); bool removeOutfit(uint16_t lookType); bool removeOutfitAddon(uint16_t lookType, uint8_t addons); - bool getOutfitAddons(const std::shared_ptr outfit, uint8_t &addons) const; + bool getOutfitAddons(const std::shared_ptr &outfit, uint8_t &addons) const; bool canFamiliar(uint16_t lookType) const; void addFamiliar(uint16_t lookType); @@ -2853,7 +2858,7 @@ class Player final : public Creature, public Cylinder, public Bankable { uint16_t lastStatsTrainingTime = 0; uint16_t staminaMinutes = 2520; - std::vector blessings = { 0, 0, 0, 0, 0, 0, 0, 0 }; + std::vector blessings = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; uint16_t maxWriteLen = 0; uint16_t baseXpGain = 100; uint16_t voucherXpBoost = 0; diff --git a/src/game/functions/game_reload.cpp b/src/game/functions/game_reload.cpp index 0fc74bcee71..d9d9eb1f449 100644 --- a/src/game/functions/game_reload.cpp +++ b/src/game/functions/game_reload.cpp @@ -22,7 +22,7 @@ GameReload::GameReload() = default; GameReload::~GameReload() = default; -bool GameReload::init(Reload_t reloadTypes) const { +bool GameReload::init(Reload_t reloadTypes) { switch (reloadTypes) { case Reload_t::RELOAD_TYPE_ALL: return reloadAll(); @@ -32,34 +32,38 @@ bool GameReload::init(Reload_t reloadTypes) const { return reloadConfig(); case Reload_t::RELOAD_TYPE_EVENTS: return reloadEvents(); - case Reload_t::RELOAD_TYPE_CORE: - return reloadCore(); + case Reload_t::RELOAD_TYPE_MODULES: + return reloadModules(); + case Reload_t::RELOAD_TYPE_OUTFITS: + return reloadOutfits(); + case Reload_t::RELOAD_TYPE_MOUNTS: + return reloadMounts(); + case Reload_t::RELOAD_TYPE_FAMILIARS: + return reloadFamiliars(); case Reload_t::RELOAD_TYPE_IMBUEMENTS: return reloadImbuements(); + case Reload_t::RELOAD_TYPE_VOCATIONS: + return reloadVocations(); + case Reload_t::RELOAD_TYPE_CORE: + return reloadCore(); + case Reload_t::RELOAD_TYPE_GROUPS: + return reloadGroups(); + case Reload_t::RELOAD_TYPE_SCRIPTS: + return reloadScripts(); case Reload_t::RELOAD_TYPE_ITEMS: return reloadItems(); - case Reload_t::RELOAD_TYPE_MODULES: - return reloadModules(); case Reload_t::RELOAD_TYPE_MONSTERS: return reloadMonsters(); - case Reload_t::RELOAD_TYPE_MOUNTS: - return reloadMounts(); case Reload_t::RELOAD_TYPE_NPCS: return reloadNpcs(); case Reload_t::RELOAD_TYPE_RAIDS: return reloadRaids(); - case Reload_t::RELOAD_TYPE_SCRIPTS: - return reloadScripts(); - case Reload_t::RELOAD_TYPE_GROUPS: - return reloadGroups(); - case Reload_t::RELOAD_TYPE_VOCATIONS: - return reloadVocations(); default: return false; } } -uint8_t GameReload::getReloadNumber(Reload_t reloadTypes) const { +uint8_t GameReload::getReloadNumber(Reload_t reloadTypes) { return magic_enum::enum_integer(reloadTypes); } @@ -78,7 +82,7 @@ void logReloadStatus(const std::string &name, bool result) { * If it is necessary to call elsewhere, seriously think about creating a function that calls this * Changing this to public may cause some unexpected behavior or bug */ -bool GameReload::reloadAll() const { +bool GameReload::reloadAll() { std::vector reloadResults; reloadResults.reserve(magic_enum::enum_count()); @@ -93,25 +97,62 @@ bool GameReload::reloadAll() const { return std::ranges::any_of(reloadResults, [](bool result) { return result; }); } -bool GameReload::reloadChat() const { +bool GameReload::reloadChat() { const bool result = g_chat().load(); logReloadStatus("Chat", result); return result; } -bool GameReload::reloadConfig() const { +bool GameReload::reloadConfig() { const bool result = g_configManager().reload(); logReloadStatus("Config", result); return result; } -bool GameReload::reloadEvents() const { +bool GameReload::reloadEvents() { const bool result = g_events().loadFromXml(); logReloadStatus("Events", result); return result; } -bool GameReload::reloadCore() const { +bool GameReload::reloadModules() { + const bool result = g_modules().reload(); + logReloadStatus("Modules", result); + return result; +} + +bool GameReload::reloadOutfits() { + const bool result = g_game().outfits.reload(); + logReloadStatus("Outfits", result); + return result; +} + +bool GameReload::reloadMounts() { + const bool result = g_game().mounts.reload(); + logReloadStatus("Mounts", result); + return result; +} + +bool GameReload::reloadFamiliars() { + const bool result = g_game().familiars.reload(); + logReloadStatus("Familiars", result); + return result; +} + +bool GameReload::reloadImbuements() { + const bool result = g_imbuements().reload(); + logReloadStatus("Imbuements", result); + return result; +} + +bool GameReload::reloadVocations() { + const bool result = g_vocations().reload(); + reloadScripts(); + logReloadStatus("Vocations", result); + return result; +} + +bool GameReload::reloadCore() { const auto &coreFolder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__); const bool coreLoaded = g_luaEnvironment().loadFile(coreFolder + "/core.lua", "core.lua") == 0; @@ -126,25 +167,38 @@ bool GameReload::reloadCore() const { return false; } -bool GameReload::reloadImbuements() const { - const bool result = g_imbuements().reload(); - logReloadStatus("Imbuements", result); +bool GameReload::reloadGroups() { + const bool result = g_game().groups.reload(); + logReloadStatus("Groups", result); return result; } -bool GameReload::reloadItems() const { - const bool result = Item::items.reload(); - logReloadStatus("Items", result); - return result; +bool GameReload::reloadScripts() { + g_scripts().clearAllScripts(); + Zone::clearZones(); + + const auto &datapackFolder = g_configManager().getString(DATA_DIRECTORY, __FUNCTION__); + const auto &coreFolder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__); + + g_scripts().loadScripts(coreFolder + "/scripts/lib", true, false); + g_scripts().loadScripts(datapackFolder + "/scripts", false, true); + g_scripts().loadScripts(coreFolder + "/scripts", false, true); + + // It should come last, after everything else has been cleaned up. + reloadMonsters(); + reloadNpcs(); + reloadItems(); + logReloadStatus("Scripts", true); + return true; } -bool GameReload::reloadModules() const { - const bool result = g_modules().reload(); - logReloadStatus("Modules", result); +bool GameReload::reloadItems() { + const bool result = Item::items.reload(); + logReloadStatus("Items", result); return result; } -bool GameReload::reloadMonsters() const { +bool GameReload::reloadMonsters() { g_monsters().clear(); const auto &datapackFolder = g_configManager().getString(DATA_DIRECTORY, __FUNCTION__); const auto &coreFolder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__); @@ -161,50 +215,14 @@ bool GameReload::reloadMonsters() const { } } -bool GameReload::reloadMounts() const { - const bool result = g_game().mounts.reload(); - logReloadStatus("Mounts", result); - return result; -} - -bool GameReload::reloadNpcs() const { +bool GameReload::reloadNpcs() { const bool result = g_npcs().reload(); logReloadStatus("NPCs", result); return result; } -bool GameReload::reloadRaids() const { +bool GameReload::reloadRaids() { const bool result = g_game().raids.reload() && g_game().raids.startup(); logReloadStatus("Raids", result); return result; } - -bool GameReload::reloadScripts() const { - g_scripts().clearAllScripts(); - Zone::clearZones(); - - const auto &datapackFolder = g_configManager().getString(DATA_DIRECTORY, __FUNCTION__); - const auto &coreFolder = g_configManager().getString(CORE_DIRECTORY, __FUNCTION__); - - g_scripts().loadScripts(coreFolder + "/scripts/lib", true, false); - g_scripts().loadScripts(datapackFolder + "/scripts", false, true); - g_scripts().loadScripts(coreFolder + "/scripts", false, true); - - // It should come last, after everything else has been cleaned up. - reloadMonsters(); - reloadNpcs(); - logReloadStatus("Scripts", true); - return true; -} - -bool GameReload::reloadGroups() const { - const bool result = g_game().groups.reload(); - logReloadStatus("Groups", result); - return result; -} - -bool GameReload::reloadVocations() const { - const bool result = g_vocations().reload(); - logReloadStatus("Vocations", result); - return result; -} diff --git a/src/game/functions/game_reload.hpp b/src/game/functions/game_reload.hpp index 45ff35c01a2..0f59046a9d4 100644 --- a/src/game/functions/game_reload.hpp +++ b/src/game/functions/game_reload.hpp @@ -19,17 +19,19 @@ enum class Reload_t : uint8_t { RELOAD_TYPE_CHAT, RELOAD_TYPE_CONFIG, RELOAD_TYPE_EVENTS, - RELOAD_TYPE_CORE, + RELOAD_TYPE_MODULES, + RELOAD_TYPE_OUTFITS, + RELOAD_TYPE_MOUNTS, + RELOAD_TYPE_FAMILIARS, RELOAD_TYPE_IMBUEMENTS, + RELOAD_TYPE_VOCATIONS, + RELOAD_TYPE_CORE, + RELOAD_TYPE_GROUPS, + RELOAD_TYPE_SCRIPTS, RELOAD_TYPE_ITEMS, - RELOAD_TYPE_MODULES, RELOAD_TYPE_MONSTERS, - RELOAD_TYPE_MOUNTS, RELOAD_TYPE_NPCS, RELOAD_TYPE_RAIDS, - RELOAD_TYPE_SCRIPTS, - RELOAD_TYPE_GROUPS, - RELOAD_TYPE_VOCATIONS, // Every is last RELOAD_TYPE_LAST @@ -48,25 +50,27 @@ class GameReload : public Game { return inject(); } - bool init(Reload_t reloadType) const; - uint8_t getReloadNumber(Reload_t reloadTypes) const; + static bool init(Reload_t reloadType); + static uint8_t getReloadNumber(Reload_t reloadTypes); private: - bool reloadAll() const; - bool reloadChat() const; - bool reloadConfig() const; - bool reloadEvents() const; - bool reloadCore() const; - bool reloadImbuements() const; - bool reloadItems() const; - bool reloadModules() const; - bool reloadMonsters() const; - bool reloadMounts() const; - bool reloadNpcs() const; - bool reloadRaids() const; - bool reloadScripts() const; - bool reloadGroups() const; - bool reloadVocations() const; + static bool reloadAll(); + static bool reloadChat(); + static bool reloadConfig(); + static bool reloadEvents(); + static bool reloadModules(); + static bool reloadOutfits(); + static bool reloadMounts(); + static bool reloadFamiliars(); + static bool reloadImbuements(); + static bool reloadVocations(); + static bool reloadCore(); + static bool reloadGroups(); + static bool reloadScripts(); + static bool reloadItems(); + static bool reloadMonsters(); + static bool reloadNpcs(); + static bool reloadRaids(); }; constexpr auto g_gameReload = GameReload::getInstance; diff --git a/src/game/game.cpp b/src/game/game.cpp index fed3a3910a1..57daddded2e 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -4261,7 +4261,7 @@ void Game::playerSetShowOffSocket(uint32_t playerId, Outfit_t &outfit, const Pos name << item->getName() << " displaying the "; bool outfited = false; if (outfit.lookType != 0) { - const auto &outfitInfo = Outfits::getInstance().getOutfitByLookType(player->getSex(), outfit.lookType); + const auto &outfitInfo = Outfits::getInstance().getOutfitByLookType(player, outfit.lookType); if (!outfitInfo) { return; } @@ -5927,7 +5927,7 @@ void Game::playerChangeOutfit(uint32_t playerId, Outfit_t outfit, uint8_t isMoun outfit.lookMount = randomMount->clientId; } - const auto playerOutfit = Outfits::getInstance().getOutfitByLookType(player->getSex(), outfit.lookType); + const auto playerOutfit = Outfits::getInstance().getOutfitByLookType(player, outfit.lookType); if (!playerOutfit) { outfit.lookMount = 0; } diff --git a/src/game/game.hpp b/src/game/game.hpp index 3a199254259..b4be8facd09 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -582,8 +582,10 @@ class Game { bool hasDistanceEffect(uint16_t effectId); Groups groups; + Familiars familiars; Map map; Mounts mounts; + Outfits outfits; Raids raids; std::unique_ptr m_appearancesPtr; diff --git a/src/io/functions/iologindata_load_player.cpp b/src/io/functions/iologindata_load_player.cpp index 6273f8fefbb..8f7cf461fdf 100644 --- a/src/io/functions/iologindata_load_player.cpp +++ b/src/io/functions/iologindata_load_player.cpp @@ -66,7 +66,7 @@ bool IOLoginDataLoad::preLoadPlayer(std::shared_ptr player, const std::s } player->setGUID(result->getNumber("id")); - std::shared_ptr group = g_game().groups.getGroup(result->getNumber("group_id")); + const auto &group = g_game().groups.getGroup(result->getNumber("group_id")); if (!group) { g_logger().error("Player {} has group id {} which doesn't exist", player->name, result->getNumber("group_id")); return false; @@ -118,7 +118,7 @@ bool IOLoginDataLoad::loadPlayerFirst(std::shared_ptr player, DBResult_p player->setAccount(result->getNumber("account_id")); } - std::shared_ptr group = g_game().groups.getGroup(result->getNumber("group_id")); + const auto &group = g_game().groups.getGroup(result->getNumber("group_id")); if (!group) { g_logger().error("Player {} has group id {} which doesn't exist", player->name, result->getNumber("group_id")); return false; diff --git a/src/lua/functions/creatures/player/group_functions.cpp b/src/lua/functions/creatures/player/group_functions.cpp index 5acc16d72a9..f547eec1590 100644 --- a/src/lua/functions/creatures/player/group_functions.cpp +++ b/src/lua/functions/creatures/player/group_functions.cpp @@ -17,7 +17,7 @@ int GroupFunctions::luaGroupCreate(lua_State* L) { // Group(id) uint32_t id = getNumber(L, 2); - std::shared_ptr group = g_game().groups.getGroup(id); + const auto &group = g_game().groups.getGroup(id); if (group) { pushUserdata(L, group); setMetatable(L, -1, "Group"); @@ -29,7 +29,7 @@ int GroupFunctions::luaGroupCreate(lua_State* L) { int GroupFunctions::luaGroupGetId(lua_State* L) { // group:getId() - std::shared_ptr group = getUserdataShared(L, 1); + const auto &group = getUserdataShared(L, 1); if (group) { lua_pushnumber(L, group->id); } else { @@ -40,7 +40,7 @@ int GroupFunctions::luaGroupGetId(lua_State* L) { int GroupFunctions::luaGroupGetName(lua_State* L) { // group:getName() - std::shared_ptr group = getUserdataShared(L, 1); + const auto &group = getUserdataShared(L, 1); if (group) { pushString(L, group->name); } else { @@ -51,7 +51,7 @@ int GroupFunctions::luaGroupGetName(lua_State* L) { int GroupFunctions::luaGroupGetFlags(lua_State* L) { // group:getFlags() - std::shared_ptr group = getUserdataShared(L, 1); + const auto &group = getUserdataShared(L, 1); if (group) { std::bitset flags; for (uint8_t i = 0; i < magic_enum::enum_integer(PlayerFlags_t::FlagLast); ++i) { @@ -68,7 +68,7 @@ int GroupFunctions::luaGroupGetFlags(lua_State* L) { int GroupFunctions::luaGroupGetAccess(lua_State* L) { // group:getAccess() - std::shared_ptr group = getUserdataShared(L, 1); + const auto &group = getUserdataShared(L, 1); if (group) { pushBoolean(L, group->access); } else { @@ -79,7 +79,7 @@ int GroupFunctions::luaGroupGetAccess(lua_State* L) { int GroupFunctions::luaGroupGetMaxDepotItems(lua_State* L) { // group:getMaxDepotItems() - std::shared_ptr group = getUserdataShared(L, 1); + const auto &group = getUserdataShared(L, 1); if (group) { lua_pushnumber(L, group->maxDepotItems); } else { @@ -90,7 +90,7 @@ int GroupFunctions::luaGroupGetMaxDepotItems(lua_State* L) { int GroupFunctions::luaGroupGetMaxVipEntries(lua_State* L) { // group:getMaxVipEntries() - std::shared_ptr group = getUserdataShared(L, 1); + const auto &group = getUserdataShared(L, 1); if (group) { lua_pushnumber(L, group->maxVipEntries); } else { @@ -101,7 +101,7 @@ int GroupFunctions::luaGroupGetMaxVipEntries(lua_State* L) { int GroupFunctions::luaGroupHasFlag(lua_State* L) { // group:hasFlag(flag) - std::shared_ptr group = getUserdataShared(L, 1); + const auto &group = getUserdataShared(L, 1); if (group) { auto flag = static_cast(getNumber(L, 2)); pushBoolean(L, group->flags[Groups::getFlagNumber(flag)]); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 751da531273..98bacfc5e12 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -4055,7 +4055,7 @@ void ProtocolGame::sendCyclopediaCharacterInspection() { // Outfit description playerDescriptionSize++; msg.addString("Outfit", "ProtocolGame::sendCyclopediaCharacterInspection - Outfit"); - if (const auto outfit = Outfits::getInstance().getOutfitByLookType(player->getSex(), player->getDefaultOutfit().lookType)) { + if (const auto outfit = Outfits::getInstance().getOutfitByLookType(player, player->getDefaultOutfit().lookType)) { msg.addString(outfit->name, "ProtocolGame::sendCyclopediaCharacterInspection - outfit->name"); } else { msg.addString("unknown", "ProtocolGame::sendCyclopediaCharacterInspection - unknown"); From e20e7eb68b24eafdbc13b1c3c72928ee8caf3ee1 Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Wed, 12 Jun 2024 10:43:24 -0300 Subject: [PATCH 07/17] feat: monster rename functionality (#2621) --- ...{create_monster.lua => manage_monster.lua} | 32 +++++++++++++++++- src/creatures/monsters/monster.cpp | 33 ++++++++++++++++++- src/creatures/monsters/monster.hpp | 20 ++++++----- src/creatures/players/player.hpp | 9 +++-- .../creatures/monster/monster_functions.cpp | 20 ++++++++++- .../creatures/monster/monster_functions.hpp | 2 ++ src/server/network/protocol/protocolgame.cpp | 33 ++++++++++++++----- src/server/network/protocol/protocolgame.hpp | 1 + 8 files changed, 128 insertions(+), 22 deletions(-) rename data/scripts/talkactions/god/{create_monster.lua => manage_monster.lua} (83%) diff --git a/data/scripts/talkactions/god/create_monster.lua b/data/scripts/talkactions/god/manage_monster.lua similarity index 83% rename from data/scripts/talkactions/god/create_monster.lua rename to data/scripts/talkactions/god/manage_monster.lua index ce5869a2eee..da110d59265 100644 --- a/data/scripts/talkactions/god/create_monster.lua +++ b/data/scripts/talkactions/god/manage_monster.lua @@ -56,7 +56,7 @@ local createMonster = TalkAction("/m") -- @param param: String containing the command parameters. -- Format: "/m monstername, monstercount, [fiendish/influenced level], spawnRadius, [forceCreate]" -- Example: "/m rat, 10, fiendish, 5, true" --- @param: the last param is by default "false", if add "," or any value i'ts set to true +-- @param: the last param is by default "false", if add "," or any value it's set to true -- @return true if the command is executed successfully, false otherwise. function createMonster.onSay(player, words, param) -- create log @@ -127,3 +127,33 @@ end createMonster:separator(" ") createMonster:groupType("god") createMonster:register() + +----------------- Rename monster name ----------------- +local setMonsterName = TalkAction("/setmonstername") + +-- @function setMonsterName.onSay +-- @desc TalkAction to rename nearby monsters within a radius of 4 sqm. +-- Format: "/setmonstername newName" +function setMonsterName.onSay(player, words, param) + if param == "" then + player:sendCancelMessage("Command param required.") + return true + end + + local split = param:split(",") + local monsterNewName = split[1] + + local spectators, spectator = Game.getSpectators(player:getPosition(), false, false, 4, 4, 4, 4) + for i = 1, #spectators do + spectator = spectators[i] + if spectator:isMonster() then + spectator:setName(monsterNewName) + end + end + + return true +end + +setMonsterName:separator(" ") +setMonsterName:groupType("god") +setMonsterName:register() diff --git a/src/creatures/monsters/monster.cpp b/src/creatures/monsters/monster.cpp index fccc19b05e5..5e0a7d16bb4 100644 --- a/src/creatures/monsters/monster.cpp +++ b/src/creatures/monsters/monster.cpp @@ -33,7 +33,7 @@ std::shared_ptr Monster::createMonster(const std::string &name) { Monster::Monster(const std::shared_ptr mType) : Creature(), - strDescription(asLowerCaseString(mType->nameDescription)), + nameDescription(asLowerCaseString(mType->nameDescription)), mType(mType) { defaultOutfit = mType->info.outfit; currentOutfit = mType->info.outfit; @@ -64,6 +64,37 @@ void Monster::removeList() { g_game().removeMonster(static_self_cast()); } +const std::string &Monster::getName() const { + if (name.empty()) { + return mType->name; + } + return name; +} + +void Monster::setName(const std::string &name) { + if (getName() == name) { + return; + } + + this->name = name; + + // NOTE: Due to how client caches known creatures, + // it is not feasible to send creature update to everyone that has ever met it + auto spectators = Spectators().find(position, true); + for (const auto &spectator : spectators) { + if (const auto &tmpPlayer = spectator->getPlayer()) { + tmpPlayer->sendUpdateTileCreature(static_self_cast()); + } + } +} + +const std::string &Monster::getNameDescription() const { + if (nameDescription.empty()) { + return mType->nameDescription; + } + return nameDescription; +} + bool Monster::canWalkOnFieldType(CombatType_t combatType) const { switch (combatType) { case COMBAT_ENERGYDAMAGE: diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index bf9a39e4133..6c45fa3eaca 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -41,21 +41,22 @@ class Monster final : public Creature { } } - void removeList() override; void addList() override; + void removeList() override; + + const std::string &getName() const override; + void setName(const std::string &name); - const std::string &getName() const override { - return mType->name; - } // Real monster name, set on monster creation "createMonsterType(typeName)" const std::string &getTypeName() const override { return mType->typeName; } - const std::string &getNameDescription() const override { - return mType->nameDescription; - } + const std::string &getNameDescription() const override; + void setNameDescription(const std::string &nameDescription) { + this->nameDescription = nameDescription; + }; std::string getDescription(int32_t) override { - return strDescription + '.'; + return nameDescription + '.'; } CreatureType_t getType() const override { @@ -363,7 +364,8 @@ class Monster final : public Creature { uint16_t forgeStack = 0; ForgeClassifications_t monsterForgeClassification = ForgeClassifications_t::FORGE_NORMAL_MONSTER; - std::string strDescription; + std::string name; + std::string nameDescription; std::shared_ptr mType; SpawnMonster* spawnMonster = nullptr; diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index 19e3af5ca9c..947acedca54 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -153,8 +153,8 @@ class Player final : public Creature, public Cylinder, public Bankable { const std::string &getName() const override { return name; } - void setName(std::string newName) { - this->name = std::move(newName); + void setName(const std::string &name) { + this->name = name; } const std::string &getTypeName() const override { return name; @@ -1075,6 +1075,11 @@ class Player final : public Creature, public Cylinder, public Bankable { client->sendRemoveTileThing(pos, stackpos); } } + void sendUpdateTileCreature(const std::shared_ptr creature) { + if (client) { + client->sendUpdateTileCreature(creature->getPosition(), creature->getTile()->getClientIndexOfCreature(static_self_cast(), creature), creature); + } + } void sendUpdateTile(std::shared_ptr updateTile, const Position &pos) { if (client) { client->sendUpdateTile(updateTile, pos); diff --git a/src/lua/functions/creatures/monster/monster_functions.cpp b/src/lua/functions/creatures/monster/monster_functions.cpp index 1591053c391..273f6af5c99 100644 --- a/src/lua/functions/creatures/monster/monster_functions.cpp +++ b/src/lua/functions/creatures/monster/monster_functions.cpp @@ -77,7 +77,7 @@ int MonsterFunctions::luaMonsterSetType(lua_State* L) { } // Assign new MonsterType monster->mType = mType; - monster->strDescription = asLowerCaseString(mType->nameDescription); + monster->nameDescription = asLowerCaseString(mType->nameDescription); monster->defaultOutfit = mType->info.outfit; monster->currentOutfit = mType->info.outfit; monster->skull = mType->info.skull; @@ -529,6 +529,24 @@ int MonsterFunctions::luaMonsterGetName(lua_State* L) { return 1; } +int MonsterFunctions::luaMonsterSetName(lua_State* L) { + // monster:setName(name[, nameDescription]) + auto monster = getUserdataShared(L, 1); + if (!monster) { + reportErrorFunc(getErrorDesc(LUA_ERROR_MONSTER_NOT_FOUND)); + pushBoolean(L, false); + return 0; + } + + monster->setName(getString(L, 2)); + if (lua_gettop(L) >= 3) { + monster->setNameDescription(getString(L, 3)); + } + + pushBoolean(L, true); + return 1; +} + int MonsterFunctions::luaMonsterHazard(lua_State* L) { // get: monster:hazard() ; set: monster:hazard(hazard) std::shared_ptr monster = getUserdataShared(L, 1); diff --git a/src/lua/functions/creatures/monster/monster_functions.hpp b/src/lua/functions/creatures/monster/monster_functions.hpp index bf2785ae430..dd1c3827344 100644 --- a/src/lua/functions/creatures/monster/monster_functions.hpp +++ b/src/lua/functions/creatures/monster/monster_functions.hpp @@ -56,6 +56,7 @@ class MonsterFunctions final : LuaScriptInterface { registerMethod(L, "Monster", "isForgeable", MonsterFunctions::luaMonsterIsForgeable); registerMethod(L, "Monster", "getName", MonsterFunctions::luaMonsterGetName); + registerMethod(L, "Monster", "setName", MonsterFunctions::luaMonsterSetName); registerMethod(L, "Monster", "hazard", MonsterFunctions::luaMonsterHazard); registerMethod(L, "Monster", "hazardCrit", MonsterFunctions::luaMonsterHazardCrit); @@ -116,6 +117,7 @@ class MonsterFunctions final : LuaScriptInterface { static int luaMonsterIsForgeable(lua_State* L); static int luaMonsterGetName(lua_State* L); + static int luaMonsterSetName(lua_State* L); static int luaMonsterHazard(lua_State* L); static int luaMonsterHazardCrit(lua_State* L); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 98bacfc5e12..8cf0660a262 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5947,7 +5947,7 @@ void ProtocolGame::sendCreatureTurn(std::shared_ptr creature, uint32_t NetworkMessage msg; msg.addByte(0x6B); msg.addPosition(creature->getPosition()); - msg.addByte(stackPos); + msg.addByte(static_cast(stackPos)); msg.add(0x63); msg.add(creature->getID()); msg.addByte(creature->getDirection()); @@ -6385,7 +6385,7 @@ void ProtocolGame::sendAddTileItem(const Position &pos, uint32_t stackpos, std:: NetworkMessage msg; msg.addByte(0x6A); msg.addPosition(pos); - msg.addByte(stackpos); + msg.addByte(static_cast(stackpos)); AddItem(msg, item); writeToOutputBuffer(msg); } @@ -6398,7 +6398,7 @@ void ProtocolGame::sendUpdateTileItem(const Position &pos, uint32_t stackpos, st NetworkMessage msg; msg.addByte(0x6B); msg.addPosition(pos); - msg.addByte(stackpos); + msg.addByte(static_cast(stackpos)); AddItem(msg, item); writeToOutputBuffer(msg); } @@ -6413,6 +6413,23 @@ void ProtocolGame::sendRemoveTileThing(const Position &pos, uint32_t stackpos) { writeToOutputBuffer(msg); } +void ProtocolGame::sendUpdateTileCreature(const Position &pos, uint32_t stackpos, const std::shared_ptr creature) { + if (!canSee(pos)) { + return; + } + + NetworkMessage msg; + msg.addByte(0x6B); + msg.addPosition(pos); + msg.addByte(static_cast(stackpos)); + + bool known; + uint32_t removedKnown; + checkCreatureAsKnown(creature->getID(), known, removedKnown); + AddCreature(msg, creature, false, removedKnown); + writeToOutputBuffer(msg); +} + void ProtocolGame::sendUpdateTile(std::shared_ptr tile, const Position &pos) { if (!canSee(pos)) { return; @@ -6484,7 +6501,7 @@ void ProtocolGame::sendAddCreature(std::shared_ptr creature, const Pos NetworkMessage msg; msg.addByte(0x6A); msg.addPosition(pos); - msg.addByte(stackpos); + msg.addByte(static_cast(stackpos)); bool known; uint32_t removedKnown; @@ -6641,7 +6658,7 @@ void ProtocolGame::sendMoveCreature(std::shared_ptr creature, const Po } else { msg.addByte(0x6D); msg.addPosition(oldPos); - msg.addByte(oldStackPos); + msg.addByte(static_cast(oldStackPos)); msg.addPosition(newPos); } @@ -6676,7 +6693,7 @@ void ProtocolGame::sendMoveCreature(std::shared_ptr creature, const Po NetworkMessage msg; msg.addByte(0x6D); msg.addPosition(oldPos); - msg.addByte(oldStackPos); + msg.addByte(static_cast(oldStackPos)); msg.addPosition(newPos); writeToOutputBuffer(msg); } @@ -7836,7 +7853,7 @@ void ProtocolGame::RemoveTileThing(NetworkMessage &msg, const Position &pos, uin msg.addByte(0x6C); msg.addPosition(pos); - msg.addByte(stackpos); + msg.addByte(static_cast(stackpos)); } void ProtocolGame::sendKillTrackerUpdate(std::shared_ptr corpse, const std::string &name, const Outfit_t creatureOutfit) { @@ -8279,7 +8296,7 @@ void ProtocolGame::reloadCreature(std::shared_ptr creature) { if (knownCreatureSet.contains(creature->getID())) { msg.addByte(0x6B); msg.addPosition(creature->getPosition()); - msg.addByte(stackpos); + msg.addByte(static_cast(stackpos)); AddCreature(msg, creature, false, 0); } else { sendAddCreature(creature, creature->getPosition(), stackpos, false); diff --git a/src/server/network/protocol/protocolgame.hpp b/src/server/network/protocol/protocolgame.hpp index 0386093cfc4..100ca199b77 100644 --- a/src/server/network/protocol/protocolgame.hpp +++ b/src/server/network/protocol/protocolgame.hpp @@ -393,6 +393,7 @@ class ProtocolGame final : public Protocol { void sendAddTileItem(const Position &pos, uint32_t stackpos, std::shared_ptr item); void sendUpdateTileItem(const Position &pos, uint32_t stackpos, std::shared_ptr item); void sendRemoveTileThing(const Position &pos, uint32_t stackpos); + void sendUpdateTileCreature(const Position &pos, uint32_t stackpos, const std::shared_ptr creature); void sendUpdateTile(std::shared_ptr tile, const Position &pos); void sendAddCreature(std::shared_ptr creature, const Position &pos, int32_t stackpos, bool isLogin); From 7c3393a1015ff4d8c1f43c5988b33f489302e20f Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Wed, 12 Jun 2024 10:48:41 -0300 Subject: [PATCH 08/17] fix: crash on shutdown (#2676) --- src/lib/thread/thread_pool.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/thread/thread_pool.cpp b/src/lib/thread/thread_pool.cpp index 702f0c05504..b2f51ef8f9d 100644 --- a/src/lib/thread/thread_pool.cpp +++ b/src/lib/thread/thread_pool.cpp @@ -26,7 +26,7 @@ #endif ThreadPool::ThreadPool(Logger &logger) : - logger(logger), BS::thread_pool(std::max(getNumberOfCores(), DEFAULT_NUMBER_OF_THREADS)) { + BS::thread_pool(std::max(getNumberOfCores(), DEFAULT_NUMBER_OF_THREADS)), logger(logger) { start(); } @@ -35,6 +35,7 @@ void ThreadPool::start() { } void ThreadPool::shutdown() { - stopped = true; logger.info("Shutting down thread pool..."); + stopped = true; + wait(); } From f741bebc0bbd4fb04bdd5948b551f7f5ec91064a Mon Sep 17 00:00:00 2001 From: Luan Luciano Date: Thu, 13 Jun 2024 14:14:10 -0300 Subject: [PATCH 09/17] improver: mini-refactor inventory update (#2652) --- src/creatures/players/player.cpp | 36 +++++++++++++++++++------------- src/creatures/players/player.hpp | 3 +++ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 2b10c0f77ee..2c92f694197 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -1715,13 +1715,7 @@ void Player::onCreatureAppear(std::shared_ptr creature, bool isLogin) Creature::onCreatureAppear(creature, isLogin); if (isLogin && creature == getPlayer()) { - for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { - std::shared_ptr item = inventory[slot]; - if (item) { - item->startDecaying(); - g_moveEvents().onPlayerEquip(getPlayer(), item, static_cast(slot), false); - } - } + onEquipInventory(); // Refresh bosstiary tracker onLogin refreshCyclopediaMonsterTracker(true); @@ -1862,14 +1856,9 @@ void Player::onRemoveCreature(std::shared_ptr creature, bool isLogout) Creature::onRemoveCreature(creature, isLogout); if (auto player = getPlayer(); player == creature) { - for (uint8_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { - const auto item = inventory[slot]; - if (item) { - g_moveEvents().onPlayerDeEquip(getPlayer(), item, static_cast(slot)); - } - } - if (isLogout) { + onDeEquipInventory(); + if (m_party) { m_party->leaveParty(player); } @@ -2011,6 +2000,25 @@ void Player::onCreatureMove(const std::shared_ptr &creature, const std } } +void Player::onEquipInventory() { + for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { + std::shared_ptr item = inventory[slot]; + if (item) { + item->startDecaying(); + g_moveEvents().onPlayerEquip(getPlayer(), item, static_cast(slot), false); + } + } +} + +void Player::onDeEquipInventory() { + for (int32_t slot = CONST_SLOT_FIRST; slot <= CONST_SLOT_LAST; ++slot) { + std::shared_ptr item = inventory[slot]; + if (item) { + g_moveEvents().onPlayerDeEquip(getPlayer(), item, static_cast(slot)); + } + } +} + // container void Player::onAddContainerItem(std::shared_ptr item) { checkTradeState(item); diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index 947acedca54..d374bd59911 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -1315,6 +1315,9 @@ class Player final : public Creature, public Cylinder, public Bankable { void onRemoveCreature(std::shared_ptr creature, bool isLogout) override; void onCreatureMove(const std::shared_ptr &creature, const std::shared_ptr &newTile, const Position &newPos, const std::shared_ptr &oldTile, const Position &oldPos, bool teleport) override; + void onEquipInventory(); + void onDeEquipInventory(); + void onAttackedCreatureDisappear(bool isLogout) override; void onFollowCreatureDisappear(bool isLogout) override; From e1fd98e010c35471094a9a6f12c0e3af7e08f8a5 Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Fri, 14 Jun 2024 21:25:21 -0300 Subject: [PATCH 10/17] improve: async batch dispatcher (#2666) Now the asynchronous requests will be made in batches and not one at a time, that is, we will take the total number of tasks divided by the number of available threads, this avoids locking the threads to retrieve the next task to be processed. ex: if we have 1000 tasks and 8 threads, 125 tasks will be triggered per thread. (1000/8) = 125 In this PR I also brought a new method called asyncWait, with this method you can make asynchronous requests but without needing to define a group, the asynchronous tasks will be executed immediately and will wait for them to finish. --- src/game/scheduling/dispatcher.cpp | 55 +++++++++++++++++++++--------- src/game/scheduling/dispatcher.hpp | 19 +++++++++++ 2 files changed, 57 insertions(+), 17 deletions(-) diff --git a/src/game/scheduling/dispatcher.cpp b/src/game/scheduling/dispatcher.cpp index 7cff69d66bf..dbbfc020be5 100644 --- a/src/game/scheduling/dispatcher.cpp +++ b/src/game/scheduling/dispatcher.cpp @@ -56,30 +56,51 @@ void Dispatcher::executeSerialEvents(std::vector &tasks) { } void Dispatcher::executeParallelEvents(std::vector &tasks, const uint8_t groupId) { - std::atomic_uint_fast64_t totalTaskSize = tasks.size(); - std::atomic_bool isTasksCompleted = false; + asyncWait(tasks.size(), [groupId, &tasks](size_t i) { + dispacherContext.type = DispatcherType::AsyncEvent; + dispacherContext.group = static_cast(groupId); + tasks[i].execute(); - for (const auto &task : tasks) { - threadPool.detach_task([groupId, &task, &isTasksCompleted, &totalTaskSize] { - dispacherContext.type = DispatcherType::AsyncEvent; - dispacherContext.group = static_cast(groupId); - dispacherContext.taskName = task.getContext(); + dispacherContext.reset(); + }); - task.execute(); + tasks.clear(); +} - dispacherContext.reset(); +void Dispatcher::asyncWait(size_t requestSize, std::function &&f) { + if (requestSize == 0) { + return; + } - totalTaskSize.fetch_sub(1); - if (totalTaskSize.load() == 0) { - isTasksCompleted.store(true); - isTasksCompleted.notify_one(); - } - }); + // This prevents an async call from running inside another async call. + if (asyncWaitDisabled) { + for (uint_fast64_t i = 0; i < requestSize; ++i) { + f(i); + } + return; } - isTasksCompleted.wait(false); + const auto &partitions = generatePartition(requestSize); + const auto pSize = partitions.size(); - tasks.clear(); + BS::multi_future retFuture; + + if (pSize > 1) { + asyncWaitDisabled = true; + const auto min = partitions[1].first; + const auto max = partitions[partitions.size() - 1].second; + retFuture = threadPool.submit_loop(min, max, [&f](const unsigned int i) { f(i); }); + } + + const auto &[min, max] = partitions[0]; + for (uint_fast64_t i = min; i < max; ++i) { + f(i); + } + + if (pSize > 1) { + retFuture.wait(); + asyncWaitDisabled = false; + } } void Dispatcher::executeEvents(const TaskGroup startGroup) { diff --git a/src/game/scheduling/dispatcher.hpp b/src/game/scheduling/dispatcher.hpp index a6cbc8dd6dd..94b284c9316 100644 --- a/src/game/scheduling/dispatcher.hpp +++ b/src/game/scheduling/dispatcher.hpp @@ -108,6 +108,7 @@ class Dispatcher { } void asyncEvent(std::function &&f, TaskGroup group = TaskGroup::GenericParallel); + void asyncWait(size_t size, std::function &&f); uint64_t asyncCycleEvent(uint32_t delay, std::function &&f, TaskGroup group = TaskGroup::GenericParallel) { return scheduleEvent( @@ -173,6 +174,22 @@ class Dispatcher { } } + std::vector> generatePartition(size_t size) const { + if (size == 0) { + return {}; + } + + std::vector> list; + list.reserve(threadPool.get_thread_count()); + + const auto size_per_block = std::ceil(size / static_cast(threadPool.get_thread_count())); + for (uint_fast64_t i = 0; i < size; i += size_per_block) { + list.emplace_back(i, std::min(size, i + size_per_block)); + } + + return list; + } + uint_fast64_t dispatcherCycle = 0; ThreadPool &threadPool; @@ -200,6 +217,8 @@ class Dispatcher { phmap::btree_multiset, Task::Compare> scheduledTasks; phmap::parallel_flat_hash_map_m> scheduledTasksRef; + bool asyncWaitDisabled = false; + friend class CanaryServer; }; From 883c3ff7ce55b8ad69413fbb551580e310d95909 Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Fri, 14 Jun 2024 21:26:44 -0300 Subject: [PATCH 11/17] perf: optimized moveCreature and spectators (#2667) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • In moveCreature, a check was added so that the spectator's search is not called twice, now only one position is passed with the interval adjusted to assume both positions as if it were. • In spectators we no longer use vector_set but just vector and if there is a need to remove record duplication, it will use unordered_set passing the vector in the constructor which is much faster. • Why was useCacheMap disabled? As the map cache is done synchronously for each movement that a monster makes, it is better to disable it, as the pathfinder, which is one of the resources that uses this cache the most, is multithreding and thus the processing cost is divided between the threads. --- src/creatures/monsters/monster.hpp | 6 +++- src/map/map.cpp | 28 ++++++++++++++-- src/map/spectators.cpp | 51 ++++++++---------------------- src/map/spectators.hpp | 49 ++++++++++++++++++++-------- 4 files changed, 79 insertions(+), 55 deletions(-) diff --git a/src/creatures/monsters/monster.hpp b/src/creatures/monsters/monster.hpp index 6c45fa3eaca..061ad2b9879 100644 --- a/src/creatures/monsters/monster.hpp +++ b/src/creatures/monsters/monster.hpp @@ -455,7 +455,11 @@ class Monster final : public Creature { void dropLoot(std::shared_ptr corpse, std::shared_ptr lastHitCreature) override; void getPathSearchParams(const std::shared_ptr &creature, FindPathParams &fpp) override; bool useCacheMap() const override { - return !randomStepping; + // return !randomStepping; + // As the map cache is done synchronously for each movement that a monster makes, it is better to disable it, + // as the pathfinder, which is one of the resources that uses this cache the most, + // is multithreding and thus the processing cost is divided between the threads. + return false; } friend class MonsterFunctions; diff --git a/src/map/map.cpp b/src/map/map.cpp index 8b8cebeb539..82629aeae05 100644 --- a/src/map/map.cpp +++ b/src/map/map.cpp @@ -342,13 +342,35 @@ void Map::moveCreature(const std::shared_ptr &creature, const std::sha bool teleport = forceTeleport || !newTile->getGround() || !Position::areInRange<1, 1, 0>(oldPos, newPos); - auto spectators = Spectators() - .find(oldPos, true) - .find(newPos, true); + Spectators spectators; + if (!teleport && oldPos.z == newPos.z) { + int32_t minRangeX = MAP_MAX_VIEW_PORT_X; + int32_t maxRangeX = MAP_MAX_VIEW_PORT_X; + int32_t minRangeY = MAP_MAX_VIEW_PORT_Y; + int32_t maxRangeY = MAP_MAX_VIEW_PORT_Y; + + if (oldPos.y > newPos.y) { + ++minRangeY; + } else if (oldPos.y < newPos.y) { + ++maxRangeY; + } + + if (oldPos.x < newPos.x) { + ++maxRangeX; + } else if (oldPos.x > newPos.x) { + ++minRangeX; + } + + spectators.find(oldPos, true, minRangeX, maxRangeX, minRangeY, maxRangeY); + } else { + spectators.find(oldPos, true); + spectators.find(newPos, true); + } auto playersSpectators = spectators.filter(); std::vector oldStackPosVector; + oldStackPosVector.reserve(playersSpectators.size()); for (const auto &spec : playersSpectators) { if (spec->canSeeCreature(creature)) { oldStackPosVector.push_back(oldTile->getClientIndexOfCreature(spec->getPlayer(), creature)); diff --git a/src/map/spectators.cpp b/src/map/spectators.cpp index 36cce6d535b..10aaf0faf87 100644 --- a/src/map/spectators.cpp +++ b/src/map/spectators.cpp @@ -18,50 +18,27 @@ void Spectators::clearCache() { spectatorsCache.clear(); } -bool Spectators::contains(const std::shared_ptr &creature) { - return creatures.contains(creature); -} - -bool Spectators::erase(const std::shared_ptr &creature) { - return creatures.erase(creature); -} - Spectators Spectators::insert(const std::shared_ptr &creature) { if (creature) { - creatures.emplace(creature); + creatures.emplace_back(creature); } return *this; } -Spectators Spectators::insertAll(const SpectatorList &list) { +Spectators Spectators::insertAll(const CreatureVector &list) { if (!list.empty()) { - creatures.insertAll(list); - } - return *this; -} + const bool hasValue = !creatures.empty(); -Spectators Spectators::join(Spectators &anotherSpectators) { - return insertAll(anotherSpectators.creatures.data()); -} - -bool Spectators::empty() const noexcept { - return creatures.empty(); -} + creatures.insert(creatures.end(), list.begin(), list.end()); -size_t Spectators::size() noexcept { - return creatures.size(); -} - -CreatureVector::iterator Spectators::begin() noexcept { - return creatures.begin(); -} - -CreatureVector::iterator Spectators::end() noexcept { - return creatures.end(); -} - -const CreatureVector &Spectators::data() noexcept { - return creatures.data(); + // Remove duplicate + if (hasValue) { + std::unordered_set uset(creatures.begin(), creatures.end()); + creatures.clear(); + creatures.insert(creatures.end(), uset.begin(), uset.end()); + } + } + return *this; } bool Spectators::checkCache(const SpectatorsCache::FloorData &specData, bool onlyPlayers, const Position ¢erPos, bool checkDistance, bool multifloor, int32_t minRangeX, int32_t maxRangeX, int32_t minRangeY, int32_t maxRangeY) { @@ -77,7 +54,7 @@ bool Spectators::checkCache(const SpectatorsCache::FloorData &specData, bool onl } if (checkDistance) { - SpectatorList spectators; + CreatureVector spectators; spectators.reserve(creatures.size()); for (const auto &creature : *list) { const auto &specPos = creature->getPosition(); @@ -176,7 +153,7 @@ Spectators Spectators::find(const Position ¢erPos, bool multifloor, bool onl const int32_t endx2 = x2 - (x2 & SECTOR_MASK); const int32_t endy2 = y2 - (y2 & SECTOR_MASK); - SpectatorList spectators; + CreatureVector spectators; spectators.reserve(std::max(MAP_MAX_VIEW_PORT_X, MAP_MAX_VIEW_PORT_Y) * 2); const MapSector* startSector = g_game().map.getMapSector(startx1, starty1); diff --git a/src/map/spectators.hpp b/src/map/spectators.hpp index 93526e05c93..9e998da2bfa 100644 --- a/src/map/spectators.hpp +++ b/src/map/spectators.hpp @@ -16,12 +16,10 @@ class Monster; class Npc; struct Position; -using SpectatorList = std::vector>; - struct SpectatorsCache { struct FloorData { - std::optional floor; - std::optional multiFloor; + std::optional floor; + std::optional multiFloor; }; int32_t minRangeX { 0 }; @@ -48,16 +46,39 @@ class Spectators { requires std::is_base_of_v Spectators filter(); - bool contains(const std::shared_ptr &creature); - bool erase(const std::shared_ptr &creature); Spectators insert(const std::shared_ptr &creature); - Spectators insertAll(const SpectatorList &list); - Spectators join(Spectators &anotherSpectators); - bool empty() const noexcept; - size_t size() noexcept; - CreatureVector::iterator begin() noexcept; - CreatureVector::iterator end() noexcept; - const CreatureVector &data() noexcept; + Spectators insertAll(const CreatureVector &list); + Spectators join(const Spectators &anotherSpectators) { + return insertAll(anotherSpectators.creatures); + } + + bool contains(const std::shared_ptr &creature) const { + return std::ranges::find(creatures, creature) != creatures.end(); + } + + bool erase(const std::shared_ptr &creature) { + return std::erase(creatures, creature) > 0; + } + + bool empty() const noexcept { + return creatures.empty(); + } + + size_t size() const noexcept { + return creatures.size(); + } + + auto begin() const noexcept { + return creatures.begin(); + } + + auto end() const noexcept { + return creatures.end(); + } + + const auto &data() const noexcept { + return creatures; + } private: static phmap::flat_hash_map spectatorsCache; @@ -65,7 +86,7 @@ class Spectators { Spectators find(const Position ¢erPos, bool multifloor = false, bool onlyPlayers = false, int32_t minRangeX = 0, int32_t maxRangeX = 0, int32_t minRangeY = 0, int32_t maxRangeY = 0); bool checkCache(const SpectatorsCache::FloorData &specData, bool onlyPlayers, const Position ¢erPos, bool checkDistance, bool multifloor, int32_t minRangeX, int32_t maxRangeX, int32_t minRangeY, int32_t maxRangeY); - stdext::vector_set> creatures; + CreatureVector creatures; }; template From 8a2e5f2e2cbd79cb3606e1553ea233b388782ac8 Mon Sep 17 00:00:00 2001 From: Renato Machado Date: Fri, 14 Jun 2024 21:55:29 -0300 Subject: [PATCH 12/17] perf: remove browseField on container destruction (#2677) Instead of checking all the time if there is a browsefield to be destroyed, why not remove it at the time of its destruction?! Besides, the linear search of phmap::flat_hash_map is very slow. --- src/game/game.cpp | 14 -------------- src/game/game.hpp | 1 - src/items/containers/container.cpp | 4 ++++ 3 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/game/game.cpp b/src/game/game.cpp index 57daddded2e..984e675407c 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -6255,7 +6255,6 @@ void Game::checkCreatureWalk(uint32_t creatureId) { const auto &creature = getCreatureByID(creatureId); if (creature && creature->getHealth() > 0) { creature->onCreatureWalk(); - cleanup(); } } @@ -6318,7 +6317,6 @@ void Game::checkCreatures() { --end; } } - cleanup(); index = (index + 1) % EVENT_CREATURECOUNT; } @@ -7967,8 +7965,6 @@ void Game::shutdown() { map.spawnsNpc.clear(); raids.clear(); - cleanup(); - if (serviceManager) { serviceManager->stop(); } @@ -7980,16 +7976,6 @@ void Game::shutdown() { g_logger().info("Done!"); } -void Game::cleanup() { - for (auto it = browseFields.begin(); it != browseFields.end();) { - if (it->second.expired()) { - it = browseFields.erase(it); - } else { - ++it; - } - } -} - void Game::addBestiaryList(uint16_t raceid, std::string name) { auto it = BestiaryList.find(raceid); if (it != BestiaryList.end()) { diff --git a/src/game/game.hpp b/src/game/game.hpp index b4be8facd09..2de00410e5e 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -426,7 +426,6 @@ class Game { void updatePlayerHelpers(std::shared_ptr player); - void cleanup(); void shutdown(); void dieSafely(const std::string &errorMsg); void addBestiaryList(uint16_t raceid, std::string name); diff --git a/src/items/containers/container.cpp b/src/items/containers/container.cpp index 63ce657741a..6c526a8500a 100644 --- a/src/items/containers/container.cpp +++ b/src/items/containers/container.cpp @@ -63,6 +63,10 @@ std::shared_ptr Container::create(std::shared_ptr tile) { Container::~Container() { if (getID() == ITEM_BROWSEFIELD) { + if (getParent() && getParent()->getTile()) { + g_game().browseFields.erase(getParent()->getTile()); + } + for (std::shared_ptr item : itemlist) { item->setParent(getParent()); } From 81e250a8f9448c476fc12a1c63b53daa8a762aaa Mon Sep 17 00:00:00 2001 From: Elson Costa Date: Fri, 14 Jun 2024 21:56:31 -0300 Subject: [PATCH 13/17] fix: autoloot default value (#2690) --- src/creatures/players/player.hpp | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/creatures/players/player.hpp b/src/creatures/players/player.hpp index d374bd59911..802b4e6fb6e 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -2562,8 +2562,7 @@ class Player final : public Creature, public Cylinder, public Bankable { } bool checkAutoLoot(bool isBoss) const { - const bool autoLoot = g_configManager().getBoolean(AUTOLOOT, __FUNCTION__); - if (!autoLoot) { + if (!g_configManager().getBoolean(AUTOLOOT, __FUNCTION__)) { return false; } if (g_configManager().getBoolean(VIP_SYSTEM_ENABLED, __FUNCTION__) && g_configManager().getBoolean(VIP_AUTOLOOT_VIP_ONLY, __FUNCTION__) && !isVip()) { @@ -2571,18 +2570,13 @@ class Player final : public Creature, public Cylinder, public Bankable { } auto featureKV = kv()->scoped("features")->get("autoloot"); - if (featureKV.has_value()) { - auto value = featureKV->getNumber(); - if (value == 2) { - return true; - } else if (value == 1) { - return !isBoss; - } else if (value == 0) { - return false; - } + auto value = featureKV.has_value() ? featureKV->getNumber() : 0; + if (value == 2) { + return true; + } else if (value == 1) { + return !isBoss; } - - return true; + return false; } QuickLootFilter_t getQuickLootFilter() const { From b682da775f4c573d15f1dc15a899eb540a7ec969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Lu=C3=ADs=20Lucarelo=20Lamonato?= Date: Sat, 15 Jun 2024 00:13:42 -0300 Subject: [PATCH 14/17] fix: prevent client debug when purchase/sale statistics are missing (#2693) This PR introduces a change to ensure proper handling of cases where sale statistics for a specific item with tier are not found in the tierStatsMap. Fixes #2656 --- src/server/network/protocol/protocolgame.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 8cf0660a262..1c40b67d6c6 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -5857,6 +5857,8 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { msg.add(purchaseStatistics.highestPrice); msg.add(purchaseStatistics.lowestPrice); } + } else { + msg.addByte(0x00); } } else { msg.addByte(0x00); // send to old protocol ? @@ -5880,6 +5882,8 @@ void ProtocolGame::sendMarketDetail(uint16_t itemId, uint8_t tier) { msg.add(saleStatistics.highestPrice); msg.add(saleStatistics.lowestPrice); } + } else { + msg.addByte(0x00); } } else { msg.addByte(0x00); // send to old protocol ? From 4af5b2dc1898f0e69da2730bf1a41768b43c29ed Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Sat, 15 Jun 2024 00:14:03 -0300 Subject: [PATCH 15/17] fix: store UI exhaustion and improve bosslever messages (#2694) Fixed the store exhaustion to work correctly. Fixed the boss lever messages to better inform the participants. --- data/libs/functions/boss_lever.lua | 32 +++++++++++++++++-------- data/modules/scripts/gamestore/init.lua | 17 ++++++++----- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/data/libs/functions/boss_lever.lua b/data/libs/functions/boss_lever.lua index 3792cdf629d..48d00582e89 100644 --- a/data/libs/functions/boss_lever.lua +++ b/data/libs/functions/boss_lever.lua @@ -174,24 +174,36 @@ function BossLever:onUse(player) end if creature:getLevel() < self.requiredLevel then - creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, "All the players need to be level " .. self.requiredLevel .. " or higher.") + local message = "All players need to be level " .. self.requiredLevel .. " or higher." + creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, message) + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message) return false end - if self:lastEncounterTime(creature) > os.time() then - local info = lever:getInfoPositions() - for _, v in pairs(info) do - local newPlayer = v.creature - if newPlayer then - local timeLeft = self:lastEncounterTime(newPlayer) - os.time() - newPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You or a member in your team have to wait " .. getTimeInWords(timeLeft) .. " to face " .. self.name .. " again!") - if self:lastEncounterTime(newPlayer) > os.time() then - newPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) + if creature:getGroup():getId() < GROUP_TYPE_GOD and self:lastEncounterTime(creature) > os.time() then + local infoPositions = lever:getInfoPositions() + for _, posInfo in pairs(infoPositions) do + local currentPlayer = posInfo.creature + if currentPlayer then + local lastEncounter = self:lastEncounterTime(currentPlayer) + local currentTime = os.time() + if lastEncounter and currentTime < lastEncounter then + local timeLeft = lastEncounter - currentTime + local timeMessage = getTimeInWords(timeLeft) .. " to face " .. monsterName .. " again!" + local message = "You have to wait " .. timeMessage + + if currentPlayer ~= player then + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "A member in your team has to wait " .. timeMessage) + end + + currentPlayer:sendTextMessage(MESSAGE_EVENT_ADVANCE, message) + currentPlayer:getPosition():sendMagicEffect(CONST_ME_POFF) end end end return false end + self.onUseExtra(creature) return true end) diff --git a/data/modules/scripts/gamestore/init.lua b/data/modules/scripts/gamestore/init.lua index ba7398d9d3e..214aec77d43 100644 --- a/data/modules/scripts/gamestore/init.lua +++ b/data/modules/scripts/gamestore/init.lua @@ -247,6 +247,11 @@ function onRecvbyte(player, msg, byte) return player:sendCancelMessage("Store don't have offers for rookgaard citizen.") end + if player:isUIExhausted(250) then + player:sendCancelMessage("You are exhausted.") + return + end + if byte == GameStore.RecivedPackets.C_StoreEvent then elseif byte == GameStore.RecivedPackets.C_TransferCoins then parseTransferableCoins(player:getId(), msg) @@ -262,12 +267,6 @@ function onRecvbyte(player, msg, byte) parseRequestTransactionHistory(player:getId(), msg) end - if player:isUIExhausted(250) then - player:sendCancelMessage("You are exhausted.") - return false - end - - player:updateUIExhausted() return true end @@ -306,6 +305,7 @@ function parseTransferableCoins(playerId, msg) GameStore.insertHistory(accountId, GameStore.HistoryTypes.HISTORY_TYPE_NONE, player:getName() .. " transferred you this amount.", amount, GameStore.CoinType.Transferable) GameStore.insertHistory(player:getAccountId(), GameStore.HistoryTypes.HISTORY_TYPE_NONE, "You transferred this amount to " .. reciver, -1 * amount, GameStore.CoinType.Transferable) openStore(playerId) + player:updateUIExhausted() end function parseOpenStore(playerId, msg) @@ -396,6 +396,7 @@ function parseRequestStoreOffers(playerId, msg) addPlayerEvent(sendShowStoreOffers, 250, playerId, searchResultsCategory) end + player:updateUIExhausted() end function parseBuyStoreOffer(playerId, msg) @@ -532,6 +533,8 @@ function parseBuyStoreOffer(playerId, msg) sendUpdatedStoreBalances(playerId) return addPlayerEvent(sendStorePurchaseSuccessful, 650, playerId, message) end + + player:updateUIExhausted() return true end @@ -540,11 +543,13 @@ function parseOpenTransactionHistory(playerId, msg) local page = 1 GameStore.DefaultValues.DEFAULT_VALUE_ENTRIES_PER_PAGE = msg:getByte() sendStoreTransactionHistory(playerId, page, GameStore.DefaultValues.DEFAULT_VALUE_ENTRIES_PER_PAGE) + player:updateUIExhausted() end function parseRequestTransactionHistory(playerId, msg) local page = msg:getU32() sendStoreTransactionHistory(playerId, page + 1, GameStore.DefaultValues.DEFAULT_VALUE_ENTRIES_PER_PAGE) + player:updateUIExhausted() end local function getCategoriesRook() From 74a5df00160ad11ecfc4557b1dd4cf6857fb8ee7 Mon Sep 17 00:00:00 2001 From: attack787 <47985212+attack787@users.noreply.github.com> Date: Wed, 19 Jun 2024 22:49:43 -0300 Subject: [PATCH 16/17] Fix: send timeMessage when using boss lever (#2701) --- data/libs/functions/boss_lever.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/libs/functions/boss_lever.lua b/data/libs/functions/boss_lever.lua index 48d00582e89..b95bf7211b0 100644 --- a/data/libs/functions/boss_lever.lua +++ b/data/libs/functions/boss_lever.lua @@ -189,7 +189,7 @@ function BossLever:onUse(player) local currentTime = os.time() if lastEncounter and currentTime < lastEncounter then local timeLeft = lastEncounter - currentTime - local timeMessage = getTimeInWords(timeLeft) .. " to face " .. monsterName .. " again!" + local timeMessage = getTimeInWords(timeLeft) .. " to face " .. self.name .. " again!" local message = "You have to wait " .. timeMessage if currentPlayer ~= player then From e6294912ae9e260b8ecc488a186387f300440ded Mon Sep 17 00:00:00 2001 From: Eduardo Dantas Date: Thu, 20 Jun 2024 01:48:50 -0300 Subject: [PATCH 17/17] fix: prevent requesting a new trade window with each "trade" (#2700) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Identified Problems: • Item Loop Performance: The loop in the ProtocolGame::sendShop function performed key-value store (KV) access operations for each NPC item during every iteration. This was highly inefficient for NPCs with many items, such as "The Lootmonger," which has 1380 items. • Lack of Database Caching: Currently, our database does not implement caching for query results. This leads to redundant database accesses, particularly noticeable when commands like "trade" are used repeatedly, significantly increasing CPU usage and processing time. Implemented Solutions: • Optimization of the Item Loop: Necessary initialization has been moved outside the loop in the ProtocolGame::sendShop method. This reduces overhead by avoiding unnecessary repetitive database accesses. • Removal of Unnecessary Map: Removed an extraneous map in npc.hpp and simplified the use of the shop player cache. These changes aim to streamline interactions and reduce the computational load, especially during frequent trade requests with item-rich NPCs like "The Lootmonger." Additional optimizations have been made to enhance overall system performance. --- data/npclib/npc_system/npc_handler.lua | 1 - src/creatures/npcs/npc.cpp | 36 +++++++++---------- src/creatures/npcs/npc.hpp | 17 ++++----- src/creatures/players/player.cpp | 21 +++++++---- src/creatures/players/player.hpp | 2 +- .../functions/creatures/npc/npc_functions.cpp | 8 ++--- src/server/network/message/networkmessage.cpp | 4 +-- src/server/network/message/networkmessage.hpp | 15 +++++++- src/server/network/protocol/protocolgame.cpp | 32 +++++++++-------- 9 files changed, 73 insertions(+), 63 deletions(-) diff --git a/data/npclib/npc_system/npc_handler.lua b/data/npclib/npc_system/npc_handler.lua index 8f4d5f2ca48..31aaa88faaf 100644 --- a/data/npclib/npc_system/npc_handler.lua +++ b/data/npclib/npc_system/npc_handler.lua @@ -480,7 +480,6 @@ if NpcHandler == nil then -- If is npc shop, send shop window and parse default message (if not have callback on the npc) if npc:isMerchant() then - npc:closeShopWindow(player) npc:openShopWindow(player) self:say(msg, npc, player) end diff --git a/src/creatures/npcs/npc.cpp b/src/creatures/npcs/npc.cpp index e445a58fcca..53fcfd07a3c 100644 --- a/src/creatures/npcs/npc.cpp +++ b/src/creatures/npcs/npc.cpp @@ -108,7 +108,7 @@ void Npc::onRemoveCreature(std::shared_ptr creature, bool isLogout) { spawnNpc->startSpawnNpcCheck(); } - shopPlayerMap.clear(); + shopPlayers.clear(); } void Npc::onCreatureMove(const std::shared_ptr &creature, const std::shared_ptr &newTile, const Position &newPos, const std::shared_ptr &oldTile, const Position &oldPos, bool teleport) { @@ -259,7 +259,7 @@ void Npc::onPlayerBuyItem(std::shared_ptr player, uint16_t itemId, uint8 } uint32_t buyPrice = 0; - const std::vector &shopVector = getShopItemVector(player->getGUID()); + const auto &shopVector = getShopItemVector(player->getGUID()); for (const ShopBlock &shopBlock : shopVector) { if (itemType.id == shopBlock.itemId && shopBlock.itemBuyPrice != 0) { buyPrice = shopBlock.itemBuyPrice; @@ -372,7 +372,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(player->getGUID()); + const auto &shopVector = getShopItemVector(player->getGUID()); for (const ShopBlock &shopBlock : shopVector) { if (itemType.id == shopBlock.itemId && shopBlock.itemSellPrice != 0) { sellPrice = shopBlock.itemSellPrice; @@ -586,7 +586,7 @@ void Npc::setPlayerInteraction(uint32_t playerId, uint16_t topicId /*= 0*/) { void Npc::removePlayerInteraction(std::shared_ptr player) { if (playerInteractions.contains(player->getID())) { playerInteractions.erase(player->getID()); - player->closeShopWindow(true); + player->closeShopWindow(); } } @@ -643,30 +643,26 @@ bool Npc::getRandomStep(Direction &moveDirection) { return false; } -void Npc::addShopPlayer(const std::shared_ptr &player, const std::vector &shopItems /* = {}*/) { - if (!player) { - return; - } - - shopPlayerMap.try_emplace(player->getGUID(), shopItems); +bool Npc::isShopPlayer(uint32_t playerGUID) const { + return shopPlayers.find(playerGUID) != shopPlayers.end(); } -void Npc::removeShopPlayer(const std::shared_ptr &player) { - if (!player) { - return; - } +void Npc::addShopPlayer(uint32_t playerGUID) { + shopPlayers.insert(playerGUID); +} - shopPlayerMap.erase(player->getGUID()); +void Npc::removeShopPlayer(uint32_t playerGUID) { + shopPlayers.erase(playerGUID); } void Npc::closeAllShopWindows() { - for (const auto &[playerGUID, playerPtr] : shopPlayerMap) { - auto shopPlayer = g_game().getPlayerByGUID(playerGUID); - if (shopPlayer) { - shopPlayer->closeShopWindow(); + for (const auto playerGUID : shopPlayers) { + const auto &player = g_game().getPlayerByGUID(playerGUID); + if (player) { + player->closeShopWindow(); } } - shopPlayerMap.clear(); + shopPlayers.clear(); } void Npc::handlePlayerMove(std::shared_ptr player, const Position &newPos) { diff --git a/src/creatures/npcs/npc.hpp b/src/creatures/npcs/npc.hpp index 7e8be84c7f1..605aaae570e 100644 --- a/src/creatures/npcs/npc.hpp +++ b/src/creatures/npcs/npc.hpp @@ -95,14 +95,7 @@ class Npc final : public Creature { npcType->info.currencyId = currency; } - std::vector getShopItemVector(uint32_t playerGUID) { - if (playerGUID != 0) { - auto it = shopPlayerMap.find(playerGUID); - if (it != shopPlayerMap.end() && !it->second.empty()) { - return it->second; - } - } - + const std::vector &getShopItemVector(uint32_t playerGUID) const { return npcType->info.shopItemVector; } @@ -165,8 +158,10 @@ class Npc final : public Creature { internalLight = npcType->info.light; } - void addShopPlayer(const std::shared_ptr &player, const std::vector &shopItems = {}); - void removeShopPlayer(const std::shared_ptr &player); + bool isShopPlayer(uint32_t playerGUID) const; + + void addShopPlayer(uint32_t playerGUID); + void removeShopPlayer(uint32_t playerGUID); void closeAllShopWindows(); static uint32_t npcAutoID; @@ -184,7 +179,7 @@ class Npc final : public Creature { std::map playerInteractions; - phmap::flat_hash_map> shopPlayerMap; + std::unordered_set shopPlayers; std::shared_ptr npcType; std::shared_ptr spawnNpc; diff --git a/src/creatures/players/player.cpp b/src/creatures/players/player.cpp index 2c92f694197..52ceb8b3377 100644 --- a/src/creatures/players/player.cpp +++ b/src/creatures/players/player.cpp @@ -1895,31 +1895,38 @@ void Player::onRemoveCreature(std::shared_ptr creature, bool isLogout) } bool Player::openShopWindow(std::shared_ptr npc) { + Benchmark brenchmark; if (!npc) { g_logger().error("[Player::openShopWindow] - Npc is wrong or nullptr"); return false; } + if (npc->isShopPlayer(getGUID())) { + g_logger().debug("[Player::openShopWindow] - Player {} is already in shop window", getName()); + return false; + } + + npc->addShopPlayer(getGUID()); + setShopOwner(npc); sendShop(npc); std::map inventoryMap; sendSaleItemList(getAllSaleItemIdAndCount(inventoryMap)); + + g_logger().debug("[Player::openShopWindow] - Player {} has opened shop window in {} ms", getName(), brenchmark.duration()); return true; } -bool Player::closeShopWindow(bool sendCloseShopWindow /*= true*/) { +bool Player::closeShopWindow() { if (!shopOwner) { return false; } - shopOwner->removeShopPlayer(static_self_cast()); + shopOwner->removeShopPlayer(getGUID()); setShopOwner(nullptr); - if (sendCloseShopWindow) { - sendCloseShop(); - } - + sendCloseShop(); return true; } @@ -4293,7 +4300,7 @@ bool Player::hasShopItemForSale(uint16_t itemId, uint8_t subType) const { } const ItemType &itemType = Item::items[itemId]; - std::vector shoplist = shopOwner->getShopItemVector(getGUID()); + const auto &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/creatures/players/player.hpp b/src/creatures/players/player.hpp index 802b4e6fb6e..332887acc51 100644 --- a/src/creatures/players/player.hpp +++ b/src/creatures/players/player.hpp @@ -851,7 +851,7 @@ class Player final : public Creature, public Cylinder, public Bankable { void stopWalk(); bool openShopWindow(std::shared_ptr npc); - bool closeShopWindow(bool sendCloseShopWindow = true); + bool closeShopWindow(); bool updateSaleShopList(std::shared_ptr item); bool hasShopItemForSale(uint16_t itemId, uint8_t subType) const; diff --git a/src/lua/functions/creatures/npc/npc_functions.cpp b/src/lua/functions/creatures/npc/npc_functions.cpp index 8c19a4ede0a..2b14ef46b72 100644 --- a/src/lua/functions/creatures/npc/npc_functions.cpp +++ b/src/lua/functions/creatures/npc/npc_functions.cpp @@ -354,7 +354,6 @@ int NpcFunctions::luaNpcOpenShopWindow(lua_State* L) { return 1; } - npc->addShopPlayer(player); pushBoolean(L, player->openShopWindow(npc)); return 1; } @@ -405,9 +404,6 @@ int NpcFunctions::luaNpcOpenShopWindowTable(lua_State* L) { } 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; } @@ -429,7 +425,7 @@ int NpcFunctions::luaNpcCloseShopWindow(lua_State* L) { } if (player->getShopOwner() == npc) { - player->closeShopWindow(true); + player->closeShopWindow(); } pushBoolean(L, true); @@ -577,7 +573,7 @@ int NpcFunctions::luaNpcSellItem(lua_State* L) { } uint64_t pricePerUnit = 0; - const std::vector &shopVector = npc->getShopItemVector(player->getGUID()); + const auto &shopVector = npc->getShopItemVector(player->getGUID()); for (ShopBlock shopBlock : shopVector) { if (itemId == shopBlock.itemId && shopBlock.itemBuyPrice != 0) { pricePerUnit = shopBlock.itemBuyPrice; diff --git a/src/server/network/message/networkmessage.cpp b/src/server/network/message/networkmessage.cpp index 15963135560..38acc0b484c 100644 --- a/src/server/network/message/networkmessage.cpp +++ b/src/server/network/message/networkmessage.cpp @@ -40,9 +40,9 @@ Position NetworkMessage::getPosition() { return pos; } -void NetworkMessage::addString(const std::string &value, const std::string &function) { +void NetworkMessage::addString(const std::string &value, const std::string &function /* = ""*/) { size_t stringLen = value.length(); - if (value.empty()) { + if (value.empty() && !function.empty()) { g_logger().debug("[NetworkMessage::addString] - Value string is empty, function '{}'", function); } if (!canAdd(stringLen + 2)) { diff --git a/src/server/network/message/networkmessage.hpp b/src/server/network/message/networkmessage.hpp index 72f0e69c3dc..02e19253146 100644 --- a/src/server/network/message/networkmessage.hpp +++ b/src/server/network/message/networkmessage.hpp @@ -90,7 +90,20 @@ class NetworkMessage { void addBytes(const char* bytes, size_t size); void addPaddingBytes(size_t n); - void addString(const std::string &value, const std::string &function); + /** + * Adds a string to the network message buffer. + * + * @param value The string value to be added to the message buffer. + * @param function * @param function An optional parameter that specifies the function name from which `addString` is invoked. + * Including this enhances logging by adding the function name to the debug and error log messages. + * This helps in debugging by indicating the context when issues occur, such as attempting to add an + * empty string or when there are message size errors. + * + * When the function parameter is used, it aids in identifying the context in log messages, + * making it easier to diagnose issues related to network message construction, + * especially in complex systems where the same method might be called from multiple places. + */ + void addString(const std::string &value, const std::string &function = ""); void addDouble(double value, uint8_t precision = 2); diff --git a/src/server/network/protocol/protocolgame.cpp b/src/server/network/protocol/protocolgame.cpp index 1c40b67d6c6..c006e315ab1 100644 --- a/src/server/network/protocol/protocolgame.cpp +++ b/src/server/network/protocol/protocolgame.cpp @@ -4637,6 +4637,7 @@ void ProtocolGame::sendLootStats(std::shared_ptr item, uint8_t count) { } void ProtocolGame::sendShop(std::shared_ptr npc) { + Benchmark brenchmark; NetworkMessage msg; msg.addByte(0x7A); msg.addString(npc->getName(), "ProtocolGame::sendShop - npc->getName()"); @@ -4646,20 +4647,35 @@ void ProtocolGame::sendShop(std::shared_ptr npc) { msg.addString(std::string(), "ProtocolGame::sendShop - std::string()"); // Currency name } - std::vector shoplist = npc->getShopItemVector(player->getGUID()); + const auto &shoplist = npc->getShopItemVector(player->getGUID()); uint16_t itemsToSend = std::min(shoplist.size(), std::numeric_limits::max()); msg.add(itemsToSend); + // Initialize before the loop to avoid database overload on each iteration + auto talkactionHidden = player->kv()->get("npc-shop-hidden-sell-item"); + // Initialize the inventoryMap outside the loop to avoid creation on each iteration + std::map inventoryMap; + player->getAllSaleItemIdAndCount(inventoryMap); uint16_t i = 0; for (const ShopBlock &shopBlock : shoplist) { if (++i > itemsToSend) { break; } + // Hidden sell items from the shop if they are not in the player's inventory + if (talkactionHidden && talkactionHidden->get()) { + const auto &foundItem = inventoryMap.find(shopBlock.itemId); + if (foundItem == inventoryMap.end() && shopBlock.itemSellPrice > 0 && shopBlock.itemBuyPrice == 0) { + AddHiddenShopItem(msg); + continue; + } + } + AddShopItem(msg, shopBlock); } writeToOutputBuffer(msg); + g_logger().debug("ProtocolGame::sendShop - Time: {} ms, shop items: {}", brenchmark.duration(), shoplist.size()); } void ProtocolGame::sendCloseShop() { @@ -8101,7 +8117,7 @@ void ProtocolGame::AddHiddenShopItem(NetworkMessage &msg) { // Empty bytes from AddShopItem msg.add(0); msg.addByte(0); - msg.addString(std::string(), "ProtocolGame::AddHiddenShopItem - std::string()"); + msg.addString(std::string()); msg.add(0); msg.add(0); msg.add(0); @@ -8114,18 +8130,6 @@ void ProtocolGame::AddShopItem(NetworkMessage &msg, const ShopBlock &shopBlock) return; } - // Hidden sell items from the shop if they are not in the player's inventory - auto talkactionHidden = player->kv()->get("npc-shop-hidden-sell-item"); - if (talkactionHidden && talkactionHidden->get() == true) { - std::map inventoryMap; - player->getAllSaleItemIdAndCount(inventoryMap); - auto inventoryItems = inventoryMap.find(shopBlock.itemId); - if (inventoryItems == inventoryMap.end() && shopBlock.itemSellPrice > 0 && shopBlock.itemBuyPrice == 0) { - AddHiddenShopItem(msg); - return; - } - } - const ItemType &it = Item::items[shopBlock.itemId]; msg.add(shopBlock.itemId); if (it.isSplash() || it.isFluidContainer()) {