• 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 Fear spell please!

MarkSmartRemark

Lua-Noob in Training :D
Joined
Jan 27, 2010
Messages
139
Reaction score
3
Hi everyone,

ive looked all over otland and havent found any fear-like spell finished... i dont want a complicated fear system just a simple one and ive made most of it but i cant get one part..

when it moves the creature it will move him into anything no matter what.. i need it to check tile he is moving into before he goes into it.. if anyone can either fix this, or make something more compatible let me know!

And if you have a script like this (perfected ofc) then maybe we can discuss payment through pm? thanks alot in advance

Code:
-- >>Script by Tabz!<< --
--{Credits:}

-- Level 1 - 10 --

--.::.CONFIG.::.--
local feared_time = 2.5
--.::.CONFIG.::.--

local function fear(cid)
        doMoveCreature(cid, math.random(0,3))
    end

    local function allowMove(cid, target)
doCreatureSetNoMove(target, false)
end

local silenced = createConditionObject(CONDITION_MUTED)
setConditionParam(silenced, CONDITION_PARAM_TICKS, (feared_time*1000))



function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
    doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), CONST_ANI_SMALLSTONE)
    doSendMagicEffect(getCreaturePosition(target), CONST_ME_BATS)
    doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
    doCreatureSetNoMove(target, true)
    doAddCondition(cid, silenced)
    addEvent(fear, 0, target)
    addEvent(fear, 500, target)
    addEvent(fear, 1000, target)
    addEvent(fear, 1500, target)
    addEvent(fear, 2000, target)
    addEvent(allowMove, (feared_time*1000), cid, target)
    return true
end
 
try those functions "fear" and "allowMove"

Code:
local function fear(cid)
   local cpos = getCreaturePosition(cid)
   local dir = math.random(0,3)
   if dir == 0 then
     if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   elseif dir == 1 then
     if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   elseif dir == 2 then
     if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   elseif dir == 3 then
     if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   end
end

local function allowMove(cid, target)
   if isPlayer(cid) then
     doCreatureSetNoMove(target, false)
   end
end
 
try those functions "fear" and "allowMove"

Code:
local function fear(cid)
   local cpos = getCreaturePosition(cid)
   local dir = math.random(0,3)
   if dir == 0 then
     if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   elseif dir == 1 then
     if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   elseif dir == 2 then
     if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   elseif dir == 3 then
     if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
       doMoveCreature(cid, dir)
     end
   end
end

local function allowMove(cid, target)
   if isPlayer(cid) then
     doCreatureSetNoMove(target, false)
   end
end

Hey thanks!,I tried it out, tested diff scenarios.. basically, it only works under certain circumstances loll Like if the player is trapped with one space around him it works.. if he has more then 2 spaces available that arent the diagnol ones then yea, etc..

depending on whats around him sometimes it works and sometimes it doesnt, im gonna try to play around withthe script and see what i can do heh but thanks once again!
 
Code:
-- >>Script by Tabz!<< --
--{Credits:}

-- Level 1 - 10 --

--.::.CONFIG.::.--
local feared_time = 2.5
--.::.CONFIG.::.--

local function fear(cid)
local cpos = getCreaturePosition(cid)
local dir = {}
   if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
     table.insert(dir, NORTH)
   end
   if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
     table.insert(dir, WEST)
   end
   if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
     table.insert(dir, SOUTH)
   end
   if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
     table.insert(dir, EAST)
   end
   if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
   end
end

local function allowMove(cid, target)
  if isPlayer(cid) then
  doCreatureSetNoMove(target, false)
  end
end

local silenced = createConditionObject(CONDITION_MUTED)
setConditionParam(silenced, CONDITION_PARAM_TICKS, (feared_time*1000))



function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
  doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), CONST_ANI_SMALLSTONE)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BATS)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
  doCreatureSetNoMove(target, true)
  doAddCondition(cid, silenced)
  addEvent(fear, 0, target)
  addEvent(fear, 500, target)
  addEvent(fear, 1000, target)
  addEvent(fear, 1500, target)
  addEvent(fear, 2000, target)
  addEvent(allowMove, (feared_time*1000), cid, target)
  return true
end
this works like WoW :)

 
Last edited:
Code:
-- >>Script by Tabz!<< --
--{Credits:}

-- Level 1 - 10 --

--.::.CONFIG.::.--
local feared_time = 2.5
--.::.CONFIG.::.--

local function fear(cid)
local cpos = getCreaturePosition(cid)
local dir = {}
   if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
     table.insert(dir, NORTH)
   end
   if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
     table.insert(dir, WEST)
   end
   if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
     table.insert(dir, SOUTH)
   end
   if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
     table.insert(dir, EAST)
   end
   if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
   end
end

local function allowMove(cid, target)
  if isPlayer(cid) then
  doCreatureSetNoMove(target, false)
  end
end

local silenced = createConditionObject(CONDITION_MUTED)
setConditionParam(silenced, CONDITION_PARAM_TICKS, (feared_time*1000))



function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
  doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), CONST_ANI_SMALLSTONE)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BATS)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
  doCreatureSetNoMove(target, true)
  doAddCondition(cid, silenced)
  addEvent(fear, 0, target)
  addEvent(fear, 500, target)
  addEvent(fear, 1000, target)
  addEvent(fear, 1500, target)
  addEvent(fear, 2000, target)
  addEvent(allowMove, (feared_time*1000), cid, target)
  return true
end
this works like WoW :)


It works perfectly my dude! good looks man, ill give credits to you loll if i find anything wrong ill let you know. looks fine as of now though i tested it out alot heh, im gonna try to see if i can change it to a "blind" mode like in wow too.. where the effect of creature moving and condition silence cancels if they are attacked.. this is harder though and probly needs a loop or somethin in between lol idk

thanks once again though!
 
I suppose you need the "blind" spell for TFS0.3.6?
If yes, then here's a way to do it:
onCastSpell -> use a loop to move the player every 1sec, set a storage value 1, if storage still 1, move him again and so on UNTIL
onAttack(creaturescript) if attack = true, remove conditions, set storage value to -1 (this will stop the spell loop)
 
Alright man! ill give it a shot when i get some time tmrw, it definitely makes sense the way youre telling me though.. thanks for the help dude :)
 
Made so events are generated every 0.5 sec (configured) instead of static writing 500, 1000, 1500 delay on addevents for fear.
Also made a creature check on fear function so you don't get error messages in console of player dies while spell is still active.
Lua:
-- >>Script by Tabz!<< --
--{Credits:Zyntax, Tabz, Znote}

-- Level 1 - 10 --

--.::.CONFIG.::.--
local feared_time = 2.5 -- total duration
local feared_tick = 0.5 -- Move frequency
--.::.CONFIG.::.--

local function fear(cid)
  if isCreature(cid) then
    local cpos = getCreaturePosition(cid)
    local dir = {}
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
      table.insert(dir, NORTH)
    end
    if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, WEST)
    end
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
      table.insert(dir, SOUTH)
    end
    if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, EAST)
    end
    if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
    end
  end
end

local function allowMove(cid, target)
  if isPlayer(cid) and isCreature(target) then
  doCreatureSetNoMove(target, false)
  end
end

local silenced = createConditionObject(CONDITION_MUTED)
setConditionParam(silenced, CONDITION_PARAM_TICKS, (feared_time*1000))

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
  doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), CONST_ANI_SMALLSTONE)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BATS)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
  doCreatureSetNoMove(target, true)
  doAddCondition(cid, silenced)

  -- Addevent every 500ms of feared_times duration
  i = 0
  while i <= feared_time * 1000 do
    addEvent(fear, i, target)
    i = i + (feared_tick * 1000)
  end

  addEvent(allowMove, (feared_time*1000), cid, target)
  return true
end
 
Made so events are generated every 0.5 sec (configured) instead of static writing 500, 1000, 1500 delay on addevents for fear.
Also made a creature check on fear function so you don't get error messages in console of player dies while spell is still active.
Lua:
-- >>Script by Tabz!<< --
--{Credits:Zyntax, Tabz, Znote}

-- Level 1 - 10 --

--.::.CONFIG.::.--
local feared_time = 2.5 -- total duration
local feared_tick = 0.5 -- Move frequency
--.::.CONFIG.::.--

local function fear(cid)
  if isCreature(cid) then
    local cpos = getCreaturePosition(cid)
    local dir = {}
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
      table.insert(dir, NORTH)
    end
    if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, WEST)
    end
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
      table.insert(dir, SOUTH)
    end
    if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, EAST)
    end
    if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
    end
  end
end

local function allowMove(cid, target)
  if isPlayer(cid) and isCreature(target) then
  doCreatureSetNoMove(target, false)
  end
end

local silenced = createConditionObject(CONDITION_MUTED)
setConditionParam(silenced, CONDITION_PARAM_TICKS, (feared_time*1000))

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
  doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), CONST_ANI_SMALLSTONE)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BATS)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
  doCreatureSetNoMove(target, true)
  doAddCondition(cid, silenced)

  -- Addevent every 500ms of feared_times duration
  i = 0
  while i <= feared_time * 1000 do
    addEvent(fear, i, target)
    i = i + (feared_tick * 1000)
  end

  addEvent(allowMove, (feared_time*1000), cid, target)
  return true
end

Looks good znote! thanks alot, i knew there was a way to make that kind of loop or whatever it is i just dont know how loll.. didnt wanna ask for it cause i try not to annoy people for small things, looks great though! appreciate the help
 
No prob. Don't be afraid to ask for help, just just don't spam and be patient for replies. :)
im gonna try to see if i can change it to a "blind" mode like in wow too.. where the effect of creature moving and condition silence cancels if they are attacked.. this is harder though and probly needs a loop or somethin in between lol idk

To make this work you need an creatureevent onAttack script, its actually easier than it sounds.

Add to configuration on both spell and creature script:
Code:
local fearStorage = 1234 -- Storagevalue not in use

Creaturescript:
Code:
function onAttack(cid, target)
  if isPlayer(target) then
    if getPlayerStorageValue(target, fearStorage) > 0 then
      setPlayerStorageValue(target, fearStorage, 0)
      doCreatureSetNoMove(target, false) -- Let them move again
    end
  end
  return true
end
Note: To make creatureevent scripts work on players they need to be added to creatureevents.xml and registered in login.lua

The new "fear" function from spell script:
Code:
local function fear(cid)
  if isMonster(cid) or isPlayer(cid) and getPlayerStorageValue(cid, fearStorage) > 0 then
    local cpos = getCreaturePosition(cid)
    local dir = {}
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
      table.insert(dir, NORTH)
    end
    if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, WEST)
    end
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
      table.insert(dir, SOUTH)
    end
    if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, EAST)
    end
    if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
    end
  end
end

Ohh yeah and give storage value before you add the 0.5 tick addevent codes:
Code:
setPlayerStorageValue(target, fearStorage, 1)
 
No prob. Don't be afraid to ask for help, just just don't spam and be patient for replies. :)


To make this work you need an creatureevent onAttack script, its actually easier than it sounds.

Add to configuration on both spell and creature script:
Code:
local fearStorage = 1234 -- Storagevalue not in use

Creaturescript:
Code:
function onAttack(cid, target)
  if isPlayer(target) then
    if getPlayerStorageValue(target, fearStorage) > 0 then
      setPlayerStorageValue(target, fearStorage, 0)
      doCreatureSetNoMove(target, false) -- Let them move again
    end
  end
  return true
end
Note: To make creatureevent scripts work on players they need to be added to creatureevents.xml and registered in login.lua

The new "fear" function from spell script:
Code:
local function fear(cid)
  if isMonster(cid) or isPlayer(cid) and getPlayerStorageValue(cid, fearStorage) > 0 then
    local cpos = getCreaturePosition(cid)
    local dir = {}
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
      table.insert(dir, NORTH)
    end
    if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, WEST)
    end
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
      table.insert(dir, SOUTH)
    end
    if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, EAST)
    end
    if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
    end
  end
end

Ohh yeah and give storage value before you add the 0.5 tick addevent codes:
Code:
setPlayerStorageValue(target, fearStorage, 1)

thankss once again man, i tried it out and im pretty sure i installed it the way you told me to, but when i have the setStorage from the spell script on the addevent from the 0.5 i codes, it just moves the player once.. and also, was wondering, the onAttack reacts when? when a spell is made? i was thinking maybe onStatsChange would work better, so like, if the person has a fire on him, it would also cancel when the fire ticks while he is "feared".. im gonna try to use onstats change but im new to this lua stuff so ill show you what i got unless you have time and beat me to it haha, thanks!

EDIT: Sorry, in short, idk if its easier or not, but basically, while the person is "feared" ANY type of damage would take him out of it.. weather its aoe, melee, spell anything.. only reason why i thought of stats change. thanks! if its not possible its cool, everyone helped more then enough with the fear spell itself
 
Last edited:
Well, i dont know if i would call this piece code fear. Mine works that it move away from the "target", the one which cast fear. It makes just more sense, if something scare you, you move away from it, not randomly and maybe you randomly move towards to that player.
 
Well, i dont know if i would call this piece code fear. Mine works that it move away from the "target", the one which cast fear. It makes just more sense, if something scare you, you move away from it, not randomly and maybe you randomly move towards to that player.

its based on the wow spell fear which they run at random directions :p but yea what you say makes sense as well
 
spell:
Code:
-- >>Script by Tabz!<< --
--{Credits:Zyntax, Tabz, Znote}

-- Level 1 - 10 --

--.::.CONFIG.::.--
local feared_time = 2.5 -- total duration
local feared_tick = 0.5 -- Move frequency
local fearStorage = 6891 -- Fearstorage
--.::.CONFIG.::.--

local function fear(cid)
  if isMonster(cid) or isPlayer(cid) and getPlayerStorageValue(cid, fearStorage) > 0 then
    local cpos = getCreaturePosition(cid)
    local dir = {}
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
      table.insert(dir, NORTH)
    end
    if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, WEST)
    end
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
      table.insert(dir, SOUTH)
    end
    if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, EAST)
    end
    if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
    end
  end
end

local function allowMove(cid, target)
  if isPlayer(cid) and isCreature(target) then
  doCreatureSetNoMove(target, false)
  end
end

local silenced = createConditionObject(CONDITION_MUTED)
setConditionParam(silenced, CONDITION_PARAM_TICKS, (feared_time*1000))

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
  doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), CONST_ANI_SMALLSTONE)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BATS)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
  doCreatureSetNoMove(target, true)
  doAddCondition(cid, silenced)

  -- Add storage value
  setPlayerStorageValue(target, fearStorage, 1)

  -- Addevent every 500ms of feared_times duration
  i = 0
  while i <= feared_time * 1000 do
    addEvent(fear, i, target)
    i = i + (feared_tick * 1000)
  end

  addEvent(allowMove, (feared_time*1000), cid, target)
  return true
end

creaturescript fearcheck.lua
Code:
local fearStorage = 6891 -- Fearstorage

function onAttack(cid, target)
    if isPlayer(target) then
        if getPlayerStorageValue(target, fearStorage) > 0 then
            setPlayerStorageValue(target, fearStorage, 0)
            doCreatureSetNoMove(target, false) -- Let them move again
        end
    end
    return true
end

bottom of login.lua below other creature events:
Code:
registerCreatureEvent(cid, "FearCheck")

creaturescript.xml
Code:
<event type="attack" name="FearCheck" event="script" value="fearcheck.lua"/>
 
spell:
Code:
-- >>Script by Tabz!<< --
--{Credits:Zyntax, Tabz, Znote}

-- Level 1 - 10 --

--.::.CONFIG.::.--
local feared_time = 2.5 -- total duration
local feared_tick = 0.5 -- Move frequency
local fearStorage = 6891 -- Fearstorage
--.::.CONFIG.::.--

local function fear(cid)
  if isMonster(cid) or isPlayer(cid) and getPlayerStorageValue(cid, fearStorage) > 0 then
    local cpos = getCreaturePosition(cid)
    local dir = {}
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y-1,z=cpos.z}) == 1 then
      table.insert(dir, NORTH)
    end
    if queryTileAddThing(cid, {x=cpos.x-1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, WEST)
    end
    if queryTileAddThing(cid, {x=cpos.x,y=cpos.y+1,z=cpos.z}) == 1 then
      table.insert(dir, SOUTH)
    end
    if queryTileAddThing(cid, {x=cpos.x+1,y=cpos.y,z=cpos.z}) == 1 then
      table.insert(dir, EAST)
    end
    if #dir > 0 then
     doMoveCreature(cid, dir[math.random(1,#dir)])
    end
  end
end

local function allowMove(cid, target)
  if isPlayer(cid) and isCreature(target) then
  doCreatureSetNoMove(target, false)
  end
end

local silenced = createConditionObject(CONDITION_MUTED)
setConditionParam(silenced, CONDITION_PARAM_TICKS, (feared_time*1000))

function onCastSpell(cid, var)
local target = getCreatureTarget(cid)
  doSendDistanceShoot(getCreaturePosition(cid), getCreaturePosition(target), CONST_ANI_SMALLSTONE)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BATS)
  doSendMagicEffect(getCreaturePosition(target), CONST_ME_BLOCKHIT)
  doCreatureSetNoMove(target, true)
  doAddCondition(cid, silenced)

  -- Add storage value
  setPlayerStorageValue(target, fearStorage, 1)

  -- Addevent every 500ms of feared_times duration
  i = 0
  while i <= feared_time * 1000 do
    addEvent(fear, i, target)
    i = i + (feared_tick * 1000)
  end

  addEvent(allowMove, (feared_time*1000), cid, target)
  return true
end

creaturescript fearcheck.lua
Code:
local fearStorage = 6891 -- Fearstorage

function onAttack(cid, target)
    if isPlayer(target) then
        if getPlayerStorageValue(target, fearStorage) > 0 then
            setPlayerStorageValue(target, fearStorage, 0)
            doCreatureSetNoMove(target, false) -- Let them move again
        end
    end
    return true
end

bottom of login.lua below other creature events:
Code:
registerCreatureEvent(cid, "FearCheck")

creaturescript.xml
Code:
<event type="attack" name="FearCheck" event="script" value="fearcheck.lua"/>

damn, i literally just copied everything exactly the way you told me.. im not sure why its not working.. it moves the guy once and thats it =/
im using cryingdamson 0.3.6 8.6 client.. maybe its my distro or something?

EDIT: @Znote i mean im lookin at the script and i dont see why its not working.. itll probably do the cancel effect correctly but i cant seem to even check that because the player doesnt move enough.. he just moves once.. maybe the storage checking or something is affecting the moveplayer loop?
 
I don't think there is anything wrong with your TFS version
Ohh 0.3.6 is like the worst version out there. :/
Anyway I don't think it affects this functionality.

Maybe the spell instantly trigger the onattack event(since well, it is an attack) thus resulting in him loosing fear imediately?
If so there should be a fairly easy workaround.

You can just add some message commands to debug what is happening, etc doplayersendtextmessage~ when dispelled, confirm what goes wrong first. Then a fix will come.
 
Last edited:
You were right! i put the message on the onattack script (since thats the dispel right?) and it gave me the message i put. so yea im guessing the spell itself triggers cancel, is there a way to fix this adding time or something?

@Znote
 
Yeah by some easy steps we can just differentiate the storage value and figure out if player got hit by spell or not.
Code:
function onAttack(cid, target)
    if isPlayer(target) then
        -- If player is under fear spell
        if getPlayerStorageValue(target, fearStorage) > 0 then
            -- If player is feared, dispell
            if getPlayerStorageValue(target, fearStorage) == 1 then
               setPlayerStorageValue(target, fearStorage, 0)
               doCreatureSetNoMove(target, false) -- Let them move again
           -- If player just got hit by the spell
           elseif getPlayerStorageValue(target, fearStorage) > 1 then
              -- Maybe also add some cool screaming sound effects? :)
              setPlayerStorageValue(target, fearStorage, 1)
           end
        end
    end
    return true
end

in the onCastSpell, instead of giving him storage value 1, give him storage value 2. :)
Code:
  -- Add storage value
setPlayerStorageValue(target, fearStorage, 2)
 
Back
Top