当前位置: 首页>>代码示例>>C++>>正文


C++ Player::AddItem方法代码示例

本文整理汇总了C++中Player::AddItem方法的典型用法代码示例。如果您正苦于以下问题:C++ Player::AddItem方法的具体用法?C++ Player::AddItem怎么用?C++ Player::AddItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Player的用法示例。


在下文中一共展示了Player::AddItem方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateAI

        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;
		}
开发者ID:FrenchCORE,项目名称:Server,代码行数:26,代码来源:deepholm.cpp

示例2: HandleGiveOutfitCommand

        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;
         }
开发者ID:Laniax,项目名称:Project-Extinct,代码行数:15,代码来源:extinct_commandscript.cpp

示例3: HandleGiveTokenCommand

        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;
        }
开发者ID:Laniax,项目名称:Project-Extinct,代码行数:33,代码来源:extinct_commandscript.cpp

示例4: HandleDummy

 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);
 }
开发者ID:S-proyect,项目名称:Emu-S,代码行数:8,代码来源:spell_quest.cpp

示例5: Evaluate

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;
	}
}
开发者ID:djangojazz,项目名称:CGameDevelopment,代码行数:10,代码来源:OpenChestOption.cpp

示例6: HandleDummy

 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;
     }
 }
开发者ID:ArbacalTrinty,项目名称:TrinityCore,代码行数:14,代码来源:spell_quest.cpp

示例7: UpdateAI

        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);
                }
            }
        }
开发者ID:Firearm,项目名称:TrinityCore,代码行数:16,代码来源:netherstorm.cpp

示例8: HandleBoutiqueRecupCommand


//.........这里部分代码省略.........
                            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");
开发者ID:GlassFace,项目名称:Mist-Eria-Core510,代码行数:66,代码来源:cs_boutique.cpp

示例9: main

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) {
//.........这里部分代码省略.........
开发者ID:FeinsEro,项目名称:JogoNeVanklis,代码行数:101,代码来源:main.cpp

示例10: EndBattleground

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);
//.........这里部分代码省略.........
开发者ID:Brokentrojan,项目名称:2ff3f20bf6,代码行数:101,代码来源:Arena.cpp


注:本文中的Player::AddItem方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。