Leo32
Getting back into it...
- Joined
- Sep 21, 2007
- Messages
- 988
- Solutions
- 14
- Reaction score
- 537
< 10.94
The first post is for versions earlier than 10.94, before crit and mana/life leech was added to the game.
Someone should try it on an 8.6 server
10.94+
If you are using the latest TFS release, refer to the post here.
A variant of this, this and this mod.
It gives items a chance to roll rare, epic or legendary when it drops from a monster:
With the following possible attributes:
(For config and if you want to understand the code, start at the stats table in lib/core/attributes.lua)
Some of these are completely custom attributes, like elemental damage:
This requires the following updates/features:
1) Loot drop handled via Lua
2) Add the new health/mana gain coloured text messages
3) onInventoryUpdate()
4) onSpawn()
Installation: rollAttributes.zip
paste in /data
lib/core/core.lua
add below:
talkactions.xml
add below:
creaturescripts.xml
add below:
creaturescripts/scripts/login.lua
add below:
add below:
events/scripts/player.lua
add to the bottom:
events/scripts/monster.lua
add to the top of the file:
add between:
add at the end:
The core scripts are attached because they are to big to embed in post, so they're attached as rollAttributes.zip
Don't forget to paste the core scripts into your /data dir.
Extras
The first post is for versions earlier than 10.94, before crit and mana/life leech was added to the game.
Someone should try it on an 8.6 server
10.94+
If you are using the latest TFS release, refer to the post here.
What is this?
A newer version of this:Rare, Epic and Legendary Loot Rolls
Hey Guys, This is something I've been working on for a while, taking the time to get it right and get all rolls and damages to apply properly. Thought I'd give you a look, see what y'all think. When a monster drops loot, there is a chance that it rolls Rare, Epic or Legendary: Basic rolls...
otland.net
It gives items a chance to roll rare, epic or legendary when it drops from a monster:
With the following possible attributes:
(For config and if you want to understand the code, start at the stats table in lib/core/attributes.lua)
LUA:
[1] = { -- Attack
[2] = { -- Defense
[3] = { -- Extra Defense
[4] = { -- Armor
[5] = { -- Accuracy
[6] = { -- Range
[7] = { -- Equipment with < 50 charges
[8] = { -- Equipment with >= 50 charges
[9] = { -- Time
[10] = { -- Crit Chance
[11] = { -- Crit Amount (Currently Unused)
[12] = { -- Fire Damage
[13] = { -- Ice Damage
[14] = { -- Energy Damage
[15] = { -- Fire Resistance
[16] = { -- Ice Resistance
[17] = { -- Energy Resistance
[18] = { -- Earth Resistance
[19] = { -- Physical Resistance
[20] = { -- Death Resistance
[21] = { -- Spell Damage
[22] = { -- Multi Shot
[23] = { -- Stun Chance
[24] = { -- Mana Shield
[25] = { -- Sword Skill
[26] = { -- Skill Axe
[27] = { -- Skill Club
[28] = { -- Skill Melee
[29] = { -- Skill Distance
[30] = { -- Skill Shielding
[31] = { -- Magic Level
[32] = { -- Max Health i.e +100
[33] = { -- Max Mana i.e +100
[34] = { -- Max Health % i.e +10%
[35] = { -- Max Mana % i.e +10%
[36] = { -- Life Leech Chance (Currently Unused)
[37] = { -- Life Leech Amount
[38] = { -- Mana Leech Chance (Currently Unused)
[39] = { -- Mana Leech Amount
Some of these are completely custom attributes, like elemental damage:
This requires the following updates/features:
1) Loot drop handled via Lua
2) Add the new health/mana gain coloured text messages
3) onInventoryUpdate()
Player:onInventoryUpdate(item, slot, equip) · infernumx/forgottenserver@960a3f5
A free and open-source MMORPG server emulator written in C++ - Player:onInventoryUpdate(item, slot, equip) · infernumx/forgottenserver@960a3f5
github.com
Adding Monster:onSpawn(position, startup, artificial) by Leo32onGIT · Pull Request #2822 · otland/forgottenserver
This allows you to manipulate monsters as they spawn. Use example: to register onHealthChange and onManaChange events on all monsters. Thread from author @infernumx: https://otland.net/threads/tfs-...
github.com
Installation:
paste in /data
lib/core/core.lua
add below:
LUA:
-- Rolls & Custom Item Attributes
dofile('data/lib/core/attributes.lua')
talkactions.xml
add below:
XML:
<talkaction words="/roll" separator=" " script="roll.lua" />
creaturescripts.xml
add below:
XML:
<!-- Roll & Attribute Damage -->
<event type="healthchange" name="rollHealth" script="attributes.lua"/>
<event type="manachange" name="rollMana" script="attributes.lua"/>
creaturescripts/scripts/login.lua
add below:
LUA:
-- Activate Custom Item Attributes
for i = 1,10 do -- CONST_SLOT_FIRST,CONST_SLOT_LAST
local item = player:getSlotItem(i)
if item then
itemAttributes(player, item, i, true)
end
end
-- If player logged with more 'current health' than their db 'max health' due to an item attribute
local query = db.storeQuery("SELECT `health`,`mana` FROM players where `id`="..player:getGuid())
if query then
local health = tonumber(result.getDataString(query, 'health'))
local mana = tonumber(result.getDataString(query, 'mana'))
local playerHealth = player:getHealth()
local playerMana = player:getMana()
if playerHealth < health then
player:addHealth(health - playerHealth)
end
if playerMana < mana then
player:addMana(mana - playerMana)
end
result.free(query)
end
add below:
LUA:
player:registerEvent("rollHealth")
player:registerEvent("rollMana")
events/scripts/player.lua
add to the bottom:
LUA:
function Player:onInventoryUpdate(item, slot, equip)
itemAttributes(self, item, slot, equip)
end
events/scripts/monster.lua
add to the top of the file:
LUA:
-- Rarity Animations
local rare_popup = true
local rare_effect = true
local rare_effect_id = CONST_ME_STUN
LUA:
-- Apply rarity chance to corpse contents and apply animation
if rollRarity(corpse) > 0 then -- If a rare item was rolled, play animation
if rare_popup then
local spectators = Game.getSpectators(corpse:getPosition(), false, true, 7, 7, 5, 5)
for i = 1, #spectators do
spectators[i]:say(rare_text, TALKTYPE_MONSTER_SAY, false, spectators[i], corpse:getPosition())
end
end
if rare_effect then
corpse:getPosition():sendMagicEffect(rare_effect_id)
end
end
LUA:
function Monster:onSpawn(position, startup, artificial)
self:registerEvent("rollHealth")
self:registerEvent("rollMana")
return true
end
The core scripts are attached because they are to big to embed in post, so they're attached as rollAttributes.zip
Don't forget to paste the core scripts into your /data dir.
Extras
- 'Stun Target' is disabled by default, add the condition from here and uncomment the lines in creaturescripts/scripts/attributes.lua
- primaryDamage and primaryType are swapped with secondaryDamage and secondaryType on elemental damage (better, consistent visuals)
- Use the included /roll <rarity> talkaction for testing i.e /roll legendary
- Mana Leech and Life Leech apply 5ms after damage is done, this may feel different to vanilla Tibia.
- Multi shot ignores creature armor/shielding - its quite primitive.
- If you want to re-roll an item you should item:remove() it and re-create it (so it has stock base stats).
- Custom resistances apply after natural resistances and are additive.
- A unique weapon & shield using this systems on-hit mechanics can be found in extras.xml
Overwrite their information in items.xml and uncomment their code in attributes.lua for cool points.
Attachments
-
rollAttributes.zip17.9 KB · Views: 539 · VirusTotal
Last edited: