Skip to content

Commit

Permalink
fix: monster spawn interval/versperoth kill/chayenne lever (#1952)
Browse files Browse the repository at this point in the history
Let's you set a respawn time for the function: monster:setSpawnPosition(interval)

fix #1945
fix #1946
  • Loading branch information
Jonyrewind authored Dec 2, 2023
1 parent 466aa96 commit 37e387d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ monster.outfit = {
}

monster.events = {
"VesperothDeath",
"VersperothDeath",
}

monster.health = 100000
Expand Down Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions src/lua/functions/creatures/monster/monster_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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> monster = getUserdataShared<Monster>(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<uint32_t>(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<uint32_t>(interval));
spawnMonster.startSpawnMonsterCheck();

pushBoolean(L, true);
Expand Down

0 comments on commit 37e387d

Please sign in to comment.