private void Awake() { DontDestroyOnLoad(gameObject); Random r = new Random(); _cachedServerState = new ServerState(); _cachedShootData = new ShootPacket(); _userName = Environment.MachineName + " " + r.Next(100000); LogicTimer = new LogicTimer(OnLogicUpdate); _writer = new NetDataWriter(); _playerManager = new ClientPlayerManager(this); _shootsPool = new GamePool <ShootEffect>(ShootEffectContructor, 100); _packetProcessor = new NetPacketProcessor(); _packetProcessor.RegisterNestedType((w, v) => w.Put(v), reader => reader.GetVector2()); _packetProcessor.RegisterNestedType <PlayerState>(); _packetProcessor.SubscribeReusable <PlayerJoinedPacket>(OnPlayerJoined); _packetProcessor.SubscribeReusable <JoinAcceptPacket>(OnJoinAccept); _packetProcessor.SubscribeReusable <PlayerLeavedPacket>(OnPlayerLeaved); _netManager = new NetManager(this) { AutoRecycle = true, IPv6Enabled = IPv6Mode.Disabled }; _netManager.Start(); }
private void ActivateAbilityShoot(RealmTime time, Ability ability, Position target) { double arcGap = ability.ArcGap * Math.PI / 180; double startAngle = Math.Atan2(target.Y - Y, target.X - X) - (ability.NumProjectiles - 1) / 2 * arcGap; ProjectileDesc prjDesc = ability.Projectiles[0]; //Assume only one var batch = new Packet[ability.NumProjectiles]; for (int i = 0; i < ability.NumProjectiles; i++) { Projectile proj = CreateProjectile(prjDesc, ObjectDesc.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, new Position { X = X, Y = Y }, (float)(startAngle + arcGap * i), 1); Owner.EnterWorld(proj); fames.Shoot(proj); batch[i] = new ShootPacket { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = ability.AbilityType, Position = new Position { X = X, Y = Y }, Angle = proj.Angle, Damage = (short)proj.Damage, FromAbility = true }; } BroadcastSync(batch, p => this.Dist(p) < 25); }
public override void OnShoot(BasePlayer from, Vector2 to, BasePlayer hit) { var serverPlayer = (ServerPlayer)from; ShootPacket sp = new ShootPacket { FromPlayer = serverPlayer.Id, CommandId = serverPlayer.LastProcessedCommandId, ServerTick = _serverLogic.Tick, Hit = to }; _serverLogic.SendShoot(ref sp); }
private void Fire() { if (PlayerInputHandler.GetFireInput() && CanFire && PlayerStats.IsMagazineNotEmpty() && !IsReloading) { HitInfo = new RaycastHit(); if (Physics.Raycast(Camera.transform.position, Camera.transform.forward, out HitInfo)) { ShootParticle.Play(); SoundManager.FireSound(); PlayerStats.MinusAmmo(); Debug.Log(HitInfo.transform.name); if (HitInfo.transform.name == "Enemy(Clone)") { GameObject Target = HitInfo.transform.gameObject; EnemyPlayerCharacterController EnemyController = Target.GetComponent <EnemyPlayerCharacterController>(); EnemyPlayerInfo EnemyInfo = EnemyController.EnemyInfo; Debug.Log("Попаданиe по игроку: " + EnemyInfo.ClientId + " c ником " + EnemyInfo.Nickname); ShootPacket ShootPacket = new ShootPacket(EnemyInfo.ClientId); NetworkManager.SendPacket(ShootPacket); } else { ShootPacket ShootPacket = new ShootPacket(0); NetworkManager.SendPacket(ShootPacket); } CanFire = false; StartCoroutine(LockFire(0.1f)); } } else if (PlayerInputHandler.GetReloadInput() && PlayerStats.IsMagazineNotFull() && !IsReloading) { IsReloading = true; SoundManager.ReloadSound(); CanFire = false; StartCoroutine(LockFireForReloading(2f)); } }
void Activate(RealmTime time, Item item, Position target) { MP -= item.MpCost; foreach (var eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { var prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; uint s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); FameCounter.Shoot(proj); batch[i] = new ShootPacket() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0xFFFF00AA) }; BroadcastSync(batch, p => this.Dist(p) < 25); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Boost[idx] += s; UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] -= s; UpdateCount++; })); BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; this.AOE(eff.Range / 2, true, player => { (player as Player).Boost[idx] += s; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { (player as Player).Boost[idx] -= s; player.UpdateCount++; })); }); BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, p => this.Dist(p) < 25); } break; case ActivateEffects.ConditionEffectSelf: { ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, p => this.Dist(p) < 25); } break; case ActivateEffects.ConditionEffectAura: { this.AOE(eff.Range / 2, true, player => { player.ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); }); uint color = 0xffffffff; if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging) { color = 0xffff0000; } BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position() { X = eff.Range / 2 } }, p => this.Dist(p) < 25); } break; case ActivateEffects.Heal: { List <Packet> pkts = new List <Packet>(); ActivateHealHp(this, eff.Amount, pkts); BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.HealNova: { List <Packet> pkts = new List <Packet>(); this.AOE(eff.Range / 2, true, player => { ActivateHealHp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.Magic: { List <Packet> pkts = new List <Packet>(); ActivateHealMp(this, eff.Amount, pkts); BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.MagicNova: { List <Packet> pkts = new List <Packet>(); this.AOE(eff.Range / 2, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; BroadcastSync(new Packet[] { new GotoPacket() { ObjectId = Id, Position = new Position() { X = X, Y = Y } }, new ShowEffectPacket() { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position() { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, p => this.Dist(p) < 25); } break; case ActivateEffects.VampireBlast: { List <Packet> pkts = new List <Packet>(); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFF0000) }); pkts.Add(new AOEPacket() { Position = target, Radius = eff.Radius, Damage = (ushort)eff.TotalDamage, EffectDuration = 0, Effects = 0, OriginType = item.ObjectType }); int totalDmg = 0; var enemies = new List <Enemy>(); Owner.AOE(target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); var players = new List <Player>(); this.AOE(eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); Random rand = new System.Random(); for (int i = 0; i < 5; i++) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) }); } BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.Trap: { BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0xff9000ff), TargetId = Id, PosA = target }, p => this.Dist(p) < 25); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Trap trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { List <Packet> pkts = new List <Packet>(); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position() { X = target.X + 3, Y = target.Y }, Color = new ARGB(0xffffffff) }); Owner.AOE(target, 3, false, enemy => { if (enemy.HasConditionEffect(ConditionEffects.StasisImmune)) { pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), Text = "Immune" }); } else if (!enemy.HasConditionEffect(ConditionEffects.Stasis)) { enemy.ApplyConditionEffect( new ConditionEffect() { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }, new ConditionEffect() { Effect = ConditionEffectIndex.Confused, DurationMS = eff.DurationMS } ); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 } ); } )); pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), Text = "Stasis" }); } }); BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.Decoy: { var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.Lightning: { Enemy start = null; double angle = Math.Atan2(target.Y - Y, target.X - X); double diff = Math.PI / 3; Owner.AOE(target, 6, false, enemy => { if (!(enemy is Enemy)) { return; } var x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) { break; } Enemy current = start; Enemy[] targets = new Enemy[eff.MaxTargets]; for (int i = 0; i < targets.Length; i++) { targets[i] = current; Enemy next = current.GetNearestEntity(8, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && this.Dist(enemy) <= 6) as Enemy; if (next == null) { break; } else { current = next; } } List <Packet> pkts = new List <Packet>(); for (int i = 0; i < targets.Length; i++) { if (targets[i] == null) { break; } Entity prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) { targets[i].ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); } pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = new ARGB(0xffff0088), PosA = new Position() { X = targets[i].X, Y = targets[i].Y }, PosB = new Position() { X = 350 } }); } BroadcastSync(pkts, p => this.Dist(p) < 25); } break; case ActivateEffects.PoisonGrenade: { BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0xffddff00), TargetId = Id, PosA = target }, p => this.Dist(p) < 25); Placeholder x = new Placeholder(Manager, 1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position() { X = eff.Radius } }, null); List <Enemy> enemies = new List <Enemy>(); Owner.AOE(target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } break; case ActivateEffects.RemoveNegativeConditions: { this.AOE(eff.Range / 2, true, player => { ApplyConditionEffect(NegativeEffs); }); BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, p => this.Dist(p) < 25); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); BroadcastSync(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, p => this.Dist(p) < 25); } break; case ActivateEffects.IncrementStat: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } Stats[idx] += eff.Amount; int limit = int.Parse(Manager.GameData.ObjectTypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)).Attribute("max").Value); if (Stats[idx] > limit) { Stats[idx] = limit; } UpdateCount++; } break; case ActivateEffects.Dye: { if (item.Texture1 != 0) { Texture1 = item.Texture1; } if (item.Texture2 != 0) { Texture2 = item.Texture2; } SaveToCharacter(); } break; case ActivateEffects.Create: { ushort objType; if (!Manager.GameData.IdToObjectType.TryGetValue(eff.Id, out objType) || !Manager.GameData.Portals.ContainsKey(objType)) { break; } Entity entity = Resolve(Manager, objType); World w = Manager.GetWorld(Owner.Id); int TimeoutTime = Manager.GameData.Portals[objType].TimeoutTime; string DungName = Manager.GameData.Portals[objType].DungeonName; ARGB c = new ARGB(0x00FF00); entity.Move(X, Y); w.EnterWorld(entity); w.BroadcastPacket(new NotificationPacket { Color = c, Text = DungName + " opened by " + Client.Account.Name, ObjectId = Client.Player.Id }, null); w.BroadcastPacket(new TextPacket { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + Client.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => { try { w.LeaveWorld(entity); } catch (Exception ex) { log.ErrorFormat("Couldn't despawn portal.\n{0}", ex); } })); } break; } } }
public void SendShootPacket(uint objectID, bool isReliable = false) { ShootPacket shootPacket = new ShootPacket(); SendPacket(shootPacket, objectID, isReliable); }
void Activate(RealmTime time, Item item, Position target) { MP -= item.MpCost; foreach (var eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { var prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; uint s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); fames.Shoot(proj); batch[i] = new ShootPacket() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0x000099) //was 0xFFFF00AA }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.InvertNova: //inverted spell bomb behavior. Spellbombs start on the outside and move into a center point. Good for older computers that cant do perfect spellbombs { var prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; //calls the shoot packet uint s = Random.CurrentSeed; //seeds the effects and position of effects Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) //this is how many bullets are shot, atm i can't get anymore or any less shots... { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), //We can't have negative Pi? time.tickTimes, target, (float)(i + (i * Math.PI) / 4)); //This is what divides the shots from the nova, here we can make it inverted Owner.EnterWorld(proj); //the line above was (i * (Math.PI + 2) / 20)); //Took out Math.PI and put in the actual few numbers in pi to make it easier to use. However if you increase the range on spellbomb shots eventually the shots will become uneven because not using Math.PI; Math.PI uses EVERY infinite number, making each spellbomb 99.99999999999% accurate. fames.Shoot(proj); batch[i] = new ShootPacket() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, //This plays a part of the positioning of the bullets Angle = proj.Angle, //And THIS helps angle all of the bullets correctly, but you can prolly leave it as proj.Angle Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0x00500) //was 0xFFFF00AA }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Boost[idx] += s; UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] -= s; UpdateCount++; })); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Behavior.AOE(Owner, this, eff.Range / 2, true, player => { (player as Player).Boost[idx] += s; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { (player as Player).Boost[idx] -= s; player.UpdateCount++; })); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), //was 0xffffffff PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.ConditionEffectSelf: { ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), //was 0xffffffff PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.ConditionEffectAura: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { player.ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); }); uint color = 0xffffffff; if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging) { color = 0xffff0000; } Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.Heal: { List <Packet> pkts = new List <Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.HealNova: { List <Packet> pkts = new List <Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealHp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Magic: { List <Packet> pkts = new List <Packet>(); ActivateHealMp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.MagicNova: { List <Packet> pkts = new List <Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket() { ObjectId = Id, Position = new Position() { X = X, Y = Y } }, new ShowEffectPacket() { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position() { X = X, Y = Y }, Color = new ARGB(0x000000) //was 0xFFFFFFFF } }, null); } break; case ActivateEffects.VampireBlast: { List <Packet> pkts = new List <Packet>(); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFFFF) //was 0xFFFF0000 }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFFFF), //was 0xFFFF0000 TargetId = Id, PosA = target, PosB = new Position() { X = target.X + eff.Radius, Y = target.Y } }); int totalDmg = 0; var enemies = new List <Enemy>(); Behavior.AOE(Owner, target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); var players = new List <Player>(); Behavior.AOE(Owner, this, eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); Random rand = new System.Random(); for (int i = 0; i < 5; i++) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) //was 0xffffffff }); } if (enemies.Count > 0) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0Xffffffff) }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Trap: { ARGB effColor = new ARGB(0x6600CC); //was 0xFF9000FF if (eff.Color != null) { effColor = new ARGB((uint)eff.Color); } Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = effColor, TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Trap trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { List <Packet> pkts = new List <Packet>(); ARGB effColor = new ARGB(0xffffffff); if (eff.Color != null) { effColor = new ARGB((uint)eff.Color); } pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position() { X = target.X + 3, Y = target.Y }, Color = effColor }); Behavior.AOE(Owner, target, 3, false, enemy => { if (enemy.HasConditionEffect(ConditionEffects.StasisImmune)) { pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), //was 0xff00ff00 Text = "Immune" }); } else if (!enemy.HasConditionEffect(ConditionEffects.Stasis)) { enemy.ApplyConditionEffect( new ConditionEffect() { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }, new ConditionEffect() { Effect = ConditionEffectIndex.Confused, DurationMS = eff.DurationMS } ); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 } ); } )); pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), //was 0xffff0000 Text = "Stasis" }); } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Decoy: { var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.MultiDecoy: { for (var i = 0; i < eff.Amount; i++) { var decoy = Decoy.DecoyRandom(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } } break; case ActivateEffects.Lightning: { Enemy start = null; double angle = Math.Atan2(target.Y - Y, target.X - X); double diff = Math.PI / 3; Behavior.AOE(Owner, target, 6, false, enemy => { if (!(enemy is Enemy)) { return; } var x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) { break; } Enemy current = start; Enemy[] targets = new Enemy[eff.MaxTargets]; for (int i = 0; i < targets.Length; i++) { targets[i] = current; float dist = 8; Enemy next = Behavior.GetNearestEntity(current, ref dist, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && Behavior.Dist(this, enemy) <= 6) as Enemy; if (next == null) { break; } else { current = next; } } List <Packet> pkts = new List <Packet>(); for (int i = 0; i < targets.Length; i++) { if (targets[i] == null) { break; } Entity prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) { targets[i].ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); } ARGB shotColor = new ARGB(0x000000); //was 0xffff0088 if (eff.Color != null) { shotColor = new ARGB((uint)eff.Color); } pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = shotColor, PosA = new Position() { X = targets[i].X, Y = targets[i].Y }, PosB = new Position() { X = 350 } }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PoisonGrenade: { try { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0x006600), //was 0xffddff00 TargetId = Id, PosA = target }, null); Placeholder x = new Placeholder(1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { try { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position() { X = eff.Radius } }, null); } catch { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Out.WriteLine("Crash halted - Nobody likes death..."); Console.ForegroundColor = ConsoleColor.White; } List <Enemy> enemies = new List <Enemy>(); Behavior.AOE(world, target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } catch { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Out.WriteLine("Crash halted - Poison grenade??"); Console.ForegroundColor = ConsoleColor.White; } } break; case ActivateEffects.RemoveNegativeConditions: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ApplyConditionEffect(NegativeEffs); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.IncrementStat: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } Stats[idx] += eff.Amount; int limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)).Attribute("max").Value); if (Stats[idx] > limit) { Stats[idx] = limit; } UpdateCount++; } break; case ActivateEffects.Create: //this is a portal { short objType; if (!XmlDatas.IdToType.TryGetValue(eff.Id, out objType) || !XmlDatas.PortalDescs.ContainsKey(objType)) { break; // object not found, ignore } var entity = Entity.Resolve(objType); entity.Move(X, Y); int TimeoutTime = XmlDatas.PortalDescs[objType].TimeoutTime; string DungName = XmlDatas.PortalDescs[objType].DungeonName; Owner.EnterWorld(entity); ARGB c; c.A = 0; c.B = 91; c.R = 233; c.G = 176; psr.SendPacket(new NotificationPacket() { Color = c, Text = DungName + " opened by " + psr.Account.Name, ObjectId = psr.Player.Id }); World w = RealmManager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope w.BroadcastPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + psr.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation { Console.WriteLine("Couldn't despawn portal."); } })); } break; case ActivateEffects.Dye: { if (item.Texture1 != 0) { this.Texture1 = item.Texture1; } if (item.Texture2 != 0) { this.Texture2 = item.Texture2; } this.SaveToCharacter(); } break; case ActivateEffects.ShurikenAbility: { World w = RealmManager.GetWorld(Owner.Id); ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.Speedy, DurationMS = eff.DurationMS }); w.Timers.Add(new WorldTimer(eff.DurationMS * 1000, (world, t) => { try { ActivateShoot(time, item, target); } catch { } })); } break; case ActivateEffects.TomeDamage: { List <Packet> pkts = new List <Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, false, enemy => { (enemy as Enemy).Damage(this, time, (int)this.statsMgr.GetAttackDamage(eff.TotalDamage, eff.TotalDamage), false, new ConditionEffect[0]); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xFF00FF00), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Mushroom: { World w = RealmManager.GetWorld(Owner.Id); Size = eff.Amount; UpdateCount++; w.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { try { Size = 100; UpdateCount++; } catch { } })); } break; /*case ActivateEffects.PermaPet: //petcode * { * psr.Character.Pet = XmlDatas.IdToType[eff.ObjectId]; * GivePet(XmlDatas.IdToType[eff.ObjectId]); * UpdateCount++; * } break; * case ActivateEffects.Pet: //Drakes*/ case ActivateEffects.UnlockPortal: break; } } UpdateCount++; }
public void UseAbility(RealmTime time, int abilitySlot, Position target) { if (Ability[abilitySlot] == null) { return; } var ability = Ability[abilitySlot]; if (MP < ability.MpCost || AbilityCooldown[abilitySlot] != 0) { return; } MP -= ability.MpCost; AbilityCooldown[abilitySlot] = ability.Cooldown; foreach (ActivateEffect eff in ability.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { ProjectileDesc prjDesc = ability.Projectiles[0]; //Assume only one var batch = new Packet[21]; uint s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) { Projectile proj = CreateProjectile(prjDesc, ability.AbilityType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); fames.Shoot(proj); batch[i] = new ShootPacket { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = ability.AbilityType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage, FromAbility = true }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0xFFFF00AA) }; BroadcastSync(batch, p => this.Dist(p) < 25); } break; case ActivateEffects.Shoot: { ActivateAbilityShoot(time, ability, target); } break; } } UpdateCount++; }
public void SendShoot(ref ShootPacket sp) { _netManager.SendToAll(WriteSerializable(PacketType.Shoot, sp), DeliveryMethod.ReliableUnordered); }
void Activate(RealmTime time, Item item, Position target) { MP -= item.MpCost; foreach (var eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { var prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; uint s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); fames.Shoot(proj); batch[i] = new ShootPacket() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0xFFFF00AA) }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Boost[idx] += s; UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] -= s; UpdateCount++; })); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Behavior.AOE(Owner, this, eff.Range / 2, true, player => { (player as Player).Boost[idx] += s; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { (player as Player).Boost[idx] -= s; player.UpdateCount++; })); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.ConditionEffectSelf: { ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.ConditionEffectAura: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { player.ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); }); uint color = 0xffffffff; if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging) { color = 0xffff0000; } Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.Heal: { List <Packet> pkts = new List <Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.HealNova: { List <Packet> pkts = new List <Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealHp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Magic: { List <Packet> pkts = new List <Packet>(); ActivateHealMp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.MagicNova: { List <Packet> pkts = new List <Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket() { ObjectId = Id, Position = new Position() { X = X, Y = Y } }, new ShowEffectPacket() { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position() { X = X, Y = Y }, Color = new ARGB(0xFFFFFFFF) } }, null); } break; case ActivateEffects.VampireBlast: { List <Packet> pkts = new List <Packet>(); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFF0000) }); pkts.Add(new AOEPacket() { Position = target, Radius = eff.Radius, Damage = (ushort)eff.TotalDamage, EffectDuration = 0, Effects = 0, OriginType = item.ObjectType }); int totalDmg = 0; var enemies = new List <Enemy>(); Behavior.AOE(Owner, target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); var players = new List <Player>(); Behavior.AOE(Owner, this, eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); Random rand = new System.Random(); for (int i = 0; i < 5; i++) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Trap: { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0xff9000ff), TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Trap trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { List <Packet> pkts = new List <Packet>(); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position() { X = target.X + 3, Y = target.Y }, Color = new ARGB(0xffffffff) }); Behavior.AOE(Owner, target, 3, false, enemy => { if (enemy.HasConditionEffect(ConditionEffects.StasisImmune)) { pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), Text = "Immune" }); } else if (!enemy.HasConditionEffect(ConditionEffects.Stasis)) { enemy.ApplyConditionEffect( new ConditionEffect() { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }, new ConditionEffect() { Effect = ConditionEffectIndex.Confused, DurationMS = eff.DurationMS } ); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 } ); } )); pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), Text = "Stasis" }); } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Decoy: { var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.Lightning: { Enemy start = null; double angle = Math.Atan2(target.Y - Y, target.X - X); double diff = Math.PI / 3; Behavior.AOE(Owner, target, 6, false, enemy => { if (!(enemy is Enemy)) { return; } var x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) { break; } Enemy current = start; Enemy[] targets = new Enemy[eff.MaxTargets]; for (int i = 0; i < targets.Length; i++) { targets[i] = current; float dist = 8; Enemy next = Behavior.GetNearestEntity(current, ref dist, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && Behavior.Dist(this, enemy) <= 6) as Enemy; if (next == null) { break; } else { current = next; } } List <Packet> pkts = new List <Packet>(); for (int i = 0; i < targets.Length; i++) { if (targets[i] == null) { break; } Entity prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) //Start of the code made by ossimc82 { targets[i].ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); //End of the code made by ossimc82 } pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = new ARGB(0xffff0088), PosA = new Position() { X = targets[i].X, Y = targets[i].Y }, PosB = new Position() { X = 350 } }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PoisonGrenade: { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0xffddff00), TargetId = Id, PosA = target }, null); Placeholder x = new Placeholder(1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position() { X = eff.Radius } }, null); List <Enemy> enemies = new List <Enemy>(); Behavior.AOE(world, target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } break; case ActivateEffects.RemoveNegativeConditions: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ApplyConditionEffect(NegativeEffs); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.IncrementStat: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } Stats[idx] += eff.Amount; int limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)).Attribute("max").Value); if (Stats[idx] > limit) { Stats[idx] = limit; } UpdateCount++; } break; case ActivateEffects.Pet: case ActivateEffects.Create: //portals { short objType; if (!XmlDatas.IdToType.TryGetValue(eff.Id, out objType)) { /*!XmlDatas.PortalDescs.ContainsKey(objType))*/ break; // object not found, ignore } var entity = Entity.Resolve(objType); entity.Move(X, Y); int TimeoutTime = 20; //XmlDatas.PortalDescs[objType].TimeoutTime; var dungeonname = 0; Owner.EnterWorld(entity); ARGB c; c.A = 0; c.B = 0; c.G = 255; c.R = 0; //psr.SendPacket(new BuyResultPacket() //{ // Color = c, // Text = "Opened by " + psr.Account.Name //}); psr.SendPacket(new NotificationPacket() { Color = c, Text = "Opened by " + psr.Account.Name, ObjectId = psr.Player.Id }); World w = RealmManager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope w.BroadcastPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "", Text = "Opened by " + psr.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation { Console.WriteLine("Couldn't despawn portal."); } })); } break; case ActivateEffects.UnlockPortal: { break; } case ActivateEffects.Dye: { if (item.Texture1 != "0") { psr.Player.Texture1 = db.dyes_hextointmod.hextoint(item.Texture1.ToString(), item.Cloth); } if (item.Texture2 != "0") { psr.Player.Texture2 = db.dyes_hextointmod.hextoint(item.Texture2.ToString(), item.Cloth); } this.SaveToCharacter(); UpdateCount++; } break; } } UpdateCount++; }
protected override void OnReceive(int size, byte opcode, byte[] packet) { InPacket in_packet = InPacket.Parse((Opcode)opcode, packet); switch ((Opcode)opcode) { case Opcode.FAILURE: if (this.OnFailure != null) { FailurePacket failure = (FailurePacket)in_packet; this.OnFailure(failure.ErrorId, failure.ErrorDescription); } break; case Opcode.CREATE_SUCCESS: if (this.OnCreateSuccess != null) { CreateSuccessPacket create_success = (CreateSuccessPacket)in_packet; this.OnCreateSuccess(create_success.ObjectId, create_success.CharId); } break; case Opcode.TEXT: if (this.OnText != null) { TextPacket text = (TextPacket)in_packet; this.OnText(text.Name, text.ObjectId, text.ObjectType, text.Texture1Id, text.Texture2Id, text.NumStars, text.Recipient, text.Text, text.CleanText); } break; case Opcode.SHOOT: if (this.OnShoot != null) { ShootPacket shoot = (ShootPacket)in_packet; this.OnShoot(shoot.BulletId, shoot.OwnerId, shoot.ContainerType, shoot.StartingPosition, shoot.Angle, shoot.Damage); } break; case Opcode.DAMAGE: if (this.OnDamage != null) { DamagePacket damage = (DamagePacket)in_packet; this.OnDamage(damage.TargetId, damage.ConditionEffect, damage.DamageAmount, damage.BulletId, damage.ObjectId); } break; case Opcode.UPDATE: if (this.OnUpdate != null) { UpdatePacket update = (UpdatePacket)in_packet; this.OnUpdate(update.Tiles, update.NewObjects, update.Drops); } break; case Opcode.NOTIFICATION: if (this.OnNotification != null) { NotificationPacket notification = (NotificationPacket)in_packet; this.OnNotification(notification.ObjectId, notification.Text); } break; case Opcode.NEW_TICK: if (this.OnNewTick != null) { NewTickPacket new_tick = (NewTickPacket)in_packet; this.OnNewTick(new_tick.TickId, new_tick.TickTime, new_tick.Statuses); } break; case Opcode.MAPINFO: if (this.OnMapInfo != null) { MapInfoPacket map_info = (MapInfoPacket)in_packet; this.OnMapInfo(map_info.Width, map_info.Height, map_info.Name, map_info.FP, map_info.Background, map_info.AllowPlayerTeleport, map_info.ShowDisplays, map_info.ExtraXml); } break; } }
void Activate(RealmTime time, Item item, Position target) { MP -= item.MpCost; foreach (var eff in item.ActivateEffects) { switch (eff.Effect) { case ActivateEffects.BulletNova: { var prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; uint s = Random.CurrentSeed; Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), time.tickTimes, target, (float)(i * (Math.PI * 2) / 20)); Owner.EnterWorld(proj); fames.Shoot(proj); batch[i] = new ShootPacket() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, Angle = proj.Angle, Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0x000099) //was 0xFFFF00AA }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.InvertNova: //inverted spell bomb behavior. Spellbombs start on the outside and move into a center point. Good for older computers that cant do perfect spellbombs { var prjDesc = item.Projectiles[0]; //Assume only one Packet[] batch = new Packet[21]; //calls the shoot packet uint s = Random.CurrentSeed; //seeds the effects and position of effects Random.CurrentSeed = (uint)(s * time.tickTimes); for (int i = 0; i < 20; i++) //this is how many bullets are shot, atm i can't get anymore or any less shots... { Projectile proj = CreateProjectile(prjDesc, item.ObjectType, (int)statsMgr.GetAttackDamage(prjDesc.MinDamage, prjDesc.MaxDamage), //We can't have negative Pi? time.tickTimes, target, (float)(i + (i * Math.PI) / 4)); //This is what divides the shots from the nova, here we can make it inverted Owner.EnterWorld(proj); //the line above was (i * (Math.PI + 2) / 20)); //Took out Math.PI and put in the actual few numbers in pi to make it easier to use. However if you increase the range on spellbomb shots eventually the shots will become uneven because not using Math.PI; Math.PI uses EVERY infinite number, making each spellbomb 99.99999999999% accurate. fames.Shoot(proj); batch[i] = new ShootPacket() { BulletId = proj.ProjectileId, OwnerId = Id, ContainerType = item.ObjectType, Position = target, //This plays a part of the positioning of the bullets Angle = proj.Angle, //And THIS helps angle all of the bullets correctly, but you can prolly leave it as proj.Angle Damage = (short)proj.Damage }; } Random.CurrentSeed = s; batch[20] = new ShowEffectPacket() { EffectType = EffectType.Trail, PosA = target, TargetId = Id, Color = new ARGB(0x00500) //was 0xFFFF00AA }; Owner.BroadcastPackets(batch, null); } break; case ActivateEffects.Shoot: { ActivateShoot(time, item, target); } break; case ActivateEffects.StatBoostSelf: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Boost[idx] += s; UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { Boost[idx] -= s; UpdateCount++; })); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Potion, TargetId = Id, Color = new ARGB(0xffffffff) }, null); } break; case ActivateEffects.StatBoostAura: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } int s = eff.Amount; Behavior.AOE(Owner, this, eff.Range / 2, true, player => { (player as Player).Boost[idx] += s; player.UpdateCount++; Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { (player as Player).Boost[idx] -= s; player.UpdateCount++; })); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), //was 0xffffffff PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.ConditionEffectSelf: { ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), //was 0xffffffff PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.ConditionEffectAura: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { player.ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = eff.DurationMS }); }); uint color = 0xffffffff; if (eff.ConditionEffect.Value == ConditionEffectIndex.Damaging) color = 0xffff0000; Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(color), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.Heal: { List<Packet> pkts = new List<Packet>(); ActivateHealHp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.HealNova: { List<Packet> pkts = new List<Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealHp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Magic: { List<Packet> pkts = new List<Packet>(); ActivateHealMp(this, eff.Amount, pkts); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.MagicNova: { List<Packet> pkts = new List<Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ActivateHealMp(player as Player, eff.Amount, pkts); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Teleport: { Move(target.X, target.Y); UpdateCount++; Owner.BroadcastPackets(new Packet[] { new GotoPacket() { ObjectId = Id, Position = new Position() { X = X, Y = Y } }, new ShowEffectPacket() { EffectType = EffectType.Teleport, TargetId = Id, PosA = new Position() { X = X, Y = Y }, Color = new ARGB(0x000000) //was 0xFFFFFFFF } }, null); } break; case ActivateEffects.VampireBlast: { List<Packet> pkts = new List<Packet>(); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Trail, TargetId = Id, PosA = target, Color = new ARGB(0xFFFFFF) //was 0xFFFF0000 }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Diffuse, Color = new ARGB(0xFFFFFF), //was 0xFFFF0000 TargetId = Id, PosA = target, PosB = new Position() { X = target.X + eff.Radius, Y = target.Y } }); int totalDmg = 0; var enemies = new List<Enemy>(); Behavior.AOE(Owner, target, eff.Radius, false, enemy => { enemies.Add(enemy as Enemy); totalDmg += (enemy as Enemy).Damage(this, time, eff.TotalDamage, false); }); var players = new List<Player>(); Behavior.AOE(Owner, this, eff.Radius, true, player => { players.Add(player as Player); ActivateHealHp(player as Player, totalDmg, pkts); }); Random rand = new System.Random(); for (int i = 0; i < 5; i++) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0xffffffff) //was 0xffffffff }); } if (enemies.Count > 0) { Enemy a = enemies[rand.Next(0, enemies.Count)]; Player b = players[rand.Next(0, players.Count)]; pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Flow, TargetId = b.Id, PosA = new Position() { X = a.X, Y = a.Y }, Color = new ARGB(0Xffffffff) }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Trap: { ARGB effColor = new ARGB(0x6600CC); //was 0xFF9000FF if (eff.Color != null) effColor = new ARGB((uint)eff.Color); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = effColor, TargetId = Id, PosA = target }, null); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { Trap trap = new Trap( this, eff.Radius, eff.TotalDamage, eff.ConditionEffect ?? ConditionEffectIndex.Slowed, eff.EffectDuration); trap.Move(target.X, target.Y); world.EnterWorld(trap); })); } break; case ActivateEffects.StasisBlast: { List<Packet> pkts = new List<Packet>(); ARGB effColor = new ARGB(0xffffffff); if (eff.Color != null) effColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Concentrate, TargetId = Id, PosA = target, PosB = new Position() { X = target.X + 3, Y = target.Y }, Color = effColor }); Behavior.AOE(Owner, target, 3, false, enemy => { if (enemy.HasConditionEffect(ConditionEffects.StasisImmune)) { pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xff00ff00), //was 0xff00ff00 Text = "Immune" }); } else if (!enemy.HasConditionEffect(ConditionEffects.Stasis)) { enemy.ApplyConditionEffect( new ConditionEffect() { Effect = ConditionEffectIndex.Stasis, DurationMS = eff.DurationMS }, new ConditionEffect() { Effect = ConditionEffectIndex.Confused, DurationMS = eff.DurationMS } ); Owner.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { enemy.ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.StasisImmune, DurationMS = 3000 } ); } )); pkts.Add(new NotificationPacket() { ObjectId = enemy.Id, Color = new ARGB(0xffff0000), //was 0xffff0000 Text = "Stasis" }); } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Decoy: { var decoy = new Decoy(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } break; case ActivateEffects.MultiDecoy: { for (var i = 0; i < eff.Amount; i++) { var decoy = Decoy.DecoyRandom(this, eff.DurationMS, statsMgr.GetSpeed()); decoy.Move(X, Y); Owner.EnterWorld(decoy); } } break; case ActivateEffects.Lightning: { Enemy start = null; double angle = Math.Atan2(target.Y - Y, target.X - X); double diff = Math.PI / 3; Behavior.AOE(Owner, target, 6, false, enemy => { if (!(enemy is Enemy)) return; var x = Math.Atan2(enemy.Y - Y, enemy.X - X); if (Math.Abs(angle - x) < diff) { start = enemy as Enemy; diff = Math.Abs(angle - x); } }); if (start == null) break; Enemy current = start; Enemy[] targets = new Enemy[eff.MaxTargets]; for (int i = 0; i < targets.Length; i++) { targets[i] = current; float dist = 8; Enemy next = Behavior.GetNearestEntity(current, ref dist, false, enemy => enemy is Enemy && Array.IndexOf(targets, enemy) == -1 && Behavior.Dist(this, enemy) <= 6) as Enemy; if (next == null) break; else current = next; } List<Packet> pkts = new List<Packet>(); for (int i = 0; i < targets.Length; i++) { if (targets[i] == null) break; Entity prev = i == 0 ? (Entity)this : targets[i - 1]; targets[i].Damage(this, time, eff.TotalDamage, false); if (eff.ConditionEffect != null) targets[i].ApplyConditionEffect(new ConditionEffect() { Effect = eff.ConditionEffect.Value, DurationMS = (int)(eff.EffectDuration * 1000) }); ARGB shotColor = new ARGB(0x000000); //was 0xffff0088 if (eff.Color != null) shotColor = new ARGB((uint)eff.Color); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.Lightning, TargetId = prev.Id, Color = shotColor, PosA = new Position() { X = targets[i].X, Y = targets[i].Y }, PosB = new Position() { X = 350 } }); } Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.PoisonGrenade: { try { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.Throw, Color = new ARGB(0x006600), //was 0xffddff00 TargetId = Id, PosA = target }, null); Placeholder x = new Placeholder(1500); x.Move(target.X, target.Y); Owner.EnterWorld(x); Owner.Timers.Add(new WorldTimer(1500, (world, t) => { try { Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, Color = new ARGB(0xffddff00), TargetId = x.Id, PosA = new Position() { X = eff.Radius } }, null); } catch { Console.ForegroundColor = ConsoleColor.DarkRed; Console.Out.WriteLine("Crash halted - Nobody likes death..."); Console.ForegroundColor = ConsoleColor.White; } List<Enemy> enemies = new List<Enemy>(); Behavior.AOE(world, target, eff.Radius, false, enemy => PoisonEnemy(enemy as Enemy, eff)); })); } catch { Console.ForegroundColor = ConsoleColor.DarkBlue; Console.Out.WriteLine("Crash halted - Poison grenade??"); Console.ForegroundColor = ConsoleColor.White; } } break; case ActivateEffects.RemoveNegativeConditions: { Behavior.AOE(Owner, this, eff.Range / 2, true, player => { ApplyConditionEffect(NegativeEffs); }); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = eff.Range / 2 } }, null); } break; case ActivateEffects.RemoveNegativeConditionsSelf: { ApplyConditionEffect(NegativeEffs); Owner.BroadcastPacket(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xffffffff), PosA = new Position() { X = 1 } }, null); } break; case ActivateEffects.IncrementStat: { int idx = -1; switch ((StatsType)eff.Stats) { case StatsType.MaximumHP: idx = 0; break; case StatsType.MaximumMP: idx = 1; break; case StatsType.Attack: idx = 2; break; case StatsType.Defense: idx = 3; break; case StatsType.Speed: idx = 4; break; case StatsType.Vitality: idx = 5; break; case StatsType.Wisdom: idx = 6; break; case StatsType.Dexterity: idx = 7; break; } Stats[idx] += eff.Amount; int limit = int.Parse(XmlDatas.TypeToElement[ObjectType].Element(StatsManager.StatsIndexToName(idx)).Attribute("max").Value); if (Stats[idx] > limit) Stats[idx] = limit; UpdateCount++; } break; case ActivateEffects.Create: //this is a portal { short objType; if (!XmlDatas.IdToType.TryGetValue(eff.Id, out objType) || !XmlDatas.PortalDescs.ContainsKey(objType)) break;// object not found, ignore var entity = Entity.Resolve(objType); entity.Move(X, Y); int TimeoutTime = XmlDatas.PortalDescs[objType].TimeoutTime; string DungName = XmlDatas.PortalDescs[objType].DungeonName; Owner.EnterWorld(entity); ARGB c; c.A = 0; c.B = 91; c.R = 233; c.G = 176; psr.SendPacket(new NotificationPacket() { Color = c, Text = DungName + " opened by " + psr.Account.Name, ObjectId = psr.Player.Id }); World w = RealmManager.GetWorld(Owner.Id); //can't use Owner here, as it goes out of scope w.BroadcastPacket(new TextPacket() { BubbleTime = 0, Stars = -1, Name = "", Text = DungName + " opened by " + psr.Account.Name }, null); w.Timers.Add(new WorldTimer(TimeoutTime * 1000, (world, t) => //default portal close time * 1000 { try { w.LeaveWorld(entity); } catch //couldn't remove portal, Owner became null. Should be fixed with RealmManager implementation { Console.WriteLine("Couldn't despawn portal."); } })); } break; case ActivateEffects.Dye: { if (item.Texture1 != 0) { this.Texture1 = item.Texture1; } if (item.Texture2 != 0) { this.Texture2 = item.Texture2; } this.SaveToCharacter(); } break; case ActivateEffects.ShurikenAbility: { World w = RealmManager.GetWorld(Owner.Id); ApplyConditionEffect(new ConditionEffect() { Effect = ConditionEffectIndex.Speedy, DurationMS = eff.DurationMS }); w.Timers.Add(new WorldTimer(eff.DurationMS * 1000, (world, t) => { try { ActivateShoot(time, item, target); } catch { } })); } break; case ActivateEffects.TomeDamage: { List<Packet> pkts = new List<Packet>(); Behavior.AOE(Owner, this, eff.Range / 2, false, enemy => { (enemy as Enemy).Damage(this, time, (int)this.statsMgr.GetAttackDamage(eff.TotalDamage, eff.TotalDamage), false, new ConditionEffect[0]); }); pkts.Add(new ShowEffectPacket() { EffectType = EffectType.AreaBlast, TargetId = Id, Color = new ARGB(0xFF00FF00), PosA = new Position() { X = eff.Range / 2 } }); Owner.BroadcastPackets(pkts, null); } break; case ActivateEffects.Mushroom: { World w = RealmManager.GetWorld(Owner.Id); Size = eff.Amount; UpdateCount++; w.Timers.Add(new WorldTimer(eff.DurationMS, (world, t) => { try { Size = 100; UpdateCount++; } catch { } })); } break; /*case ActivateEffects.PermaPet: //petcode { psr.Character.Pet = XmlDatas.IdToType[eff.ObjectId]; GivePet(XmlDatas.IdToType[eff.ObjectId]); UpdateCount++; } break; case ActivateEffects.Pet: //Drakes*/ case ActivateEffects.UnlockPortal: break; } } UpdateCount++; }