TFS 1.X+ I have weird Health/Mana bug with transforms

Discussion in 'Support' started by henkas, Jun 2, 2018.

  1. henkas

    henkas Member

    Joined:
    Jul 8, 2015
    Messages:
    270
    Likes Received:
    12
    Best Answers:
    3
    Is it really so stupid then? "getting from the transform(tovoc) vocation id, same with stats/effect/looktype"? Or your english is just bad and i just understood your comment in the different way so you mean
    Code (Text):
    1.  
    2. Transformations = {
    3.  
    4. [1] = { toVoc = 5, effect = CONST_ME_HITAREA, lookType = 5 }, this line is getting level
    5. [5] = { fromVoc = 1, toVoc = 26, effect = CONST_ME_FIREATTACK, lookType = 6, addHp = 100, addMana = 100, level = 50 }, from this line?
    6. [26] = { fromVoc = 5, toVoc = 27, effect = CONST_ME_GIANTICE, lookType = 7, addHp = 1000, addMana = 1000, level = 100 }
    7.  
    8. }
     
  2. insaiyan

    insaiyan New Member

    Joined:
    May 27, 2018
    Messages:
    17
    Likes Received:
    3
    Best Answers:
    1
    grammar has nothing to do with understanding, beside that the whole subject is based on the lack of basic mathematical concepts, why you should check the level of the character you currently are, when you have the last transform, you check lvl of vocation that dont exist? When you buy food in a market, do you pay after eating? every thinking human beeing after seeing that 100 lvl is required and looking at config would deduce what the "problem" is
     
    Last edited: Jun 13, 2018 at 12:35 AM
  3. Sarah Wesker

    Sarah Wesker S.E ©

    Joined:
    Mar 16, 2017
    Messages:
    235
    Likes Received:
    93
    Best Answers:
    14
    i doesn't want to disrespect anyone, @insaiyan he is right, you do not understand the logic of my code, find someone who can explain my code step by step, i think that is what you are trying to do.

    @bayview explain to @henkas how it works please.
    :mad:
     
  4. henkas

    henkas Member

    Joined:
    Jul 8, 2015
    Messages:
    270
    Likes Received:
    12
    Best Answers:
    3
    Well i dont know where you live but in my country and other countrys you can take the stuff and eat in line because it doesnt matter you still have to pay so you can pay before or after. Who knows maybe it was a bug. But anyway it took couple mins to understand this messy config structure. But lets go to the point this transform system has the same Health/Mana Bug
     
  5. insaiyan

    insaiyan New Member

    Joined:
    May 27, 2018
    Messages:
    17
    Likes Received:
    3
    Best Answers:
    1
    of course you can do it like this, no one will punish you for lack of culture, but still you show with this behavior that you are potential thief. if you have problem with elementary math you can do something like @gudan garam said that is calculate your max health instead of using function getMaxHealth. I dont know 1.2 structure well but it should looks like
    Code (Text):
    1. function CalculateMaxHealth()
    2. local beginerHealth = 1000
    3. local healthpoints = (beginerHealth+(player:getVocation():getHealthGain() * player:getLevel()))
    4. for slot = CONST_SLOT_FIRST,CONST_SLOT_LAST do
    5. local item = player:getSlotItem(slot)
    6. if item.uid > 0 then
    7. if ItemType(item).getAbilities().stats[STAT_MAXHITPOINTS] then
    8. healthpoints = healthpoints + ItemType(item).getAbilities().stats[STAT_MAXHITPOINTS]
    9. end
    10. end
    11. end
    12. return healthpoints
    13. end
    14. function CalculateMaxMana()
    15. local beginerMana = 1000
    16. local manapoints = (beginerMana+(player:getVocation():getManaGain() * player:getLevel()))
    17. for slot = CONST_SLOT_FIRST,CONST_SLOT_LAST do
    18. local item = player:getSlotItem(slot)
    19. if item.uid > 0 then
    20. if ItemType(item).getAbilities().stats[STAT_MAXMANAPOINTS] then
    21. manapoints = manapoints + ItemType(item).getAbilities().stats[STAT_MAXMANAPOINTS]
    22. end
    23. end
    24. end
    25. return manapoints
    26. end
    and now use it in death/login in creaturescripts
    Code (Text):
    1.  
    2. player:setMaxHealth(CalculateMaxHealth())
    3. player:setMaxHealth(CalculateMaxMana())
    you can also add this to transform/revert but you must sum up all previous transform stats, if the transform 1 will add +100 and transform 2 +200 transform 3 + 400 so in config transform 1 addhp=100 transform 2 addhp = 300 transform 3 addhp =700
    Code (Text):
    1.  
    2. player:setMaxHealth(CalculateMaxHealth() + (newTrans.addHp or 0))
    3. player:setMaxHealth(CalculateMaxMana() + (newTrans.addMana or 0))
     
    Last edited: Jun 13, 2018 at 2:09 PM
    Sarah Wesker likes this.
  6. Madzix

    Madzix Member

    Joined:
    Sep 8, 2016
    Messages:
    33
    Likes Received:
    43
    Best Answers:
    7
    The problem is that "setMaxHealth" change only your character health while "getMaxHealth" gets your character health+temporary health.
    If you're using TFS 1.2+ you can use "getBaseMaxHealth" and "getBaseMaxMana" to remove this "bug" otherwise you might need to use calculation(might be inaccurate if you use in other places "setMaxHealth") or just copy-paste to your source these functions.

    Example:
    Code (Text):
    1.  
    2. player:setMaxHealth(player:getBaseMaxHealth() + TRANS.addHealth)
    3. player:setMaxMana(player:getBaseMaxMana() + TRANS.addMana)
    4.  
     
    henkas likes this.
  7. henkas

    henkas Member

    Joined:
    Jul 8, 2015
    Messages:
    270
    Likes Received:
    12
    Best Answers:
    3
    [​IMG]

    Ammm
    Code (Text):
    1.  
    2. 1>..\src\luascript.cpp(2053): error C2065: 'luaPlayerGetBaseMaxHealth': undeclared identifier
    3. 1>..\src\luascript.cpp(2054): error C2039: 'luaPlayerGetBaseMaxMana': is not a member of 'LuaScriptInterface'
    4. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    5. 1>..\src\luascript.cpp(2054): error C2065: 'luaPlayerGetBaseMaxMana': undeclared identifier
    6. 1>..\src\luascript.cpp(7461): error C2039: 'luaPlayerGetBaseMaxHealth': is not a member of 'LuaScriptInterface'
    7. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    8. 1>..\src\luascript.cpp(7464): error C2065: 'getUserdata': undeclared identifier
    9. 1>..\src\luascript.cpp(7464): error C2275: 'Player': illegal use of this type as an expression
    10. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
    11. 1>..\src\luascript.cpp(7466): error C2248: 'Creature::healthMax': cannot access protected member declared in class 'Creature'
    12. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\creature.h(511): note: see declaration of 'Creature::healthMax'
    13. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\monster.h(26): note: see declaration of 'Creature'
    14. 1>..\src\luascript.cpp(7473): error C2039: 'luaPlayerGetBaseMaxMana': is not a member of 'LuaScriptInterface'
    15. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    16. 1>..\src\luascript.cpp(7476): error C2065: 'getUserdata': undeclared identifier
    17. 1>..\src\luascript.cpp(7476): error C2275: 'Player': illegal use of this type as an expression
    18. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
    19. 1>..\src\luascript.cpp(7478): error C2248: 'Player::manaMax': cannot access protected member declared in class 'Player'
    20. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\player.h(1146): note: see declaration of 'Player::manaMax'
    21. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
    Code (Text):
    1.  
    2. 1>..\src\luascript.cpp(2053): error C2065: 'luaPlayerGetBaseMaxHealth': undeclared identifier
    3. 1>..\src\luascript.cpp(2054): error C2039: 'luaPlayerGetBaseMaxMana': is not a member of 'LuaScriptInterface'
    4. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    5. 1>..\src\luascript.cpp(2054): error C2065: 'luaPlayerGetBaseMaxMana': undeclared identifier
    6. 1>..\src\luascript.cpp(7461): error C2039: 'luaPlayerGetBaseMaxHealth': is not a member of 'LuaScriptInterface'
    7. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    8. 1>..\src\luascript.cpp(7464): error C2065: 'getUserdata': undeclared identifier
    9. 1>..\src\luascript.cpp(7464): error C2275: 'Player': illegal use of this type as an expression
    10. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
    11. 1>..\src\luascript.cpp(7466): error C2248: 'Creature::healthMax': cannot access protected member declared in class 'Creature'
    12. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\creature.h(511): note: see declaration of 'Creature::healthMax'
    13. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\monster.h(26): note: see declaration of 'Creature'
    14. 1>..\src\luascript.cpp(7473): error C2039: 'luaPlayerGetBaseMaxMana': is not a member of 'LuaScriptInterface'
    15. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    16. 1>..\src\luascript.cpp(7476): error C2065: 'getUserdata': undeclared identifier
    17. 1>..\src\luascript.cpp(7476): error C2275: 'Player': illegal use of this type as an expression
    18. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
    19. 1>..\src\luascript.cpp(7478): error C2248: 'Player::manaMax': cannot access protected member declared in class 'Player'
    20. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\player.h(1146): note: see declaration of 'Player::manaMax'
    21. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
     
    Last edited by a moderator: Jun 17, 2018 at 10:10 PM
  8. gudan garam

    gudan garam Active Member

    Joined:
    Feb 13, 2011
    Messages:
    196
    Likes Received:
    25
    Best Answers:
    3
    in your sources:
    luascript.cpp:

    First:

    Below
    Code (C++):
    1. registerMethod("Player", "addManaSpent", LuaScriptInterface::luaPlayerAddManaSpent);
    Add
    Code (C++):
    1.  
    2. registerMethod("Player", "getBaseMaxHealth", LuaScriptInterface::luaPlayerGetBaseMaxHealth);
    3. registerMethod("Player", "getBaseMaxMana", LuaScriptInterface::luaPlayerGetBaseMaxMana);
    Second:

    Below:
    Code (C++):
    1. int LuaScriptInterface::luaPlayerAddManaSpent(lua_State* L)
    2. {
    3.     // player:addManaSpent(amount)
    4.     Player* player = getUserdata<Player>(L, 1);
    5.     if (player) {
    6.         player->addManaSpent(getNumber<uint64_t>(L, 2));
    7.         pushBoolean(L, true);
    8.     } else {
    9.         lua_pushnil(L);
    10.     }
    11.     return 1;
    12. }
    Add:
    Code (C++):
    1. int LuaScriptInterface::luaPlayerGetBaseMaxHealth(lua_State* L)
    2. {
    3.     // player:getBaseMaxHealth()
    4.     Player* player = getUserdata<Player>(L, 1);
    5.     if (player) {
    6.         lua_pushnumber(L, player->healthMax);
    7.     } else {
    8.         lua_pushnil(L);
    9.     }
    10.     return 1;
    11. }
    12.  
    13. int LuaScriptInterface::luaPlayerGetBaseMaxMana(lua_State* L)
    14. {
    15.     // player:getBaseMaxMana()
    16.     Player* player = getUserdata<Player>(L, 1);
    17.     if (player) {
    18.         lua_pushnumber(L, player->manaMax);
    19.     } else {
    20.         lua_pushnil(L);
    21.     }
    22.     return 1;
    23. }
    24.  
     
    henkas likes this.
  9. henkas

    henkas Member

    Joined:
    Jul 8, 2015
    Messages:
    270
    Likes Received:
    12
    Best Answers:
    3
    Code (Text):
    1.  
    2. 1>..\src\luascript.cpp(2053): error C2039: 'luaPlayerGetBaseMaxHealth': is not a member of 'LuaScriptInterface'
    3. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    4. 1>..\src\luascript.cpp(2053): error C2065: 'luaPlayerGetBaseMaxHealth': undeclared identifier
    5. 1>..\src\luascript.cpp(2054): error C2039: 'luaPlayerGetBaseMaxMana': is not a member of 'LuaScriptInterface'
    6. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    7. 1>..\src\luascript.cpp(2054): error C2065: 'luaPlayerGetBaseMaxMana': undeclared identifier
    8. 1>..\src\luascript.cpp(7461): error C2039: 'luaPlayerGetBaseMaxHealth': is not a member of 'LuaScriptInterface'
    9. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    10. 1>..\src\luascript.cpp(7464): error C2065: 'getUserdata': undeclared identifier
    11. 1>..\src\luascript.cpp(7464): error C2275: 'Player': illegal use of this type as an expression
    12. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
    13. 1>..\src\luascript.cpp(7466): error C2248: 'Creature::healthMax': cannot access protected member declared in class 'Creature'
    14. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\creature.h(511): note: see declaration of 'Creature::healthMax'
    15. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\monster.h(26): note: see declaration of 'Creature'
    16. 1>..\src\luascript.cpp(7473): error C2039: 'luaPlayerGetBaseMaxMana': is not a member of 'LuaScriptInterface'
    17. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\luascript.h(199): note: see declaration of 'LuaScriptInterface'
    18. 1>..\src\luascript.cpp(7476): error C2065: 'getUserdata': undeclared identifier
    19. 1>..\src\luascript.cpp(7476): error C2275: 'Player': illegal use of this type as an expression
    20. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
    21. 1>..\src\luascript.cpp(7478): error C2248: 'Player::manaMax': cannot access protected member declared in class 'Player'
    22. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\player.h(1146): note: see declaration of 'Player::manaMax'
    23. 1>  c:\users\animal\desktop\dragon ball nuo nulio\server\src\bed.h(26): note: see declaration of 'Player'
     
  10. gudan garam

    gudan garam Active Member

    Joined:
    Feb 13, 2011
    Messages:
    196
    Likes Received:
    25
    Best Answers:
    3
    Best Answer

    I'm sorry, I forgot. You must add the declartion of thoose methods:

    luascript.h

    below:

    Code (C++):
    1. static int luaPlayerAddManaSpent(lua_State* L);
    add:

    Code (C++):
    1. static int luaPlayerGetBaseMaxHealth(lua_State* L);
    2. static int luaPlayerGetBaseMaxMana(lua_State* L);

    My bad on that.
     
  11. henkas

    henkas Member

    Joined:
    Jul 8, 2015
    Messages:
    270
    Likes Received:
    12
    Best Answers:
    3
    Yeeeeeeeeeee finally works
    Thanks so you deserve the best answer because your first post was about getbasemaxhealth. So i have last question about that health/mana problem when you die. Can you explain it more detailed how to fix it?
     

Share This Page

Loading...