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

an onManaChange event


Ah! Good thinking, should definitely be added. I might have to add drop loot too, as seems most people don't even bother with this system because it doesn't have it... just so many ways to do it... Could go with random, could be tier based, ect.


wonderful system
Thanks man! Much appreciated!
 
Ah! Good thinking, should definitely be added. I might have to add drop loot too, as seems most people don't even bother with this system because it doesn't have it... just so many ways to do it... Could go with random, could be tier based, ect.
nice thinking, if people could even imagine how amazing and personalized this system can be...
 
imagine how amazing and personalized this system can be
Exactly! I was telling my buddy the same thing, people just don't realize, it was left in the perfect state for modifying to fit almost anyones personal ambitions for a system like this! Man, I really appreciate that someone can see that :D
 
The premium and level requirements dont work for me, and dont show any errors
I'm at work right now, so I can look more into it later, but unless otserv br used onEquip before isCheck was added, or removed it, should work fine, but I still need to see the version you are working on, because last time you posted about an error that couldn't possibly be an error for that line, unless you altered, so I will need to see your altered version to help
 
I'm at work right now, so I can look more into it later, but unless otserv br used onEquip before isCheck was added, or removed it, should work fine, but I still need to see the version you are working on, because last time you posted about an error that couldn't possibly be an error for that line, unless you altered, so I will need to see your altered version to help
I am not using otservbr, i am testing it on tfs 1.3 GitHub - otland/forgottenserver: A free and open-source MMORPG server emulator written in C++ (https://github.com/otland/forgottenserver)
 
i dont know what is the real version of my tfs
when you start the server, in the console at the top, should tell you which version you are using, but I also need to see the script you are using, as mine doesn't line up with yours on the lines...

@topic, should have some updates for this system by end of weekend I am hoping, at least for sure an event for dealing with mana shield as epuncker asked for, made it, just needs tested.
 
As it has been pointed out to me, otservbr doesn't have CONDITION_EXHAUST_WEAPON, so if you get a nil value at line 114, just delete lines 114, 115, and 116. As for the premium requirements, as well as vocations, it has been pointed out to me where the problem is, and I will have the main post updated with the fixes by monday. So if you want to wait, I will have an updated version for you, and then you can just delete those three lines I mentioned and should be working fine, ofc, if you are using otservbr and they also don't have event call back for onLook, then you will need to delete that entire chunk (entire function) of code and should still work fine

Edit : Update
Had some things come up this weekend, will have to try to get the updates done by next monday instead of tomorrow
 
Last edited:
As it has been pointed out to me, otservbr doesn't have CONDITION_EXHAUST_WEAPON, so if you get a nil value at line 114, just delete lines 114, 115, and 116. As for the premium requirements, as well as vocations, it has been pointed out to me where the problem is, and I will have the main post updated with the fixes by monday. So if you want to wait, I will have an updated version for you, and then you can just delete those three lines I mentioned and should be working fine, ofc, if you are using otservbr and they also don't have event call back for onLook, then you will need to delete that entire chunk (entire function) of code and should still work fine

Edit : Update
Had some things come up this weekend, will have to try to get the updates done by next monday instead of tomorrow
Hello, I have days looking at your code, I decided to try, I have read the previous comments, and I agree that it is a wonderful system, it has many uses.
I am testing in otservbr, correct common mistakes lines 114,115,116, onLook and getGroup, and works fine without error in console, only have error in premium tag requeriment.
and now testing the attributes,

They do not work i test with players and monsters:
1.- manashield <-- show icon but player give damage on health
2.- crit
3.- lifeleech
4.- manaleech

FIX crit, lifeleech, manaleech (otservbr)
change in customequipment.lua
Lua:
    ["criticalhitchance"] =           {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SPECIALSKILL_CRITICALHITCHANCE,},
    ["criticalhitamount"] =           {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SPECIALSKILL_CRITICALHITAMOUNT,},
    ["lifeleechchance"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SPECIALSKILL_LIFELEECHCHANCE,},
    ["lifeleechamount"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SPECIALSKILL_LIFELEECHAMOUNT,},
    ["manaleechchance"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SPECIALSKILL_MANALEECHCHANCE,},
    ["manaleechamount"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SPECIALSKILL_MANALEECHAMOUNT,},
change to:
Lua:
    ["criticalhitchance"] =           {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SKILL_CRITICAL_HIT_CHANCE,},
    ["criticalhitamount"] =           {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SKILL_CRITICAL_HIT_DAMAGE,},
    ["lifeleechchance"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SKILL_LIFE_LEECH_CHANCE,},
    ["lifeleechamount"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SKILL_LIFE_LEECH_AMOUNT,},
    ["manaleechchance"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SKILL_MANA_LEECH_CHANCE,},
    ["manaleechamount"] =             {type = CONDITION_ATTRIBUTES,            param = CONDITION_PARAM_SKILL_MANA_LEECH_AMOUNT,},


Other Error in reflect:
i recived:
player:say("reflecting")

error: in function 'doTargetCombat'

FIX REFLECT:
change:
Lua:
doTargetCombat(attacker:getId(), attacker, primaryType, reflectDamage, reflectDamage, CONST_ME_NONE)
To:
Lua:
doTargetCombatHealth(player, attacker, primaryType, -reflectDamage, -reflectDamage, refs[primaryType])

add above local healthEvent = CreatureEvent("HealthProcessor") (line 199)

Lua:
local refs = {
    [COMBAT_PHYSICALDAMAGE] = CONST_ME_DRAWBLOOD,
    [COMBAT_ENERGYDAMAGE] = CONST_ME_ENERGYAREA,
    [COMBAT_EARTHDAMAGE] = CONST_ME_POISONAREA,
    [COMBAT_FIREDAMAGE] = CONST_ME_FIREAREA,
    [COMBAT_ICEDAMAGE] = CONST_ME_ICEAREA,
    [COMBAT_HOLYDAMAGE] = CONST_ME_HOLYAREA,
    [COMBAT_DEATHDAMAGE] = CONST_ME_MORTAREA
}


works fine
primary and secundary
Code:
<equip primary="death" percent="100" />
        <equip secondary="death" percent="100" />

I have doubt in this part:
Code:
    if primePercent ~= 0 then
        primaryDamage = (primaryDamage/100) * primePercent
    end

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

    return primaryDamage, primaryType, secondaryDamage, secondaryType
end


in your script:
if secondPercent ~= 0 then
secondPercent = (primaryDamage/100) * primePercent
end

i change to:
if secondPercent ~= 0 then
secondPercent = (secondaryDamage/100) * primePercent
end

Is your code correct, or is my modification correct? xD

and so far it is what I have tried of your code, it can be optimized much more

You can add something like:
onEquip and deEquip

onEquip text all atributtes
player:sendTextMessage(messageType or MESSAGE_STATUS_CONSOLE_ORANGE, ' [PLAYER STATS] Equipment Stats: Skills +10, Absorb fire 15%, Reflect fire 50%, Mana Regen:+100/s, Speed: +100, ETC) ')

deEquip Update stats
player:sendTextMessage(messageType or MESSAGE_STATUS_CONSOLE_ORANGE, ' [PLAYER STATS] Equipment Stats: Skills +5, Absorb fire 10%, Reflect fire 10%, Mana Regen:+100/s, Speed: +100, ETC) ')


I hope that my contribution serves to improve your system, and give feedback, I hope we continue to make improvements together, in your system
 
Last edited:
I've been tinkering around with this, and the script seems to work perfect.
Within the suggested example and function on giving an item to a player.
I've tried to use this in combination with custom loot so that in rare occasions a custom equipment (as like a legendary or what not).
(so basically not immediately to a player but first in the slain body)
But sadly I'm a bit stuck.

for the loot script it goes like this with my idea behind it, but that's all there is now:

Lua:
local extra_loot = {
    {hasName = "troll", items = {
        {id = 2380, chance = 40000} -- 40% (hand axe, 23801/23802/23803/etc... --> custom hand axe)
        --{id = 2160, countMax = 4, chance = 10000}
    }},
}

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
            self:addItem(t.items[i].id, count)
            -- Here i would like to convert the item the custom variant (Item:getCustomEquipId()) I think? but not sure.
        end
    end
end

function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() then return true end
    if corpse and corpse:isContainer() then
        for i = 1, #extra_loot do
            corpse:addExtraLoot(creature, extra_loot[i])
        end
    end
    return true
end

You think what I have in mind is easily possible?
@Codinablack
 
Let me start off by saying, hells yeah bro! You definitely did some work on this thing! I am happy to have you helping for the people who still choose to use otservbr, at least they will have a version that is usable! I absolutely appreciate all your effort and sharing!

add above local healthEvent = CreatureEvent("HealthProcessor") (line 199)

This part, where you add the animations, I will add to the main script, this is a definite enhancement!

The part about lifeleech, crit, and manaleech, would probably never have been fixed, as I had no clue they didn't use the same enums.


Other Error in reflect:
i recived:
player:say("reflecting"

I added that as a way to know it was working, its not an error, can easily be removed or kept.

Did you ever figure out the reason why manashield isn't working? How did you test, vs a monster or vs another player? If vs another player, did they also wear the custom equipment?


i change to:
if secondPercent ~= 0 then
secondPercent = (secondaryDamage/100) * primePercent
end

This was definitely a bug! Thanks for finding it! It was from a copy paste error that I apparently overlooked! Nice find!


and so far it is what I have tried of your code, it can be optimized much more

You can add something like:
onEquip and deEquip

onEquip text all atributtes
You are right, something like that could be added! This is what is considered an enhancement though, not really an optimization, but its definitely something I would have thought someone would have contributed by now, as I'm sure most players and users would prefer to be able to see all that the equipment has, in-game.

@beenii if you have your copy with all these edits/fixes, and its working great on otservbr, if you share with me, I will update main post to include your version, just share on the thread and I'll add a link in the main post for users seeking otservbr version, with your credits :D
Post automatically merged:

I've been tinkering around with this, and the script seems to work perfect.
Within the suggested example and function on giving an item to a player.
I've tried to use this in combination with custom loot so that in rare occasions a custom equipment (as like a legendary or what not).
(so basically not immediately to a player but first in the slain body)
But sadly I'm a bit stuck.

for the loot script it goes like this with my idea behind it, but that's all there is now:

Lua:
local extra_loot = {
    {hasName = "troll", items = {
        {id = 2380, chance = 40000} -- 40% (hand axe, 23801/23802/23803/etc... --> custom hand axe)
        --{id = 2160, countMax = 4, chance = 10000}
    }},
}

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
            self:addItem(t.items[i].id, count)
            -- Here i would like to convert the item the custom variant (Item:getCustomEquipId()) I think? but not sure.
        end
    end
end

function onDeath(creature, corpse, killer, mostDamage, unjustified, mostDamage_unjustified)
    if not creature:isMonster() then return true end
    if corpse and corpse:isContainer() then
        for i = 1, #extra_loot do
            corpse:addExtraLoot(creature, extra_loot[i])
        end
    end
    return true
end

You think what I have in mind is easily possible?
@Codinablack
Yes absolutely possible! I'm actually working on droploot right now! I absolutely love that you are making custom functions to use, did you get an error?

The way I'm going to do it, is by using the actually event onDropLoot. The version I will develop, will change one of the items in the loot, to match its custom version in the xml. Say, your hand axe for example, if the troll drops a hand axe, then it will have a chance to change the handaxe into one of your custom versions, the higher the tier, the harder it will be to get it. I'm adding in tiers, but they aren't necessary, and as you have dabbled, you can see, there are so many ways to do the same thing, so since you are pretty good with lua, I'm certain you will definitely appreciate the next release , that forreal should be done by monday at the latest this time :D

I'm so happy to see people actually using it and also editing it! You all make me happy
 
Last edited:
Let me start off by saying, hells yeah bro! You definitely did some work on this thing! I am happy to have you helping for the people who still choose to use otservbr, at least they will have a version that is usable! I absolutely appreciate all your effort and sharing!



This part, where you add the animations, I will add to the main script, this is a definite enhancement!

The part about lifeleech, crit, and manaleech, would probably never have been fixed, as I had no clue they didn't use the same enums.




I added that as a way to know it was working, its not an error, can easily be removed or kept.

Did you ever figure out the reason why manashield isn't working? How did you test, vs a monster or vs another player? If vs another player, did they also wear the custom equipment?




This was definitely a bug! Thanks for finding it! It was from a copy paste error that I apparently overlooked! Nice find!



You are right, something like that could be added! This is what is considered an enhancement though, not really an optimization, but its definitely something I would have thought someone would have contributed by now, as I'm sure most players and users would prefer to be able to see all that the equipment has, in-game.

@beenii if you have your copy with all these edits/fixes, and its working great on otservbr, if you share with me, I will update main post to include your version, just share on the thread and I'll add a link in the main post for users seeking otservbr version, with your credits :D
Post automatically merged:


Yes absolutely possible! I'm actually working on droploot right now! I absolutely love that you are making custom functions to use, did you get an error?

The way I'm going to do it, is by using the actually event onDropLoot. The version I will develop, will change one of the items in the loot, to match its custom version in the xml. Say, your hand axe for example, if the troll drops a hand axe, then it will have a chance to change the handaxe into one of your custom versions, the higher the tier, the harder it will be to get it. I'm adding in tiers, but they aren't necessary, and as you have dabbled, you can see, there are so many ways to do the same thing, so since you are pretty good with lua, I'm certain you will definitely appreciate the next release , that forreal should be done by monday at the latest this time :D

I'm so happy to see people actually using it and also editing it! You all make me happy
Ohh I'll await your results, cause that looks more like what i want.
I'm sadly not that great with lua (mostly don't know all the functions that are useable).

If you already got something to add the custom id i would like to hear see it.
Maybe i can get on from that point. :)

Alright, I couldn't wait and already made some simple script. I'll show tomorrow what I did.
 
Last edited:
@beenii if you have your copy with all these edits/fixes, and its working great on otservbr, if you share with me, I will update main post to include your version, just share on the thread and I'll add a link in the main post for users seeking otservbr version, with your credits :D
Post automatically merged:
count on me

I will see between today and tomorrow if I solve the manashield condition, Although I consider it is not very important, and I will correct the premium tag, and then I will publish the version for otservbr.

If you like, send me your discord in private, to see what improvements we will add in the future to the 2 versions.

Best regards
 
count on me

I will see between today and tomorrow if I solve the manashield condition, Although I consider it is not very important, and I will correct the premium tag, and then I will publish the version for otservbr.

If you like, send me your discord in private, to see what improvements we will add in the future to the 2 versions.

Best regards
Sarah has already shared with me the fix for both the premium, and getting vocations to read for multiple instances

The fixes look like this


Lua:
        ["vocation"] = i:match('vocation.-=.-"(.-)"'), -- Example: vocation="1" | Example: vocation="1,5,6"
    }

    -- Vocation list to number
    local vocations = requirements["vocation"]
    if vocations then
        local split = vocations:split(",")
        requirements["vocation"] = {}
        for _, id in pairs(split) do
            table.insert(requirements["vocation"], tonumber(id) or 0)
        end
    end


----------------------------------------------------

if #eq.requirements["vocation"] > 0 then
                    description = string.format("%s\nVocation Required: " ..table.concat(eq.requirements["vocation"], ', ').. "", description)
                end
if eq.requirements["premium"] and eq.requirements["premium"] > 0 then
                    if player:getPremiumTime() == 0 then
                        player:sendTextMessage(MESSAGE_INFO_DESCR,"You must have premium to equip that item!")
                        return false
                    end
                end
                if #eq.requirements["vocation"] > 0 then
                    if not table.contains(eq.requirements["vocation"], player:getVocation():getId()) then
                        player:sendTextMessage(MESSAGE_INFO_DESCR,"You don't have the proper vocation to equip that item!")
                        return false
                    end
                end
 
Good collaboration guys, I'm not a programmer, I'm just a user who uses the system, for my part I can only test, so if you need my help, count on me.
 
Back
Top