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--; }
private void _getDestCoordinates(EODirection direction, out byte destX, out byte destY) { switch (direction) { case EODirection.Up: destX = (byte) Character.X; destY = (byte) (Character.Y - 1); break; case EODirection.Down: destX = (byte) Character.X; destY = (byte) (Character.Y + 1); break; case EODirection.Right: destX = (byte) (Character.X + 1); destY = (byte) Character.Y; break; case EODirection.Left: destX = (byte) (Character.X - 1); destY = (byte) Character.Y; break; default: destX = destY = 255; break; } }
/// <summary> /// Handler for NPC_REPLY packet, when NPC takes damage from an attack (spell cast or weapon) but is still alive /// </summary> private void _handleNPCReply(OldPacket pkt) { if (OnNPCTakeDamage == null) { return; } short spellID = -1; if (pkt.Family == PacketFamily.Cast) { spellID = pkt.GetShort(); } short fromPlayerID = pkt.GetShort(); EODirection fromDirection = (EODirection)pkt.GetChar(); short npcIndex = pkt.GetShort(); int damageToNPC = pkt.GetThree(); int npcPctHealth = pkt.GetShort(); short fromTP = -1; if (pkt.Family == PacketFamily.Cast) { fromTP = pkt.GetShort(); } else if (pkt.GetChar() != 1) //some constant 1 in EOSERV { return; } OnNPCTakeDamage((byte)npcIndex, fromPlayerID, fromDirection, damageToNPC, npcPctHealth, spellID, fromTP); }
public ICharacterRenderProperties WithDirection(EODirection newDirection) { var props = MakeCopy(this); props.Direction = newDirection; return(props); }
public INPC WithDirection(EODirection direction) { var copy = MakeCopy(this); copy.Direction = direction; return(copy); }
private void _handleSpellTargetOther(OldPacket pkt) { if (OnCastSpellTargetOther == null) { return; } short targetPlayerID = pkt.GetShort(); short sourcePlayerID = pkt.GetShort(); EODirection sourcePlayerDirection = (EODirection)pkt.GetChar(); short spellID = pkt.GetShort(); int recoveredHP = pkt.GetInt(); byte targetPercentHealth = pkt.GetChar(); short targetPlayerCurrentHP = -1; if (pkt.ReadPos != pkt.Length) //include current hp for player if main player is the target { targetPlayerCurrentHP = pkt.GetShort(); } OnCastSpellTargetOther( targetPlayerID, sourcePlayerID, sourcePlayerDirection, spellID, recoveredHP, targetPercentHealth, targetPlayerCurrentHP); }
private void _npcWalk(byte index, byte x, byte y, EODirection dir) { if (World.Instance.ActiveMapRenderer == null) { return; } World.Instance.ActiveMapRenderer.NPCWalk(index, x, y, dir); }
public void BeginWalking(EODirection direction, byte destX, byte destY) { Walking = true; Direction = direction; DestX = destX; DestY = destY; }
//public OldNPC(NPCData serverNPCData, ENFRecord localNPCData) //{ // Index = serverNPCData.Index; // X = serverNPCData.X; // Y = serverNPCData.Y; // Direction = serverNPCData.Direction; // Data = localNPCData; //} public void BeginWalking(EODirection direction, byte destX, byte destY) { Walking = true; Direction = direction; DestX = destX; DestY = destY; }
internal NPCData(Packet pkt) { m_index = pkt.GetChar(); m_id = pkt.GetShort(); m_x = pkt.GetChar(); m_y = pkt.GetChar(); m_dir = (EODirection)pkt.GetChar(); }
public void Face(EODirection direction) { var packet = new PacketBuilder(PacketFamily.Face, PacketAction.Player) .AddChar((byte)direction) .Build(); _packetSendService.SendPacket(packet); }
internal NPCData(Packet pkt) { m_index = pkt.GetChar(); m_id = pkt.GetShort(); m_x = pkt.GetChar(); m_y = pkt.GetChar(); m_dir = (EODirection)pkt.GetChar(); }
public void Attack(EODirection dir) { if (Attacking) { return; } attackTimer.Change(0, 100); Direction = dir; }
public static EODirection Opposite(this EODirection direction) { switch (direction) { case EODirection.Invalid: return(EODirection.Invalid); default: return((EODirection)((int)(direction + 2) % 4)); } }
/// <summary> /// Handler for NPC_PLAYER packet, when NPC walks or talks /// </summary> private void _handleNPCPlayer(Packet pkt) { int num255s = 0; while (pkt.PeekByte() == 255) { num255s++; pkt.GetByte(); } switch (num255s) { case 0: /*npc walk!*/ { //npc remove from view sets x/y to either 0,0 or 252,252 based on target coords byte index = pkt.GetChar(); byte x = pkt.GetChar(), y = pkt.GetChar(); EODirection dir = (EODirection)pkt.GetChar(); if (pkt.GetByte() != 255 || pkt.GetByte() != 255 || pkt.GetByte() != 255 || OnNPCWalk == null) { return; } OnNPCWalk(index, x, y, dir); } break; case 1: /*npc attack!*/ { byte index = pkt.GetChar(); bool isDead = pkt.GetChar() == 2; //2 if target player is dead, 1 if alive EODirection dir = (EODirection)pkt.GetChar(); //NPC direction short targetPlayerID = pkt.GetShort(); int damage = pkt.GetThree(); //damage done to player int pctHealth = pkt.GetThree(); //percentage of health remaining of target player if (pkt.GetByte() != 255 || pkt.GetByte() != 255 || OnNPCAttack == null) { return; } OnNPCAttack(index, isDead, dir, targetPlayerID, damage, pctHealth); } break; case 2: /*npc talk!*/ { byte index = pkt.GetChar(); byte msgLength = pkt.GetChar(); string msg = pkt.GetFixedString(msgLength); if (OnNPCChat == null) { return; } OnNPCChat(index, msg); } break; } }
private void _handleFacePlayer(Packet pkt) { short playerId = pkt.GetShort(); EODirection dir = (EODirection)pkt.GetChar(); if (OnPlayerFace != null) { OnPlayerFace(playerId, dir); } }
public void Face(EODirection direction) { var renderProperties = _characterRepository.MainCharacter.RenderProperties; renderProperties = renderProperties.WithDirection(direction); var newMainCharacter = _characterRepository.MainCharacter.WithRenderProperties(renderProperties); _characterRepository.MainCharacter = newMainCharacter; }
public void Attack(EODirection dir) { if (NPC.Attacking) { return; } _actionStartTime = DateTime.Now; NPC.BeginAttacking(dir); }
public void Walk(byte x, byte y, EODirection dir) { if (NPC.Walking) { return; } _actionStartTime = DateTime.Now; NPC.BeginWalking(dir, x, y); }
/// <summary> /// Change the direction of the currently logged in player /// </summary> /// <param name="dir">Direction to face the currently logged in player</param> /// <returns>True on successful send, false otherwise</returns> public bool FacePlayer(EODirection dir) { if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet pkt = new Packet(PacketFamily.Face, PacketAction.Player); pkt.AddChar((byte)dir); return m_client.SendPacket(pkt); }
public bool AttackUse(EODirection direction) { if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet pkt = new Packet(PacketFamily.Attack, PacketAction.Use); pkt.AddChar((byte)direction); pkt.AddThree(DateTime.Now.ToEOTimeStamp()); return m_client.SendPacket(pkt); }
private void _npcTakeDamage(byte npcIndex, short fromPlayerID, EODirection fromDirection, int damageToNPC, int npcPctHealth, short spellID, short fromTP) { OldWorld.Instance.ActiveMapRenderer.NPCTakeDamage(npcIndex, fromPlayerID, fromDirection, damageToNPC, npcPctHealth, spellID); if (fromTP >= 0) { OldWorld.Instance.MainPlayer.ActiveCharacter.Stats.TP = fromTP; m_game.Hud.RefreshStats(); } }
private void FaceOrAttemptWalk(EODirection direction) { if (!CurrentDirectionIs(direction)) { FaceDirection(direction); } else { AttemptToStartWalking(); } }
/// <summary> /// Sent when another player attacks (not main player) /// </summary> private void _handleAttackPlayer(Packet pkt) { if (OnOtherPlayerAttack == null) { return; } short playerId = pkt.GetShort(); EODirection dir = (EODirection)pkt.GetChar(); OnOtherPlayerAttack(playerId, dir); }
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> /// Handler for the APPEAR_REPLY packet, when an NPC comes into view /// </summary> //public static void AppearReply(Packet pkt) //{ // if (pkt.Length - pkt.ReadPos != 8 || pkt.GetChar() != 0 || pkt.GetByte() != 255) return; //malformed packet // World.Instance.ActiveMapRenderer.AddOtherNPC(new NPC(pkt)); //} /// <summary> /// Handler for NPC_PLAYER packet, when NPC walks or talks /// </summary> public static void NPCPlayer(Packet pkt) { int num255s = 0; while (pkt.PeekByte() == 255) { num255s++; pkt.GetByte(); } switch (num255s) { case 0: /*npc walk!*/ { //npc remove from view sets x/y to either 0,0 or 252,252 based on target coords byte index = pkt.GetChar(); byte x = pkt.GetChar(), y = pkt.GetChar(); EODirection dir = (EODirection)pkt.GetChar(); if (pkt.GetByte() != 255 || pkt.GetByte() != 255 || pkt.GetByte() != 255) { return; } World.Instance.ActiveMapRenderer.NPCWalk(index, x, y, dir); } break; case 1: /*npc attack!*/ { byte index = pkt.GetChar(); bool isDead = pkt.GetChar() == 2; //2 if target player is dead, 1 if alive EODirection dir = (EODirection)pkt.GetChar(); //NPC direction short targetPlayerID = pkt.GetShort(); int damage = pkt.GetThree(); //damage done to player int pctHealth = pkt.GetThree(); //percentage of health remaining of target player if (pkt.GetByte() != 255 || pkt.GetByte() != 255) { return; } World.Instance.ActiveMapRenderer.NPCAttack(index, isDead, dir, targetPlayerID, damage, pctHealth); } break; case 2: /*npc talk!*/ { byte index = pkt.GetChar(); byte msgLength = pkt.GetChar(); string msg = pkt.GetFixedString(msgLength); World.Instance.ActiveMapRenderer.RenderChatMessage(TalkType.NPC, index, msg, ChatType.Note); } break; } }
public void Walk(byte x, byte y, EODirection dir) { if (Walking) { return; } walkTimer.Change(0, 100); //use 100ms for now.... //the direction is required for the walk callback Direction = dir; DestX = x; DestY = y; }
/// <summary> /// Change the direction of the currently logged in player /// </summary> /// <param name="dir">Direction to face the currently logged in player</param> /// <returns>True on successful send, false otherwise</returns> public bool FacePlayer(EODirection dir) { if (!m_client.ConnectedAndInitialized || !Initialized) { return(false); } Packet pkt = new Packet(PacketFamily.Face, PacketAction.Player); pkt.AddChar((byte)dir); return(m_client.SendPacket(pkt)); }
private void _handleOtherPlayerWalk(Packet pkt) { if (OnOtherPlayerWalk == null) { return; } short playerID = pkt.GetShort(); EODirection dir = (EODirection)pkt.GetChar(); byte x = pkt.GetChar(); byte y = pkt.GetChar(); OnOtherPlayerWalk(playerID, dir, x, y); }
public bool PlayerWalk(EODirection dir, byte destX, byte destY, bool admin = false) { if (!m_client.ConnectedAndInitialized || !Initialized) return false; Packet builder = new Packet(PacketFamily.Walk, admin ? PacketAction.Admin : PacketAction.Player); //change family/action builder.AddChar((byte) dir); builder.AddThree(DateTime.Now.ToEOTimeStamp()); builder.AddChar(destX); builder.AddChar(destY); return m_client.SendPacket(builder); }
public bool AttackUse(EODirection direction) { if (!m_client.ConnectedAndInitialized || !Initialized) { return(false); } Packet pkt = new Packet(PacketFamily.Attack, PacketAction.Use); pkt.AddChar((byte)direction); pkt.AddThree(DateTime.Now.ToEOTimeStamp()); return(m_client.SendPacket(pkt)); }
/// <summary> /// Handler for NPC_REPLY packet, when NPC takes damage from an attack (spell cast or weapon) but is still alive /// </summary> public static void NPCReply(Packet pkt) { short fromPlayerID = pkt.GetShort(); EODirection fromDirection = (EODirection)pkt.GetChar(); short npcIndex = pkt.GetShort(); int damageToNPC = pkt.GetThree(); int npcPctHealth = pkt.GetShort(); if (pkt.GetChar() != 1) { return; } World.Instance.ActiveMapRenderer.NPCTakeDamage(npcIndex, fromPlayerID, fromDirection, damageToNPC, npcPctHealth); }
public Texture2D GetNPCTexture(int baseGraphic, NPCFrame whichFrame, EODirection direction) { int offset; switch (whichFrame) { case NPCFrame.Standing: offset = direction == EODirection.Down || direction == EODirection.Right ? 1 : 3; break; case NPCFrame.StandingFrame1: offset = direction == EODirection.Down || direction == EODirection.Right ? 2 : 4; break; case NPCFrame.WalkFrame1: offset = direction == EODirection.Down || direction == EODirection.Right ? 5 : 9; break; case NPCFrame.WalkFrame2: offset = direction == EODirection.Down || direction == EODirection.Right ? 6 : 10; break; case NPCFrame.WalkFrame3: offset = direction == EODirection.Down || direction == EODirection.Right ? 7 : 11; break; case NPCFrame.WalkFrame4: offset = direction == EODirection.Down || direction == EODirection.Right ? 8 : 12; break; case NPCFrame.Attack1: offset = direction == EODirection.Down || direction == EODirection.Right ? 13 : 15; break; case NPCFrame.Attack2: offset = direction == EODirection.Down || direction == EODirection.Right ? 14 : 16; break; default: return(null); } var baseGfx = (baseGraphic - 1) * 40; return(_gfxManager.TextureFromResource(GFXTypes.NPC, baseGfx + offset, true)); }
public bool PlayerWalk(EODirection dir, byte destX, byte destY, bool admin = false) { if (!m_client.ConnectedAndInitialized || !Initialized) { return(false); } Packet builder = new Packet(PacketFamily.Walk, admin ? PacketAction.Admin : PacketAction.Player); //change family/action builder.AddChar((byte)dir); builder.AddThree(DateTime.Now.ToEOTimeStamp()); builder.AddChar(destX); builder.AddChar(destY); return(m_client.SendPacket(builder)); }
public static EODirection Opposite(this EODirection direction) { switch (direction) { case EODirection.Down: return(EODirection.Up); case EODirection.Left: return(EODirection.Right); case EODirection.Up: return(EODirection.Down); case EODirection.Right: return(EODirection.Left); case EODirection.Invalid: return(EODirection.Invalid); default: throw new ArgumentOutOfRangeException(nameof(direction), direction, null); } }
public Texture2D GetNPCTexture() { EODirection dir = npc.Direction; int baseGfx = (npc.Data.Graphic - 1) * 40; int offset; switch (npc.Frame) { case NPCFrame.Standing: offset = dir == EODirection.Down || dir == EODirection.Right ? 1 : 3; break; case NPCFrame.StandingFrame1: offset = dir == EODirection.Down || dir == EODirection.Right ? 2 : 4; break; case NPCFrame.WalkFrame1: offset = dir == EODirection.Down || dir == EODirection.Right ? 5 : 9; break; case NPCFrame.WalkFrame2: offset = dir == EODirection.Down || dir == EODirection.Right ? 6 : 10; break; case NPCFrame.WalkFrame3: offset = dir == EODirection.Down || dir == EODirection.Right ? 7 : 11; break; case NPCFrame.WalkFrame4: offset = dir == EODirection.Down || dir == EODirection.Right ? 8 : 12; break; case NPCFrame.Attack1: offset = dir == EODirection.Down || dir == EODirection.Right ? 13 : 15; break; case NPCFrame.Attack2: offset = dir == EODirection.Down || dir == EODirection.Right ? 14 : 16; break; default: return(null); } return(GFXLoader.TextureFromResource(GFXTypes.NPC, baseGfx + offset, true)); }
internal CharacterData(Packet pkt) { m_name = pkt.GetBreakString(); if (m_name.Length > 1) m_name = char.ToUpper(m_name[0]) + m_name.Substring(1); m_id = pkt.GetShort(); m_map = pkt.GetShort(); m_x = pkt.GetShort(); m_y = pkt.GetShort(); m_facing = (EODirection)pkt.GetChar(); pkt.GetChar(); //value is always 6? unknown m_guildTag = pkt.GetFixedString(3); m_level = pkt.GetChar(); m_gender = pkt.GetChar(); m_hairstyle = pkt.GetChar(); m_haircolor = pkt.GetChar(); m_race = pkt.GetChar(); m_maxhp = pkt.GetShort(); m_hp = pkt.GetShort(); m_maxtp = pkt.GetShort(); m_tp = pkt.GetShort(); m_boots = pkt.GetShort(); pkt.Skip(3 * sizeof(short)); //other paperdoll data is 0'd out m_armor = pkt.GetShort(); pkt.Skip(sizeof(short)); m_hat = pkt.GetShort(); m_shield = pkt.GetShort(); m_weapon = pkt.GetShort(); m_sit = (SitState)pkt.GetChar(); m_hidden = pkt.GetChar() != 0; }
private void _playerCastTargetSpell(short targetPlayerID, short fromPlayerID, EODirection sourcePlayerDirection, short spellID, int recoveredHP, byte targetPercentHealth, short targetPlayerCurrentHP) { World.Instance.ActiveMapRenderer.PlayerCastSpellTarget(fromPlayerID, targetPlayerID, sourcePlayerDirection, spellID, recoveredHP, targetPercentHealth); if (targetPlayerCurrentHP > 0) { World.Instance.MainPlayer.ActiveCharacter.Stats.HP = targetPlayerCurrentHP; m_game.Hud.RefreshStats(); } }
private void _npcWalk(byte index, byte x, byte y, EODirection dir) { if (World.Instance.ActiveMapRenderer == null) return; World.Instance.ActiveMapRenderer.NPCWalk(index, x, y, dir); }
private void _npcLeaveView(byte index, int damageToNPC, short playerID, EODirection playerDirection, short playerTP = -1, short spellID = -1) { if (World.Instance.ActiveMapRenderer == null) return; World.Instance.ActiveMapRenderer.RemoveOtherNPC(index, damageToNPC, playerID, playerDirection, spellID); if (playerTP >= 0) { World.Instance.MainPlayer.ActiveCharacter.Stats.TP = playerTP; m_game.Hud.RefreshStats(); } }
private void _npcTakeDamage(byte npcIndex, short fromPlayerID, EODirection fromDirection, int damageToNPC, int npcPctHealth, short spellID, short fromTP) { World.Instance.ActiveMapRenderer.NPCTakeDamage(npcIndex, fromPlayerID, fromDirection, damageToNPC, npcPctHealth, spellID); if (fromTP >= 0) { World.Instance.MainPlayer.ActiveCharacter.Stats.TP = fromTP; m_game.Hud.RefreshStats(); } }
public void NPCAttack(byte index, bool isTargetPlayerDead, EODirection dir, short targetPlayerId, int damageToPlayer, int playerPctHealth) { lock (_npcListLock) { NPC toAttack = npcList.Find(_npc => _npc.Index == index); if (toAttack != null && !toAttack.Attacking) { toAttack.Attack(dir); } } lock (_rendererListLock) { CharacterRenderer rend = targetPlayerId == World.Instance.MainPlayer.ActiveCharacter.ID ? World.Instance.ActiveCharacterRenderer : otherRenderers.Find(_rend => _rend.Character.ID == targetPlayerId); if (rend == null) return; //couldn't find other player :( rend.Character.Stats.HP = (short) Math.Max(rend.Character.Stats.HP - damageToPlayer, 0); if (rend.Character == World.Instance.MainPlayer.ActiveCharacter && ((EOGame) Game).Hud != null) { //update health in UI ((EOGame) Game).Hud.RefreshStats(); } rend.SetDamageCounterValue(damageToPlayer, playerPctHealth); if (isTargetPlayerDead) rend.Die(); } }
public void NPCTakeDamage(short npcIndex, short fromPlayerID, EODirection fromDirection, int damageToNPC, int npcPctHealth, short spellID = -1) { lock (_npcListLock) { NPC toDamage = npcList.Find(_npc => _npc.Index == npcIndex); if (toDamage == null) return; toDamage.SetDamageCounterValue(damageToNPC, npcPctHealth); toDamage.HP -= damageToNPC; _renderSpellOnNPC(spellID, toDamage); lock (otherRenderers) { CharacterRenderer rend = fromPlayerID == World.Instance.MainPlayer.ActiveCharacter.ID ? World.Instance.ActiveCharacterRenderer : otherRenderers.Find(_rend => _rend.Character.ID == fromPlayerID); if (rend == null) return; toDamage.Opponent = rend.Character; //for fighting protection, no KSing! if (rend.Character.RenderData.facing != fromDirection) rend.Character.RenderData.SetDirection(fromDirection); } } }
/// <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; }
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(); }
public void SetDirection(EODirection direction) { facing = direction; update = true; }
private void _npcAttack(byte index, bool dead, EODirection dir, short id, int damage, int health) { World.Instance.ActiveMapRenderer.NPCAttack(index, dead, dir, id, damage, health); }
public void OtherPlayerWalk(short ID, EODirection direction, byte x, byte y) { lock (_rendererListLock) { CharacterRenderer rend = otherRenderers.Find(_rend => _rend.Character.ID == ID); if (rend != null) { rend.Character.Walk(direction, x, y, false); var ti = GetTileInfo(rend.Character.DestX, rend.Character.DestY); bool isWater = ti.ReturnType == TileInfoReturnType.IsTileSpec && ti.Spec == TileSpec.Water; bool isSpike = ti.ReturnType == TileInfoReturnType.IsTileSpec && ti.Spec == TileSpec.SpikesTrap; rend.PlayerWalk(isWater, isSpike); } } }
public void OtherPlayerFace(short ID, EODirection direction) { lock (_rendererListLock) { int ndx; if ((ndx = otherRenderers.FindIndex(x => x.Character.ID == ID)) >= 0) otherRenderers[ndx].Character.RenderData.SetDirection(direction); } }
public void Attack(EODirection dir) { if (NPC.Attacking) return; _actionStartTime = DateTime.Now; NPC.BeginAttacking(dir); }
private void _otherPlayerWalk(short id, EODirection dir, byte x, byte y) { World.Instance.ActiveMapRenderer.OtherPlayerWalk(id, dir, x, y); }
//convenience wrapper private void _chkWalk(TileSpec spec, EODirection dir, byte destX, byte destY) { bool walkValid = true; switch (spec) { case TileSpec.ChairDown: //todo: make character sit in chairs case TileSpec.ChairLeft: case TileSpec.ChairRight: case TileSpec.ChairUp: case TileSpec.ChairDownRight: case TileSpec.ChairUpLeft: case TileSpec.ChairAll: walkValid = NoWall; break; case TileSpec.Chest: walkValid = NoWall; if (!walkValid) { MapChest chest = World.Instance.ActiveMapRenderer.MapRef.Chests.Find(_c => _c.x == destX && _c.y == destY); if (chest != null) { string requiredKey = null; switch (Character.CanOpenChest(chest)) { case ChestKey.Normal: requiredKey = "Normal Key"; break; case ChestKey.Silver: requiredKey = "Silver Key"; break; case ChestKey.Crystal: requiredKey = "Crystal Key"; break; case ChestKey.Wraith: requiredKey = "Wraith Key"; break; default: EOChestDialog.Show(((EOGame)Game).API, chest.x, chest.y); break; } if (requiredKey != null) { EODialog.Show(DATCONST1.CHEST_LOCKED, XNADialogButtons.Ok, EODialogStyle.SmallDialogSmallHeader); ((EOGame)Game).Hud.SetStatusLabel(DATCONST2.STATUS_LABEL_TYPE_WARNING, DATCONST2.STATUS_LABEL_THE_CHEST_IS_LOCKED_EXCLAMATION, " - " + requiredKey); } } else { EOChestDialog.Show(((EOGame)Game).API, destX, destY); } } break; case TileSpec.BankVault: walkValid = NoWall; if (!walkValid) { EOLockerDialog.Show(((EOGame)Game).API, destX, destY); } break; case TileSpec.Board1: //todo: boards? case TileSpec.Board2: case TileSpec.Board3: case TileSpec.Board4: case TileSpec.Board5: case TileSpec.Board6: case TileSpec.Board7: case TileSpec.Board8: walkValid = NoWall; break; case TileSpec.Jukebox: //todo: jukebox? walkValid = NoWall; break; case TileSpec.MapEdge: case TileSpec.Wall: walkValid = NoWall; break; } if (State != CharacterActionState.Walking && walkValid) { _char.Walk(dir, destX, destY, NoWall); PlayerWalk(spec == TileSpec.Water); } }
public void OtherPlayerAttack(short ID, EODirection direction) { lock (_rendererListLock) { CharacterRenderer rend = otherRenderers.Find(_rend => _rend.Character.ID == ID); if (rend != null) { rend.Character.Attack(direction); var info = GetTileInfo((byte) rend.Character.X, (byte) rend.Character.Y); rend.PlayerAttack(info.ReturnType == TileInfoReturnType.IsTileSpec && info.Spec == TileSpec.Water); } } }
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--; }
private void _npcTakeDamage(byte npcIndex, short fromPlayerID, EODirection fromDirection, int damageToNPC, int npcPctHealth) { World.Instance.ActiveMapRenderer.NPCTakeDamage(npcIndex, fromPlayerID, fromDirection, damageToNPC, npcPctHealth); }
public void PlayerCastSpellTarget(short fromPlayerID, short targetPlayerID, EODirection fromPlayerDirection, short spellID, int recoveredHP, byte targetPercentHealth) { lock (_rendererListLock) { bool fromIsMain = false; var fromRenderer = otherRenderers.Find(x => x.Character.ID == fromPlayerID); var toRenderer = otherRenderers.Find(x => x.Character.ID == targetPlayerID); if (fromRenderer == null && fromPlayerID == World.Instance.MainPlayer.ActiveCharacter.ID) { fromIsMain = true; fromRenderer = World.Instance.ActiveCharacterRenderer; } if (toRenderer == null && targetPlayerID == World.Instance.MainPlayer.ActiveCharacter.ID) toRenderer = World.Instance.ActiveCharacterRenderer; if (fromRenderer != null) //do source renderer stuff { if (!fromIsMain) { bool showShoutName = fromRenderer != toRenderer; fromRenderer.StopShouting(showShoutName); fromRenderer.StartCastingSpell(); } fromRenderer.Character.RenderData.SetDirection(fromPlayerDirection); } if (toRenderer != null) //do target renderer stuff { toRenderer.SetDamageCounterValue(recoveredHP, targetPercentHealth, true); _renderSpellOnPlayer(spellID, toRenderer); } } }
private void _otherPlayerAttack(short playerid, EODirection dir) { World.Instance.ActiveMapRenderer.OtherPlayerAttack(playerid, dir); }
public void RemoveOtherNPC(byte index, int damage = 0, short playerID = 0, EODirection playerDirection = (EODirection)0, short spellID = -1) { lock (_npcListLock) { NPC npc = npcList.Find(_npc => _npc.Index == index); if (npc != null) { if (damage > 0) //npc was killed - will do cleanup later { npc.HP = Math.Max(npc.HP - damage, 0); npc.FadeAway(); npc.Opponent = null; npc.SetDamageCounterValue(damage, 0); _renderSpellOnNPC(spellID, npc); } else //npc is out of view or done fading away { npc.Visible = false; npc.HideChatBubble(); npc.Dispose(); npcList.Remove(npc); } } } if (playerID > 0) { lock (_rendererListLock) { var renderer = otherRenderers.Find(x => x.Character.ID == playerID); if (renderer != null) { renderer.Character.RenderData.SetDirection(playerDirection); renderer.StopShouting(true); renderer.StartCastingSpell(); } else if (playerID == World.Instance.MainPlayer.ActiveCharacter.ID) World.Instance.ActiveCharacterRenderer.Character.RenderData.SetDirection(playerDirection); } } }
private void _playerFace(short playerId, EODirection dir) { World.Instance.ActiveMapRenderer.OtherPlayerFace(playerId, dir); }
public void NPCWalk(byte index, byte x, byte y, EODirection dir) { lock (_npcListLock) { NPC toWalk = npcList.Find(_npc => _npc.Index == index); if (toWalk != null && !toWalk.Walking) { toWalk.Walk(x, y, dir); } } }