Block Renegeration

Discussion in 'Requests' started by Christopher172, Jul 13, 2018.

  1. Christopher172

    Christopher172 New Member

    Joined:
    Jun 16, 2016
    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Hello.
    I'm developing a spell that the user stays invisible for a certain time. So far so good, but I wanted to make sure that while the character is invisible, he does not have regeneration. Is there any constant or something I can set in the player so that it is unable to regenerate HP / MANA?
     
  2. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,813
    Likes Received:
    1,706
    Best Answers:
    283
    i don't think this is possible, by default in the sources it regens your health and mana from what's defined in vocations.xml
    maybe it would work if you set a special vocation with no regeneration and changed the vocation of the player, but that's the only thing i can think of without touching the sources
     
  3. Christopher172

    Christopher172 New Member

    Joined:
    Jun 16, 2016
    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Thank you for your reply.
     
  4. Zippiex

    Zippiex Member

    Joined:
    Nov 4, 2015
    Messages:
    252
    Likes Received:
    19
    Best Answers:
    2
    I think it's possible. I'm not good at this but I'm pretty sure you can make some edit in sources.
     
  5. Christopher172

    Christopher172 New Member

    Joined:
    Jun 16, 2016
    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Okay, you know what file I should look for?
     
  6. Zippiex

    Zippiex Member

    Joined:
    Nov 4, 2015
    Messages:
    252
    Likes Received:
    19
    Best Answers:
    2
    No, but I think @elf knows.
     
  7. Snurq

    Snurq Member

    Joined:
    Jul 7, 2012
    Messages:
    47
    Likes Received:
    9
    Best Answers:
    0
    why dont just remove certain amount of hp/mana every x sec?
     
  8. Himii

    Himii Well-Known Member

    Joined:
    Jan 19, 2011
    Messages:
    1,194
    Likes Received:
    148
    Best Answers:
    1
    Players regenerate different amounts depending on if they have been eating food


    Elf is ralely online but there is some others here that would be able to do it but it is a bit of work and will probably be hard to get done for free
     
  9. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    3,813
    Likes Received:
    1,706
    Best Answers:
    283
    by all means it is possible, just not with what you're given by default. i just wasn't sure if you wanted to edit sources
    what server version are you using?
     
  10. Christopher172

    Christopher172 New Member

    Joined:
    Jun 16, 2016
    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    We do not know exactly how much x.

    Thank you.

    Not problem.

    The version my sourcers is 1.2
     
  11. Ninja

    Ninja Global Moderator Staff Member Global Moderator

    Joined:
    Apr 6, 2010
    Messages:
    5,925
    Likes Received:
    1,546
    Best Answers:
    25
    Here you go (Moving this thread to Requests by the way) :p

    condition.cpp
    Code (C++):
    1. bool ConditionRegeneration::executeCondition(Creature* creature, int32_t interval)
    2. {
    3.     internalHealthTicks += interval;
    4.     internalManaTicks += interval;
    5.  
    6.     if (creature->hasRegenerationBlocked() || creature->getZone() == ZONE_PROTECTION) {
    7.         return ConditionGeneric::executeCondition(creature, interval);
    8.     }
    9.  
    10.     if (internalHealthTicks >= healthTicks) {
    11.         internalHealthTicks = 0;
    12.  
    13.         int32_t realHealthGain = creature->getHealth();
    14.         creature->changeHealth(healthGain);
    15.         realHealthGain = creature->getHealth() - realHealthGain;
    16.  
    17.         if (isBuff && realHealthGain > 0) {
    18.             Player* player = creature->getPlayer();
    19.             if (player) {
    20.                 std::string healString = std::to_string(realHealthGain) + (realHealthGain != 1 ? " hitpoints." : " hitpoint.");
    21.  
    22.                 TextMessage message(MESSAGE_HEALED, "You were healed for " + healString);
    23.                 message.position = player->getPosition();
    24.                 message.primary.value = realHealthGain;
    25.                 message.primary.color = TEXTCOLOR_MAYABLUE;
    26.                 player->sendTextMessage(message);
    27.  
    28.                 SpectatorHashSet spectators;
    29.                 g_game.map.getSpectators(spectators, player->getPosition(), false, true);
    30.                 spectators.erase(player);
    31.                 if (!spectators.empty()) {
    32.                     message.type = MESSAGE_HEALED_OTHERS;
    33.                     message.text = player->getName() + " was healed for " + healString;
    34.                     for (Creature* spectator : spectators) {
    35.                         spectator->getPlayer()->sendTextMessage(message);
    36.                     }
    37.                 }
    38.             }
    39.         }
    40.     }
    41.  
    42.     if (internalManaTicks >= manaTicks) {
    43.         internalManaTicks = 0;
    44.  
    45.         if (Player* player = creature->getPlayer()) {
    46.             int32_t realManaGain = player->getMana();
    47.             player->changeMana(manaGain);
    48.             realManaGain = player->getMana() - realManaGain;
    49.  
    50.             if (isBuff && realManaGain > 0) {
    51.                 std::string manaGainString = std::to_string(realManaGain);
    52.  
    53.                 TextMessage message(MESSAGE_HEALED, "You gained " + manaGainString + " mana.");
    54.                 message.position = player->getPosition();
    55.                 message.primary.value = realManaGain;
    56.                 message.primary.color = TEXTCOLOR_MAYABLUE;
    57.                 player->sendTextMessage(message);
    58.  
    59.                 SpectatorHashSet spectators;
    60.                 g_game.map.getSpectators(spectators, player->getPosition(), false, true);
    61.                 spectators.erase(player);
    62.                 if (!spectators.empty()) {
    63.                     message.type = MESSAGE_HEALED_OTHERS;
    64.                     message.text = player->getName() + " gained " + manaGainString + " mana.";
    65.                     for (Creature* spectator : spectators) {
    66.                         spectator->getPlayer()->sendTextMessage(message);
    67.                     }
    68.                 }
    69.             }
    70.         }
    71.     }
    72.  
    73.     return ConditionGeneric::executeCondition(creature, interval);
    74. }
    creature.h
    Code (C++):
    1. bool hasRegenerationBlocked() const {
    2.     return blockRegeneration;
    3. }
    4.  
    5. bool blockRegeneration = false;
    luascript.cpp
    Code (C++):
    1. registerMethod("Creature", "hasRegenerationBlocked", LuaScriptInterface::luaCreatureHasRegenerationBlocked);
    2. registerMethod("Creature", "blockRegeneration", LuaScriptInterface::luaCreatureBlockRegeneration);
    3.  
    4. int LuaScriptInterface::luaCreatureHasRegenerationBlocked(lua_State* L)
    5. {
    6.     // creature:hasRegenerationBlocked()
    7.     Creature* creature = getUserdata<Creature>(L, 1);
    8.     if (!creature) {
    9.         lua_pushnil(L);
    10.         return 1;
    11.     }
    12.  
    13.     pushBoolean(L, creature->hasRegenerationBlocked());
    14.     return 1;
    15. }
    16.  
    17. int LuaScriptInterface::luaCreatureBlockRegeneration(lua_State* L)
    18. {
    19.     // creature:blockRegeneration(boolean)
    20.     Creature* creature = getUserdata<Creature>(L, 1);
    21.     if (!creature) {
    22.         lua_pushnil(L);
    23.         return 1;
    24.     }
    25.  
    26.     creature->blockRegeneration = getBoolean(L, 2);
    27.     pushBoolean(L, true);
    28.     return 1;
    29. }
    luascript.h
    Code (C++):
    1. static int luaCreatureHasRegenerationBlocked(lua_State* L);
    2. static int luaCreatureBlockRegeneration(lua_State* L);
     
    Zippiex likes this.
  12. Zippiex

    Zippiex Member

    Joined:
    Nov 4, 2015
    Messages:
    252
    Likes Received:
    19
    Best Answers:
    2
    Ninja power! :)
     
  13. Christopher172

    Christopher172 New Member

    Joined:
    Jun 16, 2016
    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Masters!!!
    I go test more afternoom. I am not my house.
     

Share This Page

Loading...