Skip to content

Commit

Permalink
fix account manager / fix broadcast / add getWaypoints
Browse files Browse the repository at this point in the history
  • Loading branch information
MillhioreBT committed Apr 7, 2024
1 parent 5cdbab8 commit ea4679e
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion data/talkactions/scripts/broadcast.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ function onSay(player, words, param)

print("> " .. player:getName() .. " broadcasted: \"" .. param .. "\".")
for _, targetPlayer in ipairs(Game.getPlayers()) do
targetPlayer:sendPrivateMessage(player, param, TALKTYPE_BROADCAST)
targetPlayer:sendTextMessage(MESSAGE_STATUS_WARNING, param)
end
return false
end
2 changes: 1 addition & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3457,7 +3457,7 @@ void Game::playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type, s
return;
}

if (g_config[ConfigKeysBoolean::ACCOUNT_MANAGER] && player->isAccountManager()) {
if (player->isAccountManager()) {
if (player->isMuted() > 0) {
player->removeMessageBuffer();
}
Expand Down
15 changes: 15 additions & 0 deletions src/luagame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,19 @@ int luaGameSaveAccountStorageValues(lua_State* L)

return 1;
}

int luaGameGetWaypoints(lua_State* L)
{
// Game.getWaypoints()
lua_createtable(L, g_game.map.waypoints.size(), 0);

for (const auto& [name, position] : g_game.map.waypoints) {
pushPosition(L, position);
setMetatable(L, -1, "Position");
lua_setfield(L, -2, name.c_str());
}
return 1;
}
} // namespace

void LuaScriptInterface::registerGame()
Expand Down Expand Up @@ -690,4 +703,6 @@ void LuaScriptInterface::registerGame()
registerMethod("Game", "getAccountStorageValue", luaGameGetAccountStorageValue);
registerMethod("Game", "setAccountStorageValue", luaGameSetAccountStorageValue);
registerMethod("Game", "saveAccountStorageValues", luaGameSaveAccountStorageValues);

registerMethod("Game", "getWaypoints", luaGameGetWaypoints);
}
22 changes: 22 additions & 0 deletions src/lualoot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@ int luaLootSetChance(lua_State* L)
return 1;
}

int luaLootSetMinCount(lua_State* L)
{
// loot:setMinCount(min)
Loot* loot = getUserdata<Loot>(L, 1);
if (loot) {
loot->lootBlock.countmin = getInteger<uint32_t>(L, 2);
pushBoolean(L, true);
} else {
lua_pushnil(L);
}
return 1;
}

int luaLootSetMaxCount(lua_State* L)
{
// loot:setMaxCount(max)
Expand Down Expand Up @@ -152,4 +165,13 @@ void LuaScriptInterface::registerLoot()
registerMetaMethod("Loot", "__gc", luaDeleteLoot);
registerMetaMethod("Loot", "__close", luaDeleteLoot);
registerMethod("Loot", "delete", luaDeleteLoot);

registerMethod("Loot", "setId", luaLootSetId);
registerMethod("Loot", "setMinCount", luaLootSetMaxCount);
registerMethod("Loot", "setMaxCount", luaLootSetMaxCount);
registerMethod("Loot", "setSubType", luaLootSetSubType);
registerMethod("Loot", "setChance", luaLootSetChance);
registerMethod("Loot", "setActionId", luaLootSetActionId);
registerMethod("Loot", "setDescription", luaLootSetDescription);
registerMethod("Loot", "addChildLoot", luaLootAddChildLoot);
}
1 change: 1 addition & 0 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ void Lua::pushLoot(lua_State* L, const std::vector<LootBlock>& lootList)
setField(L, "itemId", lootBlock.id);
setField(L, "chance", lootBlock.chance);
setField(L, "subType", lootBlock.subType);
setField(L, "minCount", lootBlock.countmin);
setField(L, "maxCount", lootBlock.countmax);
setField(L, "actionId", lootBlock.actionId);
setField(L, "text", lootBlock.text);
Expand Down
2 changes: 2 additions & 0 deletions src/monsters.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const uint32_t MAX_LOOTCHANCE = 100000;
struct LootBlock
{
uint16_t id;
uint32_t countmin;
uint32_t countmax;
uint32_t chance;

Expand All @@ -23,6 +24,7 @@ struct LootBlock
LootBlock()
{
id = 0;
countmin = 1;
countmax = 1;
chance = 0;

Expand Down
4 changes: 2 additions & 2 deletions src/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,7 +1350,7 @@ void ProtocolGame::parseEnableSharedPartyExperience(NetworkMessage& msg)

void ProtocolGame::parseModalWindowAnswer(NetworkMessage& msg)
{
if (isOTCv8) {
if (!isOTCv8) {
return;
}

Expand Down Expand Up @@ -2181,7 +2181,7 @@ void ProtocolGame::sendInventoryItem(slots_t slot, const Item* item)

void ProtocolGame::sendModalWindow(const ModalWindow& modalWindow)
{
if (isOTCv8) {
if (!isOTCv8) {
return;
}

Expand Down

0 comments on commit ea4679e

Please sign in to comment.