Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.37 KB | None | 0 0
  1. /*Pk weapons
  2. for snow by newguy
  3. this goes in map.cpp in Map::AttackPK
  4. under if (character_ptr->hp < 0)
  5. I havent gotten to compile it so there maybe errors
  6. You also need to add a pk_config file in world.cpp and world.hpp for this to work
  7. This is used to load the items and chances
  8. */
  9. int item[10];int dchance[10]
  10. for (int i = 0; i < static_cast<int>(this->server->world->pk_config["DropAmount"]);i++)
  11. {
  12.     item[i] = static_cast<int>(this->server->world->pk_config[util::to_string(i+1) + ".item"]);
  13.         dchance[i] = static_cast<int>(this->server->world->pk_config[util::to_string(i+1) + ".chance"]);
  14.  
  15. }
  16.  
  17. //actually checking the chance
  18. for (int i = 0;  i < static_cast<int>(this->server->world->pk_config["DropAmount"]); i++)
  19. {
  20.     int number = util::rand(1,100);
  21.     //Checking if they got the item
  22.     if (dchance[i] >= number)
  23.     {
  24.        
  25.        //adding the item
  26.        from->AddItem(item[i], 1);
  27.        PacketBuilder builder;
  28.  
  29.             builder.SetID(PACKET_ITEM, PACKET_GET);
  30.             builder.AddShort(0);
  31.             builder.AddShort(item[i]);
  32.             builder.AddThree(1);
  33.             builder.AddChar(this->player->character->weight);
  34.             builder.AddChar(this->player->character->maxweight);
  35.             from->player->client->SendBuilder(builder);
  36.         //the reason break is here, is so people wont get like 5 items from one kill.
  37.         break;
  38.  
  39.  
  40.     }  
  41.    
  42.    
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement