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

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
Hello OtLand.
I put together four different scripts in one lib which took a lot of work to make them compatible, they work as one system now.

TFS I used:
1.1 from 29 Mar 2015
No, it won't work on 1.0
No, no version for 0.2/0.3/0.4, move on already!

As it's made of four different upgrade systems(listed below), it won't work with any other upgrade system including these listed below (original authors mentioned in threads).
1. http://otland.net/threads/tfs-1-0-slot-system-first-1-0-upgrade.206697/
2. http://otland.net/threads/tfs-1-1-random-item-stats.228990/
3. http://otland.net/threads/tfs-1-1-items-upgrading-by-jewels.228712/
4. my elemental dmg/protection system written just for this script

It's very complex(2k+ lines) and I didn't had much time to do detailed tests.
If you spot any bugs please report them here.

Some items:
00:29 You see a crystal ring.
It weighs 0.90 oz.
[loot.+30%][water.+100%][earth.+10][lifedrain.+10]

00:30 You see a runed sword (Atk:45, Def:54 +2).
It can only be wielded properly by players of level 65 or higher.
It weighs 46.00 oz.
[fire.+10%][undeads.+10%][def.+70%][physical.+10%]

00:33 You see a demon armor (Arm:16).
It weighs 80.00 oz.
[lifedrain.+10][holy.+10][physical.+5%][regMP.+10]
Features:
- disable option for events so you may turn off thing you don't want
- exp/loot rings

- elemental protection on armors
- elemental damage on weapons (may cause lags)
- regeneration
- skill conditions
- extra hp/mp
- weapon upgrades as slots and levels
- weapon level system
- custom items lootable
- looted items have modified name - configurable preffix and suffix for effects

- a lot of examples for scripters who want to develop their own systems

Missing Features:
- modal window enchanting
- perks
- slot remover

Known bugs:
- loot: non upgradable items get +x



Installation:
Recommended: [TFS 1.x] lib folder in "data" like 0.4

actions.xml
Code:
<action itemid="8305" script="slot.lua"/>
<action itemid="8310" script="slot.lua"/>
<action fromid="8298" toid="8301" script="slot.lua"/>
slot.lua action
Code:
function onUse(player, item, fromPosition, itemEx, toPosition)
return stat_onUse(player, item, fromPosition, itemEx, toPosition)
end
creaturescripts.xml
Code:
    <event type="login" name="statLogin" script="stats.lua"/>
    <event type="healthchange" name="statHP" script="stats.lua"/>
    <event type="manachange" name="statMP" script="stats.lua"/>
    <event type="preparedeath" name="statPVE" script="stats.lua"/>
    <event type="kill" name="statLoot" script="stats.lua"/>
    <event type="death" name="statDeath" script="stats.lua"/>
stats.lua creaturescript
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    return stat_onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
end

function onManaChange(creature, attacker, manaChange, origin)
    return stat_onManaChange(creature, attacker, manaChange, origin)
end

function onPrepareDeath(creature, lastHitKiller, mostDamageKiller)
    return stat_onPrepareDeath(creature, lastHitKiller, mostDamageKiller)
end

function onKill(player, target, lastHit)
    return stat_onKill(player, target, lastHit)
end

function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    return stat_onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
end

function onLogin(player)
    return stat_onLogin(player)
end
events.xml
(this line exist in your file already, just set enabled to "1")
Code:
<event class="Creature" method="onTargetCombat" enabled="1" />
creature.lua event
(replace default function to this)
Code:
function Creature:onTargetCombat(target)
   return stat_onTargetCombat(self, target)
end
player.lua event
replace
Code:
function Player:onLook(thing, position, distance)
   local description = "You see " .. thing:getDescription(distance)
to
Code:
function Player:onLook(thing, position, distance)
   local description = "You see " .. thing:getDescription(distance)
   description = stat_onLook(thing, description)
replace
Code:
function Player:onLookInTrade(partner, item, distance)
self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. item:getDescription(distance))
end
to
Code:
function Player:onLookInTrade(partner, item, distance)
   local description = item:getDescription(distance)
   description = stat_onLook(item, description)
   self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. description)
end
lib file
If you use this: [TFS 1.x] lib folder in "data" like 0.4, create stats.lua in lib folder, otherwise create it in "data" and add this to global.lua:
Code:
dofile('data/stats.lua')
and the final part
stats.lua : http://pastebin.com/cD17xq1S
 
Last edited:

Eldin

Eldin Projects
Joined
Jun 12, 2008
Messages
1,301
Reaction score
522
Location
Sweden
:eek::eek::eek::eek::eek::eek:

:eek::eek::eek::eek::eek:..........

To drunk to test it right now, looking forward to Wake up, uhm o_O

Well done once again Zbizu!

Kind Regards,
Eldin.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
ids:
add slot: 8300
upgrade item: 8301
 
Last edited:

7804364

Member
Joined
Mar 6, 2010
Messages
472
Reaction score
6
Hello OtLand.
I put together four different scripts in one lib which took a lot of work to make them compatible, they work as one system now.

TFS I used:
1.1 from 1 Mar 2015
No, it won't work on 1.0
No, no version for 0.2/0.3/0.4, move on already!

As it's made of four different upgrade systems(listed below), it won't work with any other upgrade system including these listed below (original authors mentioned in threads).
1. http://otland.net/threads/tfs-1-0-slot-system-first-1-0-upgrade.206697/
2. http://otland.net/threads/tfs-1-1-random-item-stats.228990/
3. http://otland.net/threads/tfs-1-1-items-upgrading-by-jewels.228712/
4. my elemental dmg/protection system written just for this script

It's very complex(2k+ lines) and I didn't had much time to do detailed tests.
If you spot any bugs please report them here.

Some items:


Features:
- exp/loot rings
- elemental protection on armors
- elemental damage on weapons (may cause lags)
- regeneration
- skill conditions
- extra hp/mp
- weapon upgrades as slots and levels
- weapon level system
- custom items lootable
- looted items have modified name(configurable preffix and suffix for effects)
- a lot of examples for scripters who want to develop their own systems

Missing Features:
- modal window enchanting
- perks
- slot remover

Known bugs:
- stats reset when they reach negative values on negative upgrade level
- weapon level upgrader may work buggy on detailed surfaces



Installation:
Recommended: [TFS 1.x] lib folder in "data" like 0.4

actions.xml
Code:
<action itemid="8300" script="stat_slot.lua"/>
<action itemid="8301" script="stat_slot.lua"/>
stat_slot.lua action
Code:
function onUse(player, item, fromPosition, itemEx, toPosition)
return stat_onUse(player, item, fromPosition, itemEx, toPosition)
end
creaturescripts.xml
Code:
<event type="login" name="statLogin" script="stats.lua"/>
<event type="healthchange" name="statHP" script="stats.lua"/>
<event type="manachange" name="statMP" script="stats.lua"/>
<event type="preparedeath" name="statPVE" script="stats.lua"/>
<event type="kill" name="statLoot" script="stats.lua"/>
stats.lua creaturescript
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
   return stat_onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
end

function onManaChange(creature, attacker, manaChange, origin)
   return stat_onManaChange(creature, attacker, manaChange, origin)
end

function onPrepareDeath(creature, lastHitKiller, mostDamageKiller)
   return stat_onPrepareDeath(creature, lastHitKiller, mostDamageKiller)
end

function onKill(player, target, lastHit)
   return stat_onKill(player, target, lastHit)
end

function onLogin(player)
   return stat_onLogin(player)
end
events.xml
(this line exist in your file already, just set enabled to "1")
Code:
<event class="Creature" method="onTargetCombat" enabled="1" />
creature.lua event
(replace default function to this)
Code:
function Creature:onTargetCombat(target)
   return stat_onTargetCombat(self, target)
end
lib file
If you use this: [TFS 1.x] lib folder in "data" like 0.4, create stats.lua in lib folder, otherwise create it in "data" and add this to global.lua:
Code:
dofile('data/stats.lua')
and the final part
stats.lua : http://pastebin.com/ERQvgxg2
[Warning - Actions::registerEvent] Duplicate registered item with id: 8300
[Warning - Event::checkScript] Can not load script: scripts/stats.lua
cannot open data/creaturescripts/scripts/stats.lua: No such file or directory
[Error - CreatureEvent::configureEvent] Invalid type for creature event: statHP
[Warning - BaseEvents::loadFromXml] Failed to configure event
[Error - CreatureEvent::configureEvent] Invalid type for creature event: statMP
[Warning - BaseEvents::loadFromXml] Failed to configure event
[Warning - Event::checkScript] Can not load script: scripts/stats.lua
cannot open data/creaturescripts/scripts/stats.lua: No such file or directory
[Warning - Event::checkScript] Can not load script: scripts/stats.lua
cannot open data/creaturescripts/scripts/stats.lua: No such file or directory
[Warning - Events::load] Unknown class: Creature


ON USE I GET



Lua Script Error: [Action Interface]
data/actions/scripts/stat_slot.lua:eek:nUse
data/actions/scripts/stat_slot.lua:2: attempt to call global 'stat_onUse' (a nil value)
stack traceback:
[C]: in function 'stat_onUse'
data/actions/scripts/stat_slot.lua:2: in function <data/actions/scripts/stat_slot.lua:1>

Lua Script Error: [Action Interface]
data/actions/scripts/stat_slot.lua:eek:nUse
data/actions/scripts/stat_slot.lua:2: attempt to call global 'stat_onUse' (a nil value)
stack traceback:
[C]: in function 'stat_onUse'
data/actions/scripts/stat_slot.lua:2: in function <data/actions/scripts/stat_slot.lua:1>
 

Blinkz

Experienced Lurker
Joined
May 17, 2009
Messages
2,325
Reaction score
848
That's awesome really looking forward to this in some servers
 

Codinablack

Dreamer
Joined
Dec 26, 2013
Messages
1,216
Reaction score
372
Omg you did amazing work here my friend, thank you very much for this release!
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
As this script is still WIP, I'm open to all feature requests.
Just suggest what would you like to see in this system and I'll try to implement that.
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
Code:
function Creature:onTargetCombat(target)
  return true
end
to
Code:
function Creature:onTargetCombat(target)
  return stat_onTargetCombat(self, target)
end
 

calveron

Bravemansworld
Joined
Feb 5, 2008
Messages
173
Reaction score
14
Location
Sweden
What I have looks a little different:
Code:
function Creature:onTargetCombat(target)
    if not self then
        return true
    end
When I replace it I get this error:
Code:
[Warning - Events::load] Can not load script: creature.lua
data/events/scripts/creature.lua:63: '<eof>' expected near 'end'
 

7804364

Member
Joined
Mar 6, 2010
Messages
472
Reaction score
6
data/actions/scripts/stat_slot.lua:eek:nUse
data/lib/stats.lua:1296: attempt to index local 'player' (a number value)
stack traceback:
[C]: ?
data/lib/stats.lua:1296: in function <data/lib/stats.lua:1172>
(tail call): ?

Lua Script Error: [Action Interface]
data/actions/scripts/stat_slot.lua:eek:nUse
data/lib/stats.lua:1179: attempt to call method 'getCharges' (a nil value)
stack traceback:
[C]: in function 'getCharges'
data/lib/stats.lua:1179: in function <data/lib/stats.lua:1172>
(tail call): ?
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
data/actions/scripts/stat_slot.lua:eek:nUse
data/lib/stats.lua:1296: attempt to index local 'player' (a number value)
stack traceback:
[C]: ?
data/lib/stats.lua:1296: in function <data/lib/stats.lua:1172>
(tail call): ?

Lua Script Error: [Action Interface]
data/actions/scripts/stat_slot.lua:eek:nUse
data/lib/stats.lua:1179: attempt to call method 'getCharges' (a nil value)
stack traceback:
[C]: in function 'getCharges'
data/lib/stats.lua:1179: in function <data/lib/stats.lua:1172>
(tail call): ?
use tfs 1.1 so it will pass player userdata instead of "cid"
 

7804364

Member
Joined
Mar 6, 2010
Messages
472
Reaction score
6
use tfs 1.1 so it will pass player userdata instead of "cid"
i dont know how to convert my 10.53 tfs 1.0 to tfs 1.1 can you shed some light or let me know how to change the player data to cid?
 
OP
zbizu

zbizu

Veteran OT User
Joined
Nov 22, 2010
Messages
2,460
Reaction score
1,357
Location
Poland
link to stats.lua updated

new feature:
- you may enable/disable events now

fixes:
- duration on rings is now recognized correctly
- no "duplicate stat" message anymore
- fixed manadrain
- fixed combat for drain type stats
- fixed bug with recognizing upgrademagicitems value


@7804364
see installation
all places where it's return stat_on...(player
do
return stat_on...(Player(player)
 

7804364

Member
Joined
Mar 6, 2010
Messages
472
Reaction score
6
link to stats.lua updated

new feature:
- you may enable/disable events now

fixes:
- duration on rings is now recognized correctly
- no "duplicate stat" message anymore
- fixed manadrain
- fixed combat for drain type stats
- fixed bug with recognizing upgrademagicitems value


@7804364
see installation
all places where it's return stat_on...(player
do
return stat_on...(Player(player)
OK so i change
return stat_onLogin(player)
to
return stat_onLogin(Player(player))
 
Top