Skip to content

Commit 37e387d

Browse files
authored
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
1 parent 466aa96 commit 37e387d

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

data-otservbr-global/monster/quests/bigfoots_burden/versperoth.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ monster.outfit = {
1414
}
1515

1616
monster.events = {
17-
"VesperothDeath",
17+
"VersperothDeath",
1818
}
1919

2020
monster.health = 100000
@@ -84,16 +84,16 @@ monster.defenses = {
8484
}
8585

8686
monster.elements = {
87-
{ type = COMBAT_PHYSICALDAMAGE, percent = 0 },
88-
{ type = COMBAT_ENERGYDAMAGE, percent = 0 },
87+
{ type = COMBAT_PHYSICALDAMAGE, percent = 30 },
88+
{ type = COMBAT_ENERGYDAMAGE, percent = 45 },
8989
{ type = COMBAT_EARTHDAMAGE, percent = 0 },
90-
{ type = COMBAT_FIREDAMAGE, percent = 90 },
90+
{ type = COMBAT_FIREDAMAGE, percent = 50 },
9191
{ type = COMBAT_LIFEDRAIN, percent = 0 },
9292
{ type = COMBAT_MANADRAIN, percent = 0 },
9393
{ type = COMBAT_DROWNDAMAGE, percent = 0 },
94-
{ type = COMBAT_ICEDAMAGE, percent = 0 },
95-
{ type = COMBAT_HOLYDAMAGE, percent = 0 },
96-
{ type = COMBAT_DEATHDAMAGE, percent = 0 },
94+
{ type = COMBAT_ICEDAMAGE, percent = 45 },
95+
{ type = COMBAT_HOLYDAMAGE, percent = 40 },
96+
{ type = COMBAT_DEATHDAMAGE, percent = 55 },
9797
}
9898

9999
monster.immunities = {

data-otservbr-global/scripts/actions/quests/chayenne_realm/lever.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ local chayenneLever = Action()
33
function chayenneLever.onUse(player, item, fromPosition, itemEx, toPosition)
44
if item.itemid == 2772 then
55
if Game.getStorageValue(Storage.ChayenneKeyTime) > os.time() then
6-
player:sendTendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait few minutes to use again.")
6+
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You need to wait few minutes to use again.")
77
return true
88
end
99

src/lua/functions/creatures/monster/monster_functions.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "creatures/monsters/monsters.hpp"
1616
#include "lua/functions/creatures/monster/monster_functions.hpp"
1717
#include "map/spectators.hpp"
18+
#include "game/scheduling/events_scheduler.hpp"
1819

1920
int MonsterFunctions::luaMonsterCreate(lua_State* L) {
2021
// Monster(id or userdata)
@@ -350,19 +351,22 @@ int MonsterFunctions::luaMonsterSearchTarget(lua_State* L) {
350351
}
351352

352353
int MonsterFunctions::luaMonsterSetSpawnPosition(lua_State* L) {
353-
// monster:setSpawnPosition()
354+
// monster:setSpawnPosition(interval)
354355
std::shared_ptr<Monster> monster = getUserdataShared<Monster>(L, 1);
355356
if (!monster) {
356357
lua_pushnil(L);
357358
return 1;
358359
}
359360

361+
uint32_t eventschedule = g_eventsScheduler().getSpawnMonsterSchedule();
362+
360363
const Position &pos = monster->getPosition();
361364
monster->setMasterPos(pos);
362365

363366
g_game().map.spawnsMonster.getspawnMonsterList().emplace_front(pos, 5);
364367
SpawnMonster &spawnMonster = g_game().map.spawnsMonster.getspawnMonsterList().front();
365-
spawnMonster.addMonster(monster->mType->name, pos, DIRECTION_NORTH, 60000);
368+
uint32_t interval = getNumber<uint32_t>(L, 2, 90) * 1000 * 100 / std::max((uint32_t)1, (g_configManager().getNumber(RATE_SPAWN, __FUNCTION__) * eventschedule));
369+
spawnMonster.addMonster(monster->mType->typeName, pos, DIRECTION_NORTH, static_cast<uint32_t>(interval));
366370
spawnMonster.startSpawnMonsterCheck();
367371

368372
pushBoolean(L, true);

0 commit comments

Comments
 (0)