• 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

Colors

Joined
Mar 22, 2013
Messages
812
Solutions
4
Reaction score
271
This script should be mainly used by people who doesn't give outfits/addons as "donation rewards", but we all know that is not going to happen...

So, this script is really simple yet functional. Is not tested on combat but I didn't find any bug atm.

Creaturescripts:
1.- creaturescripts/scripts/yourloginscript.lua
Before the last return true add:
Code:
  player:setOutfit(player:getOutfit())

Events:
1.- events/events.xml
Just enable the onChangeOutfit method (change enabled="0" to enabled="1").
Code:
    <event class="Creature" method="onChangeOutfit" enabled="1" />

2.- events/scripts/creature.lua
Search and replace:
Code:
function Creature:onChangeOutfit(outfit)
    return true
end

To:
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)

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}},
    [130] = {[3] = {condition = {distance, sword, hp}}}
}

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

And that's it, now you just have to add your outfits, addons and conditions or even mounts to create some weird new attributes to your players.
 
gr8 m8 r8 8/8

Code:
--Colors (Head, Body, Legs, Feet) and lookTypeEx are unused, but I still keep them here because I'm stupid.

lol nope, you just gave an example of doing team outfit bonuses
 
nice colors! I've nearly got all my recipes done for your crafting system too lol
 
Wow, great work Colors!

Code:
player:setOutfit(player:getOutfit())

at the end of the login script was a clever little hack.

Thanks for the contribution!
Red
 
Wow, great work Colors!

Code:
player:setOutfit(player:getOutfit())

at the end of the login script was a clever little hack.

Thanks for the contribution!
Red
can you explain this lil hack pls? :)
 
can you explain this lil hack pls? :)

Creature: onChangeOutfit executes when a creature's outfit changes.
Therefore, you'd have to change your outfit to receive the bonus.

Executing player:setOutfit(player:getOutfit()) as they login executes Creature: onChangeOutfit. This sets the outfit bonus when they login.

Red
 
You should make it so that if you're modifying things like hp/mana, it should add onto their current hp as well as increasing their max. If they have 200 max and they switch to the outfit, they have 200/newMaxHp and it does that every time you switch to that outfit or even if you switch to another outfit that offers an hp bonus.
 
You should make it so that if you're modifying things like hp/mana, it should add onto their current hp as well as increasing their max. If they have 200 max and they switch to the outfit, they have 200/newMaxHp and it does that every time you switch to that outfit or even if you switch to another outfit that offers an hp bonus.
No, that could be used to abuse mana train or use the hp attributes as a "health potion".

As for the speed attribute you need to change the CONDITION_ATTRIBUTE to CONDITION_HASTE. Just take a look at your haste spells.
 
How can I do this with mounts, and can I add things like elemental weakness/strength? If so, could I get an example? On another note, can I make it set/unset storage values? For custom skills/stats as an example?
 
How can I do this with mounts, and can I add things like elemental weakness/strength? If so, could I get an example? On another note, can I make it set/unset storage values? For custom skills/stats as an example?
Umm yeah that can be added, but not directly... You'll need to create more table options (ex: weakness = {blabla, blabla2}, strenght = {blabla, blabla2}) and move the conditions and the whole table into a lib file so can be loaded globally... Maybe I can update this in a couple of days since I'm like 160 commits behind on the TFS.
But to be honest is just an onHealthChange script :p
 
c904905454.png

It looks way too messy :(
 
I made a similar system, but I assigned every outfit to their own functions, this allowed me to add more complex outfit bonuses. If I remember correctly I did it by assigning numbers (outfit IDs) to different functions in a table. Something like this:
Code:
local outfits = {
  [128] = function(player)     local buff = Condition(CONDITION_ATTRIBUTES)
  buff:setParameter(CONDITION_PARAM_TICKS, -1)
  buff:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 20)
buff:setParameter(CONDITION_PARAM_SUBID, 11)
player:addCondition(buff)
end
}

With a system like that I could add whatever bonuses I wanted in an easy way but it might be harder for other people to adjust, I was just wondering what's your thoughts on having it like me? I'm really noob scripter and would like to hear your opinion

And I guess my way of making the script is really messy compared to yours :p
 
Back
Top