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

same thing, it gives me the "youre free" cancel i put under the dispel.. he stops after one move and sends me the message >.<

@Znote
 
I think you should use onStatChange() since onAttack will be triggered as soon as you "click" the target resulting in the problem you have now :)

do StatChange and it will work!
 
How many times is onAttack being triggered after the spell?

Its getting triggered only once after the attack, i've been playing around w the script but havent been able to come up with anything : /

I think you should use onStatChange() since onAttack will be triggered as soon as you "click" the target resulting in the problem you have now :)

do StatChange and it will work!

thanks for the idea, im not really sure how to use onStatChange that well but yea i said the same thing earlier, i want conditions like fire and poison to take it off too, and aoe spells, would you be able to guide me a little better?

thanks in advance to both of you!
 
just replace onAttack with onStatsChange()
and edit the creaturescripts.xml from "attack" to "statchange"
this should do it
CAUTION:
My guess is that the Player will be freed of the fear Status if he loses HEALTH !
if he dodges 2 attacks or they are blocked then he will remain in the fear Status!

But even poison/fire/energy dmg will lift the effect
 
just replace onAttack with onStatsChange()
and edit the creaturescripts.xml from "attack" to "statchange"
this should do it
CAUTION:
My guess is that the Player will be freed of the fear Status if he loses HEALTH !
if he dodges 2 attacks or they are blocked then he will remain in the fear Status!

But even poison/fire/energy dmg will lift the effect

Thats exactly how i want it ;) quick question, does i need to put like, (cid, attacker, etc) and all these other things ive seen inside the onStatsChange()? or does cid, target suffice?
 
Code:
onStatsChange(cid, target, attacker)
PHP:
event type="statchange"
if im not mistaken :p

Yea, i tried it out, and it lets the player move again but doesnt remove him when he loses health after hes feared >.< i feel like the script is so close its just missing something so small haha in both statschange or attack lmao i think statschange is better for this though
 
Did you replace
Code:
if isPlayer(target)
to
Code:
if isPlayer(cid)
?
You need to check for the person who's losing health now, not the attacker!

like this:
Code:
function onStatChange(cid, target, attacker)
if isPlayer(cid) then
-- If player is under fear spell
if getPlayerStorageValue(cid, fearStorage) > 0 then
-- If player is feared, dispell
if getPlayerStorageValue(cid, fearStorage) == 1 then
setPlayerStorageValue(cid, fearStorage, 0)
doCreatureSetNoMove(cid, false) -- Let them move again
-- If player just got hit by the spell
elseif getPlayerStorageValue(cid, fearStorage) > 1 then
-- Maybe also add some cool screaming sound effects? :)
setPlayerStorageValue(cid, fearStorage, 1)
end
end
end
return true
end
should do it ... iguess ^^
 
Did you replace
Code:
if isPlayer(target)
to
Code:
if isPlayer(cid)
?
You need to check for the person who's losing health now, not the attacker!

like this:
Code:
function onStatChange(cid, target, attacker)
if isPlayer(cid) then
-- If player is under fear spell
if getPlayerStorageValue(cid, fearStorage) > 0 then
-- If player is feared, dispell
if getPlayerStorageValue(cid, fearStorage) == 1 then
setPlayerStorageValue(cid, fearStorage, 0)
doCreatureSetNoMove(cid, false) -- Let them move again
-- If player just got hit by the spell
elseif getPlayerStorageValue(cid, fearStorage) > 1 then
-- Maybe also add some cool screaming sound effects? :)
setPlayerStorageValue(cid, fearStorage, 1)
end
end
end
return true
end
should do it ... iguess ^^

This one didnt work for me, i did it with @Znote script earlier and it did work! i changed it to onStats.. so this was it
Code:
local fearStorage = 7000 -- Fearstorage

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

and set storage to 1 in spell.. it works perfectly.. thanks to both of you!
 
Back
Top