Skip to content

Commit

Permalink
* Fix spells
Browse files Browse the repository at this point in the history
  • Loading branch information
jprzimba committed Jan 27, 2025
1 parent 089ab69 commit d83c8b1
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 6 deletions.
17 changes: 15 additions & 2 deletions data/scripts/runes/magic_wall.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
function onCreateMagicWall(creature, position)
local tile = Tile(position)
if tile and tile:getTopCreature() and not tile:getTopCreature():isPlayer() then
if not tile then
return false
end

if tile:hasFlag(TILESTATE_FLOORCHANGE) then
return false
end

if tile:getTopCreature() and not tile:getTopCreature():isPlayer() then
return false
end

local magicWall
if Game.getWorldType() == WORLD_TYPE_NO_PVP then
magicWall = ITEM_MAGICWALL_SAFE
else
magicWall = ITEM_MAGICWALL
end

local item = Game.createItem(magicWall, 1, position)
item:setDuration(16, 24)
if item then
item:setDuration(16, 24)
item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("Casted by: %s", creature:getName()))
end
end

local combat = Combat()
Expand Down
17 changes: 15 additions & 2 deletions data/scripts/runes/wild_growth.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,29 @@
function onCreateWildGrowth(creature, position)
local tile = Tile(position)
if tile and tile:getTopCreature() and not tile:getTopCreature():isPlayer() then
if not tile then
return false
end

if tile:hasFlag(TILESTATE_FLOORCHANGE) then
return false
end

if tile:getTopCreature() and not tile:getTopCreature():isPlayer() then
return false
end

local wildGrowth
if Game.getWorldType() == WORLD_TYPE_NO_PVP then
wildGrowth = ITEM_WILDGROWTH_SAFE
else
wildGrowth = ITEM_WILDGROWTH
end

local item = Game.createItem(wildGrowth, 1, position)
item:setDuration(30, 60)
if item then
item:setDuration(30)
item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, string.format("Casted by: %s", creature:getName()))
end
end

local combat = Combat()
Expand Down
12 changes: 10 additions & 2 deletions src/creatures/combat/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1990,8 +1990,16 @@ void AreaCombat::getList(const Position &centerPos, const Position &targetPos, s

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));
if (area->getValue(y, x) != 0) {
std::shared_ptr<Tile> tile = g_game().map.getTile(tmpPos);
if (tile && tile->hasFlag(TILESTATE_FLOORCHANGE)) {
++tmpPos.x;
continue;
}

if (g_game().isSightClear(casterPos, tmpPos, true)) {
list.emplace_back(g_game().map.getOrCreateTile(tmpPos));
}
}
++tmpPos.x;
}
Expand Down

0 comments on commit d83c8b1

Please sign in to comment.