• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Attack type :

Androw23

New Member
Joined
Jun 3, 2020
Messages
20
Reaction score
4
Location
USA
Morning, running on TFS 1.2

Is there a way I can change the donation wand attack type to customize effect rather than : ice, flame or death
I used to see some ots have like cake effect.
 
Solution
Add this to your data/weapons/weapons.xml and change id/level whatever.
XML:
    <wand id="WANDID" level="xxx" mana="20" script="scriptnamehere.lua" />
        <vocation name="Sorcerer" />
    </wand>
Then in your data/weapons/scripts/makecustomscriptname.lua and add this to it.
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, CONST_ME_CAKE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_CAKE)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(player, var)
    return...
Post your script or change the line with any of these
Effects on target/player:
C++:
    CONST_ME_DRAWBLOOD = 1,
    CONST_ME_LOSEENERGY = 2,
    CONST_ME_POFF = 3,
    CONST_ME_BLOCKHIT = 4,
    CONST_ME_EXPLOSIONAREA = 5,
    CONST_ME_EXPLOSIONHIT = 6,
    CONST_ME_FIREAREA = 7,
    CONST_ME_YELLOW_RINGS = 8,
    CONST_ME_GREEN_RINGS = 9,
    CONST_ME_HITAREA = 10,
    CONST_ME_TELEPORT = 11,
    CONST_ME_ENERGYHIT = 12,
    CONST_ME_MAGIC_BLUE = 13,
    CONST_ME_MAGIC_RED = 14,
    CONST_ME_MAGIC_GREEN = 15,
    CONST_ME_HITBYFIRE = 16,
    CONST_ME_HITBYPOISON = 17,
    CONST_ME_MORTAREA = 18,
    CONST_ME_SOUND_GREEN = 19,
    CONST_ME_SOUND_RED = 20,
    CONST_ME_POISONAREA = 21,
    CONST_ME_SOUND_YELLOW = 22,
    CONST_ME_SOUND_PURPLE = 23,
    CONST_ME_SOUND_BLUE = 24,
    CONST_ME_SOUND_WHITE = 25,
    CONST_ME_BUBBLES = 26,
    CONST_ME_CRAPS = 27,
    CONST_ME_GIFT_WRAPS = 28,
    CONST_ME_FIREWORK_YELLOW = 29,
    CONST_ME_FIREWORK_RED = 30,
    CONST_ME_FIREWORK_BLUE = 31,
    CONST_ME_STUN = 32,
    CONST_ME_SLEEP = 33,
    CONST_ME_WATERCREATURE = 34,
    CONST_ME_GROUNDSHAKER = 35,
    CONST_ME_HEARTS = 36,
    CONST_ME_FIREATTACK = 37,
    CONST_ME_ENERGYAREA = 38,
    CONST_ME_SMALLCLOUDS = 39,
    CONST_ME_HOLYDAMAGE = 40,
    CONST_ME_BIGCLOUDS = 41,
    CONST_ME_ICEAREA = 42,
    CONST_ME_ICETORNADO = 43,
    CONST_ME_ICEATTACK = 44,
    CONST_ME_STONES = 45,
    CONST_ME_SMALLPLANTS = 46,
    CONST_ME_CARNIPHILA = 47,
    CONST_ME_PURPLEENERGY = 48,
    CONST_ME_YELLOWENERGY = 49,
    CONST_ME_HOLYAREA = 50,
    CONST_ME_BIGPLANTS = 51,
    CONST_ME_CAKE = 52,
    CONST_ME_GIANTICE = 53,
    CONST_ME_WATERSPLASH = 54,
    CONST_ME_PLANTATTACK = 55,
    CONST_ME_TUTORIALARROW = 56,
    CONST_ME_TUTORIALSQUARE = 57,
    CONST_ME_MIRRORHORIZONTAL = 58,
    CONST_ME_MIRRORVERTICAL = 59,
    CONST_ME_SKULLHORIZONTAL = 60,
    CONST_ME_SKULLVERTICAL = 61,
    CONST_ME_ASSASSIN = 62,
    CONST_ME_STEPSHORIZONTAL = 63,
    CONST_ME_BLOODYSTEPS = 64,
    CONST_ME_STEPSVERTICAL = 65,
    CONST_ME_YALAHARIGHOST = 66,
    CONST_ME_BATS = 67,
    CONST_ME_SMOKE = 68,
    CONST_ME_INSECTS = 69,
    CONST_ME_DRAGONHEAD = 70,
    CONST_ME_ORCSHAMAN = 71,
    CONST_ME_ORCSHAMAN_FIRE = 72,
    CONST_ME_THUNDER = 73,
    CONST_ME_FERUMBRAS = 74,
    CONST_ME_CONFETTI_HORIZONTAL = 75,
    CONST_ME_CONFETTI_VERTICAL = 76,
    // 77-157 are empty
    CONST_ME_BLACKSMOKE = 158,
    // 159-166 are empty
    CONST_ME_REDSMOKE = 167,
    CONST_ME_YELLOWSMOKE = 168,
    CONST_ME_GREENSMOKE = 169,
    CONST_ME_PURPLESMOKE = 170,
Distance effects:
C++:
    CONST_ANI_SPEAR = 1,
    CONST_ANI_BOLT = 2,
    CONST_ANI_ARROW = 3,
    CONST_ANI_FIRE = 4,
    CONST_ANI_ENERGY = 5,
    CONST_ANI_POISONARROW = 6,
    CONST_ANI_BURSTARROW = 7,
    CONST_ANI_THROWINGSTAR = 8,
    CONST_ANI_THROWINGKNIFE = 9,
    CONST_ANI_SMALLSTONE = 10,
    CONST_ANI_DEATH = 11,
    CONST_ANI_LARGEROCK = 12,
    CONST_ANI_SNOWBALL = 13,
    CONST_ANI_POWERBOLT = 14,
    CONST_ANI_POISON = 15,
    CONST_ANI_INFERNALBOLT = 16,
    CONST_ANI_HUNTINGSPEAR = 17,
    CONST_ANI_ENCHANTEDSPEAR = 18,
    CONST_ANI_REDSTAR = 19,
    CONST_ANI_GREENSTAR = 20,
    CONST_ANI_ROYALSPEAR = 21,
    CONST_ANI_SNIPERARROW = 22,
    CONST_ANI_ONYXARROW = 23,
    CONST_ANI_PIERCINGBOLT = 24,
    CONST_ANI_WHIRLWINDSWORD = 25,
    CONST_ANI_WHIRLWINDAXE = 26,
    CONST_ANI_WHIRLWINDCLUB = 27,
    CONST_ANI_ETHEREALSPEAR = 28,
    CONST_ANI_ICE = 29,
    CONST_ANI_EARTH = 30,
    CONST_ANI_HOLY = 31,
    CONST_ANI_SUDDENDEATH = 32,
    CONST_ANI_FLASHARROW = 33,
    CONST_ANI_FLAMMINGARROW = 34,
    CONST_ANI_SHIVERARROW = 35,
    CONST_ANI_ENERGYBALL = 36,
    CONST_ANI_SMALLICE = 37,
    CONST_ANI_SMALLHOLY = 38,
    CONST_ANI_SMALLEARTH = 39,
    CONST_ANI_EARTHARROW = 40,
    CONST_ANI_EXPLOSION = 41,
    CONST_ANI_CAKE = 42,

    CONST_ANI_TARSALARROW = 44,
    CONST_ANI_VORTEXBOLT = 45,

    CONST_ANI_PRISMATICBOLT = 48,
    CONST_ANI_CRYSTALLINEARROW = 49,
    CONST_ANI_DRILLBOLT = 50,
    CONST_ANI_ENVENOMEDARROW = 51,

    CONST_ANI_GLOOTHSPEAR = 53,
    CONST_ANI_SIMPLEARROW = 54,
In your script change this line for the effect showing on target/player.
Lua:
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_YOUREFFECTNAMEORNUMBERHERE)
In your script change this line for the distance effect shows before hitting the target/player
Lua:
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_YOUREFFECTNAMEORNUMBERHERE)
 
Do I edit it inside items.xml ?

for example :
<item id="7735" article="a" name="spellwand">
<attribute key="weight" value="75" />
<attribute key="weaponType" value="wand" />
<attribute key="shootType" value="Ice" />
<attribute key="range" value="10" />
 
Doesn't work like this, If your script doesn't have a Lua script then you'll have to create one.
How is it added to weapons.xml? Post the whole line.
 
Doesn't work like this, If your script doesn't have a Lua script then you'll have to create one.
How is it added to weapons.xml? Post the whole line.
It actually doesn't have lua script, probably that's why it limit my options with fire,death,ice,energy
 
Add this to your data/weapons/weapons.xml and change id/level whatever.
XML:
    <wand id="WANDID" level="xxx" mana="20" script="scriptnamehere.lua" />
        <vocation name="Sorcerer" />
    </wand>
Then in your data/weapons/scripts/makecustomscriptname.lua and add this to it.
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, CONST_ME_CAKE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_CAKE)

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2) + 12
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(player, var)
    return combat:execute(player, var)
end
Don't forget to remove your existing XML line for wand.
 
Solution
the wand should deal between 3000-3500
for both sorcerer and druid
takes 300 mana
from lvl 400
effect is "cake type " for distance and target effect
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_CAKE)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_CAKE)

function onGetFormulaValues(player, level, maglevel)
    local min = 3000
    local max = 3500
    return -min, -max
end

local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(player, var)
    return combat:execute(player, var)
end

Edited @M0ustafa script so you can mark him as best answer

About the mana cost etc.
You can setup it in Weapons.xml as you want

Make sure to add the range etc in items.xml
explain:

<item id="ITEMID" article="a" name="ITEMNAME">
<attribute key="weight" value="3500" />
<attribute key="weaponType" value="wand" />
<attribute key="range" value="9" />
</item>
 
If you gonna use the one with area posted by DoktorHolzbein then change this
Lua:
setCombatArea(combat, area)
to this
Lua:
combat:setArea(area)
 
Back
Top