Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: monster spawn interval/versperoth kill/chayenne lever #1952

Merged
merged 4 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading