public static void SendToArena(ArenaPlayer arenaPlayer, MemoryStream inStream, Boolean sendToSource) { if (arenaPlayer == null) { return; } Arena arena = arenaPlayer.WorldPlayer.ActiveArena; if (arena == null) { return; } Packet packet = new Packet(inStream); for (Byte i = 0; i < arena.ArenaPlayers.Count; i++) { ArenaPlayer targetArenaPlayer = arena.ArenaPlayers[i]; if (targetArenaPlayer == null || (targetArenaPlayer == arenaPlayer && !sendToSource)) { continue; } Send(targetArenaPlayer.WorldPlayer, packet); } }
public Sign(Int16 objectId, ArenaPlayer owner, Spell spell, Vector3 location, Single direction, Byte[] rawData) { if (spell == SpellManager.CTFOrbSpell) { IsCTFOrb = true; } RawData = rawData; RawData[13] = 0; ObjectId = objectId; Owner = owner; Team = spell.NoTeam ? Team.None : owner.ActiveTeam; Spell = spell; Location = new Vector3(location.X, location.Y, location.Z); Direction = direction; Location.X += (Single)(-spell.CastDistance * Math.Sin(Direction)) - (spell.Width * 0.5f); Location.Y += (Single)(spell.CastDistance * Math.Cos(Direction)) - (spell.Width * 0.5f); Location.Z = (Location.Z + spell.Elevation) - (spell.Tall * 0.25f); BoundingBox = new OrientedBoundingBox(Location, new Vector3(spell.Width, spell.Width, spell.Tall), Direction); Duration = new Interval(Spell.DurationTimer, false); OwnerDistance = Vector3.Distance(BoundingBox.Origin, Owner.BoundingBox.Origin); if (IsAura) { AuraBoundingSphere = new BoundingSphere(BoundingBox.Origin, (Spell.EffectRadius * 2) + (owner.BoundingBox.ExtentSphere.Radius * 3)); AuraEffectSphere = new BoundingSphere(BoundingBox.Origin, Spell.EffectRadius); AuraPulse = new Interval(Spell.AuraPulseTimer, true); AuraHealth = Spell.AuraHealth; } }
public static void SendTo(Arena arena, MemoryStream inStream, SendToType sendToType) { if (arena == null) { return; } Packet packet = new Packet(inStream); for (Byte i = 0; i < arena.ArenaPlayers.Count; i++) { ArenaPlayer arenaPlayer = arena.ArenaPlayers[i]; if (arenaPlayer == null) { continue; } if (sendToType.HasFlag(SendToType.All)) { Send(arenaPlayer.WorldPlayer, packet); continue; } if (sendToType.HasFlag(SendToType.Arena)) { if (arenaPlayer.WorldPlayer.ActiveArena == arena) { Send(arenaPlayer.WorldPlayer, packet); } } } }
public Projectile(Vector3 location, Spell spell, Single direction, Single angle, ArenaPlayer owner) { Spell = spell; Location = location; Direction = direction; Velocity = spell.Velocity; Angle = angle; Size = new Vector3(spell.Width * 0.5f, spell.Width, spell.Tall); Single zRadians = MathHelper.DegreesToRadians(Angle); Single cosZRadians = (Single)Math.Cos(zRadians); Location.X += -(((Single)Math.Sin(Direction) + (Size.X * 0.5f)) * cosZRadians); Location.Y += (Single)Math.Sin(Direction) * cosZRadians; if (zRadians < 0) { Location.Z += Math.Abs(zRadians * 4f) + 4f; } Owner = owner; Team = owner.ActiveTeam; GravityStepDelta = 0; GravityStepCount = 0; DistanceTicks = new TickCounter(30, 50); Duration = new Interval(Spell.DurationTimer, false); BoundingBox = new OrientedBoundingBox(Location, Size, direction); OriginalOrigin = BoundingBox.Origin; OriginalAngle = Angle; }
public CTFOrb(Team team, Int16 objectId) { _orbState = CTFOrbState.InHomeShrine; _orbPlayer = null; _orbSign = null; _team = team; _objectId = objectId; }
public Bolt(ArenaPlayer owner, ArenaPlayer target, Spell spell, Single distance) { Owner = owner; Target = target; Spell = spell; Distance = distance; Velocity = spell.Range / ((Single)spell.MaxTimer / 1000); }
public void ResetOrb() { lock (SyncRoot) { _orbPlayer = null; _orbSign = null; _orbState = CTFOrbState.InHomeShrine; } }
public CTFOrbState ChangeState(ArenaPlayer arenaPlayer) { lock (SyncRoot) { switch (OrbState) { case CTFOrbState.InHomeShrine: { if (arenaPlayer.ActiveTeam != _team && arenaPlayer.ActiveTeam != Team.Neutral) { _orbSign = null; _orbPlayer = arenaPlayer; _orbState = CTFOrbState.OnEnemyPlayer; } break; } case CTFOrbState.OnEnemyPlayer: { if (arenaPlayer.ActiveTeam != _team) { ResetOrb(); } break; } case CTFOrbState.OnGround: { if (arenaPlayer.ActiveTeam != _team && arenaPlayer.ActiveTeam != Team.Neutral) { _orbSign = null; _orbPlayer = arenaPlayer; _orbState = CTFOrbState.OnEnemyPlayer; } else { ResetOrb(); } break; } } } return(OrbState); }
public CTFOrbState ChangeState(Sign sign) { lock (SyncRoot) { switch (OrbState) { case CTFOrbState.OnEnemyPlayer: { _orbPlayer = null; _orbSign = sign; _orbState = CTFOrbState.OnGround; break; } } } return(OrbState); }
public Wall(Int16 objectId, ArenaPlayer owner, Spell spell, Vector3 location, Single direction, Byte[] rawData) { RawData = rawData; RawData[13] = 0; ObjectId = objectId; Owner = owner; Team = Owner.ActiveTeam; Spell = spell; CurrentHp = spell.HitPoints; Location = new Vector3(location.X, location.Y, location.Z); Location.X += (Single)(-(spell.CastDistance + (spell.Thick * 0.5f)) * Math.Sin(direction)) - (spell.Length * 0.5f); Location.Y += (Single)((spell.CastDistance + (spell.Thick * 0.5f)) * Math.Cos(direction)) - (spell.Thick * 0.5f); Direction = direction; BoundingBox = new OrientedBoundingBox(Location, new Vector3(spell.Length, spell.Thick, spell.MaxWallHeight), direction); Duration = new Interval(Spell.DurationTimer, false); WeakenedDuration = null; }
public Effect(Spell spell, ArenaPlayer caster, EffectType effectType) { Owner = caster; switch (spell.Type) { case SpellType.Projectile: { switch (effectType) { case EffectType.Death: { OwnerSpell = spell; EffectSpell = SpellManager.Spells[spell.DeathSpellEffect]; break; } case EffectType.Area: { Spell areaSpell = SpellManager.Spells[spell.AreaEffectSpell]; OwnerSpell = areaSpell; EffectSpell = SpellManager.Spells[areaSpell.TargetSpellEffect]; break; } } break; } case SpellType.Rune: { switch (effectType) { case EffectType.Death: { OwnerSpell = spell; EffectSpell = SpellManager.Spells[spell.DeathSpellEffect]; break; } case EffectType.AuraCaster: { Spell auraCasterSpell = SpellManager.Spells[spell.AuraCasterEffect]; OwnerSpell = auraCasterSpell; EffectSpell = SpellManager.Spells[auraCasterSpell.TargetSpellEffect]; break; } case EffectType.AuraTarget: { Spell auraTargetSpell = SpellManager.Spells[spell.AuraCasterEffect]; OwnerSpell = auraTargetSpell; EffectSpell = SpellManager.Spells[auraTargetSpell.TargetSpellEffect]; break; } } break; } case SpellType.Target: { OwnerSpell = spell; switch (effectType) { case EffectType.Caster: { EffectSpell = SpellManager.Spells[spell.CasterSpellEffect]; break; } case EffectType.Target: { EffectSpell = SpellManager.Spells[spell.TargetSpellEffect]; break; } } break; } default: { OwnerSpell = spell; EffectSpell = spell; break; } } if (EffectSpell != null) { Duration = EffectSpell.Effect == SpellEffectType.Bleed ? new Interval(1000, EffectSpell.Duration / 1000) : new Interval(EffectSpell.Duration, false); } else { Duration = new Interval(1, false); } }
private void ProcessArenas() { Boolean resetStatusUpdate = false; while (WorkerThread != null) { lock (Arenas.SyncRoot) { for (Int32 i = Arenas.Count - 1; i >= 0; i--) { Arena arena = Arenas[i]; if (arena == null) { continue; } lock (arena.SyncRoot) { if (arena.CurrentState == Arena.State.Ended) { continue; } if (arena.CurrentState == Arena.State.CleanUp) { Arenas.Remove(arena); continue; } Team winningTeam = arena.WinningTeam; if (arena.CountdownTick == null && winningTeam != Team.Neutral) { switch (winningTeam) { case Team.Chaos: { arena.CurrentState = Arena.State.ChaosVictory; break; } case Team.Balance: { arena.CurrentState = Arena.State.BalanceVictory; break; } case Team.Order: { arena.CurrentState = Arena.State.OrderVictory; break; } } arena.CountdownTick = new Interval(29000, false); } else if (winningTeam == Team.Neutral) { arena.CurrentState = Arena.State.Normal; arena.CountdownTick = null; } if (arena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.GuildRules)) { if (arena.GuildRulesBroadcast.HasElapsed) { if (arena.ArenaPlayers.GetTeamPlayerCount(Team.Chaos) > 0 || !arena.ArenaTeams.Chaos.Shrine.IsDead) { Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Chaos: {0:0.00}", arena.ArenaTeams.Chaos.Shrine.GuildPoints)), Network.SendToType.Arena); } if (arena.ArenaPlayers.GetTeamPlayerCount(Team.Order) > 0 || !arena.ArenaTeams.Order.Shrine.IsDead) { Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Order: {0:0.00}", arena.ArenaTeams.Order.Shrine.GuildPoints)), Network.SendToType.Arena); } if (arena.ArenaPlayers.GetTeamPlayerCount(Team.Balance) > 0 || !arena.ArenaTeams.Balance.Shrine.IsDead) { Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Balance: {0:0.00}", arena.ArenaTeams.Balance.Shrine.GuildPoints)), Network.SendToType.Arena); } Team guildWinTeam = Team.Neutral; if (winningTeam == Team.Neutral) { if (arena.ArenaTeams.Order.Shrine.GuildPoints > arena.ArenaTeams.Chaos.Shrine.GuildPoints && arena.ArenaTeams.Order.Shrine.GuildPoints > arena.ArenaTeams.Balance.Shrine.GuildPoints) { guildWinTeam = Team.Order; } if (arena.ArenaTeams.Balance.Shrine.GuildPoints > arena.ArenaTeams.Chaos.Shrine.GuildPoints && arena.ArenaTeams.Balance.Shrine.GuildPoints > arena.ArenaTeams.Order.Shrine.GuildPoints) { guildWinTeam = Team.Balance; } if (arena.ArenaTeams.Chaos.Shrine.GuildPoints > arena.ArenaTeams.Order.Shrine.GuildPoints && arena.ArenaTeams.Chaos.Shrine.GuildPoints > arena.ArenaTeams.Balance.Shrine.GuildPoints) { guildWinTeam = Team.Chaos; } } else { guildWinTeam = winningTeam; } Network.SendTo(arena, GamePacket.Outgoing.System.DirectTextMessage(null, String.Format("[Guild Match] Winning Team: {0}", (guildWinTeam == Team.Neutral) ? "None" : guildWinTeam.ToString())), Network.SendToType.Arena); } if (arena.Duration.RemainingSeconds < 600 && arena.GuildRulesBroadcast.Duration == 600000) { arena.GuildRulesBroadcast = new Interval(120000, true); } if (arena.CountdownTick != null && arena.CountdownTick.ElapsedSeconds >= 9) { Single pointsGiven = 1f; if (arena.CountdownTick.ElapsedSeconds >= 10) { pointsGiven += 0.33f * (arena.CountdownTick.ElapsedSeconds - 10); } switch (winningTeam) { case Team.Chaos: { arena.ArenaTeams.Chaos.Shrine.GuildPoints += pointsGiven; break; } case Team.Balance: { arena.ArenaTeams.Balance.Shrine.GuildPoints += pointsGiven; break; } case Team.Order: { arena.ArenaTeams.Order.Shrine.GuildPoints += pointsGiven; break; } case Team.Neutral: { break; } } } } if (arena.CountdownTick != null && arena.CountdownTick.HasElapsed) { arena.EndState = arena.CurrentState; arena.CurrentState = Arena.State.Ended; continue; } if ((arena.TimeLimit - arena.Duration.ElapsedSeconds) <= 60 && arena.CurrentState == Arena.State.Normal) { arena.CurrentState = Arena.State.OneMinute; } if (arena.Duration.HasElapsed) { arena.CurrentState = Arena.State.Ended; continue; } if (StatusTick.HasElapsed) { if (arena.ArenaPlayers.Count > 0) { arena.IdleDuration.Reset(); } if (arena.IdleDuration.HasElapsed) { arena.CurrentState = Arena.State.Ended; } resetStatusUpdate = true; for (Int32 j = 0; j < arena.ArenaPlayers.Count; j++) { ArenaPlayer arenaPlayer = arena.ArenaPlayers[j]; if (arenaPlayer == null) { continue; } Network.Send(arenaPlayer.WorldPlayer, GamePacket.Outgoing.World.ArenaState(arena, arenaPlayer.WorldPlayer)); Network.SendTo(arena, GamePacket.Outgoing.Arena.PlayerState(arenaPlayer), Network.SendToType.Arena); } } } } } if (resetStatusUpdate) { resetStatusUpdate = false; StatusTick.Reset(); } Thread.Sleep(100); } }
public ProjectileGroup(ArenaPlayer owner, Spell spell, Vector3 location, Single direction, Single angle) { Single xOffset, yOffset; Vector3 tLocation; Projectiles = new ListCollection <Projectile>(); Owner = owner; Team = Owner.ActiveTeam; location.X += (-spell.CastDistance * (Single)Math.Sin(direction)) + 1f; location.Y += (spell.CastDistance * (Single)Math.Cos(direction)) - (spell.Width * 0.5f); switch (spell.Gravity) { case true: { location.Z += (spell.MaxStep * 0.5f) * (MathHelper.DegreesToRadians(angle) + 1); break; } case false: { location.Z += spell.Elevation + angle; break; } } switch (spell.SideBySide) { case SpellProjectileType.Tandem: { for (Int32 i = 0; i < spell.NumProjectiles; i++) { Projectiles.Add(new Projectile(location, spell, direction, angle, owner)); location.X += -spell.ProjectileSpacing * (Single)Math.Sin(direction); location.Y += spell.ProjectileSpacing * (Single)Math.Cos(direction); } break; } case SpellProjectileType.HorizontalLine: { if (spell.NumProjectiles != 2) { return; } xOffset = -(spell.ProjectileSpacing * 0.5f) * (Single)Math.Sin(direction + MathHelper.RightAngleRadians); yOffset = (spell.ProjectileSpacing * 0.5f) * (Single)Math.Cos(direction + MathHelper.RightAngleRadians); tLocation = new Vector3(location.X + xOffset, location.Y + yOffset, location.Z); Projectiles.Add(new Projectile(tLocation, spell, direction, angle, owner)); xOffset = -(spell.ProjectileSpacing * 0.5f) * (Single)Math.Sin(direction - MathHelper.RightAngleRadians); yOffset = (spell.ProjectileSpacing * 0.5f) * (Single)Math.Cos(direction - MathHelper.RightAngleRadians); tLocation = new Vector3(location.X + xOffset, location.Y + yOffset, location.Z); Projectiles.Add(new Projectile(tLocation, spell, direction, angle, owner)); break; } case SpellProjectileType.DoubleRow: { if (spell.NumProjectiles != 3) { return; } Single zOffset = spell.ProjectileSpacing; xOffset = -(spell.ProjectileSpacing * 0.5f) * (Single)Math.Sin(direction + MathHelper.RightAngleRadians); yOffset = (spell.ProjectileSpacing * 0.5f) * (Single)Math.Cos(direction + MathHelper.RightAngleRadians); tLocation = new Vector3(location.X + xOffset, location.Y + yOffset, location.Z - zOffset); Projectiles.Add(new Projectile(tLocation, spell, direction, angle, owner)); xOffset = -(spell.ProjectileSpacing * 0.5f) * (Single)Math.Sin(direction - MathHelper.RightAngleRadians); yOffset = (spell.ProjectileSpacing * 0.5f) * (Single)Math.Cos(direction - MathHelper.RightAngleRadians); tLocation = new Vector3(location.X + xOffset, location.Y + yOffset, location.Z - zOffset); Projectiles.Add(new Projectile(tLocation, spell, direction, angle, owner)); tLocation = new Vector3(location.X, location.Y, location.Z); Projectiles.Add(new Projectile(tLocation, spell, direction, angle, owner)); break; } } }
public ArenaTeam GetCarriedOrbTeam(ArenaPlayer arenaPlayer) { return(this.FirstOrDefault(arenaTeam => arenaPlayer == arenaTeam.ShrineOrb.OrbPlayer)); }
public Boolean IsPlayerCarryingOrb(ArenaPlayer arenaPlayer) { return(this.Any(arenaTeam => arenaPlayer == arenaTeam.ShrineOrb.OrbPlayer)); }
public ArenaPlayer(Player player, Arena arena) { lock (arena.SyncRoot) { WorldPlayer = player; OwnerArena = arena; lock (OwnerArena.ArenaPlayers.SyncRoot) { OwnerArena.ArenaPlayers.ForEach(delegate(ArenaPlayer arenaPlayer) { if (arenaPlayer.WorldPlayer == player) { OwnerArena.PlayerLeft(arenaPlayer); } }); } if ((ArenaPlayerId = OwnerArena.ArenaPlayers.GetAvailablePlayerId()) == 0) { return; } WorldPlayer.PingInitialized = false; WorldPlayer.TableId = 0; WorldPlayer.ActiveArena = arena; WorldPlayer.LastArenaId = arena.ArenaId; ActiveTeam = OwnerArena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.NoTeams) ? Team.Neutral : WorldPlayer.ActiveTeam; ActiveCharacter = player.ActiveCharacter; _previousLocation = new Vector3(0, 0, 0); _previousLocationTick = 0; Location = new Vector3(0, 0, 0); Direction = 0; CurrentGridBlock = null; CurrentGridBlockFlagData = new GridBlockFlagData(); InCombatTime = new Interval(7000, false); NonFriendlyWallTime = new Interval(1000, false); FriendlyWallTime = new Interval(1000, false); ValhallaProtection = new Interval(2000, false); ActiveTime = new Interval(0, false); BoundingBox = new OrientedBoundingBox(Location, PlayerStandingSize, 0.0f); StatusFlags = StatusFlag.None; SpecialFlags = SpecialFlag.None; Effects = new Effect[21]; MoveSpeed = 0; StateReceivedCount = 0; LastStateReceived = NativeMethods.PerformanceCount; LastAttacker = null; JoinTime = DateTime.Now; HasFliedSinceHackDetect = false; MaxHp = player.ActiveCharacter.MaxHealth; if (ActiveShrine == null) { if (ActiveTeam == Team.Neutral) { CurrentHp = MaxHp; } else { return; } } else { if (ActiveShrine.IsDisabled) { Network.Send(WorldPlayer, GamePacket.Outgoing.Player.SendPlayerId(this)); Thread.Sleep(500); Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.SuccessfulArenaEntry()); Thread.Sleep(100); OwnerArena.ArenaKickPlayer(this); return; } CurrentHp = ActiveShrine.IsDead ? (Int16)0 : MaxHp; } Network.Send(WorldPlayer, GamePacket.Outgoing.Player.SendPlayerId(this)); if (!WorldPlayer.Flags.HasFlag(PlayerFlag.Hidden)) { Network.SendTo(WorldPlayer, GamePacket.Outgoing.World.PlayerLeave(WorldPlayer), Network.SendToType.Tavern, false); Network.SendTo(WorldPlayer, GamePacket.Outgoing.World.PlayerJoin(WorldPlayer), Network.SendToType.Tavern, false); Network.SendToArena(this, GamePacket.Outgoing.Arena.PlayerJoin(this), false); } if (OwnerArena.ArenaPlayerHistory.FindByCharacterId(WorldPlayer.ActiveCharacter.CharacterId) == null) { OwnerArena.ArenaPlayerHistory.Add(this); } WorldPlayer.ActiveArenaPlayer = this; OwnerArena.ArenaPlayers.Add(this); OwnerArena.AveragePlayerLevel = OwnerArena.ArenaPlayers.GetAveragePlayerLevel(); } lock (OwnerArena.SyncRoot) { Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.UpdateShrinePoolState(arena)); } Thread.Sleep(500); Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.SuccessfulArenaEntry()); Thread.Sleep(100); lock (OwnerArena.SyncRoot) { for (Int32 i = 0; i < OwnerArena.Signs.Count; i++) { Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.CastSign(this, OwnerArena.Signs[i].RawData)); } } Thread.Sleep(100); lock (OwnerArena.SyncRoot) { for (Int32 i = 0; i < OwnerArena.Walls.Count; i++) { Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.CastWall(arena.Walls[i].RawData)); } } Thread.Sleep(100); lock (OwnerArena.SyncRoot) { for (Int32 i = 0; i < arena.Grid.Triggers.Count; i++) { Network.Send(WorldPlayer, GamePacket.Outgoing.Arena.ActivatedTrigger(OwnerArena.Grid.Triggers[i])); } } if (OwnerArena.Ruleset.Mode == ArenaRuleset.ArenaMode.Custom) { Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("This arena has the following rules: {0}.", arena.Ruleset.Rules))); } if (OwnerArena.Ruleset.Rules.HasFlag(ArenaRuleset.ArenaRule.ExpEvent)) { Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("If your team wins this match, you will earn {0:0,0} experience.", (WorldPlayer.Flags.HasFlag(PlayerFlag.MagestormPlus) ? OwnerArena.EventExp * 2f : OwnerArena.EventExp)))); } Network.Send(WorldPlayer, GamePacket.Outgoing.System.DirectTextMessage(WorldPlayer, String.Format("This arena currently has an EXP bonus of {0}%.", ((arena.Grid.ExpBonus + (Properties.Settings.Default.ExpMultiplier - 1.0f) + (WorldPlayer.Flags.HasFlag(PlayerFlag.MagestormPlus) ? 0.2f : 0.0f)) * 100)))); }