• 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...
Just add storage with timer to player which have blind, then in statschange (during the attack) make all hits as miss (return false).
 
Just add storage with timer to player which have blind, then in statschange (during the attack) make all hits as miss (return false).
Can you explain better? :eek:
I mean, you are saying the spell needs to give it's target a storage value, that will stand for 5 seconds:
Lua:
setPlayerStorageValue(cid, 22334, os.time() + 1*50*50*2)
And this storage will make the player return false on casting a spell?
 
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, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)
setCombatCallback(combat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
   return doCombat(cid, combat, var)
end
creaturescripts:
Code:
function onStatsChange(cid, attacker, type, combat, value)
   if isPlayer(attacker) and (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and getPlayerStorageValue(attacker, 1111) == 1 then
       doSendAnimatedText(getCreaturePosition(attacker), "MISS!", TEXTCOLOR_WHITE)
       return false
   end
   return true
end
add this to login.lua
Code:
setPlayerStorageValue(cid, 1111, -1)
registerCreatureEvent(cid, "miss")
 
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:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SUDDENDEATH)

function onCastSpell(cid, var)
   return doCombat(cid, combat, var) and setPlayerStorageValue(var, 1111, os.time())
end
creaturescripts:
Code:
function onStatsChange(cid, attacker, type, combat, value)
   local blind_time = 5 -- in seconds
   if isPlayer(attacker) and (type == STATSCHANGE_HEALTHLOSS or STATSCHANGE_MANALOSS) and (os.time() - getPlayerStorageValue(cid, 1111)) >= blind_time then
       doSendAnimatedText(getCreaturePosition(attacker), "MISS!", TEXTCOLOR_WHITE)
       return false
   end
   return true
end
Okay, think i'm getting it now. What should be my event type in creaturescripts.xml?
 
Done, but now another issue:
NGA5AIP.png
 
HTML:
<?xml version="1.0" encoding="UTF-8"?>

<creaturescripts>
    <event type="login" name="PlayerLogin" event="script" value="login.lua"/>

    <event type="joinchannel" name="GuildMotd" event="script" value="guildmotd.lua"/>
    <event type="receivemail" name="Mail" event="script" value="mail.lua"/>
    <event type="reportbug" name="SaveReportBug" script="reportbug.lua"/>
    <event type="advance" name="AdvanceSave" event="script" value="advancesave.lua"/>
   
    <event type="death" name="PlayerPokeDeath" event="script" value="playerpdeath.lua"/>
    <event type="death" name="DiePoke" event="script" value="goback.lua"/>
    <event type="logout" name="LogoutPoke" event="script" value="goback.lua"/>
    <event type="login" name="LoginPoke" event="script" value="goback.lua"/>


    <event type="moveitem" name="MoveItem" event="script" value="moveitem.lua"/>
    <event type="statschange" name="miss" event="script" value="blind.lua"/>


    <event type="think" name="Idle" event="script" value="idle.lua"/>
    <event type="think" name="SkullCheck" event="script" value="skullcheck.lua"/>
   
    <!-- script de outfit por voc.
    <event type="login" name="LoginClass" event="script" value="vocouts.lua"/>
    <event type="outfit" name="OutfitClass" event="script" value="vocouts.lua"/> -->
   
</creaturescripts>

Lua:
local config = {
    loginMessage = getConfigValue('loginMessage'),
    useFragHandler = getBooleanFromString(getConfigValue('useFragHandler'))
}

function onLogin(cid)
    local loss = getConfigValue('deathLostPercent')
    if(loss ~= nil) then
        doPlayerSetLossPercent(cid, PLAYERLOSS_EXPERIENCE, loss * 10)
    end

    local accountManager = getPlayerAccountManager(cid)
    if(accountManager == MANAGER_NONE) then
        local lastLogin, str = getPlayerLastLoginSaved(cid), config.loginMessage
        if(lastLogin > 0) then
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
            str = "Your last visit was on " .. os.date("%a %b %d %X %Y", lastLogin) .. "."
        else
            str = str .. " Please choose your outfit."
            doPlayerSendOutfitWindow(cid)
        end

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_DEFAULT, str)
    elseif(accountManager == MANAGER_NAMELOCK) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, it appears that your character has been namelocked, what would you like as your new name?")
    elseif(accountManager == MANAGER_ACCOUNT) then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to manage your account and if you want to start over then type 'cancel'.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Hello, type 'account' to create an account or type 'recover' to recover an account.")
    end

    if(not isPlayerGhost(cid)) then
        doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
    end

    registerCreatureEvent(cid, "Mail")
    registerCreatureEvent(cid, "MoveItem")
    registerCreatureEvent(cid, "GuildMotd")
    registerCreatureEvent(cid, "statschange")

    registerCreatureEvent(cid, "Idle")
    if(config.useFragHandler) then
        registerCreatureEvent(cid, "SkullCheck")
    end
    registerCreatureEvent(cid, "ReportBug")
    registerCreatureEvent(cid, "AdvanceSave")
    return true
end
 
Where it is?
Code:
registerCreatureEvent(cid, "miss")
My bad. It is "working" now, although the blind effect never wores off (i can't do damage anymore) plus: the move effect can't be casted when blind, so the player has sure the move missed, can you do that change? Thanks for the help so far and sorry for the newbie skills
 
Player cannot move? Updated, check now.
Player is moving normally.
Updated and now not working anymore, no miss o_O

Change was => to <= right?
It is exactly how you posted, just added the 2 lines to the spell:
Lua:
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -10, -1, -20, 5, 5, 1.4, 2.1)
 
Back
Top