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

[TFS 1.1] Outfit Bonuses

So I managed to figure out my previous errors, however I've run into another problem... :(
I've been using this template to create bonuses:
Code:
local hp = Condition(CONDITION_ATTRIBUTES)
hp:setParameter(CONDITION_PARAM_TICKS, -1)
hp:setParameter(CONDITION_PARAM_SUBID, 100)
hp:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 300)

I have figured out most bonuses +melee skills, +regeneration, +magic level.... But I can't figure out how to make a bonus for element resist. For example: +10% Fire Resist. Does anyone know how to do this?

Unfortunately there are currently no conditions for this, and so you need a script for onHealthChange and you have to calculate it all yourself but I haven't gotten around to it yet myself. If I ever decide to make it, I'll release it here :p
 
@Blaggo
This should work.
For the condition, just add this below the other conditions:
Code:
local resistFire = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 120)


Then, make a creaturescript and name it as you please, register in creaturescripts.xml and in login.lua, enter:
Code:
local resists = { {120, COMBAT_FIREDAMAGE, 20} } -- {subId, damageType, resistancePercent}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    for i = 1, #resists do
        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, resists[i][1]) then
            if primaryType == resists[i][2] then
                primaryDamage = (primaryDamage - (primaryDamage * (resists[i][3] / 100)))
            end
            if secondaryType == resists[i][2] then
                secondaryDamage = (secondaryDamage - (secondaryDamage * (resists[i][3] / 100)))
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

The existing codebase will do the rest.
Let me know if you have any issues with it.

To add more elements, just add them to the table called 'resists' and add a condition with a matching subId.
 
@Blaggo
This should work.
For the condition, just add this below the other conditions:
Code:
local resistFire = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 120)


Then, make a creaturescript and name it as you please, register in creaturescripts.xml and in login.lua, enter:
Code:
local resists = { {120, COMBAT_FIREDAMAGE, 20} } -- {subId, damageType, resistancePercent}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    for i = 1, #resists do
        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, resists[i][1]) then
            if primaryType == resists[i][2] then
                primaryDamage = (primaryDamage - (primaryDamage * (resists[i][3] / 100)))
            end
            if secondaryType == resists[i][2] then
                secondaryDamage = (secondaryDamage - (secondaryDamage * (resists[i][3] / 100)))
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

The existing codebase will do the rest.
Let me know if you have any issues with it.

To add more elements, just add them to the table called 'resists' and add a condition with a matching subId.

How do I register in creaturescripts.xml and in login.lua? Because I can't get it to work, could you help me?
 
How do I register in creaturescripts.xml and in login.lua? Because I can't get it to work, could you help me?
creaturescripts.xml:
Code:
<event type="healthchange" name="resist" script="resist.lua"/>
login.lua:
Code:
player:registerEvent("resist")
 
[Warning - Events::load] Can not load script: creature.lua
data/events/scripts/creature.lua:5: '<name>' expected near 'function'
>> Loading monsters
>> Loading outfits
>> Checking world type... PVP
>> Loading map
> Map size: 2048x2048.
> Map loading time: 1.267 seconds.
> Loaded house items in: 0 s
>> Initializing gamestate
>> Loaded all modules, server starting up...
>> Valhalla Server Online!

function Creature:eek:nTargetCombat(target)
return stat_onTargetCombat(self, target)
end

function function Creature:eek:nChangeOutfit(outfit)
return local hp = Condition(CONDITION_ATTRIBUTES)
hp:setParameter(CONDITION_PARAM_TICKS, -1)
hp:setParameter(CONDITION_PARAM_SUBID, 100)
hp:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 2000)

local distance = Condition(CONDITION_ATTRIBUTES)
distance:setParameter(CONDITION_PARAM_TICKS, -1)
distance:setParameter(CONDITION_PARAM_SUBID, 101)
distance:setParameter(CONDITION_PARAM_SKILL_DISTANCEPERCENT, 150)

local sword = Condition(CONDITION_ATTRIBUTES)
sword:setParameter(CONDITION_PARAM_TICKS, -1)
sword:setParameter(CONDITION_PARAM_SUBID, 102)
sword:setParameter(CONDITION_PARAM_SKILL_SWORDPERCENT, 150)

oldOutfit = {}

outfitBonuses = {
[128] = {[1] = {condition = distance}, [2] = {condition = sword}, [3] = {condition = hp}},
[129] = {[3] = {condition = hp}},
[289] = {[3] = {condition = {distance, sword, hp}}}
}

function Creature:eek:nChangeOutfit(outfit)
if self:isPlayer() then
local getOutfit = self:getOutfit()
oldOutfit[self:getId()] = { --Colors (Head, Body, Legs, Feet) and lookTypeEx are unused, but I still keep them here because I'm stupid.
lookHead = getOutfit.lookHead;
lookBody = getOutfit.lookBody;
lookLegs = getOutfit.lookLegs;
lookFeet = getOutfit.lookFeet;
lookType = getOutfit.lookType;
lookTypeEx = getOutfit.lookTypeEx;
lookAddons = getOutfit.lookAddons;
lookMount = getOutfit.lookMount;
}

local old = oldOutfit[self:getId()]
local oldOutfit_t = outfitBonuses[old.lookType]
if oldOutfit_t and oldOutfit_t[old.lookAddons] then
local oldCondition = oldOutfit_t[old.lookAddons].condition
if type(oldCondition) == "table" then
for _, condition in pairs(oldCondition) do
self:removeCondition(condition:getType(), condition:getId(), condition:getSubId())
end
else
self:removeCondition(oldCondition:getType(), oldCondition:getId(), oldCondition:getSubId())
end
end

local currentOutfit = outfitBonuses[outfit.lookType]
if currentOutfit and currentOutfit[outfit.lookAddons] then
local newCondition = currentOutfit[outfit.lookAddons].condition
if type(newCondition) == "table" then
for _, condition in pairs(newCondition) do
self:addCondition(condition)
end
else
self:addCondition(newCondition)
end
end
end
return true
end
return true
end

function Creature:eek:nAreaCombat(tile, isAggressive)
return true
end

function Creature:eek:nTargetCombat(target)
return true
end



ANY ideas?
 
Code:
function function Creature:eek:nChangeOutfit(outfit)
remove one of the 'function' words ;)
 
lol thanks i stared at it for a good 20 mins and kept looking it right over
 
so no errors everything seems to be in the right place yet none of the bonuses seem to be working, would appreciate any input.

function Creature:eek:nTargetCombat(target)
return stat_onTargetCombat(self, target)
end

function Creature:eek:nChangeOutfit(outfit)
local hp = Condition(CONDITION_ATTRIBUTES)
hp:setParameter(CONDITION_PARAM_TICKS, -1)
hp:setParameter(CONDITION_PARAM_SUBID, 100)
hp:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 2000000)

local distance = Condition(CONDITION_ATTRIBUTES)
distance:setParameter(CONDITION_PARAM_TICKS, -1)
distance:setParameter(CONDITION_PARAM_SUBID, 101)
distance:setParameter(CONDITION_PARAM_SKILL_DISTANCEPERCENT, 150)

local sword = Condition(CONDITION_ATTRIBUTES)
sword:setParameter(CONDITION_PARAM_TICKS, -1)
sword:setParameter(CONDITION_PARAM_SUBID, 102)
sword:setParameter(CONDITION_PARAM_SKILL_SWORDPERCENT, 150)

oldOutfit = {}

outfitBonuses = {
[633] = {[1] = {condition = distance}, [2] = {condition = sword}, [3] = {condition = hp}},
[633] = {[3] = {condition = hp}},
[633] = {[2] = {condition = {distance, sword, hp}}}
}

function Creature:eek:nChangeOutfit(outfit)
if self:isPlayer() then
local getOutfit = self:getOutfit()
oldOutfit[self:getId()] = { --Colors (Head, Body, Legs, Feet) and lookTypeEx are unused, but I still keep them here because I'm stupid.
lookHead = getOutfit.lookHead;
lookBody = getOutfit.lookBody;
lookLegs = getOutfit.lookLegs;
lookFeet = getOutfit.lookFeet;
lookType = getOutfit.lookType;
lookTypeEx = getOutfit.lookTypeEx;
lookAddons = getOutfit.lookAddons;
lookMount = getOutfit.lookMount;
}

local old = oldOutfit[self:getId()]
local oldOutfit_t = outfitBonuses[old.lookType]
if oldOutfit_t and oldOutfit_t[old.lookAddons] then
local oldCondition = oldOutfit_t[old.lookAddons].condition
if type(oldCondition) == "table" then
for _, condition in pairs(oldCondition) do
self:removeCondition(condition:getType(), condition:getId(), condition:getSubId())
end
else
self:removeCondition(oldCondition:getType(), oldCondition:getId(), oldCondition:getSubId())
end
end

local currentOutfit = outfitBonuses[outfit.lookType]
if currentOutfit and currentOutfit[outfit.lookAddons] then
local newCondition = currentOutfit[outfit.lookAddons].condition
if type(newCondition) == "table" then
for _, condition in pairs(newCondition) do
self:addCondition(condition)
end
else
self:addCondition(newCondition)
end
end
end
return true
end
return true
end

function Creature:eek:nAreaCombat(tile, isAggressive)
return true
end

function Creature:eek:nTargetCombat(target)
return true
end
 
i did, then at some point it would make everyone look invisible then crash the game if you tried to change your outfit again.
 
hmm... been messing around with this, and is there some way to get rid of the haste symbol? i did dis, everything works correctly but it's really dumb to see a haste icon

local speed = Condition(CONDITION_HASTE)
speed:setParameter(CONDITION_PARAM_TICKS, -1)
speed:setParameter(CONDITION_PARAM_SUBID, 102)
speed:setParameter(CONDITION_PARAM_SPEED, 100)
 
Unless you change sources I think is not possible, at least in that way (Using conditions)
 
whats the correct value for magiclevel TFS 1.1? I tried STAT_MAGICLEVELPOINTS and SKILL_MAGICLEVELPERCENT, none of which worked
 
Is it possible to modify this to make it like check for full outfits and have bonus for full outfits?

I mean: I have full citizen addon.. 5% fire resist.. i have citizen and hunter, 5% fire resist and 10 speed. So instead of checking the actual outfit, it checks how many outfits the player earned and gives bones based on that.
 
Is it possible to modify this to make it like check for full outfits and have bonus for full outfits?

Of course it is.
You will need if statement with "outfit.lookAddons == 3" in Creature:eek:nChangeOutfit(outfit)
 
Hello, I'm having a problem, the system don't work :eek:
what I do:
copy the system to creature.lua
enable it in events.xml
try make just a little thing to see if is loading it
Code:
function Creature:onChangeOutfit(outfit)
    if self:isPlayer() then
        self:getPosition():sendMagicEffect(CONST_ME_MAGIC_BLUE)
register in login.lua
when I change outfits then send the magic effect ... so the system is loaded
I change the values in the bonuses
Code:
outfitBonuses = {
    [128] = {[3] = {condition = distance}},
    [129] = {[3] = {condition = hp}},
    [635] = {[3] = {condition = {sword, hp}}} -- test
}
just for test, but don't work D:
 
It will work when I do this:

[129] = {[3] = {condition = hp*2}}, ?

or this:

[129] = {[3] = {condition = hp, hp}},


@Blaggo
This should work.
For the condition, just add this below the other conditions:
Code:
local resistFire = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 120)


Then, make a creaturescript and name it as you please, register in creaturescripts.xml and in login.lua, enter:
Code:
local resists = { {120, COMBAT_FIREDAMAGE, 20} } -- {subId, damageType, resistancePercent}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    for i = 1, #resists do
        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, resists[i][1]) then
            if primaryType == resists[i][2] then
                primaryDamage = (primaryDamage - (primaryDamage * (resists[i][3] / 100)))
            end
            if secondaryType == resists[i][2] then
                secondaryDamage = (secondaryDamage - (secondaryDamage * (resists[i][3] / 100)))
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

The existing codebase will do the rest.
Let me know if you have any issues with it.

To add more elements, just add them to the table called 'resists' and add a condition with a matching subId.

Also how can I ADD resists for death for example, I added to the tab like this:
Code:
local resists = {

{120, COMBAT_DEATHDAMAGE, 20},
{121, COMBAT_EARTHDAMAGE, 20},
{122, COMBAT_ENERGYDAMAGE, 20},
{123, COMBAT_FIREDAMAGE, 20},
{124, COMBAT_ICEDAMAGE, 20},
{125, COMBAT_PHYSICALDAMAG, 20}

} -- {subId, damageType, resistancePercent}
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not creature:isPlayer() then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    if primaryType == COMBAT_HEALING then
        return primaryDamage, primaryType, secondaryDamage, secondaryType
    end
    for i = 1, #resists do
        if creature:getCondition(CONDITION_ATTRIBUTES, CONDITIONID_COMBAT, resists[i][1]) then
            if primaryType == resists[i][2] then
                primaryDamage = (primaryDamage - (primaryDamage * (resists[i][3] / 100)))
            end
            if secondaryType == resists[i][2] then
                secondaryDamage = (secondaryDamage - (secondaryDamage * (resists[i][3] / 100)))
            end
        end
    end
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

bit it doesn't work

Also declared locals:
PHP:
local resistFire = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 123)

local resistIce = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 124)

local resistEarth = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 121)

local resistDeath = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 120)

local resistPhysical = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 125)

local resistEnergy = Condition(CONDITION_ATTRIBUTES)
resistFire:setParameter(CONDITION_PARAM_TICKS, -1)
resistFire:setParameter(CONDITION_PARAM_SUBID, 122)
 
Last edited:
Back
Top