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

Problem with stun script

bomba

Member
Joined
Feb 26, 2008
Messages
635
Reaction score
7
Location
Brazil
Thing not found!

Script:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_INVISIBLE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, condition)

function onAttack(cid, weapon, target)
    if getPlayerStorageValue(cid, eSkill.dexterity) >= 1 then
      local chance = math.random(1, 1000)
        if chance > 0 and chance <= getPlayerStorageValue(cid, eSkill.dexterity) and getDistanceBetween(getCreaturePos(cid), getCreaturePos(target)) <= 1 then
          doAddCondition(cid, condition)
        end
    end
  return true
end
 
Last edited:
Code:
local stunTime = 2000 -- in ms, 2000ms = 2 seconds

function canMove(target)
    if isCreature(target)
        doCreatureSetNoMove(target, 0)
    end
    return true
end

function onAttack(cid, target)
    local chance = math.random(1, 1000)
    if ((chance > 0) and (chance <= getPlayerStorageValue(cid, eSkill.dexterity))) then
        doCreatureSetNoMove(target, 1)
        doSendMagicEffect(getCreaturePosition(target), CONST_ME_STUN)
        doSendAnimatedText(getCreaturePosition(target), "STUNNED", TEXTCOLOR_WHITE)
        addEvent(canMove, stunTime, target)
    end
    return true
end
 
Very good! But stuns every time, even if I do not hit the player or monster.

I want something to check if the hit was effected.
Code:
if lossHitpoints(target) == true then
Is there any similar function?
 
Stuns everytime becouse you set weapon range to any.

Code:
local stunTime = 2000 -- in ms, 2000ms = 2 seconds

function canMove(target)
    if isCreature(target)
        doCreatureSetNoMove(target, 0)
    end
    return true
end

function onAttack(cid, target)
    local chance = math.random(1, 1000)
    if chance <= getPlayerStorageValue(cid, eSkill.dexterity) and getDistanceBetween(getCreaturePosition(cid), getCreaturePosition(target)) <= 1 then
        doCreatureSetNoMove(target, 1)
        doSendMagicEffect(getCreaturePosition(target), CONST_ME_STUN)
        doSendAnimatedText(getCreaturePosition(target), "STUNNED", TEXTCOLOR_WHITE)
        addEvent(canMove, stunTime, target)
    end
    return true
end
 
Thing not found:
thing_not_found.jpg


Function:
Code:
function getDistanceBetween(fromPosition, toPosition)
    local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
    local diff = math.max(x, y)
    if(fromPosition.z ~= toPosition.z) then
        diff = diff + 9 + 6
    end

    return diff
end

The line 7:
Code:
local x, y = math.abs(fromPosition.x - toPosition.x), math.abs(fromPosition.y - toPosition.y)
 
you have this function in your sources?
Code:
function doStun(target, var)
 
Help-me, Thing not found!
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_INVISIBLE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, condition)

function onAttack(cid, weapon, target)
    if getPlayerStorageValue(cid, eSkill.dexterity) >= 1 then
      local chance = math.random(1, 1000)
        if chance > 0 and chance <= getPlayerStorageValue(cid, eSkill.dexterity) and getDistanceBetween(getCreaturePos(cid), getCreaturePos(target)) <= 1 then
          doAddCondition(cid, condition)
        end
    end
  return true
end
 
My script is working very well. Problem is with your eSkill.dexterity and XML files where you didn't properly configured the weapon.
That's why nobody is helping you in this topic.
 
Back
Top