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

Revscripts(1.3) Custom Equipment {SYC}

@Codinablack It seems I don't see the special bonuses on the items, is there something I'm missing?

15:14 You see a cyclops battle shield (Legendary) (Def:25 +3).
It weighs 62.00 oz.
A rare battle shield, once used by a cyclops legend.

this one should for example also show the healthgain
XML:
    <equipment baseItem="2513" equipId="25133" article="a" name="cyclops battle shield (Legendary)" >
        <equip attr="description" value="A rare battle shield, once used by a cyclops legend." />
        <equip attr="defense" value="25" />
        <equip attr="extradef" value="3" />
        <equip buff="healthgain" value="3" />
    </equipment>
 
@Codinablack It seems I don't see the special bonuses on the items, is there something I'm missing?

15:14 You see a cyclops battle shield (Legendary) (Def:25 +3).
It weighs 62.00 oz.
A rare battle shield, once used by a cyclops legend.

this one should for example also show the healthgain
XML:
    <equipment baseItem="2513" equipId="25133" article="a" name="cyclops battle shield (Legendary)" >
        <equip attr="description" value="A rare battle shield, once used by a cyclops legend." />
        <equip attr="defense" value="25" />
        <equip attr="extradef" value="3" />
        <equip buff="healthgain" value="3" />
    </equipment>
The description is handled in the "onLook" part of the script. I didn't add description for every single thing that an eq can have, I left that up to the users on how they wanted the description to be read, but I already provided the hook, and the basic string manipulation as example.

I guess I could add configuration options for the users to decide to show conditions, show penalties, ect, but thats not a huge priority for me at this point. The other things I mentioned need completed first

As for the previous thing you asked about for droploot, you would want to modify the customequipment.lua to include the custom function you are making, and from there you would try to create an item from scratch by reading the table the same way I do in the custom function for player:addCustomEquipment()
 
The description is handled in the "onLook" part of the script. I didn't add description for every single thing that an eq can have, I left that up to the users on how they wanted the description to be read, but I already provided the hook, and the basic string manipulation as example.

I guess I could add configuration options for the users to decide to show conditions, show penalties, ect, but thats not a huge priority for me at this point. The other things I mentioned need completed first

As for the previous thing you asked about for droploot, you would want to modify the customequipment.lua to include the custom function you are making, and from there you would try to create an item from scratch by reading the table the same way I do in the custom function for player:addCustomEquipment()
Alright I see, what you mean. I have added them now like this and it works perfect:


Lua:
lookEvent.onLook = function(self, thing, position, distance, description)
    if thing:isItem() then
        if thing:getCustomEquipId() then
            local eq = customEquipment[thing:getCustomEquipId()]
            if eq then
            -- Description generation
                -- Buffs
                if eq.conditions["healthgain"] then
                    description = string.format("%s\nHealth Regeneration: +" ..eq.conditions["healthgain"].. "", description)
                end
                if eq.conditions["managain"] then
                    description = string.format("%s\nMana Regeneration: +" ..eq.conditions["managain"].. "", description)
                end   
                if eq.conditions["maxhitpoints"] then
                    description = string.format("%s\nMaximum hitpoints: +" ..eq.conditions["maxhitpoints"].. "", description)
                end                   
                if eq.conditions["maxmanapoints"] then
                    description = string.format("%s\nMaximum manapoints : +" ..eq.conditions["maxmanapoints"].. "", description)
                end                   
                if eq.conditions["magicpoints"] then
                    description = string.format("%s\nMagic boost: +" ..eq.conditions["magicpoints"].. "", description)
                end   
                if eq.conditions["meleeskill"] then
                    description = string.format("%s\nMelee boost: +" ..eq.conditions["meleeskill"].. "", description)
                end   
                if eq.conditions["speed"] then
                    description = string.format("%s\nSpeed boost: +" ..eq.conditions["speed"].. "", description)
                end   
                if eq.conditions["soul"] then
                    description = string.format("%s\nSoul boost: +" ..eq.conditions["soul"].. "", description)
                end   
                if eq.conditions["manashield"] then
                    description = string.format("%s\nManashield Activation ", description)
                end       
                if eq.conditions["invis"] then
                    description = string.format("%s\nInvisible Activation ", description)
                end   
                -- Skills
                if eq.conditions["fistskill"] then
                    description = string.format("%s\nFist skill boost: +" ..eq.conditions["fistskill"].. "", description)
                end   
                if eq.conditions["clubskill"] then
                    description = string.format("%s\nClub skill boost: +" ..eq.conditions["clubskill"].. "", description)
                end   
                if eq.conditions["swordskill"] then
                    description = string.format("%s\nSword skill boost: +" ..eq.conditions["swordskill"].. "", description)
                end   
                if eq.conditions["axeskill"] then
                    description = string.format("%s\nAxe skill boost: +" ..eq.conditions["axeskill"].. "", description)
                end   
                if eq.conditions["distanceskill"] then
                    description = string.format("%s\nDistance skill boost: +" ..eq.conditions["distanceskill"].. "", description)
                end   
                if eq.conditions["shieldskill"] then
                    description = string.format("%s\nShield skill boost: +" ..eq.conditions["shieldskill"].. "", description)
                end   
                if eq.conditions["fishingskill"] then
                    description = string.format("%s\nFishing skill boost: +" ..eq.conditions["fishingskill"].. "", description)
                end   
                -- Special skill
                if eq.conditions["criticalhitchance"] then
                    description = string.format("%s\nCritical hit chance: +" ..eq.conditions["criticalhitchance"].. "", description)
                end   
                if eq.conditions["criticalhitamount"] then
                    description = string.format("%s\nCritical hit amount: +" ..eq.conditions["criticalhitamount"].. "", description)
                end   
                if eq.conditions["lifeleechchance"] then
                    description = string.format("%s\nLife leech chance: +" ..eq.conditions["lifeleechchance"].. "", description)
                end   
                if eq.conditions["lifeleechamount"] then
                    description = string.format("%s\nLife leech amount: +" ..eq.conditions["lifeleechamount"].. "", description)
                end   
                if eq.conditions["manaleechchance"] then
                    description = string.format("%s\nMana leech chance: +" ..eq.conditions["manaleechchance"].. "", description)
                end   
                if eq.conditions["manaleechamount"] then
                    description = string.format("%s\nMana leech amount: +" ..eq.conditions["manaleechamount"].. "", description)
                end   
                
                -- Requirements
                if eq.requirements["level"] and type(eq.requirements["level"]) == "number" then
                    description = string.format("%s\nLevel Required: %d", description, eq.requirements["level"])
                end
                if eq.requirements["magiclevel"] and type(eq.requirements["magiclevel"]) == "number" then
                    description = string.format("%s\nMagic Level Required: %d", description, eq.requirements["magiclevel"])
                end
                if eq.requirements["premium"] and eq.requirements["premium"] > 0 then
                    description = string.format("%s\nPremium Required", description)
                end
                if eq.requirements["vocation"] then
                    description = string.format("%s\nVocation Required: " ..eq.requirements["vocation"].. "", description)
                end           
                --- attributes reload onLook
                if attributeReload then
                    if reloadOnLook then
                        for attr, val in pairs(eq.attributes) do
                            item:setAttribute(attr, val)
                        end
                    end
                end
            end
        end
    end
    return description
end
Post automatically merged:

One thing I would love to see configurable is like the "ticks" on health/mana.
Like now it's each second, would be nice if it can be configured to your own likings.
(I have a low rate server so each second 1 or 2 hp/mana is already a lot.)
 
Last edited:
Alright I see, what you mean. I have added them now like this and it works perfect:


Lua:
lookEvent.onLook = function(self, thing, position, distance, description)
    if thing:isItem() then
        if thing:getCustomEquipId() then
            local eq = customEquipment[thing:getCustomEquipId()]
            if eq then
            -- Description generation
                -- Buffs
                if eq.conditions["healthgain"] then
                    description = string.format("%s\nHealth Regeneration: +" ..eq.conditions["healthgain"].. "", description)
                end
                if eq.conditions["managain"] then
                    description = string.format("%s\nMana Regeneration: +" ..eq.conditions["managain"].. "", description)
                end 
                if eq.conditions["maxhitpoints"] then
                    description = string.format("%s\nMaximum hitpoints: +" ..eq.conditions["maxhitpoints"].. "", description)
                end                 
                if eq.conditions["maxmanapoints"] then
                    description = string.format("%s\nMaximum manapoints : +" ..eq.conditions["maxmanapoints"].. "", description)
                end                 
                if eq.conditions["magicpoints"] then
                    description = string.format("%s\nMagic boost: +" ..eq.conditions["magicpoints"].. "", description)
                end 
                if eq.conditions["meleeskill"] then
                    description = string.format("%s\nMelee boost: +" ..eq.conditions["meleeskill"].. "", description)
                end 
                if eq.conditions["speed"] then
                    description = string.format("%s\nSpeed boost: +" ..eq.conditions["speed"].. "", description)
                end 
                if eq.conditions["soul"] then
                    description = string.format("%s\nSoul boost: +" ..eq.conditions["soul"].. "", description)
                end 
                if eq.conditions["manashield"] then
                    description = string.format("%s\nManashield Activation ", description)
                end     
                if eq.conditions["invis"] then
                    description = string.format("%s\nInvisible Activation ", description)
                end 
                -- Skills
                if eq.conditions["fistskill"] then
                    description = string.format("%s\nFist skill boost: +" ..eq.conditions["fistskill"].. "", description)
                end 
                if eq.conditions["clubskill"] then
                    description = string.format("%s\nClub skill boost: +" ..eq.conditions["clubskill"].. "", description)
                end 
                if eq.conditions["swordskill"] then
                    description = string.format("%s\nSword skill boost: +" ..eq.conditions["swordskill"].. "", description)
                end 
                if eq.conditions["axeskill"] then
                    description = string.format("%s\nAxe skill boost: +" ..eq.conditions["axeskill"].. "", description)
                end 
                if eq.conditions["distanceskill"] then
                    description = string.format("%s\nDistance skill boost: +" ..eq.conditions["distanceskill"].. "", description)
                end 
                if eq.conditions["shieldskill"] then
                    description = string.format("%s\nShield skill boost: +" ..eq.conditions["shieldskill"].. "", description)
                end 
                if eq.conditions["fishingskill"] then
                    description = string.format("%s\nFishing skill boost: +" ..eq.conditions["fishingskill"].. "", description)
                end 
                -- Special skill
                if eq.conditions["criticalhitchance"] then
                    description = string.format("%s\nCritical hit chance: +" ..eq.conditions["criticalhitchance"].. "", description)
                end 
                if eq.conditions["criticalhitamount"] then
                    description = string.format("%s\nCritical hit amount: +" ..eq.conditions["criticalhitamount"].. "", description)
                end 
                if eq.conditions["lifeleechchance"] then
                    description = string.format("%s\nLife leech chance: +" ..eq.conditions["lifeleechchance"].. "", description)
                end 
                if eq.conditions["lifeleechamount"] then
                    description = string.format("%s\nLife leech amount: +" ..eq.conditions["lifeleechamount"].. "", description)
                end 
                if eq.conditions["manaleechchance"] then
                    description = string.format("%s\nMana leech chance: +" ..eq.conditions["manaleechchance"].. "", description)
                end 
                if eq.conditions["manaleechamount"] then
                    description = string.format("%s\nMana leech amount: +" ..eq.conditions["manaleechamount"].. "", description)
                end 
              
                -- Requirements
                if eq.requirements["level"] and type(eq.requirements["level"]) == "number" then
                    description = string.format("%s\nLevel Required: %d", description, eq.requirements["level"])
                end
                if eq.requirements["magiclevel"] and type(eq.requirements["magiclevel"]) == "number" then
                    description = string.format("%s\nMagic Level Required: %d", description, eq.requirements["magiclevel"])
                end
                if eq.requirements["premium"] and eq.requirements["premium"] > 0 then
                    description = string.format("%s\nPremium Required", description)
                end
                if eq.requirements["vocation"] then
                    description = string.format("%s\nVocation Required: " ..eq.requirements["vocation"].. "", description)
                end         
                --- attributes reload onLook
                if attributeReload then
                    if reloadOnLook then
                        for attr, val in pairs(eq.attributes) do
                            item:setAttribute(attr, val)
                        end
                    end
                end
            end
        end
    end
    return description
end
Post automatically merged:

One thing I would love to see configurable is like the "ticks" on health/mana.
Like now it's each second, would be nice if it can be configured to your own likings.
(I have a low rate server so each second 1 or 2 hp/mana is already a lot.)

Very nice! I added the descriptions you did to my main script and will reshare once I'm done with the droploot. I hit a bit of a snag though, was more time consuming than expected, sooooo many loops, and apparently im freezing the server trying to organize the loot right now. But if you still can't wait, here is a custom function that will allow you to transform an item into custom eq, becareful with its use, as it doesn't make sure the baseitem's id matches the item you are transforming... but here you go, should work for that drop loot container thing you were doing.


Lua:
function Item:transformToEq(equipId)
    if customEquipment[equipId] then
        for attr, val in pairs(customEquipment[equipId].attributes) do
            self:setAttribute(attr, val)
        end
        self:setCustomAttribute("CustomEquipmentId", equipId)
    else
        print("Invalid EquipID")
    end
end

Add that to the bottom of customequipment.lua and then you can use that function wherever you like to change an item into a custom equipment.

So everyone knows i haven't just been super slacking

here is the logic I had so far for the drop loot (still very rough and not working, so don't judge)


Lua:
local dropLootEvent = EventCallback

dropLootEvent.onDropLoot = function(self, corpse)
    if not enableLoot then
        return true
    end
    local lottery = {}
    local baseIds = {}
    for _ , item in pairs(corpse:getItems()) do
        if table.contains(baseItemList, item:getId()) then
            for eq, attr in pairs(customEquipment) do
                if attr.baseItem == item:getId() then
                    if attr.tier and attr.tier["lootable"] then
                        table.insert(baseIds, item:getId(), attr.equipId)
                        table.insert(lottery, attr.equipId)
                        print("we have saved eq to lottery")
                    end
                end
            end  
        end
    end

    if #lottery > 0 then
        local randNum = math.random(100)
        for k, v in pairs(lottery) do
            print(customEquipment[v].tier["chance"])
            if customEquipment[v].tier["chance"] and customEquipment[v].tier["chance"] < math.random(100) then
                table.remove(lottery, k)
                print("we removed from lottery")
            end
        end
    end

    if #lottery > 0 then
        local finalLoot = {}
        for k, v in pairs(lottery) do
            if customEquipment[v].tier.grade then
                table.insert(finalLoot, {id = v, grade = customEquipment[v].tier.grade})
            end
        end
        local prizeGrade = 100
        local sorted = 0
        while(sorted<3) do
            for k, v in pairs(finalLoot) do
                if v.grade < prizeGrade then
                    prizeGrade = v.grade
                end
                if v.grade > prizeGrade then
                    table.remove(finalLoot, k)
                end
                sorted = sorted + 1
            end
        end
        for k, v in pairs(baseIds) do
            print(k)
            print(v)
            local item = corpse:getItem(k)
            if math.random(100) > lootChance then
                item:transformToEq(v)
                Player(corpse:getCorpseOwner()):sendTextMessage(MESSAGE_LOOT, "There is something different about that loot")
            end
        end
    end

    return true
end

dropLootEvent:register(2)

and for the manashield


Lua:
local manaEvent = CreatureEvent("ManaProcessor")

function manaEvent.onManaChange(player, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

    if not player:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if not player:getCondition(CONDITION_MANASHIELD) then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    local eq = {}
    local reflectPercent = 0
    local absorbPercent = 0
    local primePercent = 0
    local secondPercent = 0

    for k , v in pairs(slotList) do
        if player:getSlotItem(k)then
            if player:getSlotItem(k):getCustomEquipId()then
                local item = player:getSlotItem(k)
                if item then
                    table.insert(eq, item)
                end
            end
        end
    end

    if #eq > 0 then
        for k,v in pairs(eq) do
            local customItem = customEquipment[v:getCustomEquipId()]
            if customItem then
                if customItem.primeTypes[primaryType] then
                    primePercent = primePercent + customItem.primeTypes[primaryType]
                    if primePercent >= maxPrimePercent then
                        primePercent = maxPrimePercent
                    end
                end
                if customItem.secondTypes[secondaryType] then
                    secondPercent = secondPercent + customItem.secondTypes[secondaryType]
                    if secondPercent >= maxSecondPercent then
                        secondPercent = maxSecondPercent
                    end
                end
                if customItem.reflects[primaryType] then
                    reflectPercent = reflectPercent + customItem.reflects[primaryType]
                    if reflectPercent >= maxReflectPercent then
                        reflectPercent = maxReflectPercent
                    end
                end
                if customItem.absorbs[primaryType] then
                    absorbPercent = absorbPercent + customItem.absorbs[primaryType]
                    if absorbPercent >= maxAbsorbPercent then
                        absorbPercent = maxAbsorbPercent
                    end
                end
            end
        end
    end

    if primePercent ~= 0 then
        primaryDamage = (primaryDamage/100) * primePercent
    end

    if secondPercent ~= 0 then
        secondPercent = (secondaryDamage/100) * secondPercent
    end

    local reflectDamage = (primaryDamage/100) * reflectPercent

    primaryDamage = primaryDamage - reflectDamage

    if reflectDamage > 0 then
        player:say("reflecting")
        --attacker:addHealth(-reflectDamage)
        doTargetCombat(attacker:getId(), attacker, primaryType, reflectDamage, reflectDamage, CONST_ME_NONE) -- can be exploited.
    end
   

    local absorbDamage = (primaryDamage/100) * absorbPercent

    primaryDamage = primaryDamage - absorbDamage

    if absorbDamage > 0 then
        player:say("absorbing")
        player:addHealth(absorbDamage)
    end

    local totalDamage = primaryDamage + secondaryDamage

    if totalDamage > player:getMana() then
        player:addHealth(totalDamage - player:getMana())
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

manaEvent:register()
 
Very nice! I added the descriptions you did to my main script and will reshare once I'm done with the droploot. I hit a bit of a snag though, was more time consuming than expected, sooooo many loops, and apparently im freezing the server trying to organize the loot right now. But if you still can't wait, here is a custom function that will allow you to transform an item into custom eq, becareful with its use, as it doesn't make sure the baseitem's id matches the item you are transforming... but here you go, should work for that drop loot container thing you were doing.


Lua:
function Item:transformToEq(equipId)
    if customEquipment[equipId] then
        for attr, val in pairs(customEquipment[equipId].attributes) do
            self:setAttribute(attr, val)
        end
        self:setCustomAttribute("CustomEquipmentId", equipId)
    else
        print("Invalid EquipID")
    end
end

Add that to the bottom of customequipment.lua and then you can use that function wherever you like to change an item into a custom equipment.

So everyone knows i haven't just been super slacking

here is the logic I had so far for the drop loot (still very rough and not working, so don't judge)


Lua:
local dropLootEvent = EventCallback

dropLootEvent.onDropLoot = function(self, corpse)
    if not enableLoot then
        return true
    end
    local lottery = {}
    local baseIds = {}
    for _ , item in pairs(corpse:getItems()) do
        if table.contains(baseItemList, item:getId()) then
            for eq, attr in pairs(customEquipment) do
                if attr.baseItem == item:getId() then
                    if attr.tier and attr.tier["lootable"] then
                        table.insert(baseIds, item:getId(), attr.equipId)
                        table.insert(lottery, attr.equipId)
                        print("we have saved eq to lottery")
                    end
                end
            end
        end
    end

    if #lottery > 0 then
        local randNum = math.random(100)
        for k, v in pairs(lottery) do
            print(customEquipment[v].tier["chance"])
            if customEquipment[v].tier["chance"] and customEquipment[v].tier["chance"] < math.random(100) then
                table.remove(lottery, k)
                print("we removed from lottery")
            end
        end
    end

    if #lottery > 0 then
        local finalLoot = {}
        for k, v in pairs(lottery) do
            if customEquipment[v].tier.grade then
                table.insert(finalLoot, {id = v, grade = customEquipment[v].tier.grade})
            end
        end
        local prizeGrade = 100
        local sorted = 0
        while(sorted<3) do
            for k, v in pairs(finalLoot) do
                if v.grade < prizeGrade then
                    prizeGrade = v.grade
                end
                if v.grade > prizeGrade then
                    table.remove(finalLoot, k)
                end
                sorted = sorted + 1
            end
        end
        for k, v in pairs(baseIds) do
            print(k)
            print(v)
            local item = corpse:getItem(k)
            if math.random(100) > lootChance then
                item:transformToEq(v)
                Player(corpse:getCorpseOwner()):sendTextMessage(MESSAGE_LOOT, "There is something different about that loot")
            end
        end
    end

    return true
end

dropLootEvent:register(2)

and for the manashield


Lua:
local manaEvent = CreatureEvent("ManaProcessor")

function manaEvent.onManaChange(player, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

    if not player:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    if not player:getCondition(CONDITION_MANASHIELD) then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end

    local eq = {}
    local reflectPercent = 0
    local absorbPercent = 0
    local primePercent = 0
    local secondPercent = 0

    for k , v in pairs(slotList) do
        if player:getSlotItem(k)then
            if player:getSlotItem(k):getCustomEquipId()then
                local item = player:getSlotItem(k)
                if item then
                    table.insert(eq, item)
                end
            end
        end
    end

    if #eq > 0 then
        for k,v in pairs(eq) do
            local customItem = customEquipment[v:getCustomEquipId()]
            if customItem then
                if customItem.primeTypes[primaryType] then
                    primePercent = primePercent + customItem.primeTypes[primaryType]
                    if primePercent >= maxPrimePercent then
                        primePercent = maxPrimePercent
                    end
                end
                if customItem.secondTypes[secondaryType] then
                    secondPercent = secondPercent + customItem.secondTypes[secondaryType]
                    if secondPercent >= maxSecondPercent then
                        secondPercent = maxSecondPercent
                    end
                end
                if customItem.reflects[primaryType] then
                    reflectPercent = reflectPercent + customItem.reflects[primaryType]
                    if reflectPercent >= maxReflectPercent then
                        reflectPercent = maxReflectPercent
                    end
                end
                if customItem.absorbs[primaryType] then
                    absorbPercent = absorbPercent + customItem.absorbs[primaryType]
                    if absorbPercent >= maxAbsorbPercent then
                        absorbPercent = maxAbsorbPercent
                    end
                end
            end
        end
    end

    if primePercent ~= 0 then
        primaryDamage = (primaryDamage/100) * primePercent
    end

    if secondPercent ~= 0 then
        secondPercent = (secondaryDamage/100) * secondPercent
    end

    local reflectDamage = (primaryDamage/100) * reflectPercent

    primaryDamage = primaryDamage - reflectDamage

    if reflectDamage > 0 then
        player:say("reflecting")
        --attacker:addHealth(-reflectDamage)
        doTargetCombat(attacker:getId(), attacker, primaryType, reflectDamage, reflectDamage, CONST_ME_NONE) -- can be exploited.
    end
 

    local absorbDamage = (primaryDamage/100) * absorbPercent

    primaryDamage = primaryDamage - absorbDamage

    if absorbDamage > 0 then
        player:say("absorbing")
        player:addHealth(absorbDamage)
    end

    local totalDamage = primaryDamage + secondaryDamage

    if totalDamage > player:getMana() then
        player:addHealth(totalDamage - player:getMana())
    end

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

manaEvent:register()
I've tried out the manashield on the example zelda sword, but it doesnt seem to work for me.
Or I misunderstand, but if i get hit i still get hp loss and not mana loss.

-- EDIT --

The way I made it possible to add these items was with the use of THIS (extra-loot-system) script.
The way i added it went as following:

First I added the normal loot in like this:

Lua:
local extra_loot = {
    {hasName = "troll", items = {
        {id = 2380, chance = 1000} -- 1% (hand axe, 23801/23802/23803/etc... --> custom hand axe)
    }},
    {hasName = "cyclops", items = {
        {id = 2513, chance = 1000} -- 1% (battle shield, 25131/25132/25133/etc... --> custom battle shield)
    }},   
}

For the loot generating part it looks like this:
Lua:
function Container:addExtraLoot(c, t)
    if t.hasName then
        local cn = c:getName():lower()
        local cm = t.hasName:lower()
        if not cn:match(cm) then
            return true
        end
    end
    
    for i = 1, #t.items do
        local count = 1
        if t.items[i].count then
            if t.items[i].countMax then
                count = math.random(t.items[i].count, t.items[i].countMax)
            else
                count = t.items[i].count
            end
        else
            if t.items[i].countMax then
                count = math.random(1, t.items[i].countMax)
            end
        end
        
        if math.random(0, 100000) <= t.items[i].chance then
            local pItem = self:addItem(t.items[i].id, count)
            local tier = math.random(1,3) -- just using 3 tiers equally dropped around the board
            local equipId = (t.items[i].id *10) + tier -- equipId (basic + tier)
            Creature:addCustomEquipment(equipId,pItem) -- I added this in the customequipment lua
        end
    end
end

and the addition from the Creature:addCustomEquipment:

Code:
function Creature:addCustomEquipment(equipId, it)
    if customEquipment[equipId] then
        local item = it
        for attr, val in pairs(customEquipment[equipId].attributes) do
            item:setAttribute(attr, val)
            item:setCustomAttribute("CustomEquipmentId", equipId)
        end
    end
end
 
Last edited:
Ok so I have finished the dropLoot. The manashield I have no idea why is not working. Haven't tested it yet, but i need more feedback, because one person says it works, other says not at all...

I got rid of Tiers, its just lootable, and lootchance tags for the xml, using integers ofc.

I still need more testing and to implement multiple vocations allowed, however i did modify premium so it should work correctly.

here is what the drop loot alone looks like now


Lua:
------ this goes with config part at beginning of script ----
local enableLoot = true --- must enable this to use tier system, and/or allow looting items from monsters corpse. Tiers determine which is more likely to spawn, rare, or common.
local lootChance = 50 --- this is used for determining if the player gets loot or not, only after corpse drops item with matching id to baseItem of custom equipment, and chance from xml is already been used.
local enableLootMessage = true --- this will let a player know if an item has been turned into custom equipment inside a corpse
-----------------------------------------------------------------------------------------



local dropLootEvent = EventCallback

dropLootEvent.onDropLoot = function(self, corpse)
    if not enableLoot then
        return true
    end
    local lottery = {}
    for index, item in pairs(corpse:getItems()) do
        if table.contains(baseItemList, item:getId()) then
            for eq, attr in pairs(customEquipment) do
                if attr.baseItem == item:getId() then
                    if attr.tier and attr.tier["lootable"] then
                        if attr.tier["chance"] and attr.tier["chance"] < math.random(100) then
                            table.insert(lottery, attr.equipId)
                        end
                    end
                end
            end 
        end
    end
    if #lottery > 0 then
        local equipId = lottery[math.random(#lottery)]
        if math.random(100) > lootChance then
            for index, item in pairs(corpse:getItems()) do
                if customEquipment[equipId].baseItem == item:getId() then
                    local name = item:getName()
                    item:transformToEq(equipId)
                    if enableLootMessage then
                        Player(corpse:getCorpseOwner()):sendTextMessage(MESSAGE_LOOT, "There is something different about that " ..name.. "!")
                    end
                end
            end
        end
    end
    return true
end

dropLootEvent:register(2)


I am attaching a picture of the system working in-game, and my current version of script and xml, for testing purposes, will update main post once all these kinks are worked out, and I add multiple vocations for requirements accepted.

This current version does have fixed premium, droploot, configs for descriptions and droploot, with all descriptions added by @Raikou special thanks to him, @beenii and sarah for their extra help on bugs and enhancements.
 

Attachments

Last edited:
I've been using it now with your latest version.

And it looks like this to me.
tgtDkK7.jpg

So the sign of mana shield is there, but it isn't actually working.
Could it be that it checks also for magic level and vocation to be working(mana shield spell?)
 
Last edited:
No, it doesn't check for that stuff. Did you alter the version at all or just drop it in as replacement? I am thinking the condition check on line 360 might be the issue, maybe I need to check for the condition more specifically. Hmm... Shouldn't it automatically take from your mana if you have a manashield on? I assumed it would... Must be something else I am overlooking. Are you using the most up to date branch of 1.3? Mine is about a dozen and a half commits old right now...
 
Mhmm weird, my version is not old it's actually quite new. Got it like almost 2 weeks I guess.
The Forgotten Server - Version 1.3

Compiled with Microsoft Visual C++ version 14.2
Compiled on Aug 20 2021 14:19:47 for platform x64
Linked with LuaJIT 2.0.5 for Lua support

My version is almost the same as yours, with some addition like i posted above for the special loot drop.
 
FINALLY FIXED! Cannot use subid only conditionId for manashield to work properly.

@Raikou @Evil Puncker


Lua:
function Player:applyEquipmentConditions(item, slot)
    local equipment = customEquipment[item:getCustomEquipId()]
    local conditionId = getConditionIdForSlot(slot)

    if conditionId then

        local conditionCount = 1

        for _index, _value in pairs(equipment.conditions) do

            if _index and _value then

                local uniqueId = (100 + (conditionId * conditionLimit)) + conditionCount
                local key = equipConditions[_index]

                if key.type == CONDITION_MANASHIELD then
                    local condition = Condition(CONDITION_MANASHIELD, conditionId)
                    if condition then
                        condition:setTicks(-1)
                        manaCombat:addCondition(condition)
                        manaCombat:execute(self, Variant(self:getId()))
                    end
                else

                    local condition = Condition(key.type, conditionId)

                    if condition then
                        condition:setParameter(key.param, _value)
                        condition:setTicks(-1)
                        condition:setParameter(CONDITION_PARAM_SUBID, uniqueId)
                        self:addCondition(condition)
                    end
                end

                conditionCount = conditionCount + 1
            end
        end
    end
end

function Player:removeEquipmentConditions(item, slot)
    local equipment = customEquipment[item:getCustomEquipId()]
    local conditionId = getConditionIdForSlot(slot)
    if conditionId then
        local conditionCount = 1
        for _index, _value in pairs(equipment.conditions) do
            local uniqueId = (100 + (conditionId * conditionLimit)) + conditionCount
            local key = equipConditions[_index]
            if key.type == CONDITION_MANASHIELD then
                manaCombat:clearConditions()
                ---manaCombat:execute(self, Variant(self:getId()))
                self:removeCondition(CONDITION_MANASHIELD, conditionId)
            else
                self:removeCondition(key.type, conditionId, uniqueId)
                conditionCount = conditionCount +1
            end
        end
    end
end
Post automatically merged:

Update here is my now current customequpiment.lua, manashield works perfectly now and should also correctly interact with reflect and absorb, as well as primary and secondary damages.

@Raikou and @Evil Puncker
 

Attachments

  • customequpiment.lua
    41.8 KB · Views: 16 · VirusTotal
Last edited:
FINALLY FIXED! Cannot use subid only conditionId for manashield to work properly.

@Raikou @Evil Puncker


Lua:
function Player:applyEquipmentConditions(item, slot)
    local equipment = customEquipment[item:getCustomEquipId()]
    local conditionId = getConditionIdForSlot(slot)

    if conditionId then

        local conditionCount = 1

        for _index, _value in pairs(equipment.conditions) do

            if _index and _value then

                local uniqueId = (100 + (conditionId * conditionLimit)) + conditionCount
                local key = equipConditions[_index]

                if key.type == CONDITION_MANASHIELD then
                    local condition = Condition(CONDITION_MANASHIELD, conditionId)
                    if condition then
                        condition:setTicks(-1)
                        manaCombat:addCondition(condition)
                        manaCombat:execute(self, Variant(self:getId()))
                    end
                else

                    local condition = Condition(key.type, conditionId)

                    if condition then
                        condition:setParameter(key.param, _value)
                        condition:setTicks(-1)
                        condition:setParameter(CONDITION_PARAM_SUBID, uniqueId)
                        self:addCondition(condition)
                    end
                end

                conditionCount = conditionCount + 1
            end
        end
    end
end

function Player:removeEquipmentConditions(item, slot)
    local equipment = customEquipment[item:getCustomEquipId()]
    local conditionId = getConditionIdForSlot(slot)
    if conditionId then
        local conditionCount = 1
        for _index, _value in pairs(equipment.conditions) do
            local uniqueId = (100 + (conditionId * conditionLimit)) + conditionCount
            local key = equipConditions[_index]
            if key.type == CONDITION_MANASHIELD then
                manaCombat:clearConditions()
                ---manaCombat:execute(self, Variant(self:getId()))
                self:removeCondition(CONDITION_MANASHIELD, conditionId)
            else
                self:removeCondition(key.type, conditionId, uniqueId)
                conditionCount = conditionCount +1
            end
        end
    end
end
Post automatically merged:

Update here is my now current customequpiment.lua, manashield works perfectly now and should also correctly interact with reflect and absorb, as well as primary and secondary damages.

@Raikou and @Evil Puncker
Manashield indeed works now, well done :)

Next one I see that's not working is the soul points, but no hurry in that. You are doing a good job.

I would prefer to see/know how the tickers work on the health generation for example.
Really would like to adjust the timer on that
 
FINALLY FIXED! Cannot use subid only conditionId for manashield to work properly.

@Raikou @Evil Puncker


Lua:
function Player:applyEquipmentConditions(item, slot)
    local equipment = customEquipment[item:getCustomEquipId()]
    local conditionId = getConditionIdForSlot(slot)

    if conditionId then

        local conditionCount = 1

        for _index, _value in pairs(equipment.conditions) do

            if _index and _value then

                local uniqueId = (100 + (conditionId * conditionLimit)) + conditionCount
                local key = equipConditions[_index]

                if key.type == CONDITION_MANASHIELD then
                    local condition = Condition(CONDITION_MANASHIELD, conditionId)
                    if condition then
                        condition:setTicks(-1)
                        manaCombat:addCondition(condition)
                        manaCombat:execute(self, Variant(self:getId()))
                    end
                else

                    local condition = Condition(key.type, conditionId)

                    if condition then
                        condition:setParameter(key.param, _value)
                        condition:setTicks(-1)
                        condition:setParameter(CONDITION_PARAM_SUBID, uniqueId)
                        self:addCondition(condition)
                    end
                end

                conditionCount = conditionCount + 1
            end
        end
    end
end

function Player:removeEquipmentConditions(item, slot)
    local equipment = customEquipment[item:getCustomEquipId()]
    local conditionId = getConditionIdForSlot(slot)
    if conditionId then
        local conditionCount = 1
        for _index, _value in pairs(equipment.conditions) do
            local uniqueId = (100 + (conditionId * conditionLimit)) + conditionCount
            local key = equipConditions[_index]
            if key.type == CONDITION_MANASHIELD then
                manaCombat:clearConditions()
                ---manaCombat:execute(self, Variant(self:getId()))
                self:removeCondition(CONDITION_MANASHIELD, conditionId)
            else
                self:removeCondition(key.type, conditionId, uniqueId)
                conditionCount = conditionCount +1
            end
        end
    end
end
Post automatically merged:

Update here is my now current customequpiment.lua, manashield works perfectly now and should also correctly interact with reflect and absorb, as well as primary and secondary damages.

@Raikou and @Evil Puncker
Will you update the lua of the first post?
 
Manashield indeed works now, well done :)
Thank you! It was a conundrum for sure!


Next one I see that's not working is the soul points, but no hurry in that. You are doing a good job.
Probably same thing as magic shield, shouldn't take long to fix now that I know what is the problem.


I would prefer to see/know how the tickers work on the health generation for example.
Really would like to adjust the timer on that
I don't know of a way to adjust that timer... maybe since its using CONDITION_REGENERATION, it will tick as often as the vocation who is wearing it is set to tick in vocations.xml? Ticks, just change the time, and they have to be set to -1 to make it work infinitely (as long as eq is on). I don't see any other method for changing the intervals for conditions.


Will you update the lua of the first post?
Yes I will, just not until I have implemented the multiple vocations feature, and have fully tested the rest of the things already added, manashield, manaevent, multiple conditions on multiple items stacked and stacked, vs monsters, vs players, just need to try to break it a bit, make sure the bugs are really gone, and fix soul points too before I update the main post, but for now I shared my lua file here , it has the extra descriptions, drop loot, onManaChange event, and working manashield, as well as premium fixed. I know for your server you need some specific things changed, you can find instructions on how to make it work for your server here
Post automatically merged:

@Raikou it does appear regeneration condition is intended to read from the vocations.xml, atleast that is the way i understand this
 
Last edited:
I'm testing now and i get like each 3 seconds the hp tick from food.
But I get each second the tick from the equipment. So I'm not sure yet how and where this goes wrong.
Sadly I dont see someway to slower it with timers or something.

I'll keep tinkering around.
 
I'm testing now and i get like each 3 seconds the hp tick from food.
But I get each second the tick from the equipment. So I'm not sure yet how and where this goes wrong.
Sadly I dont see someway to slower it with timers or something.

I'll keep tinkering around.
Yes, it seems a commit to the main branch two days ago was supposed to fix it to read from the xml, so maybe update your .exe and it should work? thats what this is I think

Post automatically merged:

I'm an idiot, I only set the healthgain amount, the healthgain ticks is a different parameter that can be set , might add a whole bunch more lines of code, but its most definitely doable, I'll work on this with those other things here and there throughout the week, and try to make sure everything is ready by end of next weekend again :D, could even make it configurable for different ticks for different items pretty easily im certain
 
Ohh the reflect function isn't working and throws errors in the log with for example bleeding.
data\scripts\weapons\customequpiment.lua:262: attempt to index local 'attacker' (a nil value)
 
Attacker should never be nil, unless the damage being received isn't from a creature. So I'm assuming its trying to reflect something like a condition damage or something... should be as easy of a fix as

if attacker then ---line 260

end --- line 276

@Raikou
 
The main post are update?

It says: Last edited: Jul 24, 2021
So i highly doubt it.
I guess best bet is to get the lua from:
 
Back
Top