[WIP] [Lua++] [C++] Health and Mana Regenerator menu

User Tag List

Results 1 to 7 of 7
  1. #1
    baptizein's Avatar Member
    Reputation
    16
    Join Date
    Jul 2008
    Posts
    65
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [WIP] [Lua++] [C++] Health and Mana Regenerator

    Health and Mana Regenerator
    Lua Script and C++ Script
    Coded by Baptizein

    What does it do?
    This script will allow players to fully regenerate their health and mana (if used) at any time for a fee, using the following item:

    Code:
    INSERT INTO items
       (`entry`, `class`, `subclass`, `field4`, `name1`, `name2`, `name3`, `name4`, `displayid`, `quality`, `flags`, `buyprice`, `sellprice`, `inventorytype`, `allowableclass`, `allowablerace`, `itemlevel`, `requiredlevel`, `RequiredSkill`, `RequiredSkillRank`, `RequiredSkillSubRank`, `RequiredPlayerRank1`, `RequiredPlayerRank2`, `RequiredFaction`, `RequiredFactionStanding`, `Unique`, `maxcount`, `ContainerSlots`, `stat_type1`, `stat_value1`, `stat_type2`, `stat_value2`, `stat_type3`, `stat_value3`, `stat_type4`, `stat_value4`, `stat_type5`, `stat_value5`, `stat_type6`, `stat_value6`, `stat_type7`, `stat_value7`, `stat_type8`, `stat_value8`, `stat_type9`, `stat_value9`, `stat_type10`, `stat_value10`, `dmg_min1`, `dmg_max1`, `dmg_type1`, `dmg_min2`, `dmg_max2`, `dmg_type2`, `dmg_min3`, `dmg_max3`, `dmg_type3`, `dmg_min4`, `dmg_max4`, `dmg_type4`, `dmg_min5`, `dmg_max5`, `dmg_type5`, `armor`, `holy_res`, `fire_res`, `nature_res`, `frost_res`, `shadow_res`, `arcane_res`, `delay`, `ammo_type`, `range`, `spellid_1`, `spelltrigger_1`, `spellcharges_1`, `spellcooldown_1`, `spellcategory_1`, `spellcategorycooldown_1`, `spellid_2`, `spelltrigger_2`, `spellcharges_2`, `spellcooldown_2`, `spellcategory_2`, `spellcategorycooldown_2`, `spellid_3`, `spelltrigger_3`, `spellcharges_3`, `spellcooldown_3`, `spellcategory_3`, `spellcategorycooldown_3`, `spellid_4`, `spelltrigger_4`, `spellcharges_4`, `spellcooldown_4`, `spellcategory_4`, `spellcategorycooldown_4`, `spellid_5`, `spelltrigger_5`, `spellcharges_5`, `spellcooldown_5`, `spellcategory_5`, `spellcategorycooldown_5`, `bonding`, `description`, `page_id`, `page_language`, `page_material`, `quest_id`, `lock_id`, `lock_material`, `sheathID`, `randomprop`, `unk203_1`, `block`, `itemset`, `MaxDurability`, `ZoneNameID`, `mapid`, `bagfamily`, `TotemCategory`, `socket_color_1`, `unk201_3`, `socket_color_2`, `unk201_5`, `socket_color_3`, `unk201_7`, `socket_bonus`, `GemProperties`, `ReqDisenchantSkill`, `unk2`)
    VALUES
       (90000, 15, 0, -1, 'Health and Mana Regenerator', '', '', '', 43359, 1, 0, 0, 0, 0, -1, -1, 100, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1500, 0, 0, 46642, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 'Created by Baptizein', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, 0, NULL, 0, 0, 0, 0, 0, 0, 0, NULL, -1, 0);
    Why create a Lua script and a C++ script?
    I wanted to give administrators the choice of which one they want to use on their server. The C++ script offers more flexibility and will allow for a better script in the future, while the Lua version doesn't need to be compiled with each new server revision. The two scripts have some differences in coding, though. With the C++ version, I opted not to add a function to check if the player is in combat or not. I'll leave this up to server admins.

    Why is it a WIP?
    I'm not an expert when it comes to Lua and C++, but I know enough to get me by some obsticles. However, on the C++ version, I couldn't get the script to set the player's mana percentage. This is due to the fact that SetHealthPct is a valid function, but SetManaPct is not. So, until I find a solution to this, it will remain removed from the code. Also, on the Lua version, I had a difficult time trying to get the script to subtract gold from the player and couldn't figure it out, so I removed the code from that part of the script and will add it in when I do get it right.

    C++ Version

    HealthMana.cpp
    Code:
    // Health and Mana Regenerator created by Baptizein
    
    #include "StdAfx.h" 
    #include "Setup.h" 
     
    class SCRIPT_DECL HealthMana : public GossipScript 
    { 
    public: 
        void GossipStart(Object * pObject, Player* Plr, bool AutoSend); 
        void GossipSelection(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code); 
        void GossipEnd(Object * pObject, Player* Plr); 
       void Destroy() 
       { 
          delete this; 
       } 
    }; 
    void HealthMana::GossipStart(Object * pObject, Player* Plr, bool AutoSend) 
        { 
            GossipMenu *Menu; 
            objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); 
     
          Menu->AddItem(0, "Restore My Health [ 5000 Gold ]", 1);   
    //    Menu->AddItem(0, "Restore My Mana [ 3000 Gold ]", 2);   
     
            if(AutoSend) 
                Menu->SendTo(Plr); 
        } 
     
    void HealthMana::GossipSelection(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code) 
        {  
            switch(IntId) 
            { 
            case 0:      
                GossipStart(pObject, Plr, true); 
                break; 
     
            case 1:    
               { 
          uint32 price=50000000;
          uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE); 
          if (currentgold>=price){ 
          int32 newgold = currentgold - price;  
          Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); 
                    Plr->SetHealthPct(100); 
          Plr->BroadcastMessage("Health has been restored. Removing 5000 gold. Thank you!"); 
          }else{ 
             Plr->BroadcastMessage("You don't have enough gold."); 
          } 
          } 
                break; 
    
    //		SetManaPct() is not an available function, so this part will be commented until I can find another solution.
    //        case 2:
    //           {
    //      if (Plr->GetPowerType() != POWER_TYPE_MANA){
    //      Plr->BroadcastMessage("You do not use mana."); break;
    //      }
    //      uint32 price=30000000;
    //      uint32 currentgold = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE); 
    //      if (currentgold>=price){ 
    //      int32 newgold = currentgold - price;  
    //      Plr->SetUInt32Value(PLAYER_FIELD_COINAGE,newgold); 
    //                Plr->SetManaPct(100); 
    //      Plr->BroadcastMessage("Mana has been restored. Removing 3000 gold. Thank you!"); 
    //      }else{ 
    //         Plr->BroadcastMessage("You don't have enough gold."); 
    //      } 
    //      } 
    //            break; 
    	} 
        } 
     
    void HealthMana::GossipEnd(Object * pObject, Player* Plr) 
    { 
        GossipScript::GossipEnd(pObject, Plr); 
    } 
     
    void SetupHealthMana(ScriptMgr * mgr) 
        { 
        GossipScript * gs = (GossipScript*) new HealthMana(); 
        mgr->register_item_gossip_script(90000,gs); 
        }
    Setup.cpp
    Code:
    #include "StdAfx.h"
    #include "Setup.h"
    #define SKIP_ALLOCATOR_SHARING 1
    #include <ScriptSetup.h>
    
    extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
    {
    	return SCRIPT_TYPE_MISC;
    }
    
    extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
    {
        SetupHealthMana(mgr);
    }
    
    #ifdef WIN32
    
    BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved )
    {
        return TRUE;
    }
    
    #endif
    Setup.h
    Code:
    #ifndef INSTANCE_SCRIPTS_SETUP_H
    #define INSTANCE_SCRIPTS_SETUP_H
    
    void SetupHealthMana(ScriptMgr * mgr);
    
    #endif
    .VCPROJ Download (Required)
    http://www.wowfare.net/downloads/pro...ana2008.vcproj



    Lua++ Version
    Code:
    -- Health and Mana Regenerator created by Baptizein
    
    local itemid = 90000
    
    function HealthMana_Start(item, event, player)
    	HealthMana_Menu(item, player)
    end
    
    function HealthMana_Menu(item, unit, event, player, id)
    	if (player:IsInCombat() == true) then
    	unit:SendChatMessage(12, 0, "You cannot use this while in combat.")
    	else
    	item:GossipCreateMenu(100, player, 0)
    	item:GossipMenuAddItem(0, "Restore My Health [ 5000 Gold ]", 1, 0)
    	item:GossipMenuAddItem(0, "Restore My Mana [ 3000 Gold ]", 2, 0)
    	item:GossipSendMenu(player)
    	end
    end
    
    function HealthMana_Selection(item, unit, event, player, id, intid, code)		
    	if(intid == 1) then
    	player:SetHealthPct(100)
    	if player:GetUInt32Value(PLAYER_FIELD_COINAGE) > 4999 then
    -- Subtract money from current gold goes here
    	unit:SendChatMessage(12, 0, "Health restored. Subtracted 5000 gold from character. Thank you!")
    	else
    	unit:SendChatMessage(12, 0, "You do not have enough gold.")
    	end
    	end
    	
    	if(intid == 2) then
    	player:GetPowerType()
    	if (player:GetPowerType() == mana) then
    	player:SetManaPct(100)
    	if player:GetUInt32Value(PLAYER_FIELD_COINAGE) < 3000 then unit:SendChatMessage(12, 0, "You do not have enough gold.")
    -- Subtract money from current gold code goes here
    	unit:SendChatMessage(12, 0, "Mana restored. Subtracted 3000 gold from character. Thank you!")
    	else
    	unit:SendChatMessage(12, 0, "Your character does not use mana.")
    	end
    	end
    	end
    end	
    
    RegisterItemGossipEvent(itemid, 1, "HealthMana_Start")
    RegisterItemGossipEvent(itemid, 2, "HealthMana_Selection")
    If someone wants to try and fix these, by all means do so. I'll gladly give +rep and full credits to that person. Anyways, enjoy what I have so far and in the meantime I'll try to get it to work 100%. Thanks for looking!
    Last edited by baptizein; 10-05-2008 at 03:34 PM. Reason: Changed color scheme per request.

    [WIP] [Lua++] [C++] Health and Mana Regenerator
  2. #2
    Sounddead's Avatar Contributor
    Reputation
    160
    Join Date
    Sep 2007
    Posts
    1,126
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nice. +rep

    I live in a shoe

  3. #3
    Fireblast's Avatar Contributor
    Reputation
    195
    Join Date
    Aug 2008
    Posts
    883
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thank you for contributing! looks good.

  4. #4
    Edge94's Avatar Contributor
    Reputation
    148
    Join Date
    Aug 2008
    Posts
    466
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    take teh blue out plox!!! It burns meh eyes!

  5. #5
    baptizein's Avatar Member
    Reputation
    16
    Join Date
    Jul 2008
    Posts
    65
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Edge94 View Post
    take teh blue out plox!!! It burns meh eyes!
    Sigh.. I spend almost a week preparing a Lua script and a C++ script for the community, and the only thing you can comment on is my font color?
    Lead Project Developer and Administrator of Team WoWfare · Developers of scripts and programs for World of Warcraft private servers

  6. #6
    Murlock.'s Avatar Knight-Lieutenant
    Reputation
    86
    Join Date
    Oct 2007
    Posts
    271
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The C++ version looks good. But, the lua one has some problems.. also the blue does sorta hurt my eyes XD

    But, not bad.. /cookie

  7. #7
    baptizein's Avatar Member
    Reputation
    16
    Join Date
    Jul 2008
    Posts
    65
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Murlock. View Post
    The C++ version looks good. But, the lua one has some problems.. also the blue does sorta hurt my eyes XD

    But, not bad.. /cookie
    I'll look over the Lua version again, but what problems are you receiving? That way I can fix it faster... and... I guess I will change the font color, as well...
    Lead Project Developer and Administrator of Team WoWfare · Developers of scripts and programs for World of Warcraft private servers

Similar Threads

  1. Rez on the spot with full health and mana in Tol Barad in under 30 seconds
    By OverLordErIcH in forum World of Warcraft Exploits
    Replies: 7
    Last Post: 03-24-2012, 06:50 AM
  2. LUA compiled threads and more
    By runiker in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 06-18-2008, 03:35 AM
  3. [Guide] How to make LUA portals easy and noobie too!
    By Ellenor in forum WoW EMU Guides & Tutorials
    Replies: 15
    Last Post: 03-05-2008, 09:10 PM
  4. Lua script help and general questions from beginner
    By WinKIller0 in forum World of Warcraft Emulator Servers
    Replies: 1
    Last Post: 02-23-2008, 04:38 AM
  5. Mana Regeneration for Hunter
    By Matt in forum World of Warcraft Guides
    Replies: 1
    Last Post: 05-14-2006, 08:14 PM
All times are GMT -5. The time now is 08:58 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search