Skip to content

Commit

Permalink
Merge branch 'main' into expert-pvp
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 13, 2025
2 parents da1db30 + a120e46 commit 60932b1
Show file tree
Hide file tree
Showing 26 changed files with 116 additions and 84 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ jobs:
uses: gittools/actions/gitversion/[email protected]

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.7.1
uses: docker/setup-buildx-action@v2
with:
install: true

- name: Login to GitHub Container Registry
uses: docker/login-action@v3.3.0
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
Expand All @@ -73,8 +73,6 @@ jobs:
tags: ghcr.io/${{ github.repository }}:${{ steps.gitversion.outputs.semVer }}
cache-from: type=gha, scope=${{ github.workflow }}
cache-to: type=gha, scope=${{ github.workflow }}
secrets: |
DEBUG=1

- name: Image digest
if: ${{ github.event_name == 'push' }}
Expand All @@ -99,7 +97,7 @@ jobs:
uses: gittools/actions/gitversion/[email protected]

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.7.1
uses: docker/setup-buildx-action@v2
with:
install: true

Expand Down
3 changes: 0 additions & 3 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ toggleMaintainMode = false
-- @field [parent=#global] #string maintainModeMessage an empty string by default, set a custom message if needed.
maintainModeMessage = ""

-- toggleTestMode get player infinite health mana and soul.
toggleTestMode = false

-- Rook system
-- NOTE: Town ids: Dawnport = 2, Rookgaard = 3
toggleRookSystem = false
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/bosses/chagorz.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local monster = {}
monster.description = "Chagorz"
monster.experience = 3250000
monster.outfit = {
lookType = 1665,
lookType = 1666,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/bosses/vemiath.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local monster = {}
monster.description = "Vemiath"
monster.experience = 3250000
monster.outfit = {
lookType = 1665,
lookType = 1668,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/familiars/druid_familiar.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local mType = Game.createMonsterType("Druid Familiar")
local mType = Game.createMonsterType("Druid familiar")
local monster = {}

monster.description = "a druid familiar"
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/familiars/knight_familiar.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local mType = Game.createMonsterType("Knight Familiar")
local mType = Game.createMonsterType("Knight familiar")
local monster = {}

monster.description = "a knight familiar"
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/familiars/paladin_familiar.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local mType = Game.createMonsterType("Paladin Familiar")
local mType = Game.createMonsterType("Paladin familiar")
local monster = {}

monster.description = "a paladin familiar"
Expand Down
2 changes: 1 addition & 1 deletion data-global/monster/quests/rotten_bood/mushroom.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ local monster = {}
monster.description = "a Mushroom"
monster.experience = 0
monster.outfit = {
lookType = 1669, --todo get correct lookType
lookType = 1773,
lookHead = 0,
lookBody = 0,
lookLegs = 0,
Expand Down
5 changes: 5 additions & 0 deletions data/XML/groups.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,4 +147,9 @@
<flag canmapclickteleport="1" />
</flags>
</group>
<group id="7" name="game tester" access="0" maxdepotitems="0" maxvipentries="200" outfit="0">
<flags>
<flag isgametester="1" />
</flags>
</group>
</groups>
5 changes: 3 additions & 2 deletions data/libs/functions/boss_lever.lua
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ function BossLever:onUse(player)
end

local checkAccountType = creature:getAccountType() < ACCOUNT_TYPE_GAMEMASTER
if checkAccountType and creature:getLevel() < self.requiredLevel then
local isGameTester = player:hasFlag(PlayerFlag_IsGameTester)
if checkAccountType and not isGameTester and creature:getLevel() < self.requiredLevel then
local message = "All players need to be level " .. self.requiredLevel .. " or higher."
creature:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, message)
return false
end

local infoPositions = lever:getInfoPositions()
if creature:getGroup():getId() < GROUP_TYPE_GOD and checkAccountType and self:lastEncounterTime(creature) > os.time() then
if creature:getGroup():getId() < GROUP_TYPE_GOD and checkAccountType and not isGameTester and self:lastEncounterTime(creature) > os.time() then
for _, posInfo in pairs(infoPositions) do
local currentPlayer = posInfo.creature
if currentPlayer then
Expand Down
2 changes: 1 addition & 1 deletion data/scripts/actions/objects/cask_and_kegs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ local targetIdList = {
local flasks = Action()

function flasks.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not target or not target:getItem() then
if not target or not target:isItem() then
return false
end

Expand Down
1 change: 1 addition & 0 deletions data/scripts/talkactions/god/flags.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ local PlayerFlags_t = {
["IsAlwaysPremium"] = IsAlwaysPremium,
["CanMapClickTeleport"] = CanMapClickTeleport,
["IgnoredByNpcs"] = IgnoredByNpcs,
["IsGameTester"] = IsGameTester,
}

local function sendValidKeys(player)
Expand Down
30 changes: 15 additions & 15 deletions data/scripts/talkactions/god/manage_storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,30 @@ function Player.getStorageValueTalkaction(self, param)
end

local split = param:split(",")
if split[2] == nil then
player:sendCancelMessage("Insufficient parameters.")
if not split[2] then
self:sendCancelMessage("Insufficient parameters.")
return true
end

local target = Player(split[1])
if target == nil then
local target = Player(split[1]:trim())
if not target then
self:sendCancelMessage("A player with that name is not online.")
return true
end

split[2] = split[2]:trimSpace()
-- Storage key Validation
local storageKey = tonumber(split[2]) or split[2]:trim()
if not storageKey then
self:sendCancelMessage("Invalid storage key or name.")
return true
end

-- Try to convert the second parameter to a number. If it's not a number, treat it as a storage name
local storageKey = tonumber(split[2])
if storageKey == nil then
-- Get the key for this storage name
local storageName = tostring(split[2])
local storageValue = target:getStorageValueByName(storageName)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. storageName .. " from player " .. split[1] .. " is: " .. storageValue .. ".")
-- Get the storage key
local storageValue = target:getStorageValue(storageKey)
if storageValue == nil then
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. split[2] .. " does not exist or is not set for player " .. target:getName() .. ".")
else
local storageValue = target:getStorageValue(storageKey)
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. storageKey .. " from player " .. split[1] .. " is: " .. storageValue .. ".")
self:sendTextMessage(MESSAGE_EVENT_ADVANCE, "The storage with id: " .. split[2] .. " from player " .. target:getName() .. " is: " .. storageValue .. ".")
end

return true
Expand All @@ -44,7 +45,6 @@ end
storageGet:separator(" ")
storageGet:groupType("gamemaster")
storageGet:register()

---------------- // ----------------
function Player.setStorageValueTalkaction(self, param)
-- Sanity check for parameters
Expand Down
5 changes: 4 additions & 1 deletion markdowns/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
- Moved emote spells to `kv` instead of `storage`. ([Tryller](https://github.com/jprzimba))
- Updated npcs and spells from 13.40 updates. ([murilo09](https://github.com/murilo09))
- Added a Rook system with configurations in `config.lua`. ([Tryller](https://github.com/jprzimba))
- Added a Test Mode with configurations in `config.lua`. ([Tryller](https://github.com/jprzimba))
- Added a new group `game tester` with flag `isgametester` in `groups.xml` and a new player flag `PlayerFlag_IsGameTester`. ([Tryller](https://github.com/jprzimba))

## Added files

Expand All @@ -29,6 +29,7 @@
- config.lua
- data/items/assets.dat
- data/items/items.xml
- data/libs/functions/boss_lever.lua
- data/libs/systems/features.lua
- data/scripts/creaturescripts/player/login.lua
- data/scripts/movements/special_tiles.lua
Expand All @@ -39,12 +40,14 @@
- data/scripts/talkactions/god/create_item.lua
- data/scripts/talkactions/god/create_summon.lua
- data/scripts/talkactions/god/create_npc.lua
- data/scripts/talkactions/god/flags.lua
- data/scripts/talkactions/player/chain_system.lua
- data/scripts/talkactions/player/emote_spell.lua
- data/scripts/spells/attack/annihilation.lua
- data/scripts/spells/attack/ultimate_ice_strike.lua
- data/scripts/spells/attack/ultimate_terra_strike.lua
- data/XML/imbuements.xml
- data/XML/groups.xml
- data-global/npc (all npc files)
- data-global/npc/the_oracle.lua (modified to rook system)
- data-global/world/world.otbm (7z file)
Expand Down
1 change: 0 additions & 1 deletion src/config/config_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ enum ConfigKey_t : uint16_t {
EXPERT_PVP_CANWALKTHROUGHMAGICWALLS,
SPELL_NAME_INSTEAD_WORDS,
LOG_PLAYERS_STATEMENTS,
TOGGLE_TEST_MODE,
ROOK_SYSTEM,
ROOK_TOWN,
LEVEL_TO_ROOK,
Expand Down
1 change: 0 additions & 1 deletion src/config/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ bool ConfigManager::load() {
loadBoolConfig(L, EXPERT_PVP_CANWALKTHROUGHMAGICWALLS, "canWalkThroughMagicWalls", false);
loadBoolConfig(L, SPELL_NAME_INSTEAD_WORDS, "spellNameInsteadOfWords", false);
loadBoolConfig(L, LOG_PLAYERS_STATEMENTS, "logPlayersStatements", false);
loadBoolConfig(L, TOGGLE_TEST_MODE, "toggleTestMode", false);
loadBoolConfig(L, ROOK_SYSTEM, "toggleRookSystem", false);
loadBoolConfig(L, TOGGLE_ADD_ROOK_ITEMS, "toggleAddRookItems", false);

Expand Down
30 changes: 15 additions & 15 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ void Combat::getCombatArea(const Position &centerPos, const Position &targetPos,
}

if (area) {
area->getList(centerPos, targetPos, list);
area->getList(centerPos, targetPos, list, getDirectionTo(targetPos, centerPos));
} else {
list.emplace_back(g_game().map.getOrCreateTile(targetPos));
}
Expand Down Expand Up @@ -261,18 +261,14 @@ ReturnValue Combat::canTargetCreature(const std::shared_ptr<Player> &player, con

ReturnValue Combat::canDoCombat(const std::shared_ptr<Creature> &caster, const std::shared_ptr<Tile> &tile, bool aggressive) {
if (tile->hasProperty(CONST_PROP_BLOCKPROJECTILE)) {
return RETURNVALUE_NOTENOUGHROOM;
return RETURNVALUE_CANNOTTHROW;
}
if (aggressive && tile->hasFlag(TILESTATE_PROTECTIONZONE)) {
return RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE;
}

if (tile->hasFlag(TILESTATE_FLOORCHANGE)) {
return RETURNVALUE_NOTENOUGHROOM;
}

if (tile->getTeleportItem()) {
return RETURNVALUE_NOTENOUGHROOM;
return RETURNVALUE_CANNOTTHROW;
}

if (caster) {
Expand Down Expand Up @@ -1965,7 +1961,9 @@ AreaCombat::~AreaCombat() {
clear();
}

void AreaCombat::getList(const Position &centerPos, const Position &targetPos, std::vector<std::shared_ptr<Tile>> &list) const {
void AreaCombat::getList(const Position &centerPos, const Position &targetPos, std::vector<std::shared_ptr<Tile>> &list, const Direction dir) const {
auto casterPos = getNextPosition(dir, targetPos);

const std::unique_ptr<MatrixArea> &area = getArea(centerPos, targetPos);
if (!area) {
return;
Expand All @@ -1977,17 +1975,19 @@ void AreaCombat::getList(const Position &centerPos, const Position &targetPos, s

const uint32_t rows = area->getRows();
const uint32_t cols = area->getCols();
list.reserve(rows * cols);

list.reserve(rows * cols);
Position tmpPos(targetPos.x - centerX, targetPos.y - centerY, targetPos.z);
for (uint32_t y = 0; y < rows; ++y, ++tmpPos.y, tmpPos.x -= cols) {
for (uint32_t x = 0; x < cols; ++x, ++tmpPos.x) {
if (area->getValue(y, x) != 0) {
if (g_game().isSightClear(targetPos, tmpPos, true)) {
list.emplace_back(g_game().map.getOrCreateTile(tmpPos));
}

for (uint32_t y = 0; y < rows; ++y) {
for (uint32_t x = 0; x < cols; ++x) {
if (area->getValue(y, x) != 0 && g_game().isSightClear(casterPos, tmpPos, true)) {
list.emplace_back(g_game().map.getOrCreateTile(tmpPos));
}
++tmpPos.x;
}
++tmpPos.y;
tmpPos.x -= cols;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/creatures/combat/combat.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class AreaCombat {
// non-assignable
AreaCombat &operator=(const AreaCombat &) = delete;

void getList(const Position &centerPos, const Position &targetPos, std::vector<std::shared_ptr<Tile>> &list) const;
void getList(const Position &centerPos, const Position &targetPos, std::vector<std::shared_ptr<Tile>> &list, const Direction dir) const;

void setupArea(const std::list<uint32_t> &list, uint32_t rows);
void setupArea(int32_t length, int32_t spread);
Expand Down
7 changes: 0 additions & 7 deletions src/creatures/combat/spells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -562,13 +562,6 @@ bool Spell::playerInstantSpellCheck(const std::shared_ptr<Player> &player, const

const auto &tile = g_game().map.getOrCreateTile(toPos);

ReturnValue ret = Combat::canDoCombat(player, tile, aggressive);
if (ret != RETURNVALUE_NOERROR) {
player->sendCancelMessage(ret);
g_game().addMagicEffect(player->getPosition(), CONST_ME_POFF);
return false;
}

if (blockingCreature && tile->getBottomVisibleCreature(player) != nullptr) {
player->sendCancelMessage(RETURNVALUE_NOTENOUGHROOM);
g_game().addMagicEffect(player->getPosition(), CONST_ME_POFF);
Expand Down
11 changes: 10 additions & 1 deletion src/creatures/monsters/monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,11 @@ bool Monster::removeTarget(const std::shared_ptr<Creature> &creature) {
totalPlayersOnScreen--;
}

targetList.erase(it);
if (auto shared = it->lock()) {
targetList.erase(it);
} else {
return false;
}

return true;
}
Expand Down Expand Up @@ -1529,6 +1533,11 @@ void Monster::doRandomStep(Direction &nextDirection, bool &result) {
}

void Monster::doWalkBack(uint32_t &flags, Direction &nextDirection, bool &result) {
if (totalPlayersOnScreen > 0) {
isWalkingBack = false;
return;
}

result = Creature::getNextStep(nextDirection, flags);
if (result) {
flags |= FLAG_PATHFINDING;
Expand Down
6 changes: 3 additions & 3 deletions src/creatures/npcs/npc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,13 +828,13 @@ void Npc::removeShopPlayer(uint32_t playerGUID) {
}

void Npc::closeAllShopWindows() {
for (const auto &playerGUID : shopPlayers | std::views::keys) {
const auto &player = g_game().getPlayerByGUID(playerGUID);
for (auto it = shopPlayers.begin(); it != shopPlayers.end();) {
const auto &player = g_game().getPlayerByGUID(it->first);
if (player) {
player->closeShopWindow();
}
it = shopPlayers.erase(it);
}
shopPlayers.clear();
}

void Npc::handlePlayerMove(const std::shared_ptr<Player> &player, const Position &newPos) {
Expand Down
Loading

0 comments on commit 60932b1

Please sign in to comment.