CreatureEvent [TFS 1.1] Ultimate item stat system (elements, skills, exp, loot and more)

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,030
Reaction score
589
Location
Canada
ok

Now ?

Code:
function Creature:onChangeOutfit(outfit)
    return true
end

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

local function removeCombatProtection(cid)
    local player = Player(cid)
    if not player then
        return true
    end

    local time = 0
    if player:isMage() then
        time = 10
    elseif player:isPaladin() then
        time = 20
    else
        time = 30
    end

    player:setStorageValue(STORAGE.COMBATPROTECTIONSTORAGE, 2)
    addEvent(function(cid)
        local player = Player(cid)
        if not player then
            return
        end

        player:setStorageValue(STORAGE.COMBATPROTECTIONSTORAGE, 0)
        player:remove()
    end, time * 1000, cid)
end

function Creature:onTargetCombat(target)
   return stat_onTargetCombat(self, target)
    if not self then
        return true
    end

    if target:isPlayer() then
        if self:isMonster() then
            local protectionStorage = target:getStorageValue(STORAGE.COMBATPROTECTIONSTORAGE)

            if target:getIp() == 0 then -- If player is disconnected, monster shall ignore to attack the player
                if protectionStorage <= 0 then
                    addEvent(removeCombatProtection, 30 * 1000, target.uid)
                    target:setStorageValue(STORAGE.COMBATPROTECTIONSTORAGE, 1)
                elseif protectionStorage == 1 then
                    self:searchTarget()
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end

                return true
            end

            if protectionStorage >= os.time() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end

    return true
end
I believe you should be able to just replace the last return true with "return stat_onTargetCombat(self, target)"
 

Mariuskens

Sword Art Online 2D-MMORPG
Joined
Nov 21, 2008
Messages
973
Reaction score
80
Location
Spain
oky im going try it also tonigh good joints needed xDDDDDD
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,030
Reaction score
589
Location
Canada
I just fully resintalled the entire system after downloading the latest rev as zip and downloaded the latest x64 exe from the nightlies (681) and it still isn't working. No errors.
 

Mariuskens

Sword Art Online 2D-MMORPG
Joined
Nov 21, 2008
Messages
973
Reaction score
80
Location
Spain
Im using this copiled (Sources from: https://github.com/otland/forgottenserver)

All Runs good but when player login appear:

-Lua script error: main interface
in atimer event called from:
<uknown scriptfile>
data/stats.lua:1965 :attempt to call global "isplayer" <a nil value>
strack tradeback:
[C]: in function "isplayer"
data/stats.lua:1965 in function <data/stats/lua:1964>

Work fine:
- Looting
- Effefcts

Not working fine:
items for upgrade: 8305, 8310, 8298 toid 8301.
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,030
Reaction score
589
Location
Canada
So it's possible to loot stuff like bones and parchments with bonuses...
 

nugo

Australia OT Mapper
Joined
Apr 1, 2009
Messages
190
Reaction score
21
I try to have a solid go at fixing these issues myself, i have come along way i fixed most of my errors/problems but im not sure about this one. I know it must be annoying but sorry lol. When i shift click to see stats i can only do it on weapons such as "fine" "uncommon" but occasional i get a weapon (unknown type) that will error in consol when i shift click it know its a rare.

@zbizu




Never mind fixed it for those interest at the bottom of stats.lua there is some green text
Code:
--[[ workaround for older tfs
function ItemType:getRequiredLevel()
        local i = Item(doCreateItemEx(self:getId()))
        local d, v = i:getDescription():match('%It can only be wielded properly by (.-)% of level (.-)% or higher')
        return v:match('%d+') or 0
end
-- ]]
Grab that function and paste it were your functions are stored (libs or compat etc) Its strange because im using tfs 1.1
 
Last edited:

nugo

Australia OT Mapper
Joined
Apr 1, 2009
Messages
190
Reaction score
21
So it's possible to loot stuff like bones and parchments with bonuses...
Yea im looting "
08:41 You see a strengthened gemmed book +2.
It weighs 13.00 oz.
Item ID: 1976
Position: 32342, 32216, 7" Golden mugs etc. Anyway to quick disable the effects on random items like these?

Gem enchants dont work for me either everything else is fine

@zbizu
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,030
Reaction score
589
Location
Canada
@nugo @zbizu
Yeah, I have the same thing. Gem enchants don't work, looting is weird with non-enchantable items being +x, but the effects on items that I enchanted previously before updating seem to work properly.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
@nugo it's a known bug. I need to fix attributes detection in loot.
Any console errors while enchanting?
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,030
Reaction score
589
Location
Canada
No console errors. Just says "you cannot use this object" at the bottom of the window and nothing more.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
id of item which you try to upgrade?
 

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,030
Reaction score
589
Location
Canada
I tried on a leather armor, a sword, dwarven legs. Not sure the IDs off the top of my head. I tried all the different gems and none worked on any item.
 

calveron

Bravemansworld
Joined
Feb 5, 2008
Messages
173
Reaction score
14
Location
Sweden
Just noticed that when having exp bonus, players gets exp from summons aswell
 

Hmoobphajej

New Member
Joined
Aug 13, 2008
Messages
11
Reaction score
0
Was this built using the official TFS 1.1 release or the nightlies? Because I just seemed to have a much harder time then normal setting it up. Eventually got it but it was a lot of figuring out on my own.

*Edit: Sorry, the official just came out recently I'm super late to the thread but definitely looking forward to contributing. Just wanted to give a heads up that some steps may be different now compared to the ones on page 1.
 
Last edited:
Top