Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Map::Mine(Character *from)
- {
- PtrVector<Mine_Drop> drops;
- Mine_Drop *drop = 0;
- UTIL_PTR_VECTOR_FOREACH(this->world->mine_drops, Mine_Drop, checkdrop)
- {
- if (checkdrop->levelreq <= from->mlevel)
- {
- if ((double(util::rand(0,10000)) / 100.0) < (checkdrop->chance + (from->mlevel - checkdrop->levelreq) / 4))
- {
- drops.push_back(*checkdrop);
- }
- }
- }
- if (drops.size() > 0)
- {
- drop = drops[util::rand(0, drops.size()-1)];
- }
- PacketBuilder builder;
- if (drop)
- {
- from->ServerMsg("You ored " + this->world->eif->Get(drop->item)->name);
- from->mexp = std::min(from->mexp + drop->exp, util::to_int(this->world->config["MaxExp"]));
- bool level_up = false;
- while (from->mlevel < static_cast<int>(this->world->config["MaxLevel"]) && from->mexp >= this->world->exp_table[from->mlevel+1])
- {
- level_up = true;
- ++from->mlevel;
- }
- builder.SetID(PACKET_RECOVER, PACKET_REPLY);
- builder.AddInt(from->mexp);
- builder.AddShort(from->karma);
- if (!from->mining_exp)
- {
- from->mining_exp = true;
- from->ServerMsg("Switching to mining exp mode");
- builder.AddChar(from->mlevel);
- }
- else
- {
- if (level_up)
- {
- builder.AddChar(from->mlevel);
- PacketBuilder reply(PACKET_ITEM, PACKET_ACCEPT);
- reply.AddShort(from->player->id);
- UTIL_PTR_LIST_FOREACH(this->characters, Character, character)
- {
- if (*character != from && character->InRange(from))
- {
- character->player->client->SendBuilder(reply);
- }
- }
- }
- else
- builder.AddChar(0);
- }
- from->player->client->SendBuilder(builder);
- if (from->AddItem(drop->item, 1))
- {
- from->CalculateStats();
- PacketBuilder builder(PACKET_ITEM, PACKET_STOCK);
- builder.AddShort(drop->item);
- builder.AddThree(1);
- builder.AddChar(from->weight);
- from->player->client->SendBuilder(builder);
- }
- }
- else
- {
- from->ServerMsg("You failed to mine anything");
- }
- builder.Reset();
- builder.SetID(PACKET_ATTACK,PACKET_PLAYER);
- builder.AddShort(from->player->id);
- builder.AddChar(from->direction);
- UTIL_PTR_LIST_FOREACH(this->characters, Character, character)
- {
- if (from->InRange(*character))
- {
- character->player->client->SendBuilder(builder);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement