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

Miss System

Booker

New Member
Joined
Apr 2, 2015
Messages
46
Reaction score
4
Hi, i'd like to know how can i make spell which makes my target Blind for x seconds. Whats is blind? When the target tries to cast a spell, he doesn't and appears a "miss" message.

I have a mud shot spell which leaves the opponent with miss, but dunno how to put this in another spell:

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, GROUNDDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 34)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 38)

function onCastSpell(cid, var)
if getPlayerStorageValue(cid, 8) >= 1 then
    return true
end

    doCreatureSay(cid, "MUD SHOT!", TALKTYPE_MONSTER)
    if getPlayerStorageValue(cid, 3) >= 1 then
    doSendAnimatedText(getThingPos(cid), "MISS", 215)
    setPlayerStorageValue(cid, 3, -1)
    return true
    end
    if getPlayerStorageValue(cid, 5) >= 1 then
        if math.random(1,100) <= 33 then
        doSendAnimatedText(getThingPos(cid), "SELF HIT", 180)
            if isPlayer(getCreatureTarget(cid)) then
            huah = getPlayerLevel(getCreatureTarget(cid))
            else
            huah = getPlayerLevel(getCreatureMaster(getCreatureTarget(cid)))
            end
        local levels = huah
        doTargetCombatHealth(getCreatureTarget(cid), cid, COMBAT_PHYSICALDAMAGE, -(math.random((levels*3),(levels*5))), -((math.random((levels*3),(levels*5))+10)), 3)
        return true
        end
    end
setPlayerStorageValue(getCreatureTarget(cid), 3, 1)
    local function backg(params)
    if isCreature(params.cid) then
    if isCreature(getCreatureTarget(cid)) then
    if getPlayerStorageValue(getCreatureTarget(cid), 3) >= 1 then
    setPlayerStorageValue(getCreatureTarget(cid), 3, -1)
    end
    end
    end
    end
doCombat(cid, combat, var)
    local function effect(params)
    if isCreature(params.cid) then
    if getPlayerStorageValue(params.cid, 3) >= 1 then
    doSendMagicEffect(getThingPos(params.cid), 34)
    end
    end
    end
addEvent(backg, 3500, {cid = cid})
local aqrvui = getCreatureTarget(cid)
for vx = 1, 7 do
addEvent(effect, vx*500, {cid = aqrvui})
end
return true
end

Note that i just want the part that makes the opponent "blind" and missing his spells.

If anyone can help, all information is nice ;)
PS: TFS 0.4
 
Last edited:
Solution
No, you need to make a spell or smth what can "blind" a player. Then in creaturescripts check if someone have blind, if yes, you need to change his dmg to 0 (return false)

example spell:
Code:
function onTargetTile(cid, pos)
   local timer = 5 -- how long miss will exist, in seconds
   local player = getTopCreature(pos)
   if isPlayer(player.uid) then
       setPlayerStorageValue(player.uid, 1111, 1)
       addEvent(function()
           if isPlayer(player.uid) then
               setPlayerStorageValue(player.uid, 1111, -1)
           end
       end, timer * 1000)
       return true
   end
   return false
end

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat...
can be done with onStatsChange
In spell.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, GROUNDDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 34)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 38)

local blindtime = 8*1000

function onCastSpell(creature, variant)
    if not getCreatureTarget(creature) ~= 0 then
        return false
    end
    local target = getCreatureTarget(creature)
    doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You have been blinded!")
    registerCreatureEvent(target, "blind")
    addEvent(function()
     if target ~= 0 then
        doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You are no longer blind.")
        unregisterCreatureEvent(target, "blind")
     end
    end,blindtime)
    return doCombat(creature, combat, variant)
end
in creaturescripts.xml
XML:
    <event type="onStatsChange" name="blind" script="blind.lua" />
in blind.lua
Lua:
local chance = 40 -- chance to miss
function onStatsChange(cid, attacker, type, combat, value)
    if type ~= STATSCHANGE_MANALOSS then
        return true
    end
    if not attacker then
        if math.random(1,100) < chance then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You failed to cast this spell because you were blinded!!")
            return false
        end
    end
return true
end
 
Last edited:
Lua:
    addEvent(function()
        doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You are no longer blind.")
        unregisterCreatureEvent(creature, "blind")
    end,blindtime)

This part will cause a crash, if target die while executing an addEvent.
 
then a
Lua:
if not target ~=0 then
is needed, I have updated
This one instead is double negative, so script will seek if target is 0.
Also you should use nil instead i believe.

Additionally, if target wouoldn't exist and addEvent wouldn't run, event "blind.lua" wouldn't be unregistered till next try.
 
can be done with onStatsChange
In spell.lua
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, GROUNDDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 34)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 38)

local blindtime = 8*1000

function onCastSpell(creature, variant)
    if not getCreatureTarget(creature) ~= 0 then
        return false
    end
    local target = getCreatureTarget(creature)
    doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You have been blinded!")
    registerCreatureEvent(target, "blind")
    addEvent(function()
     if target ~= 0 then
        doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You are no longer blind.")
        unregisterCreatureEvent(target, "blind")
     end
    end,blindtime)
    return doCombat(creature, combat, variant)
end
in creaturescripts.xml
XML:
    <event type="onStatsChange" name="blind" script="blind.lua" />
in blind.lua
Lua:
local chance = 40 -- chance to miss
function onStatsChange(cid, attacker, type, combat, value)
    if type ~= STATSCHANGE_MANALOSS then
        return true
    end
    if not attacker then
        if math.random(1,100) < chance then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You failed to cast this spell because you were blinded!!")
            return false
        end
    end
return true
end
Hey thanks for helping out, although it didn't work at all.
I changed event type from "OnStatsChange" to "statschange" in .xml cause it was causing errors, now there is none, but the miss spell won't even cast. Nothing appears when i say the words.

This is getting complicated o_O
 
Try it with a condition
spell.lua
Lua:
local blindtime = 8*1000

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, GROUNDDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 34)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 38)
    local condition = createConditionObject(CONDITION_PARALYZE)
    setConditionParam(condition, CONDITION_PARAM_SUBID, 10)
    setConditionParam(condition, CONDITION_PARAM_TICKS, blindtime)
    setCombatCondition(combat, condition)
function onCastSpell(creature, variant)
    if not getCreatureTarget(creature) ~= 0 then
        return false
    end
    local target = getCreatureTarget(creature)
    doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You have been blinded!")
    return doCombat(creature, combat, variant)
end
creaturescripts.xml
XML:
   <event type="login" name="blindlogin" script="blind.lua"/>
 <event type="onstatschange" name="blind" script="blind.lua" />
blind.lua
Lua:
local chance = 40 -- chance to miss
function onLogin(player)
    registerCreatureEvent(player, "blind")
     return true
end
function onStatsChange(cid, attacker, type, combat, value)
if type ~= STATSCHANGE_MANALOSS then
    return true
end
    if getCreatureCondition(cid, CONDITION_PARALYZE, 10) == true then
        if not attacker then
            if math.random(1,100) < chance then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You failed to cast this spell because you were blinded!")
                return false
            end
        end
    end
    return true
end
 
Last edited:
Try it with a condition
spell.lua
Lua:
local blindtime = 8*1000

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, GROUNDDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 34)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 38)
    local condition = createConditionObject(CONDITION_NONE)
    setConditionParam(condition, CONDITION_PARAM_SUBID, 10)
    setConditionParam(condition, CONDITION_PARAM_TICKS, blindtime)
    setCombatCondition(combat, condition)
function onCastSpell(creature, variant)
    if not getCreatureTarget(creature) ~= 0 then
        return false
    end
    local target = getCreatureTarget(creature)
    doPlayerSendTextMessage(target, MESSAGE_INFO_DESCR, "You have been blinded!")
    return doCombat(creature, combat, variant)
end
creaturescripts.xml
XML:
   <event type="login" name="blindlogin" script="blind.lua"/>
 <event type="onstatschange" name="blind" script="blind.lua" />
blind.lua
Lua:
local chance = 40 -- chance to miss
function onLogin(player, target)
    registerCreatureEvent(target, "blind")
     return true
end
function onStatsChange(cid, attacker, type, combat, value)
if type ~= STATSCHANGE_MANALOSS then
    return true
end
    if getCreatureCondition(cid, CONDITION_NONE, 10) == true then
        if not attacker then
            if math.random(1,100) < chance then
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"You failed to cast this spell because you were blinded!")
                return false
            end
        end
    end
    return true
end
Nope:
75Ixl2j.png
 
lol sorry forgot to change
XML:
    registerCreatureEvent(target, "blind")
to
XML:
    registerCreatureEvent(player, "blind")
fixed
EDIT:
why does onLogin even have a target argument (when does a player who just logged in have a target?)
EDIT: seems that was just a mistake on my part, carry on
 
lol sorry forgot to change
XML:
    registerCreatureEvent(target, "blind")
to
XML:
    registerCreatureEvent(player, "blind")
fixed
EDIT:
why does onLogin even have a target argument (when does a player who just logged in have a target?)
EDIT: seems that was just a mistake on my part, carry on
Okay, so now we have this issue on the spell script:
3qltePh.png
 
could be because I used CONDITION_NONE but I couldn't think of another appropriate try CONDITION_PARALYZE instead
EDIT: updated
 
@GarQet
Casts the spell now, but the miss still doesn't work. I'm casting my spells normally and no message appears.

@Aled
Still not casting it =/
The spell does need a target to cast
It's probably better done with storages anyway, let GarQet help you
I was only trying to offer an alternative
 
@Aled
Appreciate your effort man, thanks ;)

@GarQet
Holy S*, it's finally working. If you are sick of this, can stop now (already gave best answer). BUT, if there is a way to make the effect/distanceeffect not appear too when misses, it would be awesome. Anyway, thanks for all dude.
 
@Booker , If you dont want to see effects you need to remove statschange scripts and add this:
Code:
function onAttack(cid, target)
   if isPlayer(cid) and getPlayerStorageValue(cid, 1111) == 1 then
       doSendAnimatedText(getCreaturePosition(cid), "MISS!", TEXTCOLOR_WHITE)
       return false
   end
   return true
end
Code:
function onCombat(cid, target)
   if isPlayer(cid) and getPlayerStorageValue(cid, 1111) == 1 then
       doSendAnimatedText(getCreaturePosition(cid), "MISS!", TEXTCOLOR_WHITE)
       return false
   end
   return true
end
You need to register 2 scripts in login.lua and add 2 lanes to creaturescripts.xml

Hope it will work :p
 
Back
Top