本文整理汇总了C#中Packet.GetInt方法的典型用法代码示例。如果您正苦于以下问题:C# Packet.GetInt方法的具体用法?C# Packet.GetInt怎么用?C# Packet.GetInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Packet
的用法示例。
在下文中一共展示了Packet.GetInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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;
}
示例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);
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;
}
示例3: 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);
}
示例4: _handleBankReply
private void _handleBankReply(Packet pkt)
{
int characterGold = pkt.GetInt();
int bankAmount = pkt.GetInt();
if(OnBankChange != null)
OnBankChange(characterGold, bankAmount);
}
示例5: 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;
}
示例6: ItemUseData
internal ItemUseData(Packet pkt)
{
type = (ItemType)pkt.GetChar();
itemID = pkt.GetShort();
characterAmount = pkt.GetInt();
weight = pkt.GetChar();
maxWeight = pkt.GetChar();
hpGain = hp = tp = 0;
hairColor = 0;
effect = 0;
curecurse_stats = null;
expreward_stats = null;
//format differs based on item type
//(keeping this in order with how eoserv ITEM_USE handler is ordered
switch (type)
{
case ItemType.Teleport: /*Warp packet handles the rest!*/ break;
case ItemType.Heal:
{
hpGain = pkt.GetInt();
hp = pkt.GetShort();
tp = pkt.GetShort();
}
break;
case ItemType.HairDye:
{
hairColor = pkt.GetChar();
}
break;
case ItemType.Beer: /*No additional data*/ break;
case ItemType.EffectPotion:
{
effect = pkt.GetShort();
}
break;
case ItemType.CureCurse:
{
curecurse_stats = new CureCurseStats(pkt);
}
break;
case ItemType.EXPReward:
{
//note: server packets may be incorrect at this point (src/handlers/Item.cpp) because of unused builder in eoserv
//note: server also sends an ITEM_ACCEPT packet to surrounding players on level-up?
expreward_stats = new LevelUpStats(pkt, true);
}
break;
}
}
示例7: 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);
}
示例8: _handleBankOpen
private void _handleBankOpen(Packet pkt)
{
int bankGold = pkt.GetInt();
pkt.Skip(3); /*Session token - eoserv always sets 0*/
int lockerUpgrades = pkt.GetChar(); //number of locker upgrades that have been done
if (OnBankOpen != null)
OnBankOpen(bankGold, lockerUpgrades);
}
示例9: 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);
}
示例10: LevelUpStats
internal LevelUpStats(Packet pkt, bool includeExp)
{
//includeExp will be false when leveling up from NPC, true from EXPReward
//NPC handler happens slightly differently
exp = includeExp ? pkt.GetInt() : 0;
level = pkt.GetChar();
stat = pkt.GetShort();
skill = pkt.GetShort();
maxhp = pkt.GetShort();
maxtp = pkt.GetShort();
maxsp = pkt.GetShort();
}
示例11: HandleDrop
public static void HandleDrop(Packet packet, IClient client, bool fromQueue)
{
short id = packet.GetShort();
int amount = (packet.Length == 10 ? packet.GetThree() : packet.GetInt());
byte x = packet.GetChar();
byte y = packet.GetChar();
if (x == 254 && y == 254)
{
x = client.Character.X;
y = client.Character.Y;
}
client.Character.DropItem(id, amount, x, y);
}
示例12: Prepare
/// <summary>
/// Prepares skill (effectively does nothing)
/// </summary>
/// <param name="creature"></param>
/// <param name="skill"></param>
/// <param name="packet"></param>
/// <returns></returns>
public bool Prepare(Creature creature, Skill skill, Packet packet)
{
if (skill.Info.Id == SkillId.Campfire)
{
var itemId = packet.GetInt();
Send.SkillPrepare(creature, skill.Info.Id, itemId);
}
else
{
var dict = packet.GetString();
Send.SkillPrepare(creature, skill.Info.Id, dict);
}
return true;
}
示例13: 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());
}
示例14: Skill
internal Skill(Packet pkt)
{
m_id = pkt.GetShort();
m_levelReq = pkt.GetChar();
m_classReq = pkt.GetChar();
m_goldCost = pkt.GetInt();
m_skillReq = new[]
{
pkt.GetShort(),
pkt.GetShort(),
pkt.GetShort(),
pkt.GetShort()
};
m_strReq = pkt.GetShort();
m_intReq = pkt.GetShort();
m_wisReq = pkt.GetShort();
m_agiReq = pkt.GetShort();
m_conReq = pkt.GetShort();
m_chaReq = pkt.GetShort();
}
示例15: _handleItemJunk
private void _handleItemJunk(Packet pkt)
{
short id = pkt.GetShort();
int amountRemoved = pkt.GetThree();//don't really care - just math it
int amountRemaining = pkt.GetInt();
byte weight = pkt.GetChar();
byte maxWeight = pkt.GetChar();
if (OnJunkItem != null)
OnJunkItem(id, amountRemoved, amountRemaining, weight, maxWeight);
}