From 37e387dff665358ede681b1438d2199e75ca8d58 Mon Sep 17 00:00:00 2001 From: Jonyrewind Date: Sat, 2 Dec 2023 19:50:13 +0100 Subject: [PATCH] fix: monster spawn interval/versperoth kill/chayenne lever (#1952) Let's you set a respawn time for the function: monster:setSpawnPosition(interval) fix #1945 fix #1946 --- .../monster/quests/bigfoots_burden/versperoth.lua | 14 +++++++------- .../actions/quests/chayenne_realm/lever.lua | 2 +- .../creatures/monster/monster_functions.cpp | 8 ++++++-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua b/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua index c422f817bb2..1f3f3ba37b4 100644 --- a/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua +++ b/data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua @@ -14,7 +14,7 @@ monster.outfit = { } monster.events = { - "VesperothDeath", + "VersperothDeath", } monster.health = 100000 @@ -84,16 +84,16 @@ monster.defenses = { } monster.elements = { - { type = COMBAT_PHYSICALDAMAGE, percent = 0 }, - { type = COMBAT_ENERGYDAMAGE, percent = 0 }, + { type = COMBAT_PHYSICALDAMAGE, percent = 30 }, + { type = COMBAT_ENERGYDAMAGE, percent = 45 }, { type = COMBAT_EARTHDAMAGE, percent = 0 }, - { type = COMBAT_FIREDAMAGE, percent = 90 }, + { type = COMBAT_FIREDAMAGE, percent = 50 }, { type = COMBAT_LIFEDRAIN, percent = 0 }, { type = COMBAT_MANADRAIN, percent = 0 }, { type = COMBAT_DROWNDAMAGE, percent = 0 }, - { type = COMBAT_ICEDAMAGE, percent = 0 }, - { type = COMBAT_HOLYDAMAGE, percent = 0 }, - { type = COMBAT_DEATHDAMAGE, percent = 0 }, + { type = COMBAT_ICEDAMAGE, percent = 45 }, + { type = COMBAT_HOLYDAMAGE, percent = 40 }, + { type = COMBAT_DEATHDAMAGE, percent = 55 }, } monster.immunities = { diff --git a/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua b/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua index 2997a8df514..f9bc313df12 100644 --- a/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua +++ b/data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua @@ -3,7 +3,7 @@ local chayenneLever = Action() function chayenneLever.onUse(player, item, fromPosition, itemEx, toPosition) if item.itemid == 2772 then if Game.getStorageValue(Storage.ChayenneKeyTime) > os.time() then - player:sendTendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait few minutes to use again.") + player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait few minutes to use again.") return true end diff --git a/src/lua/functions/creatures/monster/monster_functions.cpp b/src/lua/functions/creatures/monster/monster_functions.cpp index e0f702f249e..5e32115a21c 100644 --- a/src/lua/functions/creatures/monster/monster_functions.cpp +++ b/src/lua/functions/creatures/monster/monster_functions.cpp @@ -15,6 +15,7 @@ #include "creatures/monsters/monsters.hpp" #include "lua/functions/creatures/monster/monster_functions.hpp" #include "map/spectators.hpp" +#include "game/scheduling/events_scheduler.hpp" int MonsterFunctions::luaMonsterCreate(lua_State* L) { // Monster(id or userdata) @@ -350,19 +351,22 @@ int MonsterFunctions::luaMonsterSearchTarget(lua_State* L) { } int MonsterFunctions::luaMonsterSetSpawnPosition(lua_State* L) { - // monster:setSpawnPosition() + // monster:setSpawnPosition(interval) std::shared_ptr monster = getUserdataShared(L, 1); if (!monster) { lua_pushnil(L); return 1; } + uint32_t eventschedule = g_eventsScheduler().getSpawnMonsterSchedule(); + const Position &pos = monster->getPosition(); monster->setMasterPos(pos); g_game().map.spawnsMonster.getspawnMonsterList().emplace_front(pos, 5); SpawnMonster &spawnMonster = g_game().map.spawnsMonster.getspawnMonsterList().front(); - spawnMonster.addMonster(monster->mType->name, pos, DIRECTION_NORTH, 60000); + uint32_t interval = getNumber(L, 2, 90) * 1000 * 100 / std::max((uint32_t)1, (g_configManager().getNumber(RATE_SPAWN, __FUNCTION__) * eventschedule)); + spawnMonster.addMonster(monster->mType->typeName, pos, DIRECTION_NORTH, static_cast(interval)); spawnMonster.startSpawnMonsterCheck(); pushBoolean(L, true);