Lua [Error] Mutation/Polymorph spell

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
Hello dear OtLanders :)

I'm trying to create a Mutation/Polymorph spell that would change the target into one of the animals on the list... The most important part of the spell (the animals) is taken from the following thread:
Lua - [Spell] Polymorph Rune
(^and that is the only part of the spell that brings about an error)

The error:
ERROR_mutation.png

Although it seems to be clear what is wrong with the script, I cannot figure out where to put the ','

The script:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_PLANTATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 6000)
local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}
local animal = animals[math.random(animals)]
for animal = animals[math.random(animals)] do
    addOutfitCondition(outfit, {lookTypeEx = animal})
end
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 6000)
local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITION_PARAM_SUBID, 1)
setConditionParam(regen, CONDITION_PARAM_BUFF, true)
setConditionParam(regen, CONDITION_PARAM_TICKS, 7 * 1000)
setConditionParam(regen, CONDITION_PARAM_HEALTHGAIN, 100)
setConditionParam(regen, CONDITION_PARAM_HEALTHTICKS, 1000)
local paralyze = createConditionObject(CONDITION_PARALYZE)
setConditionParam(paralyze, CONDITION_PARAM_TICKS, 6500)
setConditionFormula(paralyze, -0.9, 0, -0.9, 0)
setCombatCondition(combat, paralyze)
setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)
setCombatCondition(combat, paralyze)
function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
By the way, I'm currently using the [8.60] The Forgotten Server 0.3.6 (Crying Damson) V8 by Printer, from the thread: [8.60] The Forgotten Server 0.3.6 (Crying Damson) V8

Thank you in advance for your support,
Best regards! :)
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,226
Best answers
510
Reaction score
2,853
you can learn why here:
Programming in Lua : 4.3.4

but you don't even need the for loop, the original creator fucked it up

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 20000)

local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}

local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 20000)

local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITIONATTR_HEALTHGAIN, 100)
setConditionParam(regen, CONDITIONATTR_MANAGAIN, 100)
setConditionParam(regen, CONDITIONATTR_HEALTHTICKS, 1000)
setConditionParam(regen, CONDITIONATTR_MANATICKS, 1000)
setConditionParam(regen, CONDITION_PARAM_TICKS, 20000)

setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)

function onCastSpell(cid, var)
    local animal = animals[math.random(#animals)]
    addOutfitCondition(outfit, {lookType = animal})
    return doCombat(cid, combat, var)
end
 
OP
AdiMit

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
you can learn why here:
Programming in Lua : 4.3.4

but you don't even need the for loop, the original creator fucked it up

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 20000)

local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}

local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 20000)

local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITIONATTR_HEALTHGAIN, 100)
setConditionParam(regen, CONDITIONATTR_MANAGAIN, 100)
setConditionParam(regen, CONDITIONATTR_HEALTHTICKS, 1000)
setConditionParam(regen, CONDITIONATTR_MANATICKS, 1000)
setConditionParam(regen, CONDITION_PARAM_TICKS, 20000)

setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)

function onCastSpell(cid, var)
    local animal = animals[math.random(#animals)]
    addOutfitCondition(outfit, {lookType = animal})
    return doCombat(cid, combat, var)
end
Now I get this Error:
Code:
[06/04/2017 17:22:26] [Error - Spell Interface]
[06/04/2017 17:22:26] data/spells/scripts/support/mutation.lua:onCastSpell
[06/04/2017 17:22:26] Description:
[06/04/2017 17:22:26] (luaAddOutfitCondition) This function can only be used while loading the script.
Current version of the script:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_PLANTATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 6000)
local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 6000)
local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITION_PARAM_SUBID, 1)
setConditionParam(regen, CONDITION_PARAM_BUFF, true)
setConditionParam(regen, CONDITION_PARAM_TICKS, 7 * 1000)
setConditionParam(regen, CONDITION_PARAM_HEALTHGAIN, 100)
setConditionParam(regen, CONDITION_PARAM_HEALTHTICKS, 1000)
local paralyze = createConditionObject(CONDITION_PARALYZE)
setConditionParam(paralyze, CONDITION_PARAM_TICKS, 6500)
setConditionFormula(paralyze, -0.9, 0, -0.9, 0)
setCombatCondition(combat, paralyze)
setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)
setCombatCondition(combat, paralyze)
function onCastSpell(cid, var)
    local animal = animals[math.random(#animals)]
    addOutfitCondition(outfit, {lookType = animal})
    return doCombat(cid, combat, var)
end
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,226
Best answers
510
Reaction score
2,853
Now I get this Error:
Code:
[06/04/2017 17:22:26] [Error - Spell Interface]
[06/04/2017 17:22:26] data/spells/scripts/support/mutation.lua:onCastSpell
[06/04/2017 17:22:26] Description:
[06/04/2017 17:22:26] (luaAddOutfitCondition) This function can only be used while loading the script.
Current version of the script:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_PLANTATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 6000)
local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}
local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 6000)
local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITION_PARAM_SUBID, 1)
setConditionParam(regen, CONDITION_PARAM_BUFF, true)
setConditionParam(regen, CONDITION_PARAM_TICKS, 7 * 1000)
setConditionParam(regen, CONDITION_PARAM_HEALTHGAIN, 100)
setConditionParam(regen, CONDITION_PARAM_HEALTHTICKS, 1000)
local paralyze = createConditionObject(CONDITION_PARALYZE)
setConditionParam(paralyze, CONDITION_PARAM_TICKS, 6500)
setConditionFormula(paralyze, -0.9, 0, -0.9, 0)
setCombatCondition(combat, paralyze)
setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)
setCombatCondition(combat, paralyze)
function onCastSpell(cid, var)
    local animal = animals[math.random(#animals)]
    addOutfitCondition(outfit, {lookType = animal})
    return doCombat(cid, combat, var)
end
i figured it was supposed to be random every time you used it so i moved that function inside onCastSpell, but i guess you can't do that in 0.3.6
Lua:
local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 20000)
addOutfitCondition(outfit, {lookType = animal})

local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 20000)

local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITIONATTR_HEALTHGAIN, 100)
setConditionParam(regen, CONDITIONATTR_MANAGAIN, 100)
setConditionParam(regen, CONDITIONATTR_HEALTHTICKS, 1000)
setConditionParam(regen, CONDITIONATTR_MANATICKS, 1000)
setConditionParam(regen, CONDITION_PARAM_TICKS, 20000)

setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
OP
AdiMit

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
i figured it was supposed to be random every time you used it so i moved that function inside onCastSpell, but i guess you can't do that in 0.3.6
Lua:
local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 20000)
addOutfitCondition(outfit, {lookType = animal})

local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 20000)

local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITIONATTR_HEALTHGAIN, 100)
setConditionParam(regen, CONDITIONATTR_MANAGAIN, 100)
setConditionParam(regen, CONDITIONATTR_HEALTHTICKS, 1000)
setConditionParam(regen, CONDITIONATTR_MANATICKS, 1000)
setConditionParam(regen, CONDITION_PARAM_TICKS, 20000)

setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
There are no errors now, but the target disappears completely, both, from the screen and Battle list on the UI; however, I can still attack it (although it looks like I'm attacking nothingness)
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,226
Best answers
510
Reaction score
2,853
There are no errors now, but the target disappears completely, both, from the screen and Battle list on the UI; however, I can still attack it (although it looks like I'm attacking nothingness)
fuck im retarded
change
addOutfitCondition(outfit, {lookType = animal})
to
addOutfitCondition(outfit, {lookType = animals[math.random(#animals)]})
animal was nil cause i removed it, forgot to fix it after removing the variable
looktype was undefined thats why the target went invisible
 
OP
AdiMit

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
fuck im retarded
change
addOutfitCondition(outfit, {lookType = animal})
to
addOutfitCondition(outfit, {lookType = animals[math.random(#animals)]})
animal was nil cause i removed it, forgot to fix it after removing the variable
looktype was undefined thats why the target went invisible
It works almost perfectly! The only problem is that it keeps changing the target to a cat and the cat ONLY
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,226
Best answers
510
Reaction score
2,853
It works almost perfectly! The only problem is that it keeps changing the target to a cat and the cat ONLY
yeah that's whaat i was talking about a min ago
i tried putting the addOutfitCondition inside the onCastSpell function but it wouldn't work
you can do it in 1.2 but i don't know about 0.3.6, not sure how to make it random
 
OP
AdiMit

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
yeah that's whaat i was talking about a min ago
i tried putting the addOutfitCondition inside the onCastSpell function but it wouldn't work
you can do it in 1.2 but i don't know about 0.3.6, not sure how to make it random
Well, that's okay! Thank you a lot anyway! :)
I'll keep the thread unsolved for a while and, perhaps, someone might know how to fix it :)
 

Delusion

Divine Intellect
Support Team
Joined
Feb 14, 2015
Messages
5,226
Best answers
510
Reaction score
2,853
Well, that's okay! Thank you a lot anyway! :)
I'll keep the thread unsolved for a while and, perhaps, someone might know how to fix it :)
you can try this out, not sure if it will work
otherwise i don't have any other ideas
Lua:
local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 20000)

local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 20000)

local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITIONATTR_HEALTHGAIN, 100)
setConditionParam(regen, CONDITIONATTR_MANAGAIN, 100)
setConditionParam(regen, CONDITIONATTR_HEALTHTICKS, 1000)
setConditionParam(regen, CONDITIONATTR_MANATICKS, 1000)
setConditionParam(regen, CONDITION_PARAM_TICKS, 20000)

setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)

function onCastSpell(cid, var)
    setConditionParam(outfit, CONDITION_PARAM_OUTFIT, animals[math.random(#animals)])
    return doCombat(cid, combat, var)
end
 
OP
AdiMit

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
you can try this out, not sure if it will work
otherwise i don't have any other ideas
Lua:
local animals = {
    276, -- cat
    111, -- chicken
    32, -- dog
    212, -- flamingo
    224, -- frog
    60, -- pig
    21, -- rat
    14, -- sheep
    197, -- tortoise
    28 -- snake
}

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)

local outfit = createConditionObject(CONDITION_OUTFIT)
setConditionParam(outfit, CONDITION_PARAM_TICKS, 20000)

local muted = createConditionObject(CONDITION_MUTED)
setConditionParam(muted, CONDITION_PARAM_TICKS, 20000)

local regen = createConditionObject(CONDITION_REGENERATION)
setConditionParam(regen, CONDITIONATTR_HEALTHGAIN, 100)
setConditionParam(regen, CONDITIONATTR_MANAGAIN, 100)
setConditionParam(regen, CONDITIONATTR_HEALTHTICKS, 1000)
setConditionParam(regen, CONDITIONATTR_MANATICKS, 1000)
setConditionParam(regen, CONDITION_PARAM_TICKS, 20000)

setCombatCondition(combat, outfit)
setCombatCondition(combat, muted)
setCombatCondition(combat, regen)

function onCastSpell(cid, var)
    setConditionParam(outfit, CONDITION_PARAM_OUTFIT, animals[math.random(#animals)])
    return doCombat(cid, combat, var)
end
Code:
[06/04/2017 17:46:33] [Error - Spell Interface]
[06/04/2017 17:46:33] data/spells/scripts/support/mutation.lua:onCastSpell
[06/04/2017 17:46:33] Description:
[06/04/2017 17:46:33] (luaSetConditionParam) This function can only be used while loading the script.
For now, I'll stick with the cat-version, anyway, thank you again for making it work! :)
 
OP
AdiMit

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
Bump!

The issue with the animals not being selected at random every time the spell is used is still unsolved

Best regards! :)
 

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Best answers
14
Reaction score
76
If this one is not working in 0.3.6, you need to put it into talkactions :)
 
OP
AdiMit

AdiMit

c(;
Joined
May 2, 2016
Messages
70
Best answers
2
Reaction score
3
If this one is not working in 0.3.6, you need to put it into talkactions :)
Hey, thanks for your reply! :)

Could you please specify what part of the script (or perhaps the whole) needs to be put into talkactions? :)

Best regards!
 

GarQet

Own3d!
Joined
Feb 10, 2009
Messages
1,381
Best answers
14
Reaction score
76
Just put all of this and replace only the function to correct one, replece this one:
function onCastSpell(cid, var)
 
Top