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

Scripter Upgrade system

Zoool

New Member
Joined
Jul 18, 2014
Messages
163
Reaction score
2
I need advanced upgrade system.
It should work like this:
Upgrade item = "xxxx"
Useable on everything - "amulet, helmet, backpack, weapon (wand, rod, xxxx, xxxx, xxxx id), armor, shield, ring, legs, boots ....
It should be 97% chance to give one of this:
+1 mlvl
+1 dist, axe, sword, club fighting
+1% protection all
+1% protection physical
+1% protection fire
+1% protection ice
+1% protection poison
+1% protection energy
+1% protection death
+1 armor
+1 attack (if not possible than add +1 something else)
and 1% to give:
-1% death or -1% physical or -1% holy

Item can be used only 3 times on each item.
There should be 1% chance to make -1% physical, 1% chance to make -1% death, 1% chance to make -1% holy.
Should be 97% chance to make one of possitive.


I cant pay much.
+1mlvl, or +1skill are not that important.

tfs 0.4 r3884
 
Last edited:
Post your server version.
 
Even if i want only +1% protection somethin, +1% protection all? -1% protection xxx ?
 
You definitely don't need a source edit. Although source edit with a script would probably be the easiest solution.
 
You definitely don't need a source edit. Although source edit with a script would probably be the easiest solution.
@owned @Zoool
No, you don't need to edit the sources for these things.
You're both wrong on this. When you try to add protection % to an item in 0.4 with addattribute it will not absorb anything. Ive already been through this myself.
 
You're both wrong on this. When you try to add protection % to an item in 0.4 with addattribute it will not absorb anything. Ive already been through this myself.

So its impossible to make upgrade system like this? =s
 
You're both wrong on this. When you try to add protection % to an item in 0.4 with addattribute it will not absorb anything. Ive already been through this myself.
For 0.3.7, I have tried this as well.
The only working attribute I could apply to armor, was armor itself.
And even then, I had to over-write the current attribute with a separate armor function.
Weapons have a few more options, but yeah, I definitely had no luck with applying anything else.

Also, onStatsChange coupled with storage values / text on the armor is not a good option either.
onStatsChange grabs the final damage after all calculations have been completed.
If you add resistance in here, and put it back through to the character as a new damage, after returning false the original damage..
The damage will go through the player resistances twice, which give an incorrect damage value, after everything is said and done.

@owned @Zoool
No, you don't need to edit the sources for these things.

You definitely don't need a source edit. Although source edit with a script would probably be the easiest solution.

If you know of a function I'm over-looking that can actually apply elemental/physical damage reduction to a piece of armor, I'd love to see an example, either here or in PM..
I've literally spent hours at a time, between multiple months attempting to do this, and I definitely couldn't get anything to work.

So its impossible to make upgrade system like this? =s

Unless 'Imfreezing' or 'Codinablack' miraculously come up with a working piece of code, what your looking to do definitely requires a source edit, to get the functionality your looking for.

As far as I know, below is what is possible/not possible, without a source edit.
Code:
Adding skills, is possible, as a buff applied to the character.
Adding armor/def to armor/weapons, is possible.
Increasing the attack damage on weapons, is possible.

Adding elemental damage to your attacks... possible, but not as an attribute on the weapon itself.

protection +% added to armor, not possible.
 
Why not do all these effects but to different items? For example armor 1x .... +1% in stuff.... armor id 2x +2% in stuff.... armor 3x +3% in stuff ect.
 
Also, onStatsChange coupled with storage values / text on the armor is not a good option either.
onStatsChange grabs the final damage after all calculations have been completed.
If you add resistance in here, and put it back through to the character as a new damage, after returning false the original damage..
The damage will go through the player resistances twice, which give an incorrect damage value, after everything is said and done.

So /2 ?

Storage values are exactly one of the options I was thinking when replying. If there is such a bug in the onStatsChange() then put the value for half what you want would seem to be the most logical way. I am sorry I don't use that distribution but I am wondering about returning false? Why would you return false instead of true or the damage?
 
You're both wrong on this. When you try to add protection % to an item in 0.4 with addattribute it will not absorb anything. Ive already been through this myself.

Not thinking about that method, always more than one way to skin a cat
 
So /2 ?

Storage values are exactly one of the options I was thinking when replying. If there is such a bug in the onStatsChange() then put the value for half what you want would seem to be the most logical way. I am sorry I don't use that distribution but I am wondering about returning false? Why would you return false instead of true or the damage?
onStatsChange isn't bugged.
It simply gives you the value and type of damage that is about to be applied to the creature, after all calculations are said and done.
You can either return the damage true or false.
In 0.3.7, specifically, because I use it, there is no way to find the original damage, before it goes through source calculations, unless you are specifically adding the damage yourself, and adjust the damage before it goes into the source's pre-built calculations.

If your armor has 5% physical reduction and you get hit 100 damage initially, onStatsChange will tell you the damage about to be applied is 95 physical damage.
If your armor had 0% physical reduction and you get hit 100 damage initially, onStatsChange will tell you the damage about to be applied is 100 physical damage.
Not to mention shielding / armor values on shields & swords / armor as well, which would reduce the value even more.

In both cases, if you use 1% or 0.5%, your always going to get an incorrect value at the end of your calculations, especially when the numbers get higher and higher.


-- not reading back to make it more readable / proper, but don't want to erase it either.

I just know it ain't possible without a source edit.
 
How do you know he wants the damage before everything is already calculated from the sources?

From original post, taking 100 down to 95 from a 5% damage reduction looks like it is exactly what he wants.

I must be very confused... Would this script not work as I think it would?


Code:
function onStatsChange(cid, attacker, type, combat, value)
    if combat == COMBAT_PHYSICALDAMAGE then
        if type == STATSCHANGE_HEALTHLOSS and getCreatureStorage(cid, PHYS_RESIST_STORAGE_VALUE) then
            value = value * PHYS_RESIST_STORAGE_VALUE
            doTargetCombatHealth(attacker, cid, COMBAT_PHYSICALDAMAGE, -value, -value, CONST_ME_NONE)
            return false
        end
    end
return true
end

Or better yet, why would this not work the way the OP wants it to?
 
If you tell me that onStatsChange is triggering itself from doTargetCombatHealth() then we have addEvent() to fix that.
 
If the above would work, then the same could be done for items, easily. There are many ways to save information, not just what the server hands you. I know of a framework that saves any item attribute you can make up to an appropriate .lua file as a table. Loads this information just as easily as the actual item attributes, same for custom storages for players or accounts. How do you think @whitevo can create a custom condition called "DragonMagicBurn" or w/e he says when he was talking about his server. Think outside the box, if the script I posted above works as expected, then the same could be achieved with items without source edit.
 
If the above would work, then the same could be done for items, easily. There are many ways to save information, not just what the server hands you. I know of a framework that saves any item attribute you can make up to an appropriate .lua file as a table. Loads this information just as easily as the actual item attributes, same for custom storages for players or accounts. How do you think @whitevo can create a custom condition called "DragonMagicBurn" or w/e he says when he was talking about his server. Think outside the box, if the script I posted above works as expected, then the same could be achieved with items without source edit.
Onstatschange does trigger itself. How do you suppose addevent will work? When I originally tried doing this I thought of using storages, problem is you have the chance to cancel out other damage that's not a result of the initial from doing so.
 
Back
Top