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

CreatureEvent [TFS 1.1] Crafting System - ModalWindows

RazorBlade

Retired Snek
Joined
Nov 7, 2009
Messages
2,015
Solutions
3
Reaction score
629
Location
Canada
Hello everyone.

Due to popular request, and because I would like to support truly custom servers rather than sit back and watch hundreds of RL map servers pumped out, I've decided to release my custom crafting system. This system was scripted entirely by me and does not exist anywhere else. The main features are as follows:

Smithing features
- Highly configurable
- Highly user-friendly for players
- Clean, easy navigation through the system
- List of item types, alphabetical (Ammo, Helmets, Swords, etc.)
- List of items in each type, alphabetical (Arrows, Bolts, Steel Helmet, Blacksteel Sword, etc.)
- List of ingredients/items and skill requirements on each item
- Craft the item (duh)
- If enough items to craft same item again, window pops up again to offer quick and easy crafting
- If not enough items, return to list of items in chosen item type
- Set of custom skills with individually customizable rates and max skill levels
- Skills advance with the same formula as regular skills as per tibiawiki, easily configurable
- Bonus chance to craft item for half the usual ingredients
- Bonus chance increases each skill level - for the primary skill used to craft the item in question
- Bonus chance increase is customizable for each skill
- Supports tracking sets - demon set, dwarven set, dragon scale set, etc.
- Supports adding an achievement when the player crafts one of each piece in a set
- Hundreds of existing recipes that can be removed or changed as desired
- Option to require learning of each recipe individually

Tanning and smelting subsystem features
- Similar functionality to smithing, but with a smaller focus
- Tan furs, pelts and leathers into raw leather for crafting
- Smelt various metals and metal objects to produce ingots and refined metals for crafting

For smithing, click use on a molten lava well (id 12458-12461)
For smelting, click use on a lit crucible (id 8641)
For tanning, use a skinning knife (id 13828) on a fur wall (id 3869)

Keep in mind that I renamed certain things, like iron ingot is whetstone and raw leather is goosebump leather, and I also use a lot of items that may not exist in your items.xml yet (10.7 items, etc.). I'll include what I can below.

Renamed:
Whetstone (18337) changed to iron ingot
Goosebump leather (22539) changed to raw leather
Yellow powder (6547) changed to gold ore
--If there are any I missed, feel free to comment and I'll add them to this note--

There's a hell of a lot of code thanks to the 2000+ lines of recipes, so I hope you like visiting pastebin.

Let's get started.
I highly recommend this little system by @zbizu for easier operation: [TFS 1.x] lib folder in "data" like 0.4
Actions
actions.xml:
XML:
<action itemid="12458" script="crafting/smith.lua"/>
<action itemid="12459" script="crafting/smith.lua"/>
<action itemid="12460" script="crafting/smith.lua"/>
<action itemid="12461" script="crafting/smith.lua"/>
<action itemid="8641" script="crafting/smelt.lua"/>
<action itemid="13828" script="crafting/tan.lua"/>

scripts/crafting/smith.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if not Player(player) then
        return false
    end
    player:sendEquipmentWindow()
    return true
end
scripts/crafting/smelt.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if not Player(player) then
        return false
    end
    player:sendProductWindow()
    return true
end
scripts/crafting/tan.lua:
Lua:
function onUse(cid, item, fromPosition, target, toPosition, isHotkey)
    local player = Player(cid)
    if not Player(player) then
        return false
    end
    if target.itemid == 3869 then
        return player:sendPeltWindow()
    end
    return false
end


Creaturescripts
creaturescripts.xml:
XML:
    <event type="modalwindow" name="smith_modal" script="smith.lua"/>
    <event type="modalwindow" name="smelt_modal" script="smelt.lua"/>
    <event type="modalwindow" name="tan_modal" script="tan.lua"/>

smith.lua:
Lua:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:equipmentWindowChoice(modalWindowId, buttonId, choiceId)
    player:eRecipeWindowChoice(modalWindowId, buttonId, choiceId)
    player:sortedWindowChoice(modalWindowId, buttonId, choiceId)
    return true
end

smelt.lua:
Lua:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:productWindowChoice(modalWindowId, buttonId, choiceId)
    player:recipeWindowChoice(modalWindowId, buttonId, choiceId)
    return true
end

tan.lua:
Lua:
function onModalWindow(player, modalWindowId, buttonId, choiceId)
    player:peltWindowChoice(modalWindowId, buttonId, choiceId)
    player:pRecipeWindowChoice(modalWindowId, buttonId, choiceId)
    return true
end

login.lua:
somewhere outside of the first login section put this
Lua:
for i = 40000, 40012 do
            if player:getStorageValue(i) < 10 then
                player:setStorageValue(i, 10)
                player:setStorageValue(i + 1000, 0)
            end
        end
and register these events with the others at the bottom:
Lua:
    player:registerEvent("smith_modal")
    player:registerEvent("smelt_modal")
    player:registerEvent("tan_modal")

---------------------
Now for the big stuff.
These scripts will all be placed in data/lib, to be loaded by global.lua. If you don't want to use a lib folder, you can put them in data/ and load them individually by putting this in global.lua for each one:
Lua:
dofile('data/script.lua')
This is not recommended as it destroys the possibility of organization ;)

Here goes!
smith.lua:
[Lua] smith.lua - Pastebin.com

smelt.lua:
[Lua] smelt.lua - Pastebin.com

tan.lua:
[Lua] tan.lua - Pastebin.com

skills.lua:
[Lua] skills.lua - Pastebin.com

achievements.lua (necessary if using achievements for sets with my code):
[Lua] achievements.lua - Pastebin.com

sets.lua (necessary if using achievements for sets with my code):
Lua:
--Example of a set to be used with crafting achievements
sets = {
    ["demon"] = {pieces = {
        [1] = {name = "demon helmet", id = 2493, storage = 6661},
        [2] = {name = "demon armor", id = 2494, storage = 6662},
        [3] = {name = "demon legs", id = 2495, storage = 6663},
        [4] = {name = "demon shield", id = 2520, storage = 6664},
    }, achievement = "demonset"},

}

items.xml (some extra items accurate to tibiawiki):
[XML] items.xml - Pastebin.com


I believe that should be everything. If there are any issues or bugs, please post them here rather than in PM. If you have any requests for additional features, I will try to accommodate them as I see fit. If I don't feel it should be included in the public version of this system, I may add it privately for your copy of the system, but no guarantees.

If anyone has any questions about how to use or configure any part of the system, please post them here, as you are likely not the only one wondering.

Tested on a freshly installed copy of TFS 1.1 from the releases here: Releases · otland/forgottenserver · GitHub
Should work on TFS 1.2, but no guarantees. If there are any issues in TFS 1.2, I will try to address them and update accordingly.

Enjoy!

@beastn @Colors @Codinablack @StreamSide
I know you guys have been waiting on this ;)

EDIT: Changed the login.lua to check on every login if player's skill is under 10 and sets it to 10 if so.
 

Attachments

Last edited:
Hey i have a question and i'll ask here so others can see it.. its saying my smithing level is -1. Now i know i can just change it in the storage but jsut wanted to ask if its meant to be like that, why? or is it just a mistake?

EDIT
So i see what you did there..I'll explain to others.

This code here is what gives your players the skills. As you can see its happening ONLY if its the characters first login. If you are trying to implement this onto an existing server you will need to make a talk actions or something that will assign these storage's to your players.
Code:
        for i = 40000, 40012 do
                player:setStorageValue(i, 10)
                player:setStorageValue(i + 1000, 0)
        end

EDIT2: Yeah look i just made the talk action for you.. add this script and then get players to say !crafting and they will get the skills.

data/talkactions/talkactions.xml
Code:
<talkaction words="!crafting" script="get_crafting.lua"/>

data/talkactions/scripts/give_crafting.lua
Code:
function onSay(player, words, param)
        for i = 40000, 40012 do
            player:setStorageValue(i, 10)
            player:setStorageValue(i + 1000, 0)
        end
end
 
Last edited:
Hey i have a question and i'll ask here so others can see it.. its saying my smithing level is -1. Now i know i can just change it in the storage but jsut wanted to ask if its meant to be like that, why? or is it just a mistake?

EDIT
So i see what you did there..I'll explain to others.

This code here is what gives your players the skills. As you can see its happening ONLY if its the characters first login. If you are trying to implement this onto an existing server you will need to make a talk actions or something that will assign these storage's to your players.
Code:
        for i = 40000, 40012 do
                player:setStorageValue(i, 10)
                player:setStorageValue(i + 1000, 0)
        end

EDIT2: Yeah look i just made the talk action for you.. add this script and then get players to say !crafting and they will get the skills.

data/talkactions/talkactions.xml
Code:
<talkaction words="!crafting" script="get_crafting.lua"/>

data/talkactions/scripts/give_crafting.lua
Code:
function onSay(player, words, param)
        for i = 40000, 40012 do
            player:setStorageValue(i, 10)
            player:setStorageValue(i + 1000, 0)
        end
end

I made a slightly simpler workaround :p I actually had it in my original script and totally gapped on the reason I made it xD
In login.lua, it checks on every login if their skill is less than 10 and sets it to 10 if so. I initially had it set to 100 on each login, for testing purposes xD Your idea would work but it requires players to do so in order to make it work, and we don't want to rely on players to make a system work properly :p

Updated main thread
 
I made a slightly simpler workaround :p I actually had it in my original script and totally gapped on the reason I made it xD
In login.lua, it checks on every login if their skill is less than 10 and sets it to 10 if so. I initially had it set to 100 on each login, for testing purposes xD Your idea would work but it requires players to do so in order to make it work, and we don't want to rely on players to make a system work properly :p

Updated main thread
sigh.. was too late in Australia to think properly.. that would make much more sense haha
 
It was 4am when I finished typing the thread, so that's probably why I gapped as well xD
 
I think just whetstone to iron ingot, goosebump leather to raw leather and yellow powder (6547) to gold ore. if you happen to find any others, feel free to let me know and I'll note it in the main post

Included them in the first post with ids
 
Hi razor, i really appreciate your work. I'm gonna use some of your scripts on my project. Keep up the good work.
 
Back
Top