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

Chance of monster spawning when casting spell & other

PeteZa

 Magic Developer
Joined
Nov 2, 2014
Messages
91
Reaction score
63
Hi!

So I wanted someone to help me write a few scripts as I'm not good enough of a scripter to do it myself. I don't even know if that's possible to do without going to the sources, which is what I'd like.
I'M USING TFS 1.1


Ok so let's get to my requests:

1. What I want is when you cast a certain spell, there would be for example 5% chance of a monster spawning and attacking the person that casted the spell

2. Ok so the second thing I'd want is if you click on a certain item/tile with for example actionID/uniqueID 666 you'd get 1 level of fishing and you could only use that item once and when you try to click it second time it does nothing but displays text saying "Can't use it twice."

Thank you in advance for help.
 
Last edited:
Both are possible, I don't really have time right now to write it for you but maybe someone else can help you :)
 
-- Not tested.

--Add this to the spell script you want
Code:
    if math.random(1,100) == 5 then
        local monster = Game.createMonster("MONSTERS NAME", player:getPosition(), false, true)
        Creature(monster):setTarget(player)
    end


-- Fishing script.
Code:
local cfg = {
    storage = xxx, --The storage value you want to use.
    failMsg = "You can only use it once", -- Msg when the person uses it again.
    sucessMsg = "Congratulations you\'ve gained 1 fishing skill", -- Msg when the player uses it the first time
    skillType = SKILL_FISHING, -- The skill type.
}
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(cfg.storage) > 0 then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, cfg.failMsg)
        return true
    end
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, cfg.sucessMsg)
        player:setStorageValue(cfg.storage, 1)  
        player:addSkillTries(skillType, (player:getVocation():getRequiredSkillTries(skillType, target:getSkillLevel(skillType) + 1) - - target:getSkillTries(skillType)))
        player:getPosition():sendMagicEffect(29)
    return true
end

Hope it works.
Regards Alw
 
-- Not tested.

--Add this to the spell script you want
Code:
    if math.random(1,100) == 5 then
        local monster = Game.createMonster("MONSTERS NAME", player:getPosition(), false, true)
        Creature(monster):setTarget(player)
    end
for the math.random you have it as 1% at the moment.
== 5.. is the same as == 86, still 1% chance.
Also you don't need to specify the range, as it always start at 1 anyways.
Code:
if math.random(100) <= 5 then
 
Back
Top