• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Spell with both aggression types

Cornwallis

Member
Joined
Jan 3, 2010
Messages
480
Reaction score
16
I'm trying to make a spell that the first part is not aggressive so it can be casted inside protection zone and be casted at the same time as attack spells, but the second part is aggressive. The part that is casted depends which if statement is true I have this for my combats:
HTML:
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
combat1:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat1:setParameter(COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
combat1:setParameter(COMBAT_PARAM_AGGRESSIVE, false)

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat2:setParameter(COMBAT_PARAM_AGGRESSIVE, true)
is this possible? As of right now with no aggressive tag in spells.xml i can't use it in protection zone or while casting an attack spell, which i do have this spell set in the healing group. If i do aggressive="0" then it can use the part that i want aggressive in protection zone but I can cast at the same time as attack spells.
 
This is only an example, use a table and a param
Code:
local default = 0

local parameters = {
    [0] = {type = COMBAT_HEALING, effect = CONST_ME_MAGIC_BLUE, dispel = CONDITION_PARALYZE, aggressive = false},
    [1] = {type = COMBAT_HEALING, effect = CONST_ME_MAGIC_BLUE, dispel = CONDITION_PARALYZE, aggressive = true},
}

local combat = {} -- combat object for everything

for i = 0, #parameters - 1 do
    combat[i] = Combat()
    if parameters[i].type then
        combat[i]:setParameter(COMBAT_PARAM_TYPE, parameters[i].type)
    end
    if parameters[i].effect then
        combat[i]:setParameter(COMBAT_PARAM_EFFECT, parameters[i].effect)
    end
    if parameters[i].dispel then
        combat[i]:setParameter(COMBAT_PARAM_DISPEL, parameters[i].dispel)
    end
    if parameters[i].agressive ~= nil then
        combat[i]:setParameter(COMBAT_PARAM_AGGRESSIVE, parameters[i].agressive)
    end
end
-- i didn't include the callback because it is only an example
function onCastSpell(creature, var)
    local n = isInArray({'0', '1'}, var['string']) and tonumber(var['string']) or default
    combat[n]execute(creature, var)
    return true
end

Have a look at the generateConditions function in the 1st post and then review the table in the 2nd post.
https://otland.net/threads/magical-items-for-1-2-incomplete-version.242338/

Its important to understand the index of tables in order to write effect scripts, the above code is messy however as stated it was just an example, to give you an idea of how you can execute/store combat/conditions for spells.

Because spells parameters are loaded at run time you need to define them before you may use them :(

Although the parameters (of a combat/condition object) of a spell are not dynamic the values it can return on a callback function are. :)
 
Last edited:
Back
Top