• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Player and Target Direction

lazarus321

Member
Joined
May 8, 2017
Messages
222
Reaction score
23
How do I check if the creature is in the [DIRECTION_SOUTHWEST], [DIRECTION_SOUTHEAST],

[DIRECTION_NORTHWEST], [DIRECTION_NORTHEAST] positions of the player (cid)?

Sem título10.png
Sem título12.png
 
Last edited:
for TFS 1.x+
Code:
function Creature.IsInCornerToCreature(self, creature)

    local spos = self:getPosition()
    local cpos = creature:getPosition()
    local relativepos = {
        Position(-1, -1, 0)
        Position(1, -1, 0)
        Position(-1, 1, 0)
        Position(1, 1, 0)
    }

    for _, rpos in pairs(relativepos) do
        local pos = spos+rpos
        if pos == cpos then
            return true
        end
    end

    return false
end
 
what is your tfs?
TFS 1.2.

  • function Creature.IsInCornerToCreature(self, creature)
  • local spos = self:getPosition()
  • local cpos = creature:getPosition()
  • local relativepos = {
  • Position(-1, -1, 0)
  • Position(1, -1, 0)
  • Position(-1, 1, 0)
  • Position(1, 1, 0)
  • }
  • for _, rpos in pairs(relativepos) do
  • local pos = spos+rpos
  • if pos == cpos then
  • return true
  • end
  • end
  • return false
  • end
Thanks for help Sarah.

you could also use position:setDirectionOffset(dir) to get the destination pos
Thanks Vulcan too.


Well i have this spell for use on weapon...

local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat1:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
combat1:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat1:setParameter(COMBAT_PARAM_BLOCKSHIELD, true)
combat1:setFormula(COMBAT_FORMULA_SKILL, 1, 0, 1, 0)

local area = createCombatArea( {
{1, 0, 1,},
{0, 1, 0,},
{0, 1, 0,},
{0, 3, 0,},
{0, 0, 0,} } )
combat1:setArea(area)

function onUseWeapon(player, variant)
combat1:execute(player, variant)
return true
end

How i put this code for work in diagonal?
 
Back
Top