• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

MoveEvent Super Vocation Transformation Ring/Item - 8.6 removes money, item or nothing :p

Codex NG

Recurrent Flamer
Joined
Jul 24, 2015
Messages
2,994
Solutions
12
Reaction score
1,657
This hasn't been tested at all.
Code:
local c = {
    vocationStorage = 18009,
    transformStorage = 50781,
    newVocs = {
        [1] = 9,  -- 9 number is the vocation id of an epic master sorcerer in vocations.xml --
        [2] = 10, -- 10 number is the vocation id of a epic elder druid in vocations.xml --
        [3] = 11, -- 11 number is the vocation id of a epic royal paladin in vocations.xml --
        [4] = 12  -- 12 number is the vocation id of an epic elite knight in vocations.xml --
    }
    outfits = {
        [1] = { -- sorcerer new outfit after transformation --
            lookType = 130, lookHead = 19, lookBody = 71, lookLegs = 128, lookFeet = 128, lookAddons = 0
        },
        [2] = { -- druid new outfit after transformation --
            lookType = 63, lookHead = 20, lookBody = 30, lookLegs = 40, lookFeet = 50, lookAddons = 0
        },
        [3] = { -- paladin new outfit after transformation --
            lookType = 129, lookHead = 95, lookBody = 116, lookLegs = 121, lookFeet = 115, lookAddons = 0
        },
        [4] = { -- knight new outfit after transformation --
            lookType = 131, lookHead = 95, lookBody = 95, lookLegs = 95, lookFeet = 95, lookAddons = 0
        }
    }
    removeThis = {
        item = 2159, -- scarab coin
        amount = 1
    },
    interval = 1000, -- this the duration per effect
    money = 100, -- 100 gp per interval
    item = 2179 -- gold ring, item id which should be assigned to this script
}

local useThis = 'free' -- options are, item, money or free


local vocationAttrConditions = {
    [1] = {
        { CONDITION_PARAM_SKILL_SHIELD, 50 }, { CONDITION_PARAM_STAT_MAGICLEVEL, 100 }, { CONDITION_PARAM_STAT_MAXHEALTH, 1000 }, { CONDITION_PARAM_STAT_MAXMANA, 4000 }
    },
    [2] = {
        { CONDITION_PARAM_SKILL_SHIELD, 50 }, { CONDITION_PARAM_STAT_MAGICLEVEL, 100 }, { CONDITION_PARAM_STAT_MAXHEALTH, 1000 }, { CONDITION_PARAM_STAT_MAXMANA, 4000 }
    },
    [3] = {
        { CONDITION_PARAM_SKILL_DISTANCE, 100 }, { CONDITION_PARAM_SKILL_SHIELD, 50 }, { CONDITION_PARAM_STAT_MAGICLEVEL, 50 }, { CONDITION_PARAM_STAT_MAXHEALTH, 3000 }, {CONDITION_PARAM_STAT_MAXMANA, 2000}
    },
    [4] = {
        { CONDITION_PARAM_SKILL_FIST, 100 }, { CONDITION_PARAM_SKILL_CLUB, 100 }, { CONDITION_PARAM_SKILL_SWORD, 100 }, { CONDITION_PARAM_SKILL_AXE, 100 }, { CONDITION_PARAM_SKILL_SHIELD, 100 }, { CONDITION_PARAM_STAT_MAGICLEVEL, 15 }, { CONDITION_PARAM_STAT_MAXHEALTH, 5000 }, { CONDITION_PARAM_STAT_MAXMANA, 1000 }
    }
}
local attrCondition = {}
for i = 1, #c.newVocs do
    attrCondition[i] = createConditionObject(CONDITION_ATTRIBUTES)
    setConditionParam(attrCondition[i], CONDITION_PARAM_TICKS, -1)
    for x = 1, #vocationAttrConditions[i] do
        setConditionParam(attrCondition[i], vocationAttrConditions[i][x][1], vocationAttrConditions[i][x][2])
    end
end

local vocationRegenConditions = {
    [1] = {
        {CONDITION_PARAM_HEALTHGAIN, 100}, {CONDITION_PARAM_MANAGAIN, 500}
    },
    [2] = {
        {CONDITION_PARAM_HEALTHGAIN, 100}, {CONDITION_PARAM_MANAGAIN, 500}
    },
    [3] = {
        {CONDITION_PARAM_HEALTHGAIN, 300}, {CONDITION_PARAM_MANAGAIN, 200}
    },
    [4] = {
        {CONDITION_PARAM_HEALTHGAIN, 100}, {CONDITION_PARAM_MANAGAIN, 100}
    }
}

local regenCondition = {}
for i = 1, #c.newVocs do
    regenCondition[i] = createConditionObject(CONDITION_REGENERATION)
    setConditionParam(regenCondition[i], CONDITION_PARAM_TICKS, -1)
    setConditionParam(regenCondition[i], vocationRegenConditions[i][1], vocationRegenConditions[i][2])
end


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)

local haste = createConditionObject(CONDITION_HASTE)
setConditionParam(haste, CONDITION_PARAM_TICKS, -1)
setConditionFormula(haste, 2.5, 0, 3.0, 0)
setCombatCondition(combat, haste)

local manashield = createConditionObject(CONDITION_MANASHIELD)
setConditionParam(manashield, CONDITION_PARAM_TICKS, -1)
setCombatCondition(combat, manashield)


local effects = {
    [1] = {
        first = CONST_ME_ENERGYAREA,
        second = CONST_ME_BLOCKHIT,
        fling = CONST_ANI_SMALLHOLY,
        land = CONST_ME_TELEPORT,
        ring = CONST_ME_FIREWORK_YELLOW,
        orb = CONST_ME_FIREATTACK
    },
    [2] = {
        first = CONST_ME_ICEATTACK,
        second = CONST_ME_ICETORNADO,
        fling = CONST_ME_ICETORNADO,
        land = CONST_ME_ICETORNADO,
        ring = CONST_ME_FIREWORK_BLUE,
        orb = CONST_ME_MAGIC_BLUE
    },
    [3] = {
        first = CONST_ME_YELLOW_RINGS,
        second = CONST_ME_BLOCKHIT,
        fling = CONST_ANI_SMALLHOLY,
        land = CONST_ME_HOLYAREA,
        ring = CONST_ME_FIREWORK_YELLOW,
        orb = CONST_ME_MAGIC_GREEN
    },
    [4] = {
        first = CONST_ME_EXPLOSIONAREA,
        second = CONST_ME_FIREAREA,
        fling = CONST_ANI_FIRE,
        land = CONST_ME_FIREWORK_RED,
        ring = CONST_ME_FIREWORK_RED,
        orb = CONST_ME_MAGIC_RED
    }
}

function superTransform(p, c, equip)
    local pos = p.pos
    local cid = p.cid
    if not isPlayer(cid) then
        return
    end

    doSendMagicEffect(pos, effects[p.vocation].first)
    doSendMagicEffect(pos, effects[p.vocation].second)
  
    local t = {
        [1] = {x = pos.x, y = pos.y - 3, z = pos.z, stackpos = 255},
        [2] = {x = pos.x, y = pos.y + 3, z = pos.z, stackpos = 255},
        [3] = {x = pos.x - 3, y = pos.y, z = pos.z, stackpos = 255},
        [4] = {x = pos.x + 3, y = pos.y, z = pos.z, stackpos = 255},
        [5] = {x = pos.x - 2, y = pos.y - 2, z = pos.z, stackpos = 255},
        [6] = {x = pos.x + 2, y = pos.y - 2, z = pos.z, stackpos = 255},
        [7] = {x = pos.x + 2, y = pos.y + 2, z = pos.z, stackpos = 255},
        [8] = {x = pos.x - 2, y = pos.y + 2, z = pos.z, stackpos = 255}
    }

    for i = 1, #t do
        doSendDistanceShoot(pos, t[i], effects[p.vocation].fling)
    end
    for x = 1, #t do
        doSendMagicEffect(pos, t[x], effects[p.vocation].land)
    end
    if equip then
        addEvent(specialEffect, 1000, p, c)
    end
end

function resetPlayer(p, c, equip)
    local cid = p.cid
    if isPlayer(cid) then
        setPlayerStorageValue(cid, c.transformStorage, 0)
        doPlayerSetVocation(cid, getPlayerStorageValue(cid, vocationStorage))
        setPlayerStorageValue(cid, c.vocationStorage, 0)
        if equip then
            doPlayerRemoveItem(cid, c.item)
        end

        local possibleConditions = {CONDITION_OUTFIT, CONDITION_ATTRIBUTES, CONDITION_HASTE, CONDITION_MANASHIELD, CONDITION_REGENERATION}
        for n = 1, #possibleConditions do
            if hasCondition(cid, possibleConditions[n])
                doRemoveCondition(cid, possibleConditions[n])
            end
        end
    end
    return true
end

function specialEffect(p, c)
local cid = p.cid
if isPlayer(cid) and getPlayerStorageValue(cid, c.transformStorage) == 1 then
    if useThis == 'money' then
        if getPlayerMoney(cid) >= c.money then
            doPlayerRemoveMoney(cid, c.money)
        else
            return resetPlayer(p, c, true)
        end
    elseif useThis == 'item' then
        if getPlayerItemCount(cid, removeThis.item) >= removeThis.amount then
            doRemoveItem(cid, removeThis.amount)
        else
            return resetPlayer(p, c, true)
        end
    elseif useThis == 'free' then
        doCreatureSay(cid, "fri itens!", TALKTYPE_ORANGE_1)
    end
    local pos = getCreaturePosition(cid)
  
    local t = {
        [1] = {x = pos.x, y = pos.y - 3, z = pos.z, stackpos = 255},
        [2] = {x = pos.x, y = pos.y + 3, z = pos.z, stackpos = 255},
        [3] = {x = pos.x - 3, y = pos.y, z = pos.z, stackpos = 255},
        [4] = {x = pos.x + 3, y = pos.y, z = pos.z, stackpos = 255},
        [5] = {x = pos.x - 2, y = pos.y - 2, z = pos.z, stackpos = 255},
        [6] = {x = pos.x + 2, y = pos.y - 2, z = pos.z, stackpos = 255},
        [7] = {x = pos.x + 2, y = pos.y + 2, z = pos.z, stackpos = 255},
        [8] = {x = pos.x - 2, y = pos.y + 2, z = pos.z, stackpos = 255}
    }

    doSendMagicEffect(pos, effects[p.vocation].ring)
    doSendMagicEffect(pos, effects[p.vocation].orb)

    doSendMagicEffect(pos, effects[p.vocation].first)
    doSendMagicEffect(pos, effects[p.vocation].second)

    for i = 1, #t do
        doSendDistanceShoot(pos, t[i], effects[p.vocation].fling)
    end
    for x = 1, #t do
        doSendMagicEffect(pos, t[x], effects[p.vocation].land)
    end
    p.pos = pos
    addEvent(specialEffect, c.interval, p, c)
end


end

function isInTable(t, s)
    if type(t) == 'table' then
        for k, v in pairs(t) do
            if v[1] == s or v[2] == s then
                return true, k, s
            end
        end
    end
    return false
end
 
Code:
function onEquip(cid, item, slot)

    local slots = getPlayerSlotItem(cid, slot)
    if slots.itemid ~= item.itemid then
        return true
    end
   
    if useThis == 'money' then
        if getPlayerMoney(cid) < c.money then
            return false
        end
    elseif useThis == 'item' then
        if getPlayerItemCount(cid, removeThis.item) < removeThis.amount then
            return false
        end
    elseif useThis == 'free' then
        doCreatureSay(cid, "Sim!", TALKTYPE_ORANGE_1)
    else
        return false
    end
   
    if c.newVocs[getPlayerVocation(cid) - 8] then
        doPlayerSetVocation(cid, getPlayerStorageValue(cid, vocationStorage))
    end
    local vocArray = {
        [9] = {1, 5},
        [10] = {2, 6},
        [11] = {3, 7},
        [12] = {4, 8}
    }
    local condition, superVocation, playerVocation = isInTable(vocArray, getPlayerVocation(cid))
    if condition then
        setPlayerStorageValue(cid, vocationStorage, playerVocation)
        setPlayerStorageValue(cid, transformStorage, 1)
        doPlayerSetVocation(cid, superVocation)
        doSetCreatureOutfit(cid, c.outfits[playerVocation], -1)
        doAddCondition(cid, vocationAttrConditions[playerVocation])
        if isInArray({1, 2}, playerVocation) then
            doAddCondition(cid, manashield)
        end
        doAddCondition(cid, regenCondition[playerVocation])
        doAddCondition(cid, haste)
        doSetCreatureOutfit(cid, c.outfits[playerVocation], -1)
    else
        return false
    end
        
    local pos = getPlayerPosition(cid)
    doCreatureSay(cid, "Rutilus Vox", TALKTYPE_ORANGE_1)
    local p = {cid = cid, item = item, slot = slot, vocation = playerVocation, pos = pos}
   
    addEvent(superTransform, 1, p, c, true)
    return true
end

function onDeEquip(cid, item, slot)
    if isPlayer(cid) and getPlayerStorageValue(cid, c.transformStorage) == 1 then
        local p = {cid = cid, item = item, slot = slot}
        resetPlayer(p, c)
        local pos = getCreaturePosition(cid)
        doCreatureSay(cid, "Aufero Meus Donum", TALKTYPE_ORANGE_1)
        local vocation = getPlayerVocation(cid)
        local p = {cid = cid, item = item, slot = slot, vocation = vocation, pos = pos}
        superTransform(p, c)
    end
    return true
end
 
Back
Top