public void Attack(EODirection direction, byte x = 255, byte y = 255) { if (State != CharacterActionState.Standing) { return; } if (this == World.Instance.MainPlayer.ActiveCharacter) { //KS protection - vanilla eoserv does not support this! bool shouldSend = true; if (!(x == 255 && y == 255)) { TileInfo ti = World.Instance.ActiveMapRenderer.GetTileInfo(x, y); if (ti.ReturnType == TileInfoReturnType.IsOtherNPC && ti.NPC.Opponent != null && ti.NPC.Opponent != this) { EOGame.Instance.Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_INFORMATION, DATCONST2.STATUS_LABEL_UNABLE_TO_ATTACK); shouldSend = false; } } if (shouldSend && !m_packetAPI.AttackUse(direction)) { EOGame.Instance.LostConnectionDialog(); } } else if (RenderData.facing != direction) { RenderData.SetDirection(direction); } State = CharacterActionState.Attacking; Stats.sp--; }
/// <summary> /// Used to apply changes from Welcome packet to existing character. /// </summary> /// <param name="newGuy">Changes to MainPlayer.ActiveCharacter, contained in a CharacterData object</param> /// <param name="copyPaperdoll">Set to true if paperdoll data from newGuy should be applied to this character</param> public void ApplyData(CharacterData newGuy, bool copyPaperdoll = true) { ID = newGuy.ID; Name = newGuy.Name; PaddedGuildTag = newGuy.GuildTag; if (copyPaperdoll) { //only set the doll graphic info in render data - don't change the paperdoll info! RenderData.SetBoots(newGuy.Boots); RenderData.SetArmor(newGuy.Armor); RenderData.SetHat(newGuy.Hat); RenderData.SetShield(newGuy.Shield); RenderData.SetWeapon(newGuy.Weapon); } Stats.SetHP(newGuy.HP); Stats.SetMaxHP(newGuy.MaxHP); Stats.SetTP(newGuy.TP); Stats.SetMaxTP(newGuy.MaxTP); RenderData.SetDirection(newGuy.Direction); RenderData.SetHairStyle(newGuy.HairStyle); RenderData.SetHairColor(newGuy.HairColor); RenderData.SetGender(newGuy.Gender); RenderData.SetRace(newGuy.Race); RenderData.SetSitting(newGuy.Sitting); RenderData.level = newGuy.Level; RenderData.SetWalkFrame(0); State = RenderData.sitting == SitState.Standing ? CharacterActionState.Standing : CharacterActionState.Sitting; CurrentMap = newGuy.Map; X = newGuy.X; Y = newGuy.Y; //GuildRankNum = newGuy.GuildRankNum; //todo: ??? }
/// <summary> /// Used to apply changes from Welcome packet to existing character. /// </summary> /// <param name="newGuy">Changes to MainPlayer.ActiveCharacter, contained in a CharacterData object</param> /// <param name="copyPaperdoll">Set to true if paperdoll data from newGuy should be applied to this character</param> public void ApplyData(CharacterData newGuy, bool copyPaperdoll = true) { ID = newGuy.ID; Name = newGuy.Name; PaddedGuildTag = newGuy.GuildTag; if (copyPaperdoll) { //todo: is this sufficient? need to check refresh-reply EquipItem(ItemType.Boots, 0, newGuy.Boots, true); EquipItem(ItemType.Armor, 0, newGuy.Armor, true); EquipItem(ItemType.Hat, 0, newGuy.Hat, true); EquipItem(ItemType.Shield, 0, newGuy.Shield, true); EquipItem(ItemType.Weapon, 0, newGuy.Weapon, true); } Stats.SetHP(newGuy.HP); Stats.SetMaxHP(newGuy.MaxHP); Stats.SetTP(newGuy.TP); Stats.SetMaxTP(newGuy.MaxTP); //todo: is this enough for render data to be correct after call to ApplyData? RenderData.SetDirection(newGuy.Direction); RenderData.SetHairStyle(newGuy.HairStyle); RenderData.SetHairColor(newGuy.HairColor); RenderData.SetGender(newGuy.Gender); RenderData.SetRace(newGuy.Race); RenderData.SetSitting(newGuy.Sitting); RenderData.level = newGuy.Level; RenderData.SetWalkFrame(0); State = RenderData.sitting == SitState.Standing ? CharacterActionState.Standing : CharacterActionState.Sitting; CurrentMap = newGuy.Map; //MapIsPk = newGuy.MapIsPk; //todo: ??? X = newGuy.X; Y = newGuy.Y; //GuildRankNum = newGuy.GuildRankNum; //todo: ??? }
public void Face(EODirection direction) { //send packet to server: update client side if send was successful if (m_packetAPI.FacePlayer(direction)) { RenderData.SetDirection(direction); //updates the data in the character renderer as well } else { EOGame.Instance.LostConnectionDialog(); } }
/// <summary> /// Called from EOCharacterRenderer.Update (in case of MainPlayer pressing an arrow key) or Handlers.Walk (in case of another character walking) /// <para>The Character Renderer will automatically pick up that Walking == true and start a walk operation, limiting the character from walking again until it is complete</para> /// </summary> public void Walk(EODirection direction, byte destX, byte destY, bool admin) { if (State != CharacterActionState.Standing) { return; } if (this == World.Instance.MainPlayer.ActiveCharacter) { if (!m_packetAPI.PlayerWalk(direction, destX, destY, admin && AdminLevel != AdminLevel.Player)) { EOGame.Instance.LostConnectionDialog(); } } else if (RenderData.facing != direction) //if a packet WALK_PLAYER was received: face them the right way first otherwise this will look weird { RenderData.SetDirection(direction); } DestX = destX; DestY = destY; State = CharacterActionState.Walking; }