[TFS 1.1] Outfit Bonuses

OP
Colors

Colors

Joined
Mar 22, 2013
Messages
938
Solutions
4
Reaction score
268
This is how we did it on Gunzodus (now we use different system - bonus packs), I will post a code soon.
The lua code is little bit messy because you need to define all those conditions for every skill.

HTML:
<outfit type="1" looktype="128" name="Citizen" premium="0" unlocked="1" speed="10" maxhealth="100" enabled="1" />
    <outfit type="1" looktype="129" name="Hunter" premium="0" unlocked="1" skilldist="3" enabled="1" />
    <outfit type="1" looktype="130" name="Mage" premium="0" unlocked="1" maxmana="200" maxhealth="100" maglevel="4" enabled="1" />
    <outfit type="1" looktype="131" name="Knight" premium="0" unlocked="1" skillsword="3" enabled="1" />
    <outfit type="1" looktype="132" name="Nobleman" premium="0" unlocked="1" skillclub="3" enabled="1" />
    <outfit type="1" looktype="133" name="Summoner" premium="0" unlocked="1" maxmana="100" maglevel="2" enabled="1" />
    <outfit type="1" looktype="134" name="Warrior" premium="0" unlocked="1" skillsword="3" enabled="1" />
    <outfit type="1" looktype="143" name="Barbarian" premium="0" unlocked="1" skillaxe="3" enabled="1" />
    <outfit type="1" looktype="144" name="Druid" premium="0" unlocked="1" maglevel="2" enabled="1" />
    <outfit type="1" looktype="145" name="Wizard" premium="0" unlocked="1" maxmana="100" maglevel="1" enabled="1" />
    <outfit type="1" looktype="146" name="Oriental" premium="0" unlocked="1" maxhealth="120" maxmana="200" speed="15" enabled="1" />
That looks nice, it's purely made on sources or you're using some kind of xml parser in lua?
 
OP
Colors

Colors

Joined
Mar 22, 2013
Messages
938
Solutions
4
Reaction score
268
Can help with resist? :D didnt work on tfs 1.2
Did you added it? Because the original script doesn't have that function. I did have a version with a "beta" of those features, but it wasn't really good since it involves a lot of checking in a onHealth/Mana event.
I think is just better and easier to build this system in sources.

This one really depends on how you gonna do it, but it isn't added by default. You'll have to code it yourself.

Sorry.
 

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,004
Solutions
17
Reaction score
2,127
Location
Poland
GitHub
Zbizu
Hello ppl, who know how make:

1. Speed for outfit
2. Crit from new 10.98 version.
3. Mana steal from new 10.98 version.
4. hp steal from new 10.98 version.

a.) creaturescript + networkmessage
or...
b.) source edits
 

imkingran

Learning everyday.
Premium User
Joined
Jan 15, 2014
Messages
1,317
Solutions
34
Reaction score
428
@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.

At one point I was trying to make an upgrade system with elemental protections using this similar method. The only issue is when a player is wearing Mana Shield it doesn't apply and onManaChange() does not offer the same params as onHealthChange() to find the primaryType/secondaryType.

Is there a way to add elemental protections through onManaChange() as well? Or another way to do it when the player is wearing mana shield?
 

Raber

New Member
Joined
Feb 6, 2011
Messages
30
Reaction score
2
I think is better do something like this:
Code:
[128] = {[vocationId] = {[1] = {condition = distance}, [2] = {condition = sword}, [3] = {condition = hp}}},
And then change this part:
Code:
local oldOutfit_t = outfitBonuses[old.lookType]
To something like this (Just an idea):
Code:
local oldOutfit_t = outfitBonuses[old.lookType][self:getVocation():getBase():getId()]

You may need to adapt the currentOutfit part also.

Thanks for this, awesome work! A question, I made it work for a selected vocation, but not sure how to add more vocations to a certain outfit. For example, ED and MS for mage outfit.
 

Hidroponica

Member
Joined
Feb 16, 2016
Messages
75
Reaction score
8
[128] = {[1, 2, 6, 7] = {[1] = {condition = distance}, [2] = {condition = sword}, [3] = {condition = hp}}},
 

Raber

New Member
Joined
Feb 6, 2011
Messages
30
Reaction score
2
Anyone know about how to make some bonuses just for certain vocations?
 

Lolis

Member
Joined
Mar 18, 2021
Messages
17
Reaction score
12
Location
Portugal
just impletented that on TFS 1.3 and worked 100% was easy to configure and to make changes to meet my demands

Nice job! ;)

my script with all sets for 8.6 and some stats changes:
Lua:
local hp_tier1 = Condition(CONDITION_ATTRIBUTES)
hp_tier1:setParameter(CONDITION_PARAM_TICKS, -1) -- not sure but this is the time of condition to expire(?)
hp_tier1:setParameter(CONDITION_PARAM_SUBID, 100)
hp_tier1:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 150)

local hp_tier2 = Condition(CONDITION_ATTRIBUTES)
hp_tier2:setParameter(CONDITION_PARAM_TICKS, -1)
hp_tier2:setParameter(CONDITION_PARAM_SUBID, 101)
hp_tier2:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 250)

local mana_tier1 = Condition(CONDITION_ATTRIBUTES)
mana_tier1:setParameter(CONDITION_PARAM_TICKS,-1)
mana_tier1:setParameter(CONDITION_PARAM_SUBID, 102)
mana_tier1:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTS, 150)

local mana_tier2 = Condition(CONDITION_ATTRIBUTES)
mana_tier2:setParameter(CONDITION_PARAM_TICKS,-1)
mana_tier2:setParameter(CONDITION_PARAM_SUBID, 103)
mana_tier2:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTS, 300)

local ml_tier1 = Condition(CONDITION_ATTRIBUTES)
ml_tier1:setParameter(CONDITION_PARAM_TICKS,-1)
ml_tier1:setParameter(CONDITION_PARAM_SUBID, 104)
ml_tier1:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 2)

local ml_tier2 = Condition(CONDITION_ATTRIBUTES)
ml_tier2:setParameter(CONDITION_PARAM_TICKS,-1)
ml_tier2:setParameter(CONDITION_PARAM_SUBID, 105)
ml_tier2:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3)

local distance = Condition(CONDITION_ATTRIBUTES)
distance:setParameter(CONDITION_PARAM_TICKS, -1)
distance:setParameter(CONDITION_PARAM_SUBID, 106)
distance:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 4)

local sword = Condition(CONDITION_ATTRIBUTES)
sword:setParameter(CONDITION_PARAM_TICKS, -1)
sword:setParameter(CONDITION_PARAM_SUBID, 107)
sword:setParameter(CONDITION_PARAM_SKILL_SWORD, 5)

local axe = Condition(CONDITION_ATTRIBUTES)
axe:setParameter(CONDITION_PARAM_TICKS, -1)
axe:setParameter(CONDITION_PARAM_SUBID, 108)
axe:setParameter(CONDITION_PARAM_SKILL_AXE, 5)

local club = Condition(CONDITION_ATTRIBUTES)
club:setParameter(CONDITION_PARAM_TICKS, -1)
club:setParameter(CONDITION_PARAM_SUBID, 109)
club:setParameter(CONDITION_PARAM_SKILL_CLUB, 5)

local shield = Condition(CONDITION_ATTRIBUTES)
shield:setParameter(CONDITION_PARAM_TICKS, -1)
shield:setParameter(CONDITION_PARAM_SUBID, 110)
shield:setParameter(CONDITION_PARAM_SKILL_SHIELD, 8)


--local speed = Condition(CONDITION_HASTE) need to review the speed condition this one gives the stats of a speed spell like utani hur
--speed:setParameter(CONDITION_PARAM_TICKS, -1)
--speed:setParameter(CONDITION_PARAM_SUBID, 111)
--speed:setParameter(CONDITION_PARAM_SPEED, 20)

oldOutfit = {}

outfitBonuses = {
    [128] = {[3] = {condition = hp_tier1}}, --male citizen
    [129] = {[3] = {condition = distance}}, -- male hunter
    [130] = {[3] = {condition = {ml_tier1,mana_tier2}}}, -- male mage
    [131] = {[3] = {condition = {sword, hp_tier1}}}, -- male knight
    [132] = {[3] = {condition = club}}, -- male Nobleman
    [133] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- male Summoner
    [134] = {[3] = {condition = {sword, hp_tier1}}}, -- male Warrior
    [143] = {[3] = {condition = {axe, hp_tier1}}}, -- male Barbarian
    [144] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- male Druid
    [145] = {[3] = {condition = {ml_tier1, mana_tier1, hp_tier1}}}, -- male Wizard
    [146] = {[3] = {condition = {hp_tier1, mana_tier1}}}, -- male Oriental
    [151] = {[3] = {condition = {club, hp_tier1}}}, -- male Pirate
    [152] = {[3] = {condition = distance}}, -- male Assassin
    [153] = {[3] = {condition = hp_tier2}}, -- male Beggar
    [154] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- male Shaman
    [251] = {[3] = {condition = {shield, hp_tier2}}}, -- male Norseman
    [268] = {[3] = {condition = {shield, hp_tier2}}}, -- male Nightmare
    [273] = {[3] = {condition = hp_tier1}}, -- male Jester
    [278] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- male Brotherhood
    [289] = {[3] = {condition = {hp_tier2, mana_tier1}}}, -- male Demon Hunter
    [325] = {[3] = {condition = ml_tier1}}, -- male Yalaharian
    [335] = {[3] = {condition = {hp_tier2, mana_tier1}}}, -- male Warmaster
    [367] = {[3] = {condition = {mana_tier2, ml_tier2, hp_tier2}}}, -- male Wayfarer *OP
    [136] = {[3] = {condition = hp_tier1}}, --female citizen
    [137] = {[3] = {condition = distance}}, -- female hunter
    [138] = {[3] = {condition = {ml_tier1,mana_tier2}}}, -- female mage
    [139] = {[3] = {condition = {sword, hp_tier1}}}, -- female knight
    [140] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- female Nobleman
    [141] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- female Summoner
    [142] = {[3] = {condition = {sword, hp_tier1}}}, -- female Warrior
    [147] = {[3] = {condition = {axe, hp_tier1}}}, -- female Barbarian
    [148] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- female Druid
    [149] = {[3] = {condition = {ml_tier1, mana_tier1, hp_tier1}}}, -- female Wizard
    [150] = {[3] = {condition = {hp_tier1, mana_tier1}}}, -- female Oriental
    [155] = {[3] = {condition = {club, hp_tier1}}}, -- female Pirate
    [156] = {[3] = {condition = distance}}, -- female Assassin
    [157] = {[3] = {condition = hp_tier2}}, -- female Beggar
    [158] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- female Shaman
    [252] = {[3] = {condition = {shield, hp_tier2}}}, -- female Norseman
    [269] = {[3] = {condition = {shield, hp_tier2}}}, -- female Nightmare
    [270] = {[3] = {condition = hp_tier1}}, -- female Jester
    [279] = {[3] = {condition = {ml_tier1, mana_tier2}}}, -- female Brotherhood
    [288] = {[3] = {condition = {hp_tier2, mana_tier1}}}, -- female Demon Hunter
    [324] = {[3] = {condition = ml_tier1}}, -- female Yalaharian
    [336] = {[3] = {condition = {hp_tier2, mana_tier1}}}, -- female Warmaster
    [366] = {[3] = {condition = {mana_tier2, ml_tier2, hp_tier2}}} -- female Wayfarer *OP

}

function Creature:onChangeOutfit(outfit)
    if self:isPlayer() then
        local getOutfit = self:getOutfit()
        oldOutfit[self:getId()] = { --Colors (Head, Body, Legs, Feet) and lookTypeEx are unused, but just gave an example of doing team outfit bonuses
            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

function Creature:onAreaCombat(tile, isAggressive)
    return RETURNVALUE_NOERROR
end

function Creature:onTargetCombat(target)
    return RETURNVALUE_NOERROR
end

still trying to figure out how to put player with speed. Was trying to use CONDITION_HASTE but probably there is other condition for speed
 
Last edited:
Top