• 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!

Help with monster spell

Nekiro

Legendary OT User
TFS Developer
Joined
Sep 7, 2015
Messages
2,677
Solutions
127
Reaction score
2,112
Well, im really bad in scripting spells, so im asking for help u guys.
How do I make monster to hit one sqm before himself always in direction he is facing?
I want to make it in lua not in xml, because monster is talking something when he is doing this.
But he is hitting only one direction.
Code:
    arr = {
        {0, 1, 0},
        {0, 3, 0},
    }

local area = createCombatArea(arr)

local combat = createCombatObject()
setCombatArea(combat, area)
 
Last edited:
this is an example only
In "Spell.lua" add this lines:

local areaNorth = {
{0, 3, 0},
{0, 1, 0}
}

local areaSouth = {
{0, 1, 0},
{0, 3, 0}
}
local areaEast = {
{0, 0},
{1, 3},
{0, 0}
}
local areaWest = {
{0, 0},
{3, 1},
{0, 0}
}

local setAreaNorth = createCombatArea(areaNorth)
local setAreaSouth = createCombatArea(areaSouth)
local setAreaEast = createCombatArea(areaEast)
local setAreaWest = createCombatArea(areaWest)

function onCastSpell(creature, variant)

local mpos = creature:getPosition()
local target = creature:getTarget()
local tpos = target:getPosition()

if tpos.x == mpos.x and tpos.y == mpos.y then
doTargetCombatHealth(creature, target, COMBAT_PHYSICALDAMAGE, -min, -max, CONST_ME_NONE)
end

end
 
be of some use when helping or writing on others post instead of making them look stupid.

There are several ways of doing this. One way is checking look direction , and create a table accordingly. Another is to not care about creating a combat object and just getting lookdir and then execute it just like any other script.


(Written on Android Phone)
 
dont work. any other suggestions?

Obviously this will not gonna work, is said it is just a example for you to take idea. lets start from zero.

in your monster.xml file add this line on attacks:

Code:
 <attack name="monsterStrike" interval="2000" chance="20" />

now in spells.xml, add a new line:
Code:
<instant name="monsterStrike" words="###200"   aggressive="1" blockwalls="1" needtarget="0" needlearn="1" script="monster/monsterStrike.lua" />
then in "data/spells/scripts/monster/monsterStrike.lua" add this lines:

Code:
local areaNorth = {
{0, 3, 0},
{0, 1, 0}
}

local areaSouth = {
{0, 1, 0},
{0, 3, 0}
}
local areaEast = {
{0, 0},
{1, 3},
{0, 0}
}
local areaWest = {
{0, 0},
{3, 1},
{0, 0}
}

local setAreaNorth = createCombatArea(areaNorth)
local setAreaSouth = createCombatArea(areaSouth)
local setAreaEast = createCombatArea(areaEast)
local setAreaWest = createCombatArea(areaWest)

function onCastSpell(creature, var)
local target = creature:getTarget()
local tpos = target:getPosition()
local mpos = creature:getPosition()
local dmgMin = 570
local dmgMax = 750

if tpos.x == mpos.x and tpos.y < mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setWestArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.x == mpos.x and tpos.y > mpos.y then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setEastArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x > mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setSouthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
elseif tpos.y == mpos.y and tpos.x < mpos.x then
doAreaCombatHealth(creature, COMBAT_PHYSICALDAMAGE, mpos, setNorthArea, -dmgMin, -dmgMax, CONST_ME_GROUNDSHAKER)
end
end

again, this is an example but you can take an idea about the script you need to find... hope this work for you
 
@lokolokio
Just an example
Code:
local dirArea = {
    [0] = { -- north
        {0, 3, 0},
        {0, 1, 0}
    },
    [1] = { -- east
        {0, 0},
        {1, 3},
        {0, 0}  
    },
    [2] = { -- south
        {0, 1, 0},
        {0, 3, 0}
    },
    [3] = { -- west
        {0, 0},
        {3, 1},
        {0, 0}
    }
}

local combat = {}

for i = 0, #dirArea do
    combat[i] = createCombatObject()
    setCombatParam(combat[i], COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatParam(combat[i], COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
    setCombatParam(combat[i], COMBAT_PARAM_USECHARGES, true)
   
    setCombatArea(combat[i], createCombatArea(dirArea[i]))
end

function onCastSpell(cid, var)
    return doCombat(cid, combat[getCreatureLookDirection(cid)], var)
end
 
Back
Top