• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

Trinity C++ Level Up Utility Mob

Tommy

Founder
You don't need to include "ScriptPCH.h." I've mentioned that so many times already for almost a year and people still do it. CMake takes care of including the necessary files. They changed that a long time ago.

You can create a separate function to deal with leveling players without spamming the same thing since it looks unclean. I don't get the class check to be honest. Also, you want to do your 'in combat' and 'level' checks in OnGossipHello so they can't go any further than that.

Instead of using 'player->PlayerTalkClass' to send & close the menu, they have simplified defines for that:

Code:
player->CLOSE_GOSSIP_MENU();
player->SEND_GOSSIP_MENU(1, creature->GetGUID());

Also, 1 is the default npc_text to send. Since every menu had "player->CLOSE_GOSSIP_MENU();" in it, "player->CLOSE_GOSSIP_MENU();" can be put on the bottom to close everything. It would need to be changed if you don't want it to close after a certain menu is called. For example: sending more gossip menus.

Sender is kinda pointless with custom scripts, just remove that code and comment out the variable.

Another thing, use GiveLevel not SetLevel. GiveLevel sets their talents and more for their level, without them being forced to logout. It also calls "SetLevel."

Lastly, 'AddSC' is not mandatory in the script setup function name. Just clarifying that. :p

I did everything I mentioned above:

Code:
class Level_Up_Mob : public CreatureScript
{
public:
    Level_Up_Mob() : CreatureScript("Level_Up_Mob") { }

    bool OnGossipHello(Player* player, Creature* creature)
    {
        if (player->IsInCombat())
        {
            creature->MonsterWhisper("Not while you're in combat. Cheater.", player, false);
            return false;
        }

        if (player->getLevel() != 68)
            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Drink the substance.", GOSSIP_SENDER_MAIN, 1);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "I feel a little weak.. Can you help me out?", GOSSIP_SENDER_MAIN, 2);
        player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Uhh..No thanks.", GOSSIP_SENDER_MAIN,  3);
        player->SEND_GOSSIP_MENU(1, creature->GetGUID());
        return true;
    }
	
    bool OnGossipSelect(Player* player, Creature* creature, uint32 /*sender*/, uint32 action)
    {
        player->PlayerTalkClass->ClearMenus();
        switch (action)
        {
            case 1:
                LevelPlayer(68);
                break;
            case 2:
                player->SetHealth(player->GetMaxHealth());
                player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA));
                break;
            case 3:
                creature->MonsterWhisper("As you wish. *Mutters*", player, false);
                break;
        }
		
        player->CLOSE_GOSSIP_MENU();
        return true;
    }
	
    void LevelPlayer(uint8 level)
    {
        player->GiveLevel(level);
    }
};

void AddSC_Level_Up_Mob()
{
    new Level_Up_Mob();
}
 
[MENTION=1]Tommy[/MENTION], I have all the different if statements for different classes, incase they want to use a different class and give that class certain loots.

I always include ScriptPCH to be safe. It's a force of habit. That's how I learned.
=P
 
Last edited:

Tommy

Founder
[MENTION=1]Tommy[/MENTION], I have all the different if statements for different classes, incase they want to use a different class and give that class certain loots.

I always include ScriptPCH to be safe. It's a force of habit. That's how I learned.
=P

I figured the class stuff served a purpose but I couldn't figure out what because giving the player something once they leveled. Trying to be safe or not, you don't need to include the file since you're basically including the sources twice once you do that. To me, that isn't really safe. The very old sources of TC (1-2 years old - maybe older) only need to include the ScriptPCH.

ED is a place to learn, just trying to help you get even better! Regardless, thanks for the script release.
 

Seraphim

Noble Member
Don't judge me, but... I am going to keep this for reference. It seems rather useful in the case of funservers or something. :p
 
Top