Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Project_Terror.Role
{
public class Achievement : ServerSocket.Packet
{
public const ushort
Place_a_piece_of_furniture_in_your_house = 0,
House_L1 = 1,
House_L2 = 2,
House_L3 = 3,
House_L4 = 4,
Have_at_least_3_million_silver_on_hand = 5,
EquipMount = 6,
EquipLevler12Mount = 7,
VirtuteforMeteor = 9,
BreedANewMount = 11,
DyeYouHaire = 12,
ChangeYouHaireStyle = 13,
Change_the_color_of_your_clothes = 14,
ChangeYouAvatar = 15,
UsedTheGuildPortal = 16,
Receive_a_treasure_from_the_Lottery = 17,
SummonGuard = 18,
Answer_at_least_5_questions_correctly_in_the_Quiz_Show = 19,
DanceInMarket = 20,
House_L5 = 21,
AddFriend = 22;
private Role.IMapObj Object;
private CMD.BitVector BitVector32;
public Achievement(Role.IMapObj _obj)
: base(76, true)
{
Object = _obj;
WriteUshort(68, 0);
WriteUshort((ushort)CMD.GamePackets.Achievement, 2);
WriteUint(Object.UID, 8);
BitVector32 = new CMD.BitVector(32 * 13);
WriteUint(13, 12);//count int[]
}
public void AddFlag(int flag)
{
BitVector32.Add(flag);
ShowScreen(flag);
Send();
}
public void Send()
{
for (byte x = 0; x < BitVector32.bits.Length; x++)
WriteUint(BitVector32.bits[x], (ushort)(16 + 4 * x));
Object.Enqueue(this.ToArray());
}
private void ShowScreen(int flag)
{
uint FRAG_ID = (uint)(10100 + (uint)(100 * (byte)(flag / 32)) + (byte)(flag % 32) + 1);
using (ServerSocket.Packet send_me = new ServerSocket.Packet(28, true))
{
send_me.WriteUshort(20, 0);
send_me.WriteUshort((ushort)CMD.GamePackets.Achievement, 2);
send_me.WriteUshort(2, 4);//type
send_me.WriteUint(Object.UID, 8);
send_me.WriteUint(FRAG_ID, 12);
Object.Enqueue(send_me.ToArray());
}
}
public override string ToString()
{
string line = "";
foreach (uint bits in BitVector32.bits)
line += bits.ToString() + "#";
return line;
}
public byte[] ViewOpen()
{
byte[] packet = ToArray().ToArray();
packet[4] = 1;
return packet;
}
public void Load(string bas_line)
{
if (bas_line.Length == 0) return;
string[] line = bas_line.Split('#');
for(byte x =0; x< 13; x++)
BitVector32.bits[x] = uint.Parse(line[x]);
}
}
}
Code:
public class BitVector
{
public uint[] bits;
public int Size { get { return 32 * bits.Length; } }
public BitVector(int BitCount)
{
int sections = BitCount / 32;
bits = new uint[sections];
}
public void Add(int index)
{
int idx = index / 32;
uint bites = (uint)(1 << (index % 32));
bits[idx] |= bites;
}
public void Remove(int index)
{
int idx = index / 32;
uint bites = (uint)(1 << (index % 32));
bits[idx] &= ~bites;
}
public bool Contain(int index)
{
int idx = index / 32;
uint bites = (uint)(1 << (index % 32));
return ((bits[idx] & bites) == bites);
}
}
In packethandler, with id 1136
change them for your source
Code:
public class Achievement
{
public void Execute(Client.IClient client, ServerSocket.Packet packet)
{
switch (packet.ToArray()[4])
{
case 1:
{
Client.GameClient obj;
if (CMD.Src.Online.TryGetValue(packet.ReadUint(8), out obj))
{
client.Enqueue(obj.Player.MyAchievement.ViewOpen());
}
break;
}
}
}
}






