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

[Request] Select different effects with saving

henkas

Well-Known Member
Joined
Jul 8, 2015
Messages
993
Solutions
5
Reaction score
55
Hi
maybe someone have system that works like this. Lets say you create floors that looks like this
Untitled.png

So Red floor - has unique id lets say 1000,
Orange floor - id is 1001
So when you walk on these floor you you get teleported to x,y,z and you get custome MagicEffect which should be saved on database probably these effects should contain variables because later it would be nice to use it as spell like you type lets say "power up" and it applies that custome effect you selected from floor. Sorry if i'm asking to much.

Using TFS 1.2
Client 8.60
 
Solution
here the solution with utevo lux spell!
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 6)
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215)
condition:setParameter(CONDITION_PARAM_TICKS, (6 * 60 + 10) * 1000)
combat:setCondition(condition)

local storageLoadEffect = 66655
function onCastSpell(creature, variant)
    if combat:execute(creature, variant) then
        local loadEffect = math.max(1, creature:getStorageValue(storageLoadEffect))
        creature:getPosition():sendMagicEffect(loadEffect)
        return true
    end
    return false
end

---# Movement script
local effects = {
    [9000] =...
Why doesn't it help at all?
When you step on the tiles you set a storage that signifies that the player has received the magic effect.
When you say "power up" you set another storage that marks which effect is currently active.
 
Why doesn't it help at all?
When you step on the tiles you set a storage that signifies that the player has received the magic effect.
When you say "power up" you set another storage that marks which effect is currently active.
In this case the "power up" reads the storage with the selected magic effect. ^^
Ty for saving my time s2

@henkas Sorry but "at all" isn't enough for me
Just tried to help
 
Last edited:
@henkas

movements.xml
Lua:
<movevent event="StepIn" itemid="YOUR TILE ID" script="spell_tile.lua" />

movements/scripts/spell_tile.lua
Lua:
local config = {
[9000] = 10, -- [uniqueid] = magiceffect
[9001] = 20
}

function onStepIn(player, item)
    if not item:hasAttribute(ITEM_ATTRIBUTE_UNIQUEID) then
        return false
    end

    player:setStorageValue(90000, config[item.uid]) -- 90000 is the storage saving the magic effect
    return true
end

spells/scripts/yourspell.lua
Lua:
function onCastSpell(creature, variant)
    combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
    return combat:execute(creature, variant)
end
 
@henkas

movements.xml
Lua:
<movevent event="StepIn" itemid="YOUR TILE ID" script="spell_tile.lua" />

movements/scripts/spell_tile.lua
Lua:
local config = {
[9000] = 10, -- [uniqueid] = magiceffect
[9001] = 20
}

function onStepIn(player, item)
    if not item:hasAttribute(ITEM_ATTRIBUTE_UNIQUEID) then
        return false
    end

    player:setStorageValue(90000, config[item.uid]) -- 90000 is the storage saving the magic effect
    return true
end

spells/scripts/yourspell.lua
Lua:
function onCastSpell(creature, variant)
    combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
    return combat:execute(creature, variant)
end
But does it save in database? I'm pretty sure i will disappear when server will be reloaded. Btw thanks i'll try it out soon
 
But does it save in database? I'm pretty sure i will disappear when server will be reloaded. Btw thanks i'll try it out soon
For sure! ^^
Storages are saved by player id in your database.
Look for the table "players_storage"

edit: You need to re-log to refresh a player's storages plus you need to be offline to edit it.
 
Please, post your spell script.
  1. function onCastSpell(creature, variant)
  2. combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
  3. return combat:execute(creature, variant)
  4. end
i just added how you said. Or you mean other spell just like an example? if yes
Code:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   creature:addManaSpent(amount)
   creature:addMana(-amount)
   creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
   return true
end
 
  1. function onCastSpell(creature, variant)
  2. combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
  3. return combat:execute(creature, variant)
  4. end
i just added how you said. Or you mean other spell just like an example? if yes
Code:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   creature:addManaSpent(amount)
   creature:addMana(-amount)
   creature:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
   return true
end

Explain what your "aura" spell should do.
To test mine I just removed the original effect parameter from exori added the new one (it MUST be inside function onCastSpell(creature, variant) so script execute the creature:getStorageValue function properly)

Original berserk.lua:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

Edited berserk.lua:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
-- combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
    return combat:execute(creature, variant)
end
 
Explain what your "aura" spell should do.
To test mine I just removed the original effect parameter from exori added the new one (it MUST be inside function onCastSpell(creature, variant) so script execute the creature:getStorageValue function properly)

Original berserk.lua:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

Edited berserk.lua:
Lua:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
-- combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(AREA_SQUARE1X1))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (player:getLevel() / 5) + (skill * attack * 0.03) + 7
    local max = (player:getLevel() / 5) + (skill * attack * 0.05) + 11
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
    return combat:execute(creature, variant)
end
So yea that aura spell should bright everything around when you are walking around dark areas in tibia, and when you type aura and everything becomes light but its not so important i saw otland has this function made already, but the whole point is to apply different effect when you type that command so thats why i mentioned there is floors and when you walk into that floor you get certain effect like lets say there is 5 floor every of them hold different effects lets say you want to pick third one so that third one gives you effect if you pick first one it has different effect and it should show that certain effect when you type that command
 
So yea that aura spell should bright everything around when you are walking around dark areas in tibia, and when you type aura and everything becomes light but its not so important i saw otland has this function made already, but the whole point is to apply different effect when you type that command so thats why i mentioned there is floors and when you walk into that floor you get certain effect like lets say there is 5 floor every of them hold different effects lets say you want to pick third one so that third one gives you effect if you pick first one it has different effect and it should show that certain effect when you type that command

So is it like an utevo lux but with a magiceffect chosen by the player?
Lua:
-- Aura spell based on utevo lux
local combat = Combat()
-- removed original effect (CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 6) -- Light intensity
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215) -- Light color
condition:setParameter(CONDITION_PARAM_TICKS, (6 * 60 + 10) * 1000) -- Light time
combat:addCondition(condition)

function onCastSpell(creature, variant)
    combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
    return combat:execute(creature, variant)
end

256 Colors - Cheat Sheet - Xterm, HEX, RGB, HSL -- color table
 
So is it like an utevo lux but with a magiceffect chosen by the player?
Lua:
-- Aura spell based on utevo lux
local combat = Combat()
-- removed original effect (CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local condition = Condition(CONDITION_LIGHT)
condition:setParameter(CONDITION_PARAM_LIGHT_LEVEL, 6) -- Light intensity
condition:setParameter(CONDITION_PARAM_LIGHT_COLOR, 215) -- Light color
condition:setParameter(CONDITION_PARAM_TICKS, (6 * 60 + 10) * 1000) -- Light time
combat:addCondition(condition)

function onCastSpell(creature, variant)
    combat:setParameter(COMBAT_PARAM_EFFECT, creature:getStorageValue(90000)) -- reading the storage to set the selected effect
    return combat:execute(creature, variant)
end

256 Colors - Cheat Sheet - Xterm, HEX, RGB, HSL -- color table
Yea exactly
Untitled.png
 
So yea i tested this function but it doesnt work properly technically it should apply this effect into aura spell
[9001] = 81 -- [uniqueid] = magiceffect
but all it does is just takes random effect and applys into aura spell so it doesnt really read the storage.
 
@henkas
You gave us this script so I think it's your spells' basic structure.
Try:
Lua:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   creature:addManaSpent(amount)
   creature:addMana(-amount)
   creature:getPosition():sendMagicEffect(creature:getStorageValue(90000))
   return true
end
 
@henkas
You gave us this script so I think it's your spells' basic structure.
Try:
Lua:
function onCastSpell(creature, variant)
   local amount = creature:getMana()
   creature:addManaSpent(amount)
   creature:addMana(-amount)
   creature:getPosition():sendMagicEffect(creature:getStorageValue(90000))
   return true
end
I dont get any error with previous script, Vulcan_ already said the solution for that error. Now the whole point is that this system is not showing effect
  1. local config = {
  2. [9000] = 10, -- [uniqueid] = magiceffect
  3. [9001] = 20
  4. }
All it does is just applies random effect, its pretty far way to working. Technically it should get effect with id 10 thats what it says in config but when you type aura you get random effect not a effect from local config
 
Back
Top