本文整理汇总了C#中Packet.GetLong方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.GetLong方法的具体用法?C# Packet.GetLong怎么用?C# Packet.GetLong使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.GetLong方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Prepare
/// <summary>
/// Prepares skill, specifying the ingredients.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
/// <returns></returns>
public bool Prepare(Creature creature, Skill skill, Packet packet)
{
var ingredients = new List<Ingredient>();
var unkByte = packet.GetByte();
var method = packet.GetString();
var propEntityId = packet.GetLong();
var unkInt1 = packet.GetInt();
var count = packet.GetInt();
for (int i = 0; i < count; ++i)
{
var itemEntityId = packet.GetLong();
var amount = packet.GetFloat();
// Check item
var item = creature.Inventory.GetItem(itemEntityId);
if (item == null)
{
Log.Warning("Cooking.Prepare: Creature '{0:X16}' tried to use non-existent item.", creature.EntityId);
return false;
}
ingredients.Add(new Ingredient(item, amount));
}
// Check tools
if (!this.CheckTools(creature, method))
return false;
// Check rank
if (!this.CheckRank(creature, method, skill.Info.Rank))
return false;
// Check prop
if (!this.CheckProp(creature, method, propEntityId))
return false;
// Save information
creature.Temp.CookingIngredients = ingredients;
creature.Temp.CookingMethod = method;
// Update tools
// Item dura
// Item exp
// Item dura
Send.SkillUse(creature, skill.Info.Id, this.GetTime(method));
skill.State = SkillState.Used;
Send.Effect(creature, Effect.Cooking, (byte)1, method);
return true;
}
示例2: Use
/// <summary>
/// Uses skill, the actual usage is in Complete.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var location = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
var areaPosition = new Position(location);
// Check range
if (!creature.GetPosition().InRange(areaPosition, Range))
{
this.Cancel(creature, skill);
Send.SkillUseSilentCancel(creature);
Send.Notice(creature, Localization.Get("Out of range."));
return;
}
// Reduce Dice
if (creature.Inventory.RightHand != null)
creature.Inventory.Decrement(creature.Inventory.RightHand);
var number = (byte)(RandomProvider.Get().Next(6));
Send.UseMotion(creature, 27, 2, false, false);
Send.Effect(creature, Effect.Dice, 0, "process", location, number); // [200200, NA233 (2016-08-12)] New 0 int after effect id
Send.SkillUse(creature, skill.Info.Id, location, unkInt1, unkInt2);
skill.Stacks = 0;
}
示例3: Use
/// <summary>
/// Uses skill, the actual usage is in Complete.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var location = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
var areaPosition = new Position(location);
// Check range
if (!creature.GetPosition().InRange(areaPosition, Range))
{
this.Cancel(creature, skill);
Send.SkillUseSilentCancel(creature);
Send.Notice(creature, Localization.Get("Out of range."));
return;
}
// Reduce Dice
if (creature.Inventory.RightHand != null)
creature.Inventory.Decrement(creature.Inventory.RightHand);
Send.UseMotion(creature, 27, 2, false, false);
Send.Effect(creature, Effect.Dice, "process", location, (byte)3);
Send.SkillUse(creature, skill.Info.Id, location, unkInt1, unkInt2);
skill.Stacks = 0;
}
示例4: Use
/// <summary>
/// Handles using the skill with the information from the packet.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var targetAreaId = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
Use(creature, skill, targetAreaId, unkInt1, unkInt2);
}
示例5: Use
/// <summary>
/// Uses skill on target.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var entityId = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
// Get creature
var target = creature.Region.GetCreature(entityId);
if (target == null)
goto L_End;
// Check range
if (!creature.GetPosition().InRange(target.GetPosition(), Range))
{
Send.Notice(creature, Localization.Get("Not in range.")); // Unofficial
goto L_End;
}
// TODO: Check target validity once we have skill target support
// Calculate heal amount
var rnd = RandomProvider.Get();
var healAmount = rnd.Next((int)skill.RankData.Var1, (int)skill.RankData.Var3 + 1);
// Add magic attack bonus
healAmount += (int)(creature.MagicAttack / 10);
// Add wand bonus
if (creature.RightHand != null && creature.RightHand.HasTag("/healing_wand/"))
healAmount += 5;
// Reduce user's stamina if target is the user
if (target == creature && target.Life < target.LifeInjured)
{
creature.Stamina -= healAmount;
Send.StatUpdate(creature, StatUpdateType.Private, Stat.Stamina, Stat.Hunger, Stat.StaminaMax);
}
// Skill training
// Call before heal to calculate if in distress
this.OnUseSkillOnTarget(creature, target);
ChannelServer.Instance.Events.OnPlayerHealsCreature(creature, target, skill);
// Heal target
target.Life += healAmount;
Send.StatUpdateDefault(target);
Send.Effect(target, Effect.HealLife, healAmount);
// Reduce stacks
skill.Stacks--;
L_End:
Send.Effect(creature, Effect.StackUpdate, "healing_stack", (byte)skill.Stacks, (byte)0);
Send.Effect(creature, Effect.UseMagic, "healing", entityId);
Send.SkillUse(creature, skill.Info.Id, entityId, unkInt1, unkInt2);
}
示例6: Prepare
/// <summary>
/// Prepares skill.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
/// <returns></returns>
public bool Prepare(Creature creature, Skill skill, Packet packet)
{
var itemEntityId = packet.GetLong();
var enchantEntityId = packet.GetLong();
// Get items
var item = creature.Inventory.GetItem(itemEntityId);
if (item == null)
{
Log.Warning("HiddenEnchant.Prepare: Creature '{0:X16}' tried to enchant non-existing item.");
return false;
}
var enchant = creature.Inventory.GetItem(enchantEntityId);
if (enchant == null)
{
Log.Warning("HiddenEnchant.Prepare: Creature '{0:X16}' tried to enchant with non-existing enchant item.");
return false;
}
// Only elementals supported for now
if (enchant.HasTag("/elemental/"))
{
}
else
{
Send.ServerMessage(creature, Localization.Get("Enchanting hasn't been implemented yet."));
return false;
}
creature.Temp.SkillItem1 = item;
creature.Temp.SkillItem2 = enchant;
Send.Echo(creature, Op.SkillUse, packet);
skill.State = SkillState.Used;
return true;
}
示例7: RebirthEventInfoRequest
private void RebirthEventInfoRequest(ChannelClient client, Packet packet)
{
var entityId = packet.GetLong();
var creature = client.GetCreatureSafe(packet.Id);
if (!IsEventActive("new_rebirth_event"))
{
Send.MsgBox(creature, L("The event is over."));
return;
}
if (creature.Vars.Perm[StartPlayTimeVar] == null)
return;
SendRebirthEventInfo(creature);
}
示例8: Use
/// <summary>
/// Starts fishing at target location.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var targetPositionId = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
var pos = new Position(targetPositionId);
creature.Temp.FishingProp = new Prop(274, creature.RegionId, pos.X, pos.Y, 1, 1, 0, "empty");
creature.Region.AddProp(creature.Temp.FishingProp);
creature.TurnTo(pos);
Send.Effect(creature, Effect.Fishing, (byte)FishingEffectType.Cast, true);
Send.SkillUse(creature, skill.Info.Id, targetPositionId, unkInt1, unkInt2);
this.StartFishing(creature, 1000);
}
示例9: PacketReading
public void PacketReading()
{
var testPacket = GetTestPacket();
// Read from packet
var buffer = testPacket.Build();
var packet = new Packet(buffer, 0);
Assert.Equal(0x01234567, packet.Op);
Assert.Equal(0x0123456789101112, packet.Id);
Assert.Equal(byte.MaxValue / 2, packet.GetByte());
Assert.Equal(short.MaxValue / 2, packet.GetShort());
Assert.Equal(ushort.MaxValue / 2, packet.GetUShort());
Assert.Equal(int.MaxValue / 2, packet.GetInt());
Assert.Equal(uint.MaxValue / 2, packet.GetUInt());
Assert.Equal(long.MaxValue / 2, packet.GetLong());
Assert.Equal(ulong.MaxValue / 2, packet.GetULong());
Assert.Equal(float.MaxValue / 2, packet.GetFloat());
Assert.Equal("foobar^2", packet.GetString());
Assert.Equal(new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, packet.GetBin());
Assert.Equal(PacketElementType.None, packet.Peek());
// Read from offset packet
var buffer2 = new byte[3 + testPacket.GetSize()];
buffer2[0] = 2;
buffer2[1] = 3;
buffer2[2] = 1;
testPacket.Build(ref buffer2, 3);
var packet2 = new Packet(buffer2, 3);
Assert.Equal(0x01234567, packet2.Op);
Assert.Equal(0x0123456789101112, packet2.Id);
Assert.Equal(byte.MaxValue / 2, packet2.GetByte());
Assert.Equal(short.MaxValue / 2, packet2.GetShort());
Assert.Equal(ushort.MaxValue / 2, packet2.GetUShort());
Assert.Equal(int.MaxValue / 2, packet2.GetInt());
Assert.Equal(uint.MaxValue / 2, packet2.GetUInt());
Assert.Equal(long.MaxValue / 2, packet2.GetLong());
Assert.Equal(ulong.MaxValue / 2, packet2.GetULong());
Assert.Equal(float.MaxValue / 2, packet2.GetFloat());
Assert.Equal("foobar^2", packet2.GetString());
Assert.Equal(new byte[] { 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 }, packet2.GetBin());
Assert.Equal(PacketElementType.None, packet.Peek());
}
示例10: Complete
/// <summary>
/// Completes skill, healing the target.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Complete(Creature creature, Skill skill, Packet packet)
{
var entityId = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
// Get target
var target = ChannelServer.Instance.World.GetCreature(entityId);
if (target == null)
{
Send.Notice(creature, Localization.Get("Invalid target."));
goto L_End;
}
// Check range
if (!creature.GetPosition().InRange(target.GetPosition(), Range))
{
Send.Notice(creature, Localization.Get("Out of range."));
goto L_End;
}
// Check bandage, make sure he still has the item and that
// it wasn't switched with something else somehow.
if (creature.Temp.SkillItem1 == null || !creature.Temp.SkillItem1.HasTag("/bandage/") || !creature.Inventory.Has(creature.Temp.SkillItem1))
{
Log.Warning("FirstAid.Complete: Creature '{0:X16}' apparently switched the skill item somehow, between Ready and Complete.", creature.EntityId);
Send.Notice(creature, Localization.Get("Invalid bandage."));
goto L_End;
}
// Remove bandage
if (!creature.Inventory.Decrement(creature.Temp.SkillItem1))
{
Log.Error("FirstAid.Complete: Decrementing the skill item failed somehow.");
Send.Notice(creature, Localization.Get("Unknown error."));
goto L_End;
}
// Fails if target is moving.
if (target.IsMoving)
{
// Unofficial
Send.Notice(creature, Localization.Get("Failed because target was moving."));
// Fail motion?
goto L_End;
}
// Heal injuries
var rnd = RandomProvider.Get();
var heal = rnd.Next((int)skill.RankData.Var1, (int)skill.RankData.Var2 + 1);
// Add bonus from higher grade bandages
if (creature.Temp.SkillItem1.HasTag("/common_grade/"))
heal += 3;
else if (creature.Temp.SkillItem1.HasTag("/high_grade/"))
heal += 6;
else if (creature.Temp.SkillItem1.HasTag("/highest_grade/"))
heal += 10;
// 50% efficiency if target isn't resting
if (!target.Has(CreatureStates.SitDown))
heal /= 2;
target.Injuries -= heal;
Send.StatUpdateDefault(target);
// Skill training
if (skill.Info.Rank == SkillRank.Novice)
skill.Train(1); // Use First Aid.
// First Aid animation
Send.Effect(creature, Effect.UseMagic, "healing_firstaid", entityId);
L_End:
Send.SkillComplete(creature, skill.Info.Id, entityId, unkInt1, unkInt2);
}
示例11: Use
/// <summary>
/// Uses skill, the actual usage is in Complete.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var entityId = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
creature.StopMove();
// Do checks in Complete.
Send.SkillUse(creature, skill.Info.Id, entityId, unkInt1, unkInt2);
}
示例12: Use
/// <summary>
/// Uses skill, checking if the campfire can be built at the given
/// position.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Use(Creature creature, Skill skill, Packet packet)
{
var positionId = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
// Check location
var validLocation = IsValidRegion(creature.Region) && IsValidPosition(creature, new Position(positionId));
if (!validLocation)
{
Send.Notice(creature, Localization.Get("It's a little cramped here to make a Campfire."));
creature.Skills.CancelActiveSkill();
Send.SkillUseSilentCancel(creature);
return;
}
Send.SkillUse(creature, skill.Info.Id, positionId, unkInt1, unkInt2);
}
示例13: Complete
/// <summary>
/// Completes skill
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Complete(Creature creature, Skill skill, Packet packet)
{
var location = packet.GetLong();
var unkInt1 = packet.GetInt();
var unkInt2 = packet.GetInt();
Send.SkillComplete(creature, skill.Info.Id, location, unkInt1, unkInt2);
}
示例14: Prepare
/// <summary>
/// Starts production, finished in Complete.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
/// <returns></returns>
/// <example>
/// 001 [............271D] Short : 10013
/// 002 [..............02] Byte : 2
/// 003 [........00000006] Int : 6
/// 004 [............0001] Short : 1
/// 005 [............0006] Short : 6
/// 006 [............0001] Short : 1
/// 007 [..............01] Byte : 1
/// 008 [005000CC7F17E280] Long : 22518876442452608
/// 009 [............0003] Short : 3
///
/// 001 [............271B] Short : 10011
/// 002 [..............01] Byte : 1
/// 003 [00A188D000050041] Long : 45467898185318465
/// 004 [........00000000] Int : 0
/// 005 [........00000002] Int : 2
/// 006 [............0001] Short : 1
/// 007 [............0001] Short : 1
/// 008 [............0002] Short : 2
/// 009 [..............01] Byte : 1
/// 010 [005000CC80BA58CD] Long : 22518876469876941
/// 011 [............000A] Short : 10
/// </example>
public bool Prepare(Creature creature, Skill skill, Packet packet)
{
var unkByte = packet.GetByte();
var propEntityId = 0L;
var unkInt = 0;
if (packet.Peek() == PacketElementType.Long) // Rule unknown
{
propEntityId = packet.GetLong();
unkInt = packet.GetInt();
}
var productId = packet.GetInt();
var unkShort1 = packet.GetShort();
var category = (ProductionCategory)packet.GetShort();
var amountToProduce = packet.GetShort();
var count = packet.GetByte();
var materials = new List<ProductionMaterial>(count);
for (int i = 0; i < count; ++i)
{
var entityId = packet.GetLong();
var amount = packet.GetShort();
// Check item
var item = creature.Inventory.GetItem(entityId);
if (item == null)
{
Log.Warning("ProductionSkill.Prepare: Creature '{0:X16}' tried to use non-existent item as material.", creature.EntityId);
return false;
}
materials.Add(new ProductionMaterial(item, amount));
}
// Get product data
var potentialProducts = AuraData.ProductionDb.Find(category, productId);
if (potentialProducts.Length == 0)
{
Send.ServerMessage(creature, "Unknown product.");
return false;
}
var productData = potentialProducts[0];
// Check tools
if (!this.CheckTools(creature, skill, productData))
return false;
// Check prop
if (!this.CheckProp(creature, propEntityId))
return false;
// Check mana
if (!this.CheckMana(creature, productData))
return false;
// Give skills the ability to use motions and other things.
this.OnUse(creature, skill);
// Response
Send.Echo(creature, Op.SkillUse, packet);
skill.State = SkillState.Used;
return true;
}
示例15: Complete
/// <summary>
/// Completes production.
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
public void Complete(Creature creature, Skill skill, Packet packet)
{
var unkByte = packet.GetByte();
var propEntityId = 0L;
var unkInt = 0;
if (packet.Peek() == PacketElementType.Long) // Rule unknown
{
propEntityId = packet.GetLong();
unkInt = packet.GetInt();
}
var productId = packet.GetInt();
var unkShort = packet.GetShort();
var category = (ProductionCategory)packet.GetShort();
var amountToProduce = packet.GetShort();
var count = packet.GetByte();
var materials = new List<ProductionMaterial>(count);
for (int i = 0; i < count; ++i)
{
var entityId = packet.GetLong();
var amount = packet.GetShort();
// Check item
var item = creature.Inventory.GetItem(entityId);
if (item == null)
{
Log.Warning("ProductionSkill.Prepare: Creature '{0:X16}' tried to use non-existent item as material.", creature.EntityId);
return;
}
materials.Add(new ProductionMaterial(item, amount));
}
// Check prop
if (!this.CheckProp(creature, propEntityId))
goto L_Fail;
// Check category
if (!this.CheckCategory(creature, category))
{
Log.Warning("ProductionSkill.Complete: Creature '{0:X16}' tried to use category '{1}' with skill '{2}'.", creature.EntityId, category, this.GetType().Name);
goto L_Fail;
}
// Get potential products
// Some productions can produce items of varying quality (cheap,
// common, fine, finest)
var potentialProducts = AuraData.ProductionDb.Find(category, productId);
if (potentialProducts.Length == 0)
{
Send.ServerMessage(creature, "Unknown product.");
goto L_Fail;
}
// Get reference product for checks and mats
var productData = potentialProducts[0];
// Check tools
if (!this.CheckTools(creature, skill, productData))
goto L_Fail;
// Check mana
if (!this.CheckMana(creature, productData))
goto L_Fail;
if (productData.Mana > 0)
{
creature.Mana -= productData.Mana;
Send.StatUpdate(creature, StatUpdateType.Private, Stat.Mana);
}
// Check materials
var requiredMaterials = productData.GetMaterialList();
var toReduce = new List<ProductionMaterial>();
var inUse = new HashSet<long>();
foreach (var reqMat in requiredMaterials)
{
// Check all selected items for tag matches
foreach (var material in materials)
{
// Check item and stack item for tag, pouches can be put
// into the window, reducing the contained items.
var match =
material.Item.HasTag(reqMat.Tag) ||
(material.Item.IsGatheringPouch && material.Item.Data.StackItem != null && material.Item.Data.StackItem.HasTag(reqMat.Tag));
// Satisfy requirement with item, up to the max amount
// needed or available
if (match)
{
// Cancel if one item matches multiple materials.
// It's unknown how this would be handled, can it even
// happen? Can one item maybe only be used as one material?
if (inUse.Contains(material.Item.EntityId))
{
//.........这里部分代码省略.........