• 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 Elemental damage problem TFS 1.3

Icaraii

Well-Known Member
Joined
Jan 5, 2020
Messages
469
Solutions
1
Reaction score
58
Guys, I'm with a little problem that I've being breaking my head and no solution is coming out.
My server is a custom server with only one class and 9 types of weapons that the player can change between weapons and doing so the player will change his gameplay.
Close combat weapons use sword skill and distance combat weapons use distance skill, also my server is greatly influenced by the 7 elements (physical, energy, earth, fire, ice, holy and death).

The problem begins when I try to add elemental damage to weapons:
If I use
<attribute key="elementIce" value="110" />
in item.xml I also have to use at least 1 attack
<attribute key="attack" value="1" />
If I don't do that, the weapon doesn't show it's damage. But doing that add a bug to my client, where different types of damage stack on top of each other, becaming impossible to see how much damage the player is doing.
Trying to solve the client bug I try to use a weapon script to add damage to weapons:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 1)

function onGetFormulaValues(player, skill, attack)

    local playlvl = player:getLevel()
    local sword = player:getSkillLevel(SKILL_SWORD)

    if (playlvl<300) then
    local min = ((((attack * 150000) / 5000) * ((attack * sword * 25000) / 2000) * (attack * player:getLevel() * 13000 / 3000)) / 100000000000)
    local max = ((((attack * 150000) / 5000) * ((attack * sword * 25000) / 2000) * (attack * player:getLevel() * 13000 / 3000)) / 100000000000) * (((attack * attack) * 2) / 2000)
    return -min, -max
    
    else
    local min = ((((attack * 150000) / 5000) * ((attack * sword * 25000) / 2000) * (attack * player:getLevel() * 13000 / 3000)) / 100000000000)
    local max = ((((attack * 150000) / 5000) * ((attack * sword * 25000) / 2000) * (attack * player:getLevel() * 13000 / 3000)) / 100000000000) * (((attack * attack) * 2) / 2000)
    end   
end                             

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
            
 
local area = createCombatArea( { {0, 0, 0}, {0, 3, 0}, {0, 0, 0} } )
setCombatArea(combat, area)
 
function onUseWeapon(cid, var)
        return doCombat(cid, combat, var)
 

end

The problem now it's that only works in elemental weapons. If I leave only the attack in items.xml it doesn't do any damage with this script. And now I don't know how to proceed to solve the problem.

More information:
Item.xml:
XML:
    <item id="26803" article="an" name="Iron Revolver">
        <attribute key="weight" value="2100" />
        <attribute key="attack" value="100" />
        <attribute key="weaponType" value="distance" />
        <attribute key="shootType" value="explosion" />
        <attribute key="range" value="7" />
</item>
    <item id="26805" article="an" name="Promise Of Destruction">
        <attribute key="weight" value="2200" />
        <attribute key="attack" value="50" />
        <attribute key="weaponType" value="wand" />
        <attribute key="shootType" value="smallearth" />
        <attribute key="range" value="7" />
</item>

    <item id="2214" article="an" name="Of Destruction">
        <attribute key="weight" value="2200" />
        <attribute key="attack" value="1" />
        <attribute key="elementIce" value="110" />
        <attribute key="weaponType" value="distance" />
        <attribute key="shootType" value="explosion" />
        <attribute key="range" value="7" />
</item>
I've tryed all the ways above and none of them solved my problem.

weapons.xml:
XML:
    <distance id="2214" level="20" type="ice" event="function" value="default" action="removecharge" range="8">
    </distance>
    
    <distance id="26803" level="130" unproperly="1" action="removecharge" range="8" script="distanceweapon.lua">
    </distance>
    
    <distance id="26805" level="140" action="removecharge" range="8" script="distanceweapon.lua">
    </distance>

With all I explained of my server, does anyone have a solution?
 
function onGetFormulaValues(player, skill, attack)

You actually have to return the min, max from the function, or you will get no damage.

Lua:
function onGetFormulaValues(player, skill, attack)
    local min = math.max(attack - 10, 1)
    local max = attack + 10
    return -min, -max
end
 
Back
Top