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

Discussion in 'GlobalEvents, Spells & CreatureEvents' started by zbizu, Mar 7, 2015.

  1. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,330
    Best Answers:
    0
    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:
    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 (Text):
    1. <action itemid="8305" script="slot.lua"/>
    2. <action itemid="8310" script="slot.lua"/>
    3. <action fromid="8298" toid="8301" script="slot.lua"/>
    slot.lua action
    Code (Text):
    1. function onUse(player, item, fromPosition, itemEx, toPosition)
    2. return stat_onUse(player, item, fromPosition, itemEx, toPosition)
    3. end
    creaturescripts.xml
    Code (Text):
    1.     <event type="login" name="statLogin" script="stats.lua"/>
    2.     <event type="healthchange" name="statHP" script="stats.lua"/>
    3.     <event type="manachange" name="statMP" script="stats.lua"/>
    4.     <event type="preparedeath" name="statPVE" script="stats.lua"/>
    5.     <event type="kill" name="statLoot" script="stats.lua"/>
    6.     <event type="death" name="statDeath" script="stats.lua"/>
    stats.lua creaturescript
    Code (Text):
    1. function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    2.     return stat_onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    3. end
    4.  
    5. function onManaChange(creature, attacker, manaChange, origin)
    6.     return stat_onManaChange(creature, attacker, manaChange, origin)
    7. end
    8.  
    9. function onPrepareDeath(creature, lastHitKiller, mostDamageKiller)
    10.     return stat_onPrepareDeath(creature, lastHitKiller, mostDamageKiller)
    11. end
    12.  
    13. function onKill(player, target, lastHit)
    14.     return stat_onKill(player, target, lastHit)
    15. end
    16.  
    17. function onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    18.     return stat_onDeath(creature, corpse, lasthitkiller, mostdamagekiller, lasthitunjustified, mostdamageunjustified)
    19. end
    20.  
    21. function onLogin(player)
    22.     return stat_onLogin(player)
    23. end
    events.xml
    (this line exist in your file already, just set enabled to "1")
    Code (Text):
    1. <event class="Creature" method="onTargetCombat" enabled="1" />
    creature.lua event
    (replace default function to this)
    Code (Text):
    1. function Creature:onTargetCombat(target)
    2.    return stat_onTargetCombat(self, target)
    3. end
    player.lua event
    replace
    Code (Text):
    1.  
    2. function Player:onLook(thing, position, distance)
    3.    local description = "You see " .. thing:getDescription(distance)
    4.  
    to
    Code (Text):
    1.  
    2. function Player:onLook(thing, position, distance)
    3.    local description = "You see " .. thing:getDescription(distance)
    4.    description = stat_onLook(thing, description)
    5.  
    replace
    Code (Text):
    1. function Player:onLookInTrade(partner, item, distance)
    2. self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. item:getDescription(distance))
    3. end
    to
    Code (Text):
    1. function Player:onLookInTrade(partner, item, distance)
    2.    local description = item:getDescription(distance)
    3.    description = stat_onLook(item, description)
    4.    self:sendTextMessage(MESSAGE_INFO_DESCR, "You see " .. description)
    5. 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 (Text):
    1. dofile('data/stats.lua')
    and the final part
    stats.lua : http://pastebin.com/cD17xq1S
     
    Last edited: Apr 3, 2015
  2. Eldin

    Eldin Eldin Projects Premium User

    Joined:
    Jun 12, 2008
    Messages:
    1,260
    Likes Received:
    502
    Best Answers:
    0
    :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.
     
  3. spyk3z

    spyk3z Theós:Undying

    Joined:
    Jul 23, 2007
    Messages:
    384
    Likes Received:
    86
    Best Answers:
    0
    Damn, this is awesome. Thanks!
     
  4. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,330
    Best Answers:
    0
    ids:
    add slot: 8300
    upgrade item: 8301
     
    Last edited: Mar 8, 2015
  5. 7804364

    7804364 Member

    Joined:
    Mar 6, 2010
    Messages:
    472
    Likes Received:
    10
    Best Answers:
    0
    TESTING NOW
     
  6. 7804364

    7804364 Member

    Joined:
    Mar 6, 2010
    Messages:
    472
    Likes Received:
    10
    Best Answers:
    0
    [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>
     
  7. Blinkz

    Blinkz Experienced Lurker

    Joined:
    May 17, 2009
    Messages:
    2,092
    Likes Received:
    776
    Best Answers:
    0
    That's awesome really looking forward to this in some servers
     
  8. Codinablack

    Codinablack Dreamer

    Joined:
    Dec 26, 2013
    Messages:
    1,119
    Likes Received:
    347
    Best Answers:
    0
    Omg you did amazing work here my friend, thank you very much for this release!
     
  9. Lordaeron

    Lordaeron Member

    Joined:
    Mar 15, 2014
    Messages:
    131
    Likes Received:
    7
    Best Answers:
    0
    Damn! Well done there :)
     
  10. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,330
    Best Answers:
    0
    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.
     
    Codinablack likes this.
  11. calveron

    calveron Bravemansworld Premium User

    Joined:
    Feb 5, 2008
    Messages:
    163
    Likes Received:
    8
    Best Answers:
    0
    Exactly what do I replace in creature.lua?
     
  12. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,330
    Best Answers:
    0
    Code (Text):
    1. function Creature:onTargetCombat(target)
    2.   return true
    3. end
    to
    Code (Text):
    1. function Creature:onTargetCombat(target)
    2.   return stat_onTargetCombat(self, target)
    3. end
     
  13. calveron

    calveron Bravemansworld Premium User

    Joined:
    Feb 5, 2008
    Messages:
    163
    Likes Received:
    8
    Best Answers:
    0
    What I have looks a little different:
    Code (Text):
    1.  
    2. function Creature:onTargetCombat(target)
    3.     if not self then
    4.         return true
    5.     end
    6.  
    When I replace it I get this error:
    Code (Text):
    1. [Warning - Events::load] Can not load script: creature.lua
    2. data/events/scripts/creature.lua:63: '<eof>' expected near 'end'
     
  14. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,330
    Best Answers:
    0
  15. 7804364

    7804364 Member

    Joined:
    Mar 6, 2010
    Messages:
    472
    Likes Received:
    10
    Best Answers:
    0
    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): ?
     
  16. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,330
    Best Answers:
    0
    use tfs 1.1 so it will pass player userdata instead of "cid"
     
  17. 7804364

    7804364 Member

    Joined:
    Mar 6, 2010
    Messages:
    472
    Likes Received:
    10
    Best Answers:
    0
    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?
     
  18. zbizu

    zbizu ‌‌Luakami

    Joined:
    Nov 22, 2010
    Messages:
    2,438
    Likes Received:
    1,330
    Best Answers:
    0
    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)
     
    Codinablack likes this.
  19. 7804364

    7804364 Member

    Joined:
    Mar 6, 2010
    Messages:
    472
    Likes Received:
    10
    Best Answers:
    0
    OK so i change
    return stat_onLogin(player)
    to
    return stat_onLogin(Player(player))
     
  20. RosOT

    RosOT Who am i?

    Joined:
    Feb 12, 2013
    Messages:
    719
    Likes Received:
    134
    Best Answers:
    0
    Nice :| guess I'm switching again <3 good job
     

Share This Page

Loading...