Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Fix Pack (#941)
Browse files Browse the repository at this point in the history
* Fix market imbued item

* Fix Summon Issues

* Update data/spells/scripts/summon/summons.lua

Co-Authored-By: gerotib <princessgeroo@gmail.com>

* Fix Pets Issues

* Fix boat to issavi
  • Loading branch information
FakeShinoda committed Mar 29, 2020
1 parent 3cc9d01 commit 177e076
Show file tree
Hide file tree
Showing 21 changed files with 159 additions and 62 deletions.
2 changes: 1 addition & 1 deletion data/creaturescripts/scripts/pet.lua
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion data/npc/scripts/Captain Fearless.lua
Expand Up @@ -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'})
Expand Down
2 changes: 1 addition & 1 deletion data/npc/scripts/Captain Gulliver.lua
Expand Up @@ -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)}})
Expand Down
2 changes: 1 addition & 1 deletion data/npc/scripts/Captain Harava.lua
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion data/npc/scripts/Captain Pelagia.lua
Expand Up @@ -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'})
Expand Down
2 changes: 1 addition & 1 deletion data/npc/scripts/Petros.lua
Expand Up @@ -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)}})
Expand Down
52 changes: 52 additions & 0 deletions 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()
27 changes: 27 additions & 0 deletions 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()
28 changes: 28 additions & 0 deletions 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()
36 changes: 18 additions & 18 deletions 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
Expand Down
9 changes: 4 additions & 5 deletions data/spells/scripts/summon/summons.lua
Expand Up @@ -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
Expand All @@ -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)
Expand All @@ -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
7 changes: 0 additions & 7 deletions data/spells/scripts/support/magic wall rune.lua

This file was deleted.

7 changes: 0 additions & 7 deletions data/spells/scripts/support/wild growth rune.lua

This file was deleted.

5 changes: 0 additions & 5 deletions data/spells/spells.xml
Expand Up @@ -508,7 +508,6 @@
<vocation name="Paladin" />
<vocation name="Royal Paladin" showInDescription="0" />
</rune>
<rune group="attack" spellid="86" name="Magic Wall" id="2293" allowfaruse="1" charges="3" lvl="32" maglv="9" exhaustion="2000" groupcooldown="2000" blocktype="all" script="support/magic wall rune.lua" />
<rune group="attack" spellid="116" name="Light Stone Shower" id="23722" allowfaruse="1" charges="4" lvl="1" maglv="0" cooldown="2000" groupcooldown="2000" script="attack/light stone shower.lua" />
<rune group="attack" spellid="7" name="Lightest Missile" id="23723" allowfaruse="1" charges="10" lvl="1" cooldown="2000" groupcooldown="2000" maglv="0" needtarget="1" blocktype="solid" script="attack/lightest missile.lua" >
<vocation name="Sorcerer" />
Expand All @@ -535,10 +534,6 @@
<rune group="support" spellid="78" name="Desintegrate" id="2310" allowfaruse="0" charges="3" lvl="21" maglv="4" exhaustion="2000" groupcooldown="2000" range="1" script="support/desintegrate rune.lua" />
<rune group="support" spellid="30" name="Destroy Field" id="2261" allowfaruse="1" charges="3" lvl="17" maglv="3" exhaustion="2000" groupcooldown="2000" aggressive="0" range="5" script="support/destroy field rune.lua" />
<rune group="support" spellid="14" name="Chameleon Rune" id="2291" allowfaruse="1" charges="1" level="27" magiclevel="4" cooldown="2000" groupcooldown="2000" aggressive="0" selftarget="1" blocktype="solid" script="support/chameleon.lua" />
<rune group="support" spellid="94" name="Wild Growth" id="2269" allowfaruse="1" charges="2" lvl="27" maglv="8" exhaustion="2000" groupcooldown="2000" blocktype="all" script="support/wild growth rune.lua">
<vocation name="Druid" />
<vocation name="Elder Druid" showInDescription="0" />
</rune>
<rune group="support" spellid="54" name="Paralyze" id="2278" allowfaruse="1" charges="1" lvl="54" maglv="18" exhaustion="2000" groupcooldown="2000" mana="1400" needtarget="1" blocktype="solid" script="support/paralyze rune.lua">
<vocation name="Druid" />
<vocation name="Elder Druid" showInDescription="0" />
Expand Down
3 changes: 3 additions & 0 deletions src/const.h
Expand Up @@ -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
};

Expand Down
10 changes: 4 additions & 6 deletions src/creature.cpp
Expand Up @@ -474,12 +474,10 @@ void Creature::onCreatureMove(Creature* creature, const Tile* newTile, const Pos
std::forward_list<Creature*> despawnList;
for (Creature* summon : summons) {
const Position& pos = summon->getPosition();
if (Position::getDistanceZ(newPos, pos) > 2 || (std::max<int32_t>(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<int32_t>(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<int32_t>(Position::getDistanceX(newPos, pos), Position::getDistanceY(newPos, pos)) >= 30))) {
despawnList.push_front(summon);
}
}

Expand Down
6 changes: 5 additions & 1 deletion src/game.cpp
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/game.h
Expand Up @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/item.cpp
Expand Up @@ -1956,16 +1956,14 @@ bool Item::hasMarketAttributes() const
if (duration != getDefaultDuration()) {
return false;
}
} else {
return false;
}
}

if (items[id].imbuingSlots > 0) {
for (uint8_t slot = 0; slot < items[id].imbuingSlots; slot++) {
Item* item = const_cast<Item*>(this);
uint32_t info = item->getImbuement(slot);
if (info >> 8 != 0) {
if (info) {
return false;
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/luascript.cpp
Expand Up @@ -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<Monster>(L, monster);
setMetatable(L, -1, "Monster");
} else {
Expand Down

0 comments on commit 177e076

Please sign in to comment.