Leo32
Getting back into it...
- Joined
- Sep 21, 2007
- Messages
- 987
- Solutions
- 14
- Reaction score
- 532
EDIT: Forgot to add [TFS 1.X] to title, can a mod fix this for me? ❤
This is a spell for mages, a replacement for the enchant staff spell.
It conjures a weapon that has attack based on your magicLevel/Level, the damage should scale well as sorcerers and druids can only get about 30 sword skill~
The sword disappears after 15 minutes, and cannot be placed in containers or given to other players.
It cannot be removed from hand slots and disappears if thrown on the ground.
You can get rid of the item early by either throwing it on the ground or by simply dragging a different weapon/item to the slot it is in.
items.xml
weapons.xml (put sorcerer or druid or whatever)
spells\support\conjure blade.lua
spells.xml (put sorcerer or druid or whatever)
events.xml set (onMoveItem to 1)
events\scripts\player.lua add:
This is a spell for mages, a replacement for the enchant staff spell.
It conjures a weapon that has attack based on your magicLevel/Level, the damage should scale well as sorcerers and druids can only get about 30 sword skill~
The sword disappears after 15 minutes, and cannot be placed in containers or given to other players.
It cannot be removed from hand slots and disappears if thrown on the ground.
You can get rid of the item early by either throwing it on the ground or by simply dragging a different weapon/item to the slot it is in.
items.xml
XML:
<item id="7870" article="an" name="conjured blade">
<attribute key="weight" value="500" />
<attribute key="attack" value="1" />
<attribute key="elementEnergy" value="10" />
<attribute key="weaponType" value="sword" />
<attribute key="duration" value="900" />
<attribute key="decayTo" value="0" />
</item>
weapons.xml (put sorcerer or druid or whatever)
XML:
<melee id="7870" unproperly="1" >
<vocation name="..." />
</melee>
spells\support\conjure blade.lua
Lua:
local blockingWeaponTypes = {
WEAPON_SWORD,
WEAPON_CLUB,
WEAPON_AXE,
WEAPON_DISTANCE,
WEAPON_WAND
}
local slotsToCheck = {
CONST_SLOT_LEFT,
CONST_SLOT_RIGHT
}
local conjureBlade = 7870
function onCastSpell(creature, var)
if not creature:isPlayer() then
return false
end
local function getFreeSlot()
local slot = {}
for i = 1,#slotsToCheck do
local item = creature:getSlotItem(slotsToCheck[i])
if item ~= nil then
local weaponType = ItemType(item:getId()):getWeaponType()
if item:getId() == conjureBlade then -- If its an already equipped conjured blade
return "Already Equipped"
elseif isInArray(blockingWeaponTypes, weaponType) then -- If its a two-handed weapon or another weapon
return false
end
else
table.insert(slot, slotsToCheck[i])
end
end
if slot ~= nil then
return slot[1]
else
return false
end
end
-- Check capacity
local itemWeight = ItemType(conjureBlade):getWeight()
local playerCap = creature:getFreeCapacity()
if playerCap < itemWeight then
creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You do not have enough capacity to cast this spell.")
return false
end
-- Check if free slot
local freeSlot = getFreeSlot()
if freeSlot and freeSlot ~= "Already Equipped" then
local conjuredBlade = creature:addItem(conjureBlade, 1, true, 1, freeSlot)
conjuredBlade:decay()
creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
local level = creature:getLevel()
local maglevel = creature:getMagicLevel()
local min = (level / 10) + (maglevel * 0.65)
local max = (level / 10) + (maglevel * 0.8)
local bonusattack = math.floor(math.random(min, max))
conjuredBlade:setAttribute(ITEM_ATTRIBUTE_ATTACK, bonusattack) -- Give blade damage based on mlvl/lvl
elseif freeSlot == "Already Equipped" then
creature:sendTextMessage(MESSAGE_STATUS_SMALL, "You already have a conjured blade equipped.")
return false
else
creature:sendTextMessage(MESSAGE_STATUS_SMALL, "One of your hands needs to be free to cast this spell.")
return false
end
return true
end
spells.xml (put sorcerer or druid or whatever)
XML:
<instant group="support" name="Conjure Blade" words="conjure blade" lvl="41" mana="350" prem="1" exhaustion="2000" groupcooldown="2000" aggressive="0" script="support/conjure blade.lua">
<vocation name="..." />
</instant>
events.xml set (onMoveItem to 1)
XML:
<event class="Player" method="onMoveItem" enabled="1" />
events\scripts\player.lua add:
Lua:
-- you may need to remove fromCyclinder and toCylinder if you're using an older version of TFS
function Player.onMoveItem(self, item, count, fromPosition, toPosition, fromCylinder, toCylinder)
-- Conjured Blade
if item.itemid == 7870 then
if toPosition.x == 65535 then
if toPosition.z == 0 then
if toPosition.y == 5 or toPosition.y == 6 then
return true
else
self:sendTextMessage(MESSAGE_STATUS_SMALL, "You cannot place this item here.")
return false
end
else
item:remove()
return false
end
else
item:remove()
return false
end
end
if toPosition.x == 65535 then
if toPosition.z == 0 then
if toPosition.y == 5 or toPosition.y == 6 then
local itemBeingReplaced = self:getSlotItem(toPosition.y)
if itemBeingReplaced then
if itemBeingReplaced:getId() == 7870 then
itemBeingReplaced:remove()
end
end
end
end
end
end
Last edited: