paste this into your spells.lua
Code: Select all
defineSpell{
name = "magic_bridge_spell",
uiName = "Magic Platform",
skill = "air_magic",
requirements = {"air_magic", 4, "concentration", 2},
gesture = 3214563,
manaCost = 120,
icon = 14,
spellIcon = 13,
description = "Conjure a magical platform for a brief time in front of the party.",
onCast = function(champion, x, y, direction, elevation, skillLevel)
--myx and myy are the coordinates where the magic platform will spawn.
--Starts with the party's coordinates and modifies it base on their direction.
local myx = x
local myy = y
if direction == 0 then
myy = y - 1
end
if direction == 1 then
myx = x + 1
end
if direction == 2 then
myy = y + 1
end
if direction == 3 then
myx = x - 1
end
--Makes sure only one magic platform exists at a time. The game will crash if two entities with the same ID exist.
if findEntity("magic_spell_bridge") == nil then
local bridgeelevation = party.map:getElevation(myx,myy)
local bridgeceiling = party.map:getCeilingElevation(myx,myy)
local hasbridge = false
--Checks for existing platforms by name
for i in party.map:entitiesAt(myx,myy) do
--Only considers platforms at the same elevation as the party.
if i.elevation == elevation then
--If you have any new platform entities in your mod, add them to this list.
if i.name == "forest_bridge" or i.name == "castle_bridge" or i.name == "castle_bridge_grating" or i.name == "mine_bridge_01" or i.name == "invisible_platform" then
hasbridge = true
end
if i.name == "magic_bridge" then
if i.platform:isEnabled() then
hasbridge = true
end
end
end
end
--Makes sure the tile where the magic platform will appear has a lower floor and a higher ceiling than the tile the party is standing on.
--Also makes sure no other platforms exist there and that the party has line of sight, so it will work through wall grating, but not secret doors.
--This prevents the magic platform from appearing inside of a floor or an existing bridge, which looks bad.
if bridgeelevation < elevation and bridgeceiling > elevation and hasbridge == false and party.map:checkLineOfSight(x,y,myx,myy,elevation) then
spawn("magic_bridge",party.level,myx,myy,direction,elevation,"magic_spell_bridge")
delayedCall("bridge_remover_script",3,"removebridge")
playSound("generic_spell")
else
hudPrint("You can not create a magic platform here.")
playSound("spell_fizzle")
champion:regainEnergy(110)
end
else
hudPrint("You can only create one magic platform at a time.")
playSound("spell_fizzle")
champion:regainEnergy(110)
end
end,
}
paste the following into the script of "bridge_remover_script"
Code: Select all
function removebridge()
if findEntity("magic_spell_bridge") ~= nil then
magic_spell_bridge:destroy()
end
end
edit: tweaked it so you can cast the magic platform over deactivated light bridges.