stoneharry

Untitled

Aug 1st, 2013
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.05 KB | None | 0 0
  1.  
  2.         static int MirrorImagePlayer(lua_State* L, Unit* ptr)
  3.         {
  4.             TEST_UNIT();
  5.  
  6.             Player* plr = CHECK_PLAYER(L, 1);
  7.  
  8.             if (!plr)
  9.                 return 0;
  10.  
  11.             static uint32 RaceDisplayMap[P_NUM_RACES * 2 + 2] =
  12.             {
  13.                 0U, 0U, 49U, 50U, 51U, 52U, 53U, 54U, 55U, 56U, 57U, 58U, 59U,
  14.                 60U, 1563U, 1564U, 1478U, 1479U, 6894U, 6895U, 15476U, 15475U,
  15.                 16125U, 16126U, 16981U, 16980U, 17402U, 17403U, 17576U,
  16.                 17577U, 17578U, 17579U, 21685U, 21686U, 21780U,21780U,21963U,
  17.                 21964U, 26316U, 26317U, 26871U, 26872U, 26873U, 26874U
  18.             }; // maps the race index/gender in the DB to the actual display ID
  19.  
  20.             ptr->SetDisplayId( RaceDisplayMap[(plr->getRace() << 1) | plr->getGender()] );
  21.             ptr->setRace(plr->getRace());
  22.             ptr->setGender(plr->getGender());
  23.  
  24.             ptr->SetUInt32Value(UNIT_FIELD_FLAGS_2, ptr->GetUInt32Value(UNIT_FIELD_FLAGS_2) | UNIT_FLAG2_MIRROR_IMAGE);
  25.  
  26.             WorldPacket data(SMSG_MIRRORIMAGE_DATA, 68);
  27.  
  28.             data << uint64(ptr->GetGUID());
  29.             data << uint32(plr->GetDisplayId());
  30.             data << uint8(plr->getRace());
  31.             data << uint8(plr->getGender());
  32.             data << uint8(plr->getClass());
  33.  
  34.             // facial features, like big nose, piercings, bonehead, etc
  35.             data << uint8(plr->GetByte(PLAYER_BYTES, 0));   // skin color
  36.             data << uint8(plr->GetByte(PLAYER_BYTES, 1));   // face
  37.             data << uint8(plr->GetByte(PLAYER_BYTES, 2));   // hair style
  38.             data << uint8(plr->GetByte(PLAYER_BYTES, 3));   // hair color
  39.             data << uint8(plr->GetByte(PLAYER_BYTES_2, 0)); // facial hair
  40.  
  41.             if(plr->IsInGuild())
  42.                 data << uint32(plr->GetGuildId());
  43.             else
  44.                 data << uint32(0);
  45.  
  46.             static const uint32 imageitemslots[] =
  47.             {
  48.                 EQUIPMENT_SLOT_HEAD,
  49.                 EQUIPMENT_SLOT_SHOULDERS,
  50.                 EQUIPMENT_SLOT_BODY,
  51.                 EQUIPMENT_SLOT_CHEST,
  52.                 EQUIPMENT_SLOT_WAIST,
  53.                 EQUIPMENT_SLOT_LEGS,
  54.                 EQUIPMENT_SLOT_FEET,
  55.                 EQUIPMENT_SLOT_WRISTS,
  56.                 EQUIPMENT_SLOT_HANDS,
  57.                 EQUIPMENT_SLOT_BACK,
  58.                 EQUIPMENT_SLOT_TABARD
  59.             };
  60.  
  61.             for(uint32 i = 0; i < 11; ++i)
  62.             {
  63.                 Item* item = plr->GetItemInterface()->GetInventoryItem(static_cast < int16 > (imageitemslots[i]));
  64.                 if(i == EQUIPMENT_SLOT_HEAD && plr->HasFlag(PLAYER_FLAGS, CMSG_TOGGLE_HELM))
  65.                     item = NULL;
  66.                 if(i == EQUIPMENT_SLOT_BACK && plr->HasFlag(PLAYER_FLAGS, CMSG_TOGGLE_CLOAK))
  67.                     item = NULL;
  68.                 if(item != NULL)
  69.                     data << uint32(item->GetProto()->DisplayInfoID);
  70.                 else
  71.                     data << uint32(0);
  72.             }
  73.  
  74.             Item* item = plr->GetItemInterface()->GetInventoryItem(static_cast < int16 >(EQUIPMENT_SLOT_MAINHAND));
  75.             if (item != NULL)
  76.                 ptr->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, item->GetProto()->DisplayInfoID);
  77.             item = plr->GetItemInterface()->GetInventoryItem(static_cast < int16 >(EQUIPMENT_SLOT_OFFHAND));
  78.             if (item != NULL)
  79.                 ptr->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0x1, item->GetProto()->DisplayInfoID);
  80.             item = plr->GetItemInterface()->GetInventoryItem(static_cast < int16 >(EQUIPMENT_SLOT_RANGED));
  81.             if (item != NULL)
  82.                 ptr->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 0x2, item->GetProto()->DisplayInfoID);
  83.  
  84.             ptr->SendPacket(&data);
  85.  
  86.             return 0;
  87.         }
Advertisement
Add Comment
Please, Sign In to add comment