Skip to content

Commit

Permalink
Move spells to scripts folder (#4755)
Browse files Browse the repository at this point in the history
* Move runes to dedicated folder
* Redirect old XML and lib folder to new location
* Drop unused custom spells
  • Loading branch information
ranisalt authored Sep 19, 2024
1 parent 4cd6cbe commit 25df9cf
Show file tree
Hide file tree
Showing 349 changed files with 4,385 additions and 2,014 deletions.
325 changes: 325 additions & 0 deletions data/scripts/lib/spells.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,325 @@
-- Pre-made areas

-- Waves
AREA_WAVE3 = {
{1, 1, 1},
{1, 1, 1},
{0, 3, 0}
}

AREA_WAVE4 = {
{1, 1, 1, 1, 1},
{0, 1, 1, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 3, 0, 0}
}

AREA_WAVE6 = {
{0, 0, 0, 0, 0},
{0, 1, 3, 1, 0},
{0, 0, 0, 0, 0}
}

AREA_WAVE7 = {
{1, 1, 1, 1, 1},
{1, 1, 1, 1, 1},
{0, 1, 1, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 3, 0, 0}
}

AREA_SQUAREWAVE5 = {
{1, 1, 1},
{1, 1, 1},
{1, 1, 1},
{0, 1, 0},
{0, 3, 0}
}

AREA_SQUAREWAVE6 = {
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 3, 0, 0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A_CIRCLE6X6 = {
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0},
{0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0},
{0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0}
}

-- Squares
AREA_SQUARE1X1 = {
{1, 1, 1},
{1, 3, 1},
{1, 1, 1}
}

-- Walls
AREA_WALLFIELD = {
{1, 1, 3, 1, 1}
}

AREADIAGONAL_WALLFIELD = {
{0, 0, 0, 0, 1},
{0, 0, 0, 1, 1},
{0, 1, 3, 1, 0},
{1, 1, 0, 0, 0},
{1, 0, 0, 0, 0},
}

-- This array contains all destroyable field items
FIELDS = {1487, 1488, 1489, 1490, 1491, 1492, 1493, 1494, 1495, 1496, 1500, 1501, 1502, 1503, 1504}

function Player:addPartyCondition(combat, variant, condition, baseMana)
local party = self:getParty()
if not party then
self:sendCancelMessage(RETURNVALUE_NOPARTYMEMBERSINRANGE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local positions = combat:getPositions(self, variant)
local members = party:getMembers()
members[#members + 1] = party:getLeader()

local affectedMembers = {}
for _, member in ipairs(members) do
local memberPosition = member:getPosition()
for _, position in ipairs(positions) do
if memberPosition == position then
affectedMembers[#affectedMembers + 1] = member
end
end
end

if #affectedMembers <= 1 then
self:sendCancelMessage(RETURNVALUE_NOPARTYMEMBERSINRANGE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local mana = math.ceil(#affectedMembers * math.pow(0.9, #affectedMembers - 1) * baseMana)
if self:getMana() < mana then
self:sendCancelMessage(RETURNVALUE_NOTENOUGHMANA)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

self:addMana(-mana)
self:addManaSpent(mana)

for _, member in ipairs(affectedMembers) do
member:addCondition(condition)
end

for _, position in ipairs(positions) do
position:sendMagicEffect(CONST_ME_MAGIC_BLUE)
end
return true
end

function Player:conjureItem(reagentId, conjureId, conjureCount, effect)
if not conjureCount and conjureId ~= 0 then
local itemType = ItemType(conjureId)
if itemType:getId() == 0 then
return false
end

local charges = itemType:getCharges()
if charges ~= 0 then
conjureCount = charges
end
end

if reagentId ~= 0 and not self:removeItem(reagentId, 1, -1) then
self:sendCancelMessage(RETURNVALUE_YOUNEEDAMAGICITEMTOCASTSPELL)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

local item = self:addItem(conjureId, conjureCount)
if not item then
self:sendCancelMessage(RETURNVALUE_NOTPOSSIBLE)
self:getPosition():sendMagicEffect(CONST_ME_POFF)
return false
end

if item:hasAttribute(ITEM_ATTRIBUTE_DURATION) then
item:decay()
end

self:getPosition():sendMagicEffect(item:getType():isRune() and CONST_ME_MAGIC_RED or effect)
return true
end

function Creature:addAttributeCondition(parameters)
local condition = Condition(CONDITION_ATTRIBUTES)
for _, parameter in ipairs(parameters) do
if parameter.key and parameter.value then
condition:setParameter(parameter.key, parameter.value)
end
end

self:addCondition(condition)
end
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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)
Expand All @@ -12,6 +13,20 @@ end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
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()
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local spell = Spell(SPELL_RUNE)

function onCastSpell(creature, variant, isHotkey)
return combat:execute(creature, variant)
end

spell:group("attack")
spell:id(115)
spell:name("Avalanche Rune")
spell:runeId(2274)
spell:allowFarUse(true)
spell:charges(4)
spell:runeLevel(30)
spell:runeMagicLevel(4)
spell:cooldown(2000)
spell:groupCooldown(2000)
spell:register()
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
combat:setParameter(COMBAT_PARAM_CREATEITEM, ITEM_ENERGYFIELD_PVP)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

local spell = Spell(SPELL_RUNE)

function onCastSpell(creature, variant, isHotkey)
return combat:execute(creature, variant)
end

spell:group("attack")
spell:id(55)
spell:name("Energy Bomb Rune")
spell:runeId(2262)
spell:allowFarUse(true)
spell:charges(2)
spell:runeLevel(37)
spell:runeMagicLevel(10)
spell:cooldown(2000)
spell:groupCooldown(2000)
spell:isBlocking(true, false)
spell:register()
Loading

0 comments on commit 25df9cf

Please sign in to comment.