Tested with TFS 0.3.6pl1 8.54
All kinds of weapons I made.
Most of them are from old requests, others from ideas, decided to put them all together in 1 thread.
For attack damage weapons:
Weapons.xml
For wands:
Weapons.xml
Weapons with % chance something happens
The math.random(1,10) means 10% chance.
If you don't know how to calculate the %, you can use 100 : the second number. So 100:10 = 10%, 100:20 = 5%. So for 5% will be math.random(1,20)
Double hit
10% chance to hit 2x.
doublehitweapon.lua
Paralyze
10% chance to paralyze the target.
paralyzeweapon.lua
paralyzewand.lua
Poison
10% chance to poison the target.
poisonweapon.lua
Stun
5% chance to make the target unable to move for 5 seconds.
stunwand.lua
Curse
10% chance to hit the target 10x with 10% of your hp as damage.
cursewand.lua
Healing weapons
Normal
The idea is based on lifesteal weapons. It heals % of the average damage that people will hit with a certain level, skills and attack of the weapon.
healingweapon.lua
healingwand.lua
Leech Seed
The damage is based on the health of the target, it deals 3% of the targets health and gives this as healing to the person who is using the wand.
leechseedwand.lua
Manadrain weapon
How does it work:
The target looses mana and the person who is using the weapon gets a part of this mana.
If the target doesn't have mana anymore, the manadrain and gain will stop untill the target has mana again.
For the rest it works like a normal weapon.
manadrainweapon.lua
Weapons with effects that get activated with a spell
On/Off
How does it work:
If you use the spell, you will see animated text in green with On, if you use the spell again, you see animated text in red with Off.
If the spell is on, the weapons change when you use them, if the spell is off, it will attack normal again.
spells.xml
spell.lua
The same effect for every weapon in the script with 1 spell
If you want every weapon to have the same effect with 1 spell, you can do it like this (paralyze as example)
This will paralyze the target if people use the items in the list as long as the spell is on.
creaturescripts.xml
Add this to login.lua
paralyzeeffect.lua
Different effects for each weapon with 1 spell
If you do it like this, every weapon would have his own effect when the spell is on.
Back to weapons.xml
Explosion wand
This will create an explosion area while using the wand as long as the spell stays on.
explosionwand.lua
spell.lua
Boostwand.lua
spell.lua
mixwand.lua
Quest/VIP Weapons
1 quest or vip wand
This wand will hit more if you have vip or did a certain quest (depense on which storage you add).
vipwand.lua
Multiple questwand
The damage of this wand increases when you do quests, how more quests you do, how more the wand will hit.
questwand.lua
All kinds of weapons I made.
Most of them are from old requests, others from ideas, decided to put them all together in 1 thread.
For attack damage weapons:
Weapons.xml
XML:
<melee id="XXXX" level="20" unproperly="1" event="script" value="weapon.lua"/>
For wands:
Weapons.xml
XML:
<wand id="XXXX" level="50" mana="15" event="script" value="wand.lua"> <!-- Wand -->
<vocation id="1"/>
</wand>
Weapons with % chance something happens
The math.random(1,10) means 10% chance.
If you don't know how to calculate the %, you can use 100 : the second number. So 100:10 = 10%, 100:20 = 5%. So for 5% will be math.random(1,20)
Double hit
10% chance to hit 2x.
doublehitweapon.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_REDSPARKS)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat1, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
setCombatFormula(combat1, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat2, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
local function onUseWeapon1(parameters)
doCombat(parameters.cid, combat, parameters.var)
end
local function onUseWeapon2(parameters)
doCombat(parameters.cid, combat1, parameters.var)
end
local function onUseWeapon3(parameters)
doCombat(parameters.cid, combat2, parameters.var)
end
function onUseWeapon(cid, var)
local parameters = { cid = cid, var = var, combat = combat, combat1 = combat1, combat2 = combat2 }
if getPlayerLevel(cid) >= 20 then
local chance = math.random(1,10)
if chance == 1 then
addEvent(onUseWeapon1, 1, parameters)
addEvent(onUseWeapon2, 400, parameters)
doSendAnimatedText(getPlayerPosition(cid),"Doublehit", TEXTCOLOR_RED)
else
addEvent(onUseWeapon3, 1, parameters)
end
else
doPlayerSendCancel(cid, 'You need level 20 to use this weapon.')
end
end
Paralyze
10% chance to paralyze the target.
paralyzeweapon.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_STUN)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SPEED, -150)
setCombatCondition(combat, condition)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat2, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
function onUseWeapon(cid, var)
local target = getCreatureTarget(cid)
if getPlayerLevel(cid) >= 20 then
local chance = math.random(1,10)
if chance == 1 then
doCombat(cid, combat, var)
doSendAnimatedText(getPlayerPosition(target),"Paralyzed", TEXTCOLOR_YELLOW)
else
doCombat(cid, combat2, var)
end
else
doPlayerSendCancel(cid, 'You need level 20 to use this weapon.')
end
end
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SPEED, -150)
function onUseWeapon(cid, var)
local target = getCreatureTarget(cid)
local chance = math.random(1,10)
if chance == 1 then
doTargetCombatCondition(0, target, condition, CONST_ME_STUN)
doCombat(cid, combat, var)
doSendAnimatedText(getPlayerPosition(target),"Paralyzed", TEXTCOLOR_YELLOW)
else
doCombat(cid, combat, var)
end
return true
end
Poison
10% chance to poison the target.
poisonweapon.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_GREEN_RINGS)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
local condition = createConditionObject(CONDITION_POISON)
setConditionParam(condition, CONDITION_PARAM_DELAYED, TRUE)
setConditionParam(condition, CONDITION_PARAM_STARTVALUE, -15)
setConditionParam(condition, CONDITION_PARAM_MAXVALUE, -15)
setConditionParam(condition, CONDITION_PARAM_MINVALUE, -5)
setConditionParam(condition, CONDITION_PARAM_TICKINTERVAL, 1000)
setCombatCondition(combat, condition)
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat2, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
function onUseWeapon(cid, var)
local target = getCreatureTarget(cid)
local chance = math.random(1,10)
if chance == 1 then
doCombat(cid, combat, var)
doSendAnimatedText(getPlayerPosition(target),"Poisoned!", TEXTCOLOR_GREEN)
else
doCombat(cid, combat2, var)
end
end
Stun
5% chance to make the target unable to move for 5 seconds.
stunwand.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*2) -level/5 -20
max = -(maglevel*3) -level/5 -25
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_STUN)
local function onUseWeapon1(parameters)
doCombat(parameters.cid, combat, parameters.var)
end
local function onUseWeapon2(parameters)
doCombat(parameters.cid, combat2, parameters.var)
end
function removeStun(parameters)
doCreatureSetNoMove(parameters.target, false)
end
function onUseWeapon(cid, var)
local target = getCreatureTarget(cid)
local parameters = {cid = cid, var = var, combat = combat, combat2 = combat2, target = getCreatureTarget(cid)}
local chance = math.random(1,20)
if chance == 1 and isPlayer(target) then
doCreatureSetNoMove(target, true)
addEvent(onUseWeapon1, 1, parameters)
addEvent(onUseWeapon2, 1000, parameters)
addEvent(onUseWeapon2, 2000, parameters)
addEvent(onUseWeapon2, 3000, parameters)
addEvent(onUseWeapon2, 4000, parameters)
addEvent(removeStun, 5000, parameters)
doSendAnimatedText(getPlayerPosition(target),"Stunned!", TEXTCOLOR_WHITE)
else
addEvent(onUseWeapon1, 1, parameters)
end
return true
end
Curse
10% chance to hit the target 10x with 10% of your hp as damage.
cursewand.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*2) -level/5 -20
max = -(maglevel*3) -level/5 -25
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
function onGetFormulaValues(cid)
percent = 10 -- this means 10% from the maxhealth as damage, on players this will be 5%
curse = -getCreatureMaxHealth(cid)*(percent/100)
return curse, curse
end
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local function onUseWeapon1(parameters)
doCombat(parameters.cid, combat, parameters.var)
end
local function onUseWeapon2(parameters)
doCombat(parameters.cid, combat2, parameters.var)
end
function onUseWeapon(cid, var)
local target = getCreatureTarget(cid)
local parameters = {cid = cid, var = var, combat = combat, combat2 = combat2}
local chance = math.random(1,10)
if chance == 1 then
addEvent(onUseWeapon1, 1, parameters)
addEvent(onUseWeapon2, 1000, parameters)
addEvent(onUseWeapon2, 2000, parameters)
addEvent(onUseWeapon2, 3000, parameters)
addEvent(onUseWeapon2, 4000, parameters)
addEvent(onUseWeapon2, 5000, parameters)
addEvent(onUseWeapon2, 6000, parameters)
addEvent(onUseWeapon2, 7000, parameters)
addEvent(onUseWeapon2, 8000, parameters)
addEvent(onUseWeapon2, 9000, parameters)
addEvent(onUseWeapon2, 10000, parameters)
doSendAnimatedText(getPlayerPosition(target),"Cursed!", TEXTCOLOR_GREY)
else
addEvent(onUseWeapon1, 1, parameters)
end
return true
end
Healing weapons
Normal
The idea is based on lifesteal weapons. It heals % of the average damage that people will hit with a certain level, skills and attack of the weapon.
healingweapon.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
function onUseWeapon(cid, var)
local skill = getPlayerSkill(cid,SKILL_SWORD) -- Change this to the type of weapon you are using
local mat = 0.085*0.5*50*skill+(getPlayerLevel(cid)/5) -- Change 50 to the attack of the weapon
local min = 5 -- this means 5% minimum healing
local max = 15 -- this means 15% maximum healing
local addhealth = math.random((mat * (min/100)), (mat * (max/100)))
if getPlayerLevel(cid) >= 20 then
doCreatureAddHealth(cid, addhealth)
doSendAnimatedText(getPlayerPosition(cid),"+"..addhealth.."", TEXTCOLOR_GREEN)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doCombat(cid, combat, var)
else
doPlayerSendCancel(cid, 'You need level 20 to use this weapon.')
end
end
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
local level, magic, target = getPlayerLevel(cid), getPlayerMagLevel(cid), getCreatureTarget(cid)
local mat1, mat2 = magic*2+level/10, magic*3+level/10 -- 50% from the min/max above
local xmat1, xmat2 = magic*4+level/5, magic*6+level/5 -- same as the min/max above
local percent = 10 -- change here the % of the healing.
local health, xhealth = math.random((mat1 * (percent/100)), (mat2 * (percent/100))), math.random((xmat1 * (percent/100)), (xmat2 * (percent/100)))
if isPlayer(target) then
doCreatureAddHealth(cid, health)
doSendAnimatedText(getPlayerPosition(cid),"+"..health.."", TEXTCOLOR_GREEN)
doCombat(cid, combat, var)
else
doCreatureAddHealth(cid, xhealth)
doSendAnimatedText(getPlayerPosition(cid),"+"..xhealth.."", TEXTCOLOR_GREEN)
doCombat(cid, combat, var)
end
return true
end
Leech Seed
The damage is based on the health of the target, it deals 3% of the targets health and gives this as healing to the person who is using the wand.
leechseedwand.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_SMALLPLANTS)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISON)
function onGetFormulaValues(cid)
percent = 3 -- this means the damage is 3% of the health of the target
damage = -getCreatureMaxHealth(getCreatureTarget(cid))*(percent/100)
return damage, damage
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_SMALLPLANTS)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISON)
function onGetFormulaValues(cid)
percent = 6 -- this means the damage is 3% of the health of the target, because it's on players
damage = -getCreatureMaxHealth(getCreatureTarget(cid))*(percent/100)
return damage, damage
end
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
local target = getCreatureTarget(cid)
local percent = 3 -- this means the healing is 3% of the health of the target
local health = getCreatureMaxHealth(target)*(percent/100)
local monsters = {"Training Monk", "Squirrel"} -- add here the monsters you can't attack with this wand
if isPlayer(target) then
doCreatureAddHealth(cid, health)
doSendAnimatedText(getPlayerPosition(cid),"+"..health.."", TEXTCOLOR_GREEN)
doCombat(cid, combat2, var)
else
for i, x in pairs(monsters) do
if(getCreatureName(target)) == x then
doPlayerSendCancel(cid, "You can\'t attack a "..getCreatureName(target).." with this wand.")
return false
end
end
doCreatureAddHealth(cid, health)
doSendAnimatedText(getPlayerPosition(cid),"+"..health.."", TEXTCOLOR_GREEN)
return doCombat(cid, combat, var)
end
end
Manadrain weapon
How does it work:
The target looses mana and the person who is using the weapon gets a part of this mana.
If the target doesn't have mana anymore, the manadrain and gain will stop untill the target has mana again.
For the rest it works like a normal weapon.
manadrainweapon.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*1) -level/5 -30
max = -(maglevel*1) -level/5 -50
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_BLOCKARMOR, 1)
setCombatParam(combat2, COMBAT_PARAM_BLOCKSHIELD, 1)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatFormula(combat2, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
function onUseWeapon(cid, var)
local target = getCreatureTarget(cid)
local min = getPlayerMagLevel(cid)+getPlayerLevel(cid)/5+30 -- should be the same as the min/max above
local max = getPlayerMagLevel(cid)+getPlayerLevel(cid)/5+50
local percent = 30 -- change here the % manadrain
local addmana = math.random(min * 0.5 * (percent/100), max * 0.5 * (percent/100))
if getPlayerLevel(cid) >= 20 then
if isPlayer(target) and getCreatureMana(target) >= 10 then
doCombat(cid, combat, var)
doCombat(cid, combat2, var)
doPlayerAddMana(cid, addmana)
doSendAnimatedText(getPlayerPosition(cid),"+"..addmana.."", TEXTCOLOR_LIGHTBLUE)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
else
doCombat(cid, combat2, var)
end
else
doPlayerSendCancel(cid, 'You need level 20 to use this weapon.')
end
end
Weapons with effects that get activated with a spell
On/Off
How does it work:
If you use the spell, you will see animated text in green with On, if you use the spell again, you see animated text in red with Off.
If the spell is on, the weapons change when you use them, if the spell is off, it will attack normal again.
spells.xml
XML:
<instant name="Weaponboost" words="boost" lvl="14" mana="60" prem="1" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" event="script" value="support/spell.lua">
<vocation id="1"/>
<vocation id="2"/>
<vocation id="3"/>
<vocation id="4"/>
<vocation id="5"/>
<vocation id="6"/>
<vocation id="7"/>
<vocation id="8"/>
</instant>
spell.lua
Lua:
function onCastSpell(cid, var)
local storage = 9810
if(getPlayerStorageValue(cid, storage) == -1) then
setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) + 1)
doSendAnimatedText(getPlayerPosition(cid),"On", TEXTCOLOR_GREEN)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
elseif(getPlayerStorageValue(cid, storage) == 0) then
setPlayerStorageValue(cid, storage, getPlayerStorageValue(cid, storage) - 1)
doSendAnimatedText(getPlayerPosition(cid),"Off", TEXTCOLOR_RED)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
end
return true
end
The same effect for every weapon in the script with 1 spell
If you want every weapon to have the same effect with 1 spell, you can do it like this (paralyze as example)
This will paralyze the target if people use the items in the list as long as the spell is on.
creaturescripts.xml
XML:
<event type="combat" name="Spell" event="script" value="paralyzeeffect.lua"/>
Add this to login.lua
Lua:
registerCreatureEvent(cid, "Spell")
paralyzeeffect.lua
Lua:
local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 5000)
setConditionParam(condition, CONDITION_PARAM_SPEED, -100)
function onCombat(cid, target)
local storage = 9810
local items = {2184, 2187, 7385} -- add here the weapons with the paralyze effect
if(getPlayerStorageValue(cid, storage) == 0) then
for i, x in pairs(items) do
if(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == x) or (getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == x) or (getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid == x) then
doTargetCombatCondition(0, target, condition, CONST_ME_STUN)
doPlayerAddMana(cid, -20)
end
end
end
return true
end
Different effects for each weapon with 1 spell
If you do it like this, every weapon would have his own effect when the spell is on.
Back to weapons.xml
Explosion wand
This will create an explosion area while using the wand as long as the spell stays on.
explosionwand.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_FIREAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
local area = createCombatArea({
{0, 1, 1, 1, 0},
{1, 1, 1, 1, 1},
{1, 1, 3, 1, 1},
{1, 1, 1, 1, 1},
{0, 1, 1, 1, 0}
})
setCombatArea(combat, area)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
local area = createCombatArea({
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 0, 0, 0, 1, 0},
{1, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 2, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 1},
{0, 1, 0, 0, 0, 1, 0},
{0, 0, 1, 1, 1, 0, 0}
})
setCombatArea(combat1, area)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_FIREATTACK)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
local storage = 9810
if(getPlayerStorageValue(cid, storage) == -1) then
doCombat(cid, combat2, var)
else
doPlayerAddMana(cid, -30)
doCombat(cid, combat, var)
doCombat(cid, combat1, var)
end
return true
end
For a certain time with attributes condition
How does it work:
If you use the spell, the weapon will hit more for 10 seconds.
How does it work:
If you use the spell, the weapon will hit more for 10 seconds.
spell.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000) -- time in seconds x1000
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
Boostwand.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*2) -level/5
max = -(maglevel*3) -level/5
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
if(getCreatureCondition(cid, CONDITION_ATTRIBUTES) == TRUE) then
doCombat(cid, combat2, var)
else
doCombat(cid, combat, var)
end
return true
end
More types in 1 weapon
How does it work:
This allows a person to have more types (energy, death, poison, fire) in 1 weapon, each time you use the spell, it will switch to another type.
How does it work:
This allows a person to have more types (energy, death, poison, fire) in 1 weapon, each time you use the spell, it will switch to another type.
spell.lua
Lua:
local t = {
[1] = {type = "Death", color = TEXTCOLOR_GREY}, -- this is just the text someone gets, the real effect you have to change in the weapon.
[2] = {type = "Poison", color = TEXTCOLOR_GREEN},
[3] = {type = "Fire", color = TEXTCOLOR_RED},
[4] = {type = "Energy", color = TEXTCOLOR_LIGHTBLUE}
}
function onCastSpell(cid, var)
local xstorage = 9182
local storage = getPlayerStorageValue(cid, xstorage)
local items = {2184, 2187} -- add here the weapons with the mix effect
for i, x in pairs(items) do
if(getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == x) or (getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == x) then
if storage == -1 then
setPlayerStorageValue(cid, xstorage, 1)
storage = getPlayerStorageValue(cid, xstorage)
end
if t[storage] then
setPlayerStorageValue(cid, xstorage, getPlayerStorageValue(cid, xstorage) + 1)
doSendAnimatedText(getPlayerPosition(cid),""..t[storage].type.."", t[storage].color)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
else
setPlayerStorageValue(cid, xstorage, 1)
doSendAnimatedText(getPlayerPosition(cid),"Death", TEXTCOLOR_GREY)
setPlayerStorageValue(cid, xstorage, getPlayerStorageValue(cid, xstorage) + 1)
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_GREEN)
end
return true
else
doPlayerSendCancel(cid, 'This spell has only effect if you use a mixwand.')
return false
end
end
end
mixwand.lua
Lua:
-- energy
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
-- death
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_SMALLCLOUDS)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
-- poison
local combat3 = createCombatObject()
setCombatParam(combat3, COMBAT_PARAM_TYPE, COMBAT_POISONDAMAGE)
setCombatParam(combat3, COMBAT_PARAM_EFFECT, CONST_ME_GREEN_RINGS)
setCombatParam(combat3, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_POISON)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat3, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
-- fire
local combat4 = createCombatObject()
setCombatParam(combat4, COMBAT_PARAM_TYPE, COMBAT_FIREDAMAGE)
setCombatParam(combat4, COMBAT_PARAM_EFFECT, CONST_ME_FIREHIT)
setCombatParam(combat4, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_FIRE)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5
return min, max
end
setCombatCallback(combat4, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local t = {
[1] = {type = combat1}, -- energy, change the combat numbers to switch them
[2] = {type = combat2}, -- death
[3] = {type = combat3}, -- poison
[4] = {type = combat4} -- fire
}
function onUseWeapon(cid, var)
local storage = getPlayerStorageValue(cid, 9182)
if t[storage] then
doCombat(cid, t[storage].type, var)
else
doCombat(cid, combat1, var)
end
return true
end
Quest/VIP Weapons
1 quest or vip wand
This wand will hit more if you have vip or did a certain quest (depense on which storage you add).
vipwand.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*2) -level/5
max = -(maglevel*3) -level/5
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*3) -level/5
max = -(maglevel*4) -level/5
return min, max
end
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
local storage = 12100 -- add here the storage from your vip system or quest
if(getPlayerStorageValue(cid, storage) == -1) then
doCombat(cid, combat, var)
else
doCombat(cid, combat2, var)
end
return true
end
Multiple questwand
The damage of this wand increases when you do quests, how more quests you do, how more the wand will hit.
questwand.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
function onGetFormulaValues(cid, level, maglevel)
n = 0
for i= 5000,6000 do -- add here the storage from your quests. 5000,6000 means all storages between 5000 and 6000.
if getPlayerStorageValue(cid, i) >= 1 then
n = n+1
end
end
min = -(maglevel*2) -level/5 -(n*10) -- n stands for amount of quests, n*10 means: amount of quests x10 as extra damage.
max = -(maglevel*3) -level/5 -(n*11)
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
function onUseWeapon(cid, var)
return doCombat(cid, combat, var)
end
Last edited: