From 177e076d130fb5e54cde2b3fd08028d19b197be8 Mon Sep 17 00:00:00 2001 From: Rick Date: Sun, 29 Mar 2020 14:50:57 -0300 Subject: [PATCH] Fix Pack (#941) * Fix market imbued item * Fix Summon Issues * Update data/spells/scripts/summon/summons.lua Co-Authored-By: gerotib * Fix Pets Issues * Fix boat to issavi --- data/creaturescripts/scripts/pet.lua | 2 +- data/npc/scripts/Captain Fearless.lua | 2 +- data/npc/scripts/Captain Gulliver.lua | 2 +- data/npc/scripts/Captain Harava.lua | 2 +- data/npc/scripts/Captain Pelagia.lua | 2 +- data/npc/scripts/Petros.lua | 2 +- data/scripts/runes/#example.lua | 52 +++++++++++++++++++ data/scripts/runes/magic_wall.lua | 27 ++++++++++ data/scripts/runes/wild_growth.lua | 28 ++++++++++ .../spells/scripts/summon/summon creature.lua | 36 ++++++------- data/spells/scripts/summon/summons.lua | 9 ++-- .../scripts/support/magic wall rune.lua | 7 --- .../scripts/support/wild growth rune.lua | 7 --- data/spells/spells.xml | 5 -- src/const.h | 3 ++ src/creature.cpp | 10 ++-- src/game.cpp | 6 ++- src/game.h | 2 +- src/item.cpp | 4 +- src/luascript.cpp | 3 +- src/tile.cpp | 10 +++- 21 files changed, 159 insertions(+), 62 deletions(-) create mode 100644 data/scripts/runes/#example.lua create mode 100644 data/scripts/runes/magic_wall.lua create mode 100644 data/scripts/runes/wild_growth.lua delete mode 100644 data/spells/scripts/support/magic wall rune.lua delete mode 100644 data/spells/scripts/support/wild growth rune.lua diff --git a/data/creaturescripts/scripts/pet.lua b/data/creaturescripts/scripts/pet.lua index 5a9bd7ec6..5877d33e0 100644 --- a/data/creaturescripts/scripts/pet.lua +++ b/data/creaturescripts/scripts/pet.lua @@ -31,7 +31,7 @@ function onLogin(cid) if pet then position = player:getPosition() - summonpet = Game.createMonster(pet, position) + summonpet = Game.createMonster(pet, position, true, false, cid) player:addSummon(summonpet) player:setStorageValue(STORAGE_PET, os.time() + petTimeLeft) summonpet:registerEvent('petdeath') diff --git a/data/npc/scripts/Captain Fearless.lua b/data/npc/scripts/Captain Fearless.lua index 7b02bd28c..90a072464 100644 --- a/data/npc/scripts/Captain Fearless.lua +++ b/data/npc/scripts/Captain Fearless.lua @@ -34,7 +34,7 @@ addTravelKeyword('liberty bay', 180, Position(32285, 32892, 6)) addTravelKeyword('yalahar', 185, Position(32816, 31272, 6), function(player) return player:getStorageValue(Storage.SearoutesAroundYalahar.Venore) ~= 1 and player:getStorageValue(Storage.SearoutesAroundYalahar.TownsCounter) < 5 end) addTravelKeyword('ankrahmun', 150, Position(33092, 32883, 6)) addTravelKeyword('travora', 1000, Position(32055, 32368, 6)) -addTravelKeyword('issavi', 130, Position(33957, 31515, 0)) +addTravelKeyword('issavi', 130, Position(33900, 31463, 6)) -- Darashia local travelNode = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to Darashia for |TRAVELCOST|?', cost = 60, discount = 'postman'}) diff --git a/data/npc/scripts/Captain Gulliver.lua b/data/npc/scripts/Captain Gulliver.lua index d19af86d5..90dd175bd 100644 --- a/data/npc/scripts/Captain Gulliver.lua +++ b/data/npc/scripts/Captain Gulliver.lua @@ -20,7 +20,7 @@ end addTravelKeyword('thais', 150, Position(32311, 32210, 6)) addTravelKeyword('krailos', 180, Position(33493, 31712, 6)) addTravelKeyword('travora', 1000, Position(32055, 32368, 6)) -addTravelKeyword('issavi', 130, Position(33957, 31515, 0)) +addTravelKeyword('issavi', 130, Position(33902, 31462, 6)) -- Kick keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(33487, 31986, 7), Position(33486, 31984, 7)}}) diff --git a/data/npc/scripts/Captain Harava.lua b/data/npc/scripts/Captain Harava.lua index 4c2644a97..9e5b067b2 100644 --- a/data/npc/scripts/Captain Harava.lua +++ b/data/npc/scripts/Captain Harava.lua @@ -21,7 +21,7 @@ local function addTravelKeyword(keyword, cost, destination, action, condition) travelKeyword:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, text = 'We would like to serve you some time.', reset = true}) end -addTravelKeyword('darashia', 80, Position(33270, 32441, 6)) +addTravelKeyword('darashia', 80, Position(33289, 32481, 6)) addTravelKeyword('venore', 80, Position(32954, 32022, 6)) addTravelKeyword('oramond', 100, Position(33479, 31985, 7)) addTravelKeyword('krailos', 80, Position(33492, 31712, 6)) diff --git a/data/npc/scripts/Captain Pelagia.lua b/data/npc/scripts/Captain Pelagia.lua index 430751cfe..9a68caf27 100644 --- a/data/npc/scripts/Captain Pelagia.lua +++ b/data/npc/scripts/Captain Pelagia.lua @@ -23,7 +23,7 @@ addTravelKeyword('edron', 110, Position(33176, 31765, 6)) -- {x = 33176, y = 317 addTravelKeyword('oramond', 70, Position(33479, 31985, 7)) -- {x = 33479, y = 31985, z = 7} addTravelKeyword('darashia', 120, Position(33289, 32481, 6)) -- {x = 33289, y = 32481, z = 6} addTravelKeyword('thais', 130, Position(32310, 32210, 6)) -- -addTravelKeyword('issavi', 130, Position(33957, 31515, 0)) +addTravelKeyword('issavi', 130, Position(33902, 31464, 6)) -- Darashia local travelNode = keywordHandler:addKeyword({'darashia'}, StdModule.say, {npcHandler = npcHandler, text = 'Do you seek a passage to Darashia for |TRAVELCOST|?', cost = 0, discount = 'postman'}) diff --git a/data/npc/scripts/Petros.lua b/data/npc/scripts/Petros.lua index 7c5c7b72f..0f627b781 100644 --- a/data/npc/scripts/Petros.lua +++ b/data/npc/scripts/Petros.lua @@ -26,7 +26,7 @@ addTravelKeyword('yalahar', 210, Position(32816, 31272, 6), function(player) ret addTravelKeyword('gray island', 160, Position(33196, 31984, 7)) addTravelKeyword('krailos', 200, Position(33493, 31712, 6)) addTravelKeyword('travora', 1000, Position(32055, 32368, 6)) -addTravelKeyword('issavi', 130, Position(33957, 31515, 0)) +addTravelKeyword('issavi', 130, Position(33902, 31462, 6)) -- Kick keywordHandler:addKeyword({'kick'}, StdModule.kick, {npcHandler = npcHandler, destination = {Position(33288, 32474, 6), Position(33291, 32474, 6), Position(33293, 32471, 6)}}) diff --git a/data/scripts/runes/#example.lua b/data/scripts/runes/#example.lua new file mode 100644 index 000000000..9ba6a17b8 --- /dev/null +++ b/data/scripts/runes/#example.lua @@ -0,0 +1,52 @@ +local combat = Combat() +combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING) +combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE) +combat:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE) +combat:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true) +combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false) + +function onGetFormulaValues(player, level, magicLevel) + local min = (level / 5) + (magicLevel * 3.2) + 20 + local max = (level / 5) + (magicLevel * 5.4) + 40 + return min, max +end + +combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues") + +local spell = Spell(SPELL_RUNE) + +function spell.onCastSpell(creature, variant, isHotkey) + return combat:execute(creature, variant) +end + +spell:name("test rune") +spell:runeId(2275) +spell:id(220) +spell:level(20) +spell:magicLevel(5) +spell:needTarget(true) +spell:isAggressive(false) +spell:allowFarUse(true) +spell:charges(25) +spell:vocation("sorcerer;true", "master sorcerer") +spell:register() + +local conjureRune = Spell(SPELL_INSTANT) + +function conjureRune.onCastSpell(creature, variant) + return creature:conjureItem(2260, 2275, 25) +end + +conjureRune:name("Test") +conjureRune:id(221) +conjureRune:words("adori mas test") +conjureRune:level(30) +conjureRune:mana(530) +conjureRune:group("support") +conjureRune:soul(3) +conjureRune:isAggressive(false) +conjureRune:cooldown(2000) +conjureRune:groupCooldown(2000) +conjureRune:needLearn(false) +conjureRune:vocation("sorcerer", "master sorcerer") +conjureRune:register() diff --git a/data/scripts/runes/magic_wall.lua b/data/scripts/runes/magic_wall.lua new file mode 100644 index 000000000..e09fa39c9 --- /dev/null +++ b/data/scripts/runes/magic_wall.lua @@ -0,0 +1,27 @@ +local combat = Combat() +combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY) + +function onCreateMagicWall(creature, tile) + local item = Game.createItem(ITEM_MAGICWALL, 1, tile) + item:setAttribute(ITEM_ATTRIBUTE_DURATION, math.random(14000, 20000)) +end + +combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onCreateMagicWall") + +local spell = Spell("rune") +function spell.onCastSpell(creature, variant, isHotkey) + return combat:execute(creature, variant) +end + +spell:name("Magic Wall Rune") +spell:group("attack") +spell:id(86) +spell:cooldown(2 * 1000) +spell:groupCooldown(2 * 1000) +spell:level(32) +spell:magicLevel(9) +spell:runeId(2293) +spell:charges(3) +spell:isBlocking(true, true) +spell:allowFarUse(true) +spell:register() \ No newline at end of file diff --git a/data/scripts/runes/wild_growth.lua b/data/scripts/runes/wild_growth.lua new file mode 100644 index 000000000..115af0c33 --- /dev/null +++ b/data/scripts/runes/wild_growth.lua @@ -0,0 +1,28 @@ +local combat = Combat() +combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH) + +function onCreateMagicWall(creature, tile) + local item = Game.createItem(ITEM_WILDGROWTH, 1, tile) + item:setAttribute(ITEM_ATTRIBUTE_DURATION, math.random(38000, 45000)) +end + +combat:setCallback(CALLBACK_PARAM_TARGETTILE, "onCreateMagicWall") + +local spell = Spell("rune") +function spell.onCastSpell(creature, variant, isHotkey) + return combat:execute(creature, variant) +end + +spell:name("Wild Growth Rune") +spell:group("attack") +spell:id(94) +spell:cooldown(2 * 1000) +spell:groupCooldown(2 * 1000) +spell:level(27) +spell:magicLevel(8) +spell:runeId(2269) +spell:charges(2) +spell:isBlocking(true, true) +spell:allowFarUse(true) +spell:vocation("druid", "elder druid") +spell:register() \ No newline at end of file diff --git a/data/spells/scripts/summon/summon creature.lua b/data/spells/scripts/summon/summon creature.lua index 53b3d7928..df483119e 100644 --- a/data/spells/scripts/summon/summon creature.lua +++ b/data/spells/scripts/summon/summon creature.lua @@ -1,45 +1,45 @@ -function onCastSpell(creature, variant) +function onCastSpell(player, variant) local monsterName = variant:getString() local monsterType = MonsterType(monsterName) if not monsterType then - creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - creature:getPosition():sendMagicEffect(CONST_ME_POFF) + player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) + player:getPosition():sendMagicEffect(CONST_ME_POFF) return false end - if not getPlayerFlagValue(creature, PlayerFlag_CanSummonAll) then + if not getPlayerFlagValue(player, PlayerFlag_CanSummonAll) then if not monsterType:isSummonable() then - creature:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) - creature:getPosition():sendMagicEffect(CONST_ME_POFF) + player:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE) + player:getPosition():sendMagicEffect(CONST_ME_POFF) return false end - if #creature:getSummons() >= 2 then - creature:sendCancelMessage("You cannot summon more creatures.") - creature:getPosition():sendMagicEffect(CONST_ME_POFF) + if #player:getSummons() >= 2 then + player:sendCancelMessage("You cannot summon more players.") + player:getPosition():sendMagicEffect(CONST_ME_POFF) return false end end local manaCost = monsterType:getManaCost() - if creature:getMana() < manaCost and not getPlayerFlagValue(creature, PlayerFlag_HasInfiniteMana) then - creature:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA) - creature:getPosition():sendMagicEffect(CONST_ME_POFF) + if player:getMana() < manaCost and not getPlayerFlagValue(player, PlayerFlag_HasInfiniteMana) then + player:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA) + player:getPosition():sendMagicEffect(CONST_ME_POFF) return false end - local position = creature:getPosition() - local summon = Game.createMonster(monsterName, position, true) + local position = player:getPosition() + local summon = Game.createMonster(monsterName, position, true, true, player) if not summon then - creature:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM) + player:sendCancelMessage(RETURNVALUE_NOTENOUGHROOM) position:sendMagicEffect(CONST_ME_POFF) return false end - creature:addMana(-manaCost) - creature:addManaSpent(manaCost) - creature:addSummon(summon) + player:addMana(-manaCost) + player:addManaSpent(manaCost) + player:addSummon(summon) position:sendMagicEffect(CONST_ME_MAGIC_BLUE) summon:getPosition():sendMagicEffect(CONST_ME_TELEPORT) return true diff --git a/data/spells/scripts/summon/summons.lua b/data/spells/scripts/summon/summons.lua index ac075a5ee..ba316bdc7 100644 --- a/data/spells/scripts/summon/summons.lua +++ b/data/spells/scripts/summon/summons.lua @@ -12,8 +12,7 @@ setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_BLOCKHIT) local area = createCombatArea(AREA_CIRCLE1X1) setCombatArea(combat, area) -function onCastSpell(cid, var) - local player = Player(cid) +function onCastSpell(player, variant) if not player then return false end if #player:getSummons() >= 1 then @@ -36,9 +35,9 @@ function onCastSpell(cid, var) if not summonName then return false end - local mySummon = Game.createMonster(summonName, player:getPosition(), true, false) + local mySummon = Game.createMonster(summonName, player:getPosition(), true, false, player) if not mySummon then - return combat:execute(player, var) + return combat:execute(player, variant) end player:addSummon(mySummon) @@ -50,5 +49,5 @@ function onCastSpell(cid, var) player:setStorageValue(Storage.PetSummon, os.time() + 15*60) -- 15 minutes from now player:say("My Power your Power", TALKTYPE_MONSTER_SAY) addEvent(removePet, 15*60*1000, mySummon:getId()) --I think this isn't necessary - return combat:execute(player, var) + return combat:execute(player, variant) end diff --git a/data/spells/scripts/support/magic wall rune.lua b/data/spells/scripts/support/magic wall rune.lua deleted file mode 100644 index 7c5c556cc..000000000 --- a/data/spells/scripts/support/magic wall rune.lua +++ /dev/null @@ -1,7 +0,0 @@ -local combat = Combat() -combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY) -combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_MAGICWALL) - -function onCastSpell(creature, var, isHotkey) - return combat:execute(creature, var) -end diff --git a/data/spells/scripts/support/wild growth rune.lua b/data/spells/scripts/support/wild growth rune.lua deleted file mode 100644 index a15e27c7e..000000000 --- a/data/spells/scripts/support/wild growth rune.lua +++ /dev/null @@ -1,7 +0,0 @@ -local combat = Combat() -combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH) -combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_WILDGROWTH) - -function onCastSpell(creature, var, isHotkey) - return combat:execute(creature, var) -end diff --git a/data/spells/spells.xml b/data/spells/spells.xml index b8f33ed5f..4a2def76b 100644 --- a/data/spells/spells.xml +++ b/data/spells/spells.xml @@ -508,7 +508,6 @@ - @@ -535,10 +534,6 @@ - - - - diff --git a/src/const.h b/src/const.h index 29f873fa7..d7d62c4e2 100644 --- a/src/const.h +++ b/src/const.h @@ -581,6 +581,9 @@ enum item_t : uint16_t { ITEM_KEG_START = 28579, //kegs ids are contiguous in item.otb ITEM_KEG_END = 28590, + ITEM_WALKABLE_SEA_START = 4620, + ITEM_WALKABLE_SEA_END = 4625, + ITEM_DOCUMENT_RO = 1968, //read-only }; diff --git a/src/creature.cpp b/src/creature.cpp index 48ac39c37..b9bd00069 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -474,12 +474,10 @@ void Creature::onCreatureMove(Creature* creature, const Tile* newTile, const Pos std::forward_list despawnList; for (Creature* summon : summons) { const Position& pos = summon->getPosition(); - if (Position::getDistanceZ(newPos, pos) > 2 || (std::max(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) > 30)) { - if (!summon->getMonster()->isPet()) { - despawnList.push_front(summon); - } else { - g_game.internalTeleport(summon, summon->getMaster()->getPosition(), true); - } + if (summon->getMonster()->isPet() && (Position::getDistanceZ(newPos, pos) >= 1 || (std::max(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) >= 15))) { + g_game.internalTeleport(summon, summon->getMaster()->getPosition(), true); + } else if (!summon->getMonster()->isPet() && (Position::getDistanceZ(newPos, pos) >= 2 || (std::max(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) >= 30))) { + despawnList.push_front(summon); } } diff --git a/src/game.cpp b/src/game.cpp index e80ef8ec1..11189c308 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -552,12 +552,16 @@ bool Game::internalPlaceCreature(Creature* creature, const Position& pos, bool e return true; } -bool Game::placeCreature(Creature* creature, const Position& pos, bool extendedPos /*=false*/, bool forced /*= false*/) +bool Game::placeCreature(Creature* creature, const Position& pos, bool extendedPos /*=false*/, bool forced /*= false*/, Creature* master) { if (!internalPlaceCreature(creature, pos, extendedPos, forced)) { return false; } + if (master) { + creature->setMaster(master); + } + SpectatorHashSet spectators; map.getSpectators(spectators, creature->getPosition(), true); for (Creature* spectator : spectators) { diff --git a/src/game.h b/src/game.h index 52536979c..1a1e3dd76 100644 --- a/src/game.h +++ b/src/game.h @@ -208,7 +208,7 @@ class Game * \param extendedPos If true, the creature will in first-hand be placed 2 tiles away * \param force If true, placing the creature will not fail because of obstacles (creatures/items) */ - bool placeCreature(Creature* creature, const Position& pos, bool extendedPos = false, bool force = false); + bool placeCreature(Creature* creature, const Position& pos, bool extendedPos = false, bool force = false, Creature* master = nullptr); /** * Remove Creature from the map. diff --git a/src/item.cpp b/src/item.cpp index 4910f7575..c8d203f1b 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -1956,8 +1956,6 @@ bool Item::hasMarketAttributes() const if (duration != getDefaultDuration()) { return false; } - } else { - return false; } } @@ -1965,7 +1963,7 @@ bool Item::hasMarketAttributes() const for (uint8_t slot = 0; slot < items[id].imbuingSlots; slot++) { Item* item = const_cast(this); uint32_t info = item->getImbuement(slot); - if (info >> 8 != 0) { + if (info) { return false; } } diff --git a/src/luascript.cpp b/src/luascript.cpp index d84be58ba..e8e585e30 100644 --- a/src/luascript.cpp +++ b/src/luascript.cpp @@ -4756,7 +4756,8 @@ int LuaScriptInterface::luaGameCreateMonster(lua_State* L) const Position& position = getPosition(L, 2); bool extended = getBoolean(L, 3, false); bool force = getBoolean(L, 4, false); - if (g_game.placeCreature(monster, position, extended, force)) { + Creature* master = getCreature(L, 5); + if (g_game.placeCreature(monster, position, extended, force, master)) { pushUserdata(L, monster); setMetatable(L, -1, "Monster"); } else { diff --git a/src/tile.cpp b/src/tile.cpp index b3f747b40..279440fec 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -501,6 +501,12 @@ ReturnValue Tile::queryAdd(int32_t, const Thing& thing, uint32_t, uint32_t tileF return RETURNVALUE_NOTPOSSIBLE; } + if (monster->isSummon()) { + if (ground->getID() >= ITEM_WALKABLE_SEA_START && ground->getID() <= ITEM_WALKABLE_SEA_END) { + return RETURNVALUE_NOTPOSSIBLE; + } + } + const CreatureVector* creatures = getCreatures(); if (monster->canPushCreatures() && !monster->isSummon()) { if (creatures) { @@ -1689,10 +1695,10 @@ ReturnValue HouseTile::queryAdd(int32_t index, const Thing& thing, uint32_t coun } else if (const Monster* monster = creature->getMonster()) { if (monster->isSummon()) { - if (monster->isPet() && !house->isInvited(monster->getMaster()->getPlayer())) { + if (!house->isInvited(monster->getMaster()->getPlayer())) { return RETURNVALUE_NOTPOSSIBLE; } - if (monster->isPet() && house->isInvited(monster->getMaster()->getPlayer()) && (hasFlag(TILESTATE_BLOCKSOLID) || (hasBitSet(FLAG_PATHFINDING, flags) && hasFlag(TILESTATE_NOFIELDBLOCKPATH)))) { + if (house->isInvited(monster->getMaster()->getPlayer()) && (hasFlag(TILESTATE_BLOCKSOLID) || (hasBitSet(FLAG_PATHFINDING, flags) && hasFlag(TILESTATE_NOFIELDBLOCKPATH)))) { return RETURNVALUE_NOTPOSSIBLE; } else {