Ejemplo n.º 1
0
        void UpdateAI(const uint32 diff)
        {
			if (uiExplode == NULL)
				return;

			if (uiExplode <= diff)
			{	
				DoCastAOE(SPELL_EXPLODE,true);
			
				// Checks weather a Deep Crystal is in Range
				if(me->FindNearestCreature(NPC_DEEP_CELESTITE_BUNNY, 7.0f, true))
						player->AddItem(ITEM_DEEP_CELESTITE_CRYSTAL,1);

				if(me->FindNearestCreature(NPC_DEEP_AMETHYST_BUNNY, 7.0f, true))
						player->AddItem(ITEM_DEEP_AMETHYST_CRYSTAL,1);

				if(me->FindNearestCreature(NPC_DEEP_GRANAT_BUNNY, 7.0f, true))
						player->AddItem(ITEM_DEEP_GRANAT_CRYSTAL,1);

				if(me->FindNearestCreature(NPC_DEEP_ALABASTER_BUNNY, 7.0f, true))
						player->AddItem(ITEM_DEEP_ALABASTER_CRYSTAL,1);

				me->DespawnOrUnsummon();

        	} else uiExplode -= diff;
		}
        static bool HandleGiveOutfitCommand(ChatHandler* handler, const char* args)
         {
             Player* player = handler->GetSession()->GetPlayer();
             Player* target = handler->getSelectedPlayer();

             if (target->GetSession()->GetSecurity() >= SEC_GAMEMASTER)
             {
                 player->AddItem(GM_ROBE,1);
                 player->AddItem(GM_SLIPPERS,1);
                 player->AddItem(GM_HOOD,1);
             }
             else
                 handler->PSendSysMessage("Player is not a GM thus cannot receive GM clothes.");
             return true;
         }
        static bool HandleGiveTokenCommand(ChatHandler* handler, const char* args)
        {
            uint32 currenttokens;
            Player* target = handler->getSelectedPlayer();

            if (!*args)
            {
                currenttokens = target->GetItemCount(EVENT_TOKEN, true);
                handler->PSendSysMessage("Player %d has: %s", target->GetSession()->GetPlayerName(), currenttokens);
                return true;
            }

            char* ccount = strtok ((char*) args, " ");
            uint32 count = atoi (ccount);

            if (!target)
                target = handler->GetSession()->GetPlayer();

            if (count == 0)
                return false;

            //Subtract
            if (count < 0)
            {
                target->DestroyItemCount(EVENT_TOKEN, -count, true, false);
                handler->PSendSysMessage(LANG_REMOVEITEM, EVENT_TOKEN, -count, handler->GetNameLink(target).c_str());
                return true;
            }

            target->AddItem(EVENT_TOKEN, count);

            return true;
        }
Ejemplo n.º 4
0
 void HandleDummy(SpellEffIndex /*effIndex*/)
 {
     Player* caster = GetCaster()->ToPlayer();
     if (roll_chance_i(66))
         caster->AddItem(ITEM_RED_SNAPPER, 1);
     else
         caster->CastSpell(caster, SPELL_NEW_SUMMON_TEST, true);
 }
void OpenChestOption::Evaluate(Player& player)
{
	if (m_chest->IsOpen() == false)
	{
		const Item* item = m_chest->Open();
		player.AddItem(item);

		std::cout << "You picked up a " << item->GetName() << " from the chest!" << std::endl << std::endl;
	}
}
Ejemplo n.º 6
0
 void HandleDummy(SpellEffIndex /*effIndex*/)
 {
     Player* caster = GetCaster()->ToPlayer();
     switch (urand(0, 2))
     {
         case 0: case 1:
             caster->AddItem(ITEM_RED_SNAPPER, 1);
             break;
         case 2:
             if (Creature* murloc = caster->SummonCreature(NPC_ANGRY_MURLOC, caster->GetPositionX()+5, caster->GetPositionY(), caster->GetPositionZ(), 0.0f, TEMPSUMMON_MANUAL_DESPAWN, 120000))
                 murloc->AI()->AttackStart(caster);
             break;
     }
 }
Ejemplo n.º 7
0
        void UpdateAI(uint32 const /*diff*/)
        {
            if (me->isSummon())
            {
                Player* player = me->ToTempSummon()->GetSummoner()->ToPlayer();
                if (player && player->GetQuestStatus(QUEST_BLOODY_IMPOSSIBLE) != QUEST_STATUS_INCOMPLETE)
                    return;

                if (Creature* target = me->FindNearestCreature(NPC_WARP_CHASER, 20.0f, false))
                {
                    me->CastSpell(target, SPELL_GATHER_WARP_CHASER_BLOOD);
                    target->DespawnOrUnsummon();
                    player->AddItem(ITEM_WARP_CHASER_BLOOD, 1);
                }
            }
        }
Ejemplo n.º 8
0
    static bool HandleBoutiqueRecupCommand(ChatHandler* handler, const char* args) {
        /*const uint64 playerGuid = handler->GetSession()->GetPlayer()->GetGUID();

        const char* reqcount = "SELECT count(*) FROM site_recuperations_cata WHERE idperso='%u'";
        QueryResult resultcount = LoginDatabase.PQuery(reqcount, playerGuid);
        Field* fieldscount = resultcount->Fetch();
        if (fieldscount[0].GetInt32()==0) {
            //Aucune r�©cup�©ration n'est disponible pour ce personnage
            handler->PSendSysMessage(11106, handler->GetSession()->GetPlayerName());
            return true;
        }

        //                        0   1           2        3               4       5      6      7            8                  9                         10           11                 12                        13          14                15                       16          17                18                       19          20                21                       22                  23                         24                    25                           26             27                    28              29                     30                    31                           32                   33                     34    35    36    37    38
        const char* req = "SELECT id, validation, idperso, niveauattribue, pvppve, stuff, monte, metierprin1, niveaumetierprin1, niveaumetierprin1palier, metierprin2, niveaumetierprin2, niveaumetierprin2palier, metiersec1, niveaumetiersec1, niveaumetiersec1palier, metiersec2, niveaumetiersec2, niveaumetiersec2palier, metiersec3, niveaumetiersec3, niveaumetiersec3palier, reputgardienshyjal, reputgardienshyjalpallier, reputcercleterrestre, reputcercleterrestrepallier, reputramkahen, reputramkahenpallier, reputtherazane, reputtherazanepallier, reputgardiensbaradin, reputgardiensbaradinpallier, reputpoinghurlenfer, reputpoinghurlenferpallier, sac1, sac2, sac3, sac4, monnaie FROM site_recuperations_cata WHERE idperso='%u' ORDER BY valid_date DESC LIMIT 1;";

        QueryResult result = SiteDatabase.PQuery(req, playerGuid);
        Field* fields = result->Fetch();
        uint32 recupId = fields[0].GetUInt32();
        uint32 validation = fields[1].GetUInt32();

        switch (validation) {
        case 0:
        case 1:
            //La r�©cup�©ration du personnage %s est en cours de validation par un Ma�®tre du Jeu. Reessayez plus tard
            handler->PSendSysMessage(11101, handler->GetSession()->GetPlayerName());
            return true;
            break;
        case 2:
            //La r�©cup�©ration du personnage %s a �©t�© invalid�©e par un Ma�®tre du Jeu. Consultez votre profil sur le site pour plus d'information.
            handler->PSendSysMessage(11102, handler->GetSession()->GetPlayerName());
            return true;
            break;
        case 3:
            //La r�©cup�©ration du personnage %s a �©t�© valid�©e partiellement par un Ma�®tre du Jeu. Consultez votre profil sur le site pour plus d'information.
            handler->PSendSysMessage(11103, handler->GetSession()->GetPlayerName());
            break;
        case 4:
            //La r�©cup�©ration du personnage %s a �©t�© valid�©e par un Ma�®tre du Jeu. Vous allez a pr�©sent recevoir votre �©quipement ainsi que les comp�©tences demand�©es.
            handler->PSendSysMessage(11104, handler->GetSession()->GetPlayerName());
            break;
        case 5:
            //La r�©cup�©ration du personnage %s a d�©j�  �©t�© effectu�©e.
            handler->PSendSysMessage(11105, handler->GetSession()->GetPlayerName());
            return true;
            break;
        default:
            //Aucune r�©cup�©ration n'est disponible pour ce personnage
            handler->PSendSysMessage(11106, handler->GetSession()->GetPlayerName());
            return true;
            break;
        }


        if (validation==3 || validation==4) {
            //Update de la base pour terminer la r�©cup�©ration (validation = 5)
            const char* requpdate = "UPDATE site_recuperations_cata SET validation='5' WHERE id='%u'";
            SiteDatabase.PExecute(requpdate, recupId);

            //recup�©ration du joueur
            Player* player = handler->GetSession()->GetPlayer();

            //niveau
            uint32 niveauattrib = fields[3].GetInt32();
            int32 oldlevel = player->getLevel();
            if(niveauattrib>oldlevel) {
                if (niveauattrib<2) niveauattrib=2;
                if (niveauattrib>STRONG_MAX_LEVEL) niveauattrib = STRONG_MAX_LEVEL;
                player->GiveLevel(niveauattrib);
                player->InitTalentForLevel();
                player->SetUInt32Value(PLAYER_XP, 0);
            }

            //competence de monte
            uint32 monte = fields[6].GetInt32();
            if (monte>=75) { //Apprentice
                uint32 competence = 33388;
                if (sSpellStore.LookupEntry(competence) && !player->HasSpell(competence)) {
                    SpellEntry const* monteCompetenceInfo= sSpellStore.LookupEntry(competence);
                    if (monteCompetenceInfo && SpellMgr::IsSpellValid(monteCompetenceInfo, player)){
                        player->learnSpell(competence, false);
                    }
                }
            }
            if (monte>=150) { //Journeyman
                uint32 competence = 33391;
                if (sSpellStore.LookupEntry(competence) && !player->HasSpell(competence)) {
                    SpellEntry const* monteCompetenceInfo= sSpellStore.LookupEntry(competence);
                    if (monteCompetenceInfo && SpellMgr::IsSpellValid(monteCompetenceInfo, player)){
                        player->learnSpell(competence, false);
                    }
                }
            }
            if (monte>=225) { //Expert
                uint32 competence = 34090;
                if (sSpellStore.LookupEntry(competence) && !player->HasSpell(competence)) {
                    SpellEntry const* monteCompetenceInfo= sSpellStore.LookupEntry(competence);
                    if (monteCompetenceInfo && SpellMgr::IsSpellValid(monteCompetenceInfo, player)){
                        player->learnSpell(competence, false);
                    }
                }
            }
            if (monte>=300) { //Artisan
                uint32 competence = 34091;
                if (sSpellStore.LookupEntry(competence) && !player->HasSpell(competence)) {
                    SpellEntry const* monteCompetenceInfo= sSpellStore.LookupEntry(competence);
                    if (monteCompetenceInfo && SpellMgr::IsSpellValid(monteCompetenceInfo, player)){
                        player->learnSpell(competence, false);
                    }
                }
            }
            if (monte>=375) { //Master
                uint32 competence = 90265;
                if (sSpellStore.LookupEntry(competence) && !player->HasSpell(competence)) {
                    SpellEntry const* monteCompetenceInfo= sSpellStore.LookupEntry(competence);
                    if (monteCompetenceInfo && SpellMgr::IsSpellValid(monteCompetenceInfo, player)){
                        player->learnSpell(competence, false);
                    }
                }
            }


            //metiers
            for (int i=0 ; i<5; i++) {
                uint32 skill = fields[7+3*i].GetInt32();
                uint32 niveau = fields[7+3*i+1].GetInt32();
                uint32 palier = fields[7+3*i+2].GetInt32();

                if (niveau>palier) niveau = palier;
                if (niveau<1) niveau = 1;

                const char* req = "SELECT count(*), competence FROM site_recuperations_cata_metiers WHERE id = '%u' AND niveau = '%u';";

                QueryResult metierres = SiteDatabase.PQuery(req, skill, palier);

                Field* metierfields = metierres->Fetch();
                if (metierfields[0].GetInt32() != 0) {
                    uint32 competence =  metierfields[1].GetInt32();

                    // .learn competence
                    if (sSpellStore.LookupEntry(competence) && !player->HasSpell(competence)) {
                        SpellEntry const* metierCompetenceInfo= sSpellStore.LookupEntry(competence);

                        if (metierCompetenceInfo && SpellMgr::IsSpellValid(metierCompetenceInfo, player)){
                            player->learnSpell(competence, false);
                        }
                    }

                    // .setskill command
                    if(SkillLineEntry const* sl = sSkillLineStore.LookupEntry(skill)) {
                        if (player->GetSkillValue(skill)) {
                            player->SetSkill(uint16(skill), player->GetSkillStep(uint16(skill)), uint16(niveau), uint16(palier));
                        }
                    }
                }
            }


            //reputations
            for (int i = 0; i<6 ; i++) {
                uint16 niveau = fields[22+2*i].GetInt16();
                uint16 palier = fields[22+2*i+1].GetInt16();

                niveau += palier;
                if (niveau<1) niveau = 1;
                if (niveau>42999) niveau = 42999;

                uint16 reputid;
                switch (i) {
                case 0: //gardiens hyjal
                    reputid = 1158;
                    break;
                case 1: //cercle terrestre
                    reputid = 1135;
                    break;
                case 2: //ramkahen
                    reputid = 1173;
                    break;
                case 3: //therazane
                    reputid = 1171;
                    break;
                case 4: //gardiens baradin (alliance)
                    if (!player->GetTeamId() == TEAM_ALLIANCE) continue;
                    reputid = 1177;
                    break;
                case 5: //poing hurlenfer (horde)
                    if (!player->GetTeamId() == TEAM_HORDE) continue;
                    reputid = 1178;
                    break;
                default:
                    continue;
                }

                FactionEntry const *factionEntry = sFactionStore.LookupEntry(reputid);
                if (factionEntry && factionEntry->reputationListID>=0)
                    player->SetReputation(reputid,niveau);
            }


            //monnaie
            uint32 monnaie = fields[38].GetInt32();
            if (monnaie>=0)
                player->ModifyMoney(player->GetMoney()+monnaie);

            //sacs
            int isac = 0;
            for (uint8 ibag = INVENTORY_SLOT_BAG_START; ibag < INVENTORY_SLOT_BAG_END; ibag++) {
                uint32 sacid = fields[34+isac].GetUInt32();
                if (isac==0 && sacid == 0) sacid = 4498;

                isac++;
                if (sacid != 0) {
                    if (Bag *pBag = (Bag*)player->GetItemByPos(INVENTORY_SLOT_BAG_0, ibag)) {

                        for (uint32 jsize = 0; jsize < pBag->GetBagSize(); jsize++){
                            if (pBag->GetItemByPos(jsize)){
                                player->DestroyItem(ibag, jsize, true);
                            }
                        }
                        if (pBag->IsEmpty()) {
                            player->DestroyItem(INVENTORY_SLOT_BAG_0, ibag, true);
                        } else continue;
                    }

                    ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(sacid);
                    if (pProto && pProto->InventoryType == INVTYPE_BAG) {
                        Item *sac = Item::CreateItem(sacid, 1);
                        player->EquipItem(ibag, sac, true);
                    }
                }
            }

            //equipement
            uint32 stuff = fields[5].GetUInt32();
            uint32 pvepvp = fields[4].GetUInt32();

            const char* reqniveau = "SELECT niveau, count(*) FROM site_recuperations_cata_stuff WHERE classe='%u' AND niveau <='%u' GROUP BY niveau ORDER BY niveau DESC LIMIT 1;";
            QueryResult resultniveau = SiteDatabase.PQuery(reqniveau, player->getClass(), niveauattrib);
            if (resultniveau) {
                Field* fieldsniveau = resultniveau->Fetch();

                if (fieldsniveau[1].GetUInt32() != 0) {
                    uint32 niveaupallier = fieldsniveau[0].GetUInt32();

                    QueryResult resultstuff;
                    Field* fieldstuff;
                    uint32 reqstufftype = 0;

                    bool stufffound = false;
                    //test avec tous les choix du joueur
                    if (!stufffound) {
                        const char* reqstuff = "SELECT count(*) FROM site_recuperations_cata_stuff WHERE classe='%u' AND stuff='%u' AND alliancehorde='%u' AND pvepvp='%u' AND niveau ='%u' ;";
                        resultstuff = SiteDatabase.PQuery(reqstuff, player->getClass(), stuff, player->GetTeamId()+1, pvepvp, niveaupallier);
                        if (resultstuff) {
                            fieldstuff = resultstuff->Fetch();
                            if (fieldstuff[0].GetUInt32() != 0) {
                                reqstufftype = 1;
                                stufffound = true;
                            }
                        }
                    }

                    //test en pve
                    if (!stufffound) {
                        const char* reqstuff = "SELECT count(*) FROM site_recuperations_cata_stuff WHERE classe='%u' AND stuff='%u' AND alliancehorde='%u' AND pvepvp='%u' AND niveau ='%u' ;";
                        resultstuff = SiteDatabase.PQuery(reqstuff, player->getClass(), stuff, player->GetTeamId()+1, 0, niveaupallier);
                        if (resultstuff) {
                            fieldstuff = resultstuff->Fetch();
                            if (fieldstuff[0].GetUInt32() != 0) {
                                reqstufftype = 2;
                                stufffound = true;
                            }
                        }
                    }

                    //test en pve neutre
                    if (!stufffound) {
                        const char* reqstuff = "SELECT count(*) FROM site_recuperations_cata_stuff WHERE classe='%u' AND stuff='%u' AND alliancehorde='%u' AND pvepvp='%u' AND niveau ='%u' ;";
                        resultstuff = SiteDatabase.PQuery(reqstuff, player->getClass(), stuff, 0, 0, niveaupallier);
                        if (resultstuff) {
                            fieldstuff = resultstuff->Fetch();
                            if (fieldstuff[0].GetUInt32() != 0) {
                                reqstufftype = 3;
                                stufffound = true;
                            }
                        }
                    }

                    //test en pve dps alli/horde
                    if (!stufffound) {
                        const char* reqstuff = "SELECT count(*) FROM site_recuperations_cata_stuff WHERE classe='%u' AND stuff='%u' AND alliancehorde='%u' AND pvepvp='%u' AND niveau ='%u' ;";
                        resultstuff = SiteDatabase.PQuery(reqstuff, player->getClass(), 0, player->GetTeamId()+1, 0, niveaupallier);
                        if (resultstuff) {
                            fieldstuff = resultstuff->Fetch();
                            if (fieldstuff[0].GetUInt32() != 0) {
                                reqstufftype = 4;
                                stufffound = true;
                            }
                        }
                    }

                    //test en pve neutre dps
                    if (!stufffound) {
                        const char* reqstuff = "SELECT count(*) FROM site_recuperations_cata_stuff WHERE classe='%u' AND stuff='%u' AND alliancehorde='%u' AND pvepvp='%u' AND niveau ='%u' ;";
                        resultstuff = SiteDatabase.PQuery(reqstuff, player->getClass(), 0, 0, 0, niveaupallier);
                        if (resultstuff) {
                            fieldstuff = resultstuff->Fetch();
                            if (fieldstuff[0].GetUInt32() != 0) {
                                reqstufftype = 5;
                                stufffound = true;
                            }
                        }
                    }

                    if (reqstufftype!=0) {

                        char* reqstuffattrib = "SELECT stuff_id FROM site_recuperations_cata_stuff WHERE classe='%u' AND stuff='%u' AND alliancehorde='%u' AND pvepvp='%u' AND niveau ='%u' ;";
                        QueryResult resultstuffattrib;


                        switch (reqstufftype) {
                        case 1:
                            resultstuffattrib = SiteDatabase.PQuery(reqstuffattrib, player->getClass(), stuff, player->GetTeamId()+1, pvepvp, niveaupallier);
                            break;
                        case 2:
                            resultstuffattrib = SiteDatabase.PQuery(reqstuffattrib, player->getClass(), stuff, player->GetTeamId()+1, 0, niveaupallier);
                            break;
                        case 3:
                            resultstuffattrib = SiteDatabase.PQuery(reqstuffattrib, player->getClass(), stuff, 0, 0, niveaupallier);
                            break;
                        case 4:
                            resultstuffattrib = SiteDatabase.PQuery(reqstuffattrib, player->getClass(), 0, player->GetTeamId()+1, 0, niveaupallier);
                            break;
                        case 5:
                            resultstuffattrib = SiteDatabase.PQuery(reqstuffattrib, player->getClass(), 0, 0, 0, niveaupallier);
                            break;
                        default:
                            break;
                        }

                        if(!resultstuffattrib)
                            return false;
                        uint32 bagpos = INVENTORY_SLOT_ITEM_START;
                        uint32 bag = INVENTORY_SLOT_BAG_0;

                        do {
                            Field* fieldstuffid = resultstuffattrib->Fetch();
                            uint32 stuffid = fieldstuffid[0].GetUInt32();

                            ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(stuffid);

                            if (pProto) {
                                if (bagpos == INVENTORY_SLOT_ITEM_END) {
                                    bagpos = 0;
                                    bag = INVENTORY_SLOT_BAG_START;
                                }

                                player->DestroyItem(bag, bagpos, true);
                                player->AddItem(stuffid, 1);

                                bagpos++;
                            }


                        } while (resultstuffattrib->NextRow());
                    }
                }
            }

        }*/

		
		/*
        Player *pPlayer = handler->GetSession()->GetPlayer();

        if(!pPlayer)
            return false;

        uint32 guidLow = pPlayer->GetGUIDLow();

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test1");

        QueryResult result = LoginDatabase.PQuery("SELECT id, level, stuff_wanted FROM recuperation WHERE idPerso=%u AND state=3", guidLow);
        if(!result)
        {
            handler->PSendSysMessage("Vous ne disposez pas de recuperation pour ce personnage, ou elle n'a pas encore ete validee par un maitre du jeu");
            return true;
        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test2");

        Field *recup = result->Fetch();

        uint32 id = recup[0].GetUInt32();
        uint32 stuffId = recup[2].GetUInt32();
        uint8 level = recup[1].GetUInt8();

        QueryResult metier = LoginDatabase.PQuery("SELECT skill, value, max FROM recuperation_metier WHERE idRecup = %u", id);
        QueryResult reput = LoginDatabase.PQuery("SELECT reputId, value FROM recuperation_reput WHERE idRecup = %u", id);
        QueryResult stuff = LoginDatabase.PQuery("SELECT itemId FROM recuperation_stuff WHERE spe = %u", stuffId);


        uint32 sacId = 0;
        uint32 moneyToAdd = 0;
        if(level == 85)
        {
            sacId = 21841;
            moneyToAdd = 12000 * GOLD;
        }
        else
        {
            sacId = 30744;
            moneyToAdd = 10000 * GOLD;
        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test3");

        pPlayer->ModifyMoney(moneyToAdd);

        for(uint32 i = INVENTORY_SLOT_BAG_START ; i < INVENTORY_SLOT_BAG_END ; i++)
        {
            if(Bag *pBag = (Bag*)pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
            {
                for(uint32 j = 0 ; j < pBag->GetBagSize(); j++)
                {
                    if(Item *pItem = pBag->GetItemByPos(j))
                        pPlayer->DestroyItem(INVENTORY_SLOT_BAG_0, j, false);
                }

                pPlayer->DestroyItem(INVENTORY_SLOT_BAG_0, i, true);
            }

        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test4");


        for(uint32 i = INVENTORY_SLOT_ITEM_START ; i < INVENTORY_SLOT_ITEM_END ; i++)
        {
            if(pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
                pPlayer->DestroyItem(INVENTORY_SLOT_BAG_0, i, true);
        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test5");


        for(uint32 i = 0 ; i < 4 ; i++)
        {
            pPlayer->EquipNewItem(INVENTORY_SLOT_BAG_START+i, sacId, true);
        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test6");

        pPlayer->GiveLevel(level);
        pPlayer->InitTalentForLevel();
        pPlayer->SetUInt32Value(PLAYER_XP,0);

        if(stuff)
        {
            do
            {
                Field * piece = stuff->Fetch();
                uint32 item = piece[0].GetUInt32();
                pPlayer->AddItem(item, 1);
            }
            while(stuff->NextRow());
        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test7");

        if(reput)
        {
            do
            {
                Field *rep = reput->Fetch();
                uint32 reputId = rep[0].GetUInt32();
                uint32 rank = rep[1].GetUInt32();

                FactionEntry const *fac = sFactionStore.LookupEntry(reputId);

                if(rank == 42000)
                    rank += 1000;

                pPlayer->GetReputationMgr().SetReputation(fac, rank);
            }
            while(reput->NextRow());
        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test8");

        if(metier)
        {
            do
            {
                Field *prof = metier->Fetch();

                uint32 skill = prof[0].GetUInt32();
                uint32 value = prof[1].GetUInt32();
                uint32 max = prof[2].GetUInt32();

                QueryResult profSpellQ = LoginDatabase.PQuery("SELECT competence FROM recuperation_metier_spell WHERE id = %u AND niveau = %u", skill, max);
                if(profSpellQ->GetRowCount() == 0)
                    continue;

                Field *profSpell = profSpellQ->Fetch();
                uint32 spell = profSpell->GetUInt32();

                if(!pPlayer->HasSpell(spell))
                    pPlayer->learnSpell(spell, false);

                pPlayer->SetSkill(skill, pPlayer->GetSkillStep(skill), value, max);
            }
            while(metier->NextRow());
        }

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test9");


        LoginDatabase.PQuery("UPDATE recuperation SET state=5 WHERE id=%u", id);

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test10");

        if (pPlayer->getRace() == RACE_GOBLIN)
            pPlayer->TeleportTo(1, 1569, -4398, 18, 0);
        else if (pPlayer->getRace() == RACE_WORGEN)
            pPlayer->TeleportTo(0, -8830, 626, 96, 0);

        pPlayer->SaveToDB();

	//sLog->outDebug(LOG_FILTER_NETWORKIO, "NOBODIE test11");


        return true;*/

        Player *pPlayer = handler->GetSession()->GetPlayer();

        if(!pPlayer)
            return false;

        uint32 guidLow = pPlayer->GetGUIDLow();

        QueryResult result = LoginDatabase.PQuery("SELECT id, level, stuff_wanted FROM recuperation WHERE idPerso=%u AND state=3 AND destination_realm=%u", guidLow, realmID);
        if(!result)
        {
            handler->PSendSysMessage("Vous ne disposez pas de recuperation pour ce personnage, ou elle n'a pas encore été validee par un maitre du jeu");
            return true;
        }

        Field *recup = result->Fetch();

        uint32 id = recup[0].GetUInt32();
        uint32 stuffId = recup[2].GetUInt32();
        uint8 level = recup[1].GetUInt8();

        QueryResult metier = LoginDatabase.PQuery("SELECT skill, value, max FROM recuperation_metier WHERE idRecup = %u", id);
        QueryResult reput = LoginDatabase.PQuery("SELECT reputId, value FROM recuperation_reput WHERE idRecup = %u", id);
        QueryResult stuff = LoginDatabase.PQuery("SELECT itemId FROM recuperation_stuff WHERE spe = %u", stuffId);


        uint32 sacId = 0;
        uint32 moneyToAdd = 0;
        if(level == 85)
        {
            sacId = 21841;
            moneyToAdd = 12000 * GOLD;
        }
		else if(level == 90)
		{
            sacId = 21843;
			moneyToAdd = 15000 * GOLD;
		}
        else
        {
            sacId = 30744;
            moneyToAdd = 10000 * GOLD;
        }

        pPlayer->ModifyMoney(moneyToAdd);

        for(uint32 i = INVENTORY_SLOT_BAG_START ; i < INVENTORY_SLOT_BAG_END ; i++)
        {
            if(Bag *pBag = (Bag*)pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
            {
                for(uint32 j = 0 ; j < pBag->GetBagSize(); j++)
                {
                    if(Item *pItem = pBag->GetItemByPos(j))
                        pPlayer->DestroyItem(INVENTORY_SLOT_BAG_0, j, false);
                }

                pPlayer->DestroyItem(INVENTORY_SLOT_BAG_0, i, true);
            }

        }

        for(uint32 i = INVENTORY_SLOT_ITEM_START ; i < INVENTORY_SLOT_ITEM_END ; i++)
        {
            if(pPlayer->GetItemByPos(INVENTORY_SLOT_BAG_0, i))
                pPlayer->DestroyItem(INVENTORY_SLOT_BAG_0, i, true);
        }

        for(uint32 i = 0 ; i < 4 ; i++)
        {
            pPlayer->EquipNewItem(INVENTORY_SLOT_BAG_START+i, sacId, true);
        }

        pPlayer->GiveLevel(level);
        pPlayer->InitTalentForLevel();
        pPlayer->SetUInt32Value(PLAYER_XP,0);

        if(stuff)
        {
            do
            {
                Field * piece = stuff->Fetch();
                uint32 item = piece[0].GetUInt32();
                pPlayer->AddItem(item, 1);
            }
            while(stuff->NextRow());
        }

        if(reput)
        {
            do
            {
                Field *rep = reput->Fetch();
                uint32 reputId = rep[0].GetUInt32();
                uint32 rank = rep[1].GetUInt32();

                FactionEntry const *fac = sFactionStore.LookupEntry(reputId);

                if(rank == 42000)
                    rank += 1000;

                pPlayer->GetReputationMgr().SetReputation(fac, rank);
            }
            while(reput->NextRow());
        }

        if(metier)
        {
            do
            {
                Field *prof = metier->Fetch();

                uint32 skill = prof[0].GetUInt32();
                uint32 value = prof[1].GetUInt32();
                uint32 max = prof[2].GetUInt32();

                QueryResult profSpellQ = LoginDatabase.PQuery("SELECT competence FROM recuperation_metier_spell WHERE id = %u AND niveau = %u", skill, max);
                if(profSpellQ->GetRowCount() == 0)
                    continue;

                Field *profSpell = profSpellQ->Fetch();
                uint32 spell = profSpell->GetUInt32();

                if(!pPlayer->HasSpell(spell))
                    pPlayer->learnSpell(spell, false);

                pPlayer->SetSkill(skill, pPlayer->GetSkillStep(skill), value, max);
            }
            while(metier->NextRow());
        }

        LoginDatabase.PQuery("UPDATE recuperation SET state=5 WHERE id=%u", id);

        if (pPlayer->getRace() == RACE_GOBLIN)
            pPlayer->TeleportTo(1, 1569, -4398, 18, 0);
        else if (pPlayer->getRace() == RACE_WORGEN)
            pPlayer->TeleportTo(0, -8830, 626, 96, 0);

        pPlayer->SaveToDB();

        return true;
    }
Ejemplo n.º 9
0
int main(int argc, char **argv) {

	Renderer* r = NULL;
	try {
		r = new Renderer(800, 600);
	
		EventQueue ev(r);
	
		CharacterManager cm;
		r->SetCharManager(&cm);

		Player player = Player(10, 10, "Dann Von Veigar");
		player.SetEventQueue(&ev);

		Item it = Item("Insígnia do MC Bin Laden", "insignia do mestre Bin Laden", 3000);
		player.AddItem(&it);

		Sprite s = Sprite("..\\characters\\dann.png", 1.5f, 0);
		player.SetSprite(&s);

		Asura asu = Asura{ 0,0 };
		Akhbran ahk = Akhbran{ 0,0 };

		CharFactory* cf = new CharFactory(&cm);

		Tree t = Tree(20, 20);
		Sprite stree = Sprite("..\\characters\\arvore1.png", 1, 60, 80);
		t.SetSprite(&stree);

		cf->RegisterCharacter(t.GetTypeID(), &t);


		cm.AddCharacter(&player);
		cm.SetPlayer(&player);

		
		/*
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 3, 8));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 6, 11));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 9, 20));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 12, 25));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 15, 20));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 18, 11));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 21, 8));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 24, 11));
		cm.AddCharacter(cf->PutCharacter(t.GetTypeID(), 27, 20));
		*/

		cm.AddCharacter(&asu);
		cm.AddCharacter(&ahk);

		Map* m;
		Map::LoadTiles();

		MapOpener mpop;
		m = mpop.Open("..\\maps\\map2.map");		

		if (!m) {
			char strmaperr[32];
			sprintf_s(strmaperr, 32, "Erro ao abrir o mapa!");
			throw std::runtime_error(strmaperr);
		}


		int px, py;
		m->GetInitialPlayerPos(px, py);

		float fx = px, fy = py;
		player.SetPosition(fx, fy);


		std::vector<CharacterData>* chd = m->GetCharData();

		if (chd->size() > 0) {
			for (auto i = chd->begin(); i != chd->end(); i++) {
				cm.AddCharacter(cf->PutCharacter(i->Type, i->XPos, i->YPos));
			}

		}

		r->SetMap(m);
		cm.SetMap(m);

		HUD* hud = new HUD(&player);
		r->SetHUD(hud);

	

		bool render = true;

		double fps = (1/60), start_time, end_time;

		float start_animations = al_get_time();
		float start_events = al_get_time();

		float playerdx = 0, playerdy = 0;

		start_time = al_get_time();

		while (render) {
			
			//Run events in 15fps.
			float end_events = al_get_time();
			if ((end_events - start_events) >= 1/15.0f){
				cm.DoAllEvents();
				start_events - end_events;
			}

			//Processa eventos
			if (!ev.CheckEvents()) {
				render = false;
			}


			player.Control(m);
			Event e;

			if (ev.PopEvent(e)) {

				switch (e.keycode) {

				case ALLEGRO_KEY_I:

					if (e.keyletter != 'i') continue;

					//Enumera os itens no inventário do player.
					std::vector<Item*>* list;
					player.GetAllItems(&list);

					std::stringstream line;

					for (auto i = list->begin();
					i != list->end();
						i++) {
						std::string name;
						(*i)->GetName(name);
						line << (*i)->GetID() << " - " << name << " - " << (*i)->GetValue() << " money" << std::endl;
					
					}

					MessageBoxA(al_get_win_window_handle(r->GetDisplay()), line.str().c_str(), "Inventário", 0);

					break;


				}

				
			}

			float end_animations = al_get_time();
			/* Run animations in 5 fps by default. */
			if ((end_animations - start_animations) >= 1/5.0f) {
				player.Andar(playerdx, playerdy);
				asu.Andar(playerdx, playerdy);
				ahk.Andar(playerdx, playerdy);
				playerdx = 0;
				playerdy = 0;
				start_animations = end_animations;

			}

			cm.DoAllEvents();
			
			//Os renderiza
			r->Render();


			end_time = al_get_time();

			if ((end_time - start_time) < fps) {
				double delta = (end_time - start_time);
				Sleep((fps - delta) * 1000);
				
			}
			//printf("\r%.5f ms", end_time - start_time);
			
			start_time = al_get_time();

			frames++;
		}


	}
	catch (std::runtime_error& e) {
		if (r)
			MessageBoxA(r->GetDisplay() ? al_get_win_window_handle(r->GetDisplay()) : NULL,
				e.what(), "Dois Demônios - Erro", MB_ICONERROR);
		else
			MessageBoxA(NULL, e.what(), "Dois Demônios - Erro", MB_ICONERROR);
		return -1;
	}

	delete r;
	return 0;
}
Ejemplo n.º 10
0
void Arena::EndBattleground(uint32 winner)
{
    // arena rating calculation
    if (isRated())
    {
        uint32 loserTeamRating        = 0;
        uint32 loserMatchmakerRating  = 0;
        int32  loserChange            = 0;
        int32  loserMatchmakerChange  = 0;
        uint32 winnerTeamRating       = 0;
        uint32 winnerMatchmakerRating = 0;
        int32  winnerChange           = 0;
        int32  winnerMatchmakerChange = 0;

        ArenaTeam* winnerArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(winner));
        ArenaTeam* loserArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeam(winner)));

        if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam)
        {
            loserTeamRating = loserArenaTeam->GetRating();
            loserMatchmakerRating = GetArenaMatchmakerRating(GetOtherTeam(winner));
            winnerTeamRating = winnerArenaTeam->GetRating();
            winnerMatchmakerRating = GetArenaMatchmakerRating(winner);

            if (winner != 0)
            {
                winnerMatchmakerChange = winnerArenaTeam->WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, winnerChange);
                loserMatchmakerChange = loserArenaTeam->LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, loserChange);

                TC_LOG_DEBUG("bg.arena", "match Type: %u --- Winner: old rating: %u, rating gain: %d, old MMR: %u, MMR gain: %d --- Loser: old rating: %u, rating loss: %d, old MMR: %u, MMR loss: %d ---",
                    GetArenaType(), winnerTeamRating, winnerChange, winnerMatchmakerRating, winnerMatchmakerChange,
                    loserTeamRating, loserChange, loserMatchmakerRating, loserMatchmakerChange);

                SetArenaMatchmakerRating(winner, winnerMatchmakerRating + winnerMatchmakerChange);
                SetArenaMatchmakerRating(GetOtherTeam(winner), loserMatchmakerRating + loserMatchmakerChange);

                // bg team that the client expects is different to TeamId
                // alliance 1, horde 0
                uint8 winnerTeam = winner == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE;
                uint8 loserTeam = winner == ALLIANCE ? BG_TEAM_HORDE : BG_TEAM_ALLIANCE;

                _arenaTeamScores[winnerTeam].Assign(winnerChange, winnerMatchmakerRating, winnerArenaTeam->GetName());
                _arenaTeamScores[loserTeam].Assign(loserChange, loserMatchmakerRating, loserArenaTeam->GetName());

                TC_LOG_DEBUG("bg.arena", "Arena match Type: %u for Team1Id: %u - Team2Id: %u ended. WinnerTeamId: %u. Winner rating: +%d, Loser rating: %d",
                    GetArenaType(), GetArenaTeamIdByIndex(TEAM_ALLIANCE), GetArenaTeamIdByIndex(TEAM_HORDE), winnerArenaTeam->GetId(), winnerChange, loserChange);

                if (sWorld->getBoolConfig(CONFIG_ARENA_LOG_EXTENDED_INFO))
                    for (auto const& score : PlayerScores)
                        if (Player* player = ObjectAccessor::FindConnectedPlayer(ObjectGuid(HIGHGUID_PLAYER, score.first)))
                        {
                            TC_LOG_DEBUG("bg.arena", "Statistics match Type: %u for %s (GUID: %u, Team: %d, IP: %s): %s",
                                GetArenaType(), player->GetName().c_str(), score.first, player->GetArenaTeamId(GetArenaType() == 5 ? 2 : GetArenaType() == 3),
                                player->GetSession()->GetRemoteAddress().c_str(), score.second->ToString().c_str());
                        }
            }
            // Deduct 16 points from each teams arena-rating if there are no winners after 45+2 minutes
            else
            {
                _arenaTeamScores[BG_TEAM_ALLIANCE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, winnerMatchmakerRating, winnerArenaTeam->GetName());
                _arenaTeamScores[BG_TEAM_HORDE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, loserMatchmakerRating, loserArenaTeam->GetName());

                winnerArenaTeam->FinishGame(ARENA_TIMELIMIT_POINTS_LOSS);
                loserArenaTeam->FinishGame(ARENA_TIMELIMIT_POINTS_LOSS);
            }

            uint8 aliveWinners = GetAlivePlayersCountByTeam(winner);

            for (auto const& i : GetPlayers())
            {
                uint32 team = i.second.Team;

                if (i.second.OfflineRemoveTime)
                {
                    // if rated arena match - make member lost!
                    if (team == winner)
                        winnerArenaTeam->OfflineMemberLost(i.first, loserMatchmakerRating, winnerMatchmakerChange);
                    else
                        loserArenaTeam->OfflineMemberLost(i.first, winnerMatchmakerRating, loserMatchmakerChange);
                    continue;
                }

                Player* player = _GetPlayer(i.first, i.second.OfflineRemoveTime != 0, "Arena::EndBattleground");
                if (!player)
                    continue;

                // per player calculation
                if (team == winner)
                {
                    player->ModifyMoney(500);
					if (roll_chance_i(50))
						player->AddItem(6354, 1);
                    // update achievement BEFORE personal rating update
                    uint32 rating = player->GetArenaPersonalRating(winnerArenaTeam->GetSlot());
                    player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, rating ? rating : 1);
                    player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, GetMapId());

                    // Last standing - Rated 5v5 arena & be solely alive player
                    if (GetArenaType() == ARENA_TYPE_5v5 && aliveWinners == 1 && player->IsAlive())
                        player->CastSpell(player, SPELL_LAST_MAN_STANDING, true);

                    winnerArenaTeam->MemberWon(player, loserMatchmakerRating, winnerMatchmakerChange);
                }
                else
                {
                    loserArenaTeam->MemberLost(player, winnerMatchmakerRating, loserMatchmakerChange);

                    // Arena lost => reset the win_rated_arena having the "no_lose" condition
                    player->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE);
                }
            }

            // save the stat changes
            winnerArenaTeam->SaveToDB();
            loserArenaTeam->SaveToDB();
            // send updated arena team stats to players
            // this way all arena team members will get notified, not only the ones who participated in this match
            winnerArenaTeam->NotifyStatsChanged();
            loserArenaTeam->NotifyStatsChanged();
        }
    }

    // end battleground
    Battleground::EndBattleground(winner);
}