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

Lua Change outfit

Ruan Sebast

New Member
Joined
Nov 9, 2014
Messages
38
Reaction score
0
Location
Brazil
Woud like ask for help in one script.
Every time my character hit something, changes her outfit for x seconds, then back to original.
Must have a condition to the script be true, her distance cant be > 1 from target, if distance be > 1 then he change to other outfit for x seconds and back to original.
Im using tfs 1.0

Like it:

:rolleyes:
 
Last edited:
Well you need onAttack event. Then you can easily change the outfit. I would done something like this:
Code:
local attackOutfit = Condition(CONDITION_OUTFIT, CONDITIONID_COMBAT)

local outfitTable = {
    --Looktype/newLooktype/Seconds until newOutfit removes
    [100] = {newOutfit = 101, outfitInterval = 3}
}

function Creature:onTargetCombat(target)
    if self:isPlayer() then
        local table = outfitTable[self:getOutfit().lookType]
        if table then
            attackOutfit:setOutfit({lookType = table.newOutfit})
            attackOutfit:setTicks(table.outfitInterval * 1000)
            self:addCondition(attackOutfit)
        end
    end
    return true
end
 
Last edited:
Actually i got confirmation from @Dalkon that onTargetCombat working as onAttack. So go into events/scripts/ and open creature.lua and paste the code. I have updated it, so copy it.
 
http://2.ii.gl/7ljrnrjKf.png
Worked =)
Would like add now a condition to change outfit depending on what spell he cast.
And he can't move until change outfit time end's(dont need any message like 'you cannot move' or 'you're exhausted'), that's possible?

Sorry if i'm asking too much, im newbie in scripting:(
 
Last edited:
Yes, just go to the spell script and add the lines. Here is a example of edited utevo lux spell:
Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)

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 spellOutfit = Condition(CONDITION_OUTFIT, CONDITIONID_COMBAT)
local outfitConfig = {
    newOutfit = 100,
    outfitInterval = 3
}

function onCastSpell(creature, var)
        creature:setOutfit({lookType = outfitConfig.newOutfit})
        creature:setTicks(outfitConfig.outfitInterval * 1000)
    creature:addCondition(spellOutfit)
    return combat:execute(creature, var)
end
 
tell me if this works i did it for my project but i'm a complete noob ;p
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ICEATTACK)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, 0, -0.4, 0)

local condition = createConditionObject(CONDITION_HASTE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 3300)
setConditionFormula(condition, 0.3, -1000, 0.3, -1000)
setCombatCondition(combat, condition)

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

it slows for a few seconds
 
Back
Top