本文整理汇总了C#中Packet.AddInt方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.AddInt方法的具体用法?C# Packet.AddInt怎么用?C# Packet.AddInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.AddInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BankWithdraw
public bool BankWithdraw(int amount)
{
if (!m_client.ConnectedAndInitialized || !Initialized || amount < 0)
return false;
Packet pkt = new Packet(PacketFamily.Bank, PacketAction.Take);
pkt.AddInt(amount);
return m_client.SendPacket(pkt);
}
示例2: TradeAddItem
/// <summary>
/// Add an item to a pending trade offer
/// </summary>
/// <param name="itemID">Item ID of the item to add</param>
/// <param name="amount">Amount of the item to add</param>
public bool TradeAddItem(short itemID, int amount)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Trade, PacketAction.Add);
pkt.AddShort(itemID);
pkt.AddInt(amount);
return m_client.SendPacket(pkt);
}
示例3: BuyItem
/// <summary>
/// Buy an item from a shopkeeper
/// </summary>
public bool BuyItem(short ItemID, int amount)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Shop, PacketAction.Buy);
pkt.AddShort(ItemID);
pkt.AddInt(amount);
return m_client.SendPacket(pkt);
}
示例4: ResetCharacterStatSkill
public bool ResetCharacterStatSkill()
{
Packet pkt = new Packet(PacketFamily.StatSkill, PacketAction.Junk);
pkt.AddInt(1234); //shop ID, ignored by eoserv - eomain may require this to be correct
return !m_client.ConnectedAndInitialized || !Initialized || m_client.SendPacket(pkt);
}
示例5: ForgetSpell
public bool ForgetSpell(short spellID)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.StatSkill, PacketAction.Remove);
pkt.AddInt(1234); //shop ID, ignored by eoserv - eomain may require this to be correct
pkt.AddShort(spellID);
return m_client.SendPacket(pkt);
}
示例6: HandleMessage
public static void HandleMessage(Packet packet, IClient client, bool fromQueue)
{
Packet reply = new Packet(PacketFamily.Welcome, PacketAction.Reply);
client.EnterGame();
client.Character.Map.Enter(client.Character, WarpAnimation.Admin);
reply.AddShort((short)WelcomeReply.WorldInfo);
reply.AddBreak();
for (int i = 0; i < 9; ++i)
{
reply.AddBreakString("A");
}
reply.AddChar(client.Character.Weight); // Weight
reply.AddChar(client.Character.MaxWeight); // Max Weight
// Inventory
foreach (ItemStack item in client.Character.Items)
{
reply.AddShort(item.Id);
reply.AddInt(item.Amount);
}
reply.AddBreak();
// Spells
reply.AddBreak();
IEnumerable<Character> characters = client.Character.GetInRange<Character>();
IEnumerable<NPC> npcs = client.Character.GetInRange<NPC>();
IEnumerable<MapItem> items = client.Character.GetInRange<MapItem>();
reply.AddChar((byte)characters.Count());
reply.AddBreak();
// Characters
// {
foreach (Character character in characters)
{
character.InfoBuilder(ref reply);
reply.AddBreak();
}
// }
// NPCs
foreach (NPC npc in npcs)
{
npc.InfoBuilder(ref reply);
}
reply.AddBreak();
// Items
foreach (MapItem item in items)
{
item.InfoBuilder(ref reply);
}
client.Send(reply);
}
示例7: HandleRequest
public static void HandleRequest(Packet packet, IClient client, bool fromQueue)
{
int id = packet.GetInt();
if (id < 0 || id > client.Account.Characters.Count)
throw new ArgumentOutOfRangeException("Login character ID out of range");
client.SelectCharacter(client.Account.Characters[id]);
Packet reply = new Packet(PacketFamily.Welcome, PacketAction.Reply);
reply.AddShort((short)WelcomeReply.CharacterInfo);
reply.AddShort((short)client.Id);
reply.AddInt(id);
reply.AddShort((short)client.Character.Map.Data.Id);
reply.AddBytes(client.Character.Map.Data.RevisionID);
reply.AddThree((int)client.Character.Map.Data.PubFileLength);
reply.AddBytes(client.Server.ItemData.revisionId);
reply.AddShort((short)client.Server.ItemData.Count);
reply.AddBytes(client.Server.NpcData.revisionId);
reply.AddShort((short)client.Server.NpcData.Count);
reply.AddBytes(client.Server.SpellData.revisionId);
reply.AddShort((short)client.Server.SpellData.Count);
reply.AddBytes(client.Server.ClassData.revisionId);
reply.AddShort((short)client.Server.ClassData.Count);
reply.AddBreakString(client.Character.Name);
reply.AddBreakString(client.Character.Title ?? "");
reply.AddBreakString("Guild Name");
reply.AddBreakString("Guild Rank");
reply.AddChar(0); // Class
reply.AddString("TAG"); // Guild tag
reply.AddChar((byte)client.Character.Admin);
reply.AddChar(client.Character.Level); // Level
reply.AddInt(client.Character.Exp); // Exp
reply.AddInt(client.Character.Usage); // Usage
reply.AddShort(client.Character.Hp); // HP
reply.AddShort(client.Character.MaxHp); // MaxHP
reply.AddShort(client.Character.Tp); // TP
reply.AddShort(client.Character.MaxTp); // MaxTP
reply.AddShort(client.Character.MaxSp); // MaxSP
reply.AddShort(client.Character.StatPoints); // StatPts
reply.AddShort(client.Character.SkillPoints); // SkillPts
reply.AddShort(client.Character.Karma); // Karma
reply.AddShort(client.Character.MinDamage); // MinDam
reply.AddShort(client.Character.MaxDamage); // MaxDam
reply.AddShort(client.Character.Accuracy); // Accuracy
reply.AddShort(client.Character.Evade); // Evade
reply.AddShort(client.Character.Defence); // Armor
reply.AddShort(client.Character.Strength); // Str
reply.AddShort(client.Character.Wisdom); // Wis
reply.AddShort(client.Character.Intelligence); // Int
reply.AddShort(client.Character.Agility); // Agi
reply.AddShort(client.Character.Constitution); // Con
reply.AddShort(client.Character.Charisma); // Cha
// Inventory
reply.AddBreak();
reply.AddChar(1); // Guild Rank
reply.AddShort(2); // Jail map
reply.AddShort(4); // ?
reply.AddChar(24); // ?
reply.AddChar(24); // ?
reply.AddShort(10); // ?
reply.AddShort(10); // ?
reply.AddShort(0); // Admin command flood rate
reply.AddShort(2); // ?
reply.AddChar(0); // Login warning message
reply.AddBreak();
client.Send(reply);
}
示例8: CharacterTake
public bool CharacterTake(int id, out int takeID)
{
takeID = -1;
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet builder = new Packet(PacketFamily.Character, PacketAction.Take);
builder.AddInt(id);
if (!m_client.SendPacket(builder) || !m_character_responseEvent.WaitOne(Constants.ResponseTimeout))
return false;
takeID = m_character_takeID;
return true;
}
示例9: CharacterRemove
public bool CharacterRemove(int id, out CharacterRenderData[] data)
{
data = null;
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet builder = new Packet(PacketFamily.Character, PacketAction.Remove);
builder.AddShort(255);
builder.AddInt(id);
if (!m_client.SendPacket(builder) || !m_character_responseEvent.WaitOne(Constants.ResponseTimeout))
return false;
if (m_character_reply != CharacterReply.Deleted || m_character_data == null)
return false;
data = m_character_data;
return true;
}
示例10: HandleCreate
public static void HandleCreate(Packet packet, IClient client, bool fromQueue)
{
short createId = packet.GetShort();
Gender gender = (Gender)packet.GetShort();
short hairStyle = packet.GetShort();
short hairColor = packet.GetShort();
Skin skin = (Skin)packet.GetShort();
packet.GetByte();
string name = packet.GetBreakString().ToLower();
if (!Enum.IsDefined(typeof(Gender), gender))
throw new ArgumentOutOfRangeException("Invalid gender on character creation (" + gender + ")");
// TODO: Make these configurable
if (hairStyle < 1 || hairStyle > 20
|| hairColor < 0 || hairColor > 9)
throw new ArgumentOutOfRangeException("Hair parameters out of range on character creation (" + hairStyle + ", " + hairColor + ")");
if (!Enum.IsDefined(typeof(Skin), skin))
throw new ArgumentOutOfRangeException("Invalid skin on character creation (" + skin + ")");
Packet reply = new Packet(PacketFamily.Character, PacketAction.Reply);
// TODO: Make this configurable
if (client.Account.Characters.Count >= 3)
{
reply.AddShort((short)CharacterReply.Full);
client.Send(reply);
return;
}
if (!Character.ValidName(name))
{
reply.AddShort((short)CharacterReply.NotApproved);
client.Send(reply);
return;
}
// TODO: Make a CharacterExists function
var checkCharacter = from Character c in client.Server.Database.Container
where c.name == name
select 1;
if (checkCharacter.Count() != 0)
{
reply.AddShort((short)CharacterReply.Exists);
client.Send(reply);
return;
}
Character newCharacter = new Character(client.Server, client, name, gender, (byte)hairStyle, (byte)hairColor, skin);
client.Account.Characters.Add(newCharacter);
newCharacter.Store();
client.Account.Store();
client.Server.Database.Commit();
reply.AddShort((short)CharacterReply.OK);
reply.AddChar((byte)client.Account.Characters.Count);
reply.AddByte(1); // TODO: What is this?
reply.AddBreak();
// TODO: Some kind of character list packet builder
int i = 0;
foreach (Character character in client.Account.Characters)
{
reply.AddBreakString(character.Name);
reply.AddInt(i++);
reply.AddChar(character.Level);
reply.AddChar((byte)character.Gender);
reply.AddChar(character.HairStyle);
reply.AddChar(character.HairColor);
reply.AddChar((byte)character.Skin);
reply.AddChar((byte)character.Admin);
reply.AddShort((short)(character.Boots != null ? character.Boots.Data.special1 : 0));
reply.AddShort((short)(character.Armor != null ? character.Armor.Data.special1 : 0));
reply.AddShort((short)(character.Hat != null ? character.Hat.Data.special1 : 0));
reply.AddShort((short)(character.Shield != null ? character.Shield.Data.special1 : 0));
reply.AddShort((short)(character.Weapon != null ? character.Weapon.Data.special1 : 0));
reply.AddBreak();
}
client.Send(reply);
}
示例11: DoCastSelfSpell
public bool DoCastSelfSpell(short spellID)
{
if (spellID < 0) return false;
if (!Initialized || !m_client.ConnectedAndInitialized) return false;
Packet pkt = new Packet(PacketFamily.Spell, PacketAction.TargetSelf);
pkt.AddChar(1); //target type
pkt.AddShort(spellID);
pkt.AddInt(DateTime.Now.ToEOTimeStamp());
return m_client.SendPacket(pkt);
}
示例12: WelcomeMessage
public bool WelcomeMessage(int id, out WelcomeMessageData data)
{
data = null;
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet builder = new Packet(PacketFamily.Welcome, PacketAction.Message);
builder.AddThree(0x00123456); //?
builder.AddInt(id);
if (!m_client.SendPacket(builder))
return false;
if (!m_welcome_responseEvent.WaitOne(Constants.ResponseTimeout))
return false;
data = m_welcome_messageData;
m_client.IsInGame = true;
return true;
}
示例13: SelectCharacter
/// <summary>
/// Select one of the 3 characters. Sends a WELCOME_REQUEST packet.
/// </summary>
/// <param name="id">id of the selected character</param>
/// <param name="data">returned data from the server</param>
/// <returns>true on successful transfer, false otherwise</returns>
public bool SelectCharacter(int id, out WelcomeRequestData data)
{
data = null;
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet builder = new Packet(PacketFamily.Welcome, PacketAction.Request);
builder.AddInt(id);
if (!m_client.SendPacket(builder))
return false;
if (!m_welcome_responseEvent.WaitOne(Constants.ResponseTimeout))
return false;
data = m_welcome_requestData;
return true;
}
示例14: HandleTake
public static void HandleTake(Packet packet, IClient client, bool fromQueue)
{
int id = packet.GetInt();
if (id < 0 || id > client.Account.Characters.Count)
throw new ArgumentOutOfRangeException("Login character ID out of range");
Packet reply = new Packet(PacketFamily.Character, PacketAction.Player);
reply.AddShort(1000); // Delete id // TODO: Generate a deletion id and check it
reply.AddInt(id);
client.Send(reply);
}
示例15: DropItem
//255 means use character's current location
public bool DropItem(short id, int amount, byte x = 255, byte y = 255)
{
if (!m_client.ConnectedAndInitialized || !Initialized)
return false;
Packet pkt = new Packet(PacketFamily.Item, PacketAction.Drop);
pkt.AddShort(id);
pkt.AddInt(amount);
if (x == 255 && y == 255)
{
pkt.AddByte(x);
pkt.AddByte(y);
}
else
{
pkt.AddChar(x);
pkt.AddChar(y);
}
return m_client.SendPacket(pkt);
}