public Pet(RealmManager manager, PetItem petData, Player playerOwner) : base(manager, (ushort)petData.Type, true, true) { rand = new Random(); PlayerOwner = playerOwner; Info = petData; try { if (petData.InstanceId != -1) { FirstPetLevel = new PetLevel(AbilityType.First, Utils.GetEnumByName<Ability>(Utils.GetEnumName<Ability>(petData.Abilities[0].Type)), petData.Abilities[0].Points, petData.Abilities[0].Power, this); SecondPetLevel = new PetLevel(AbilityType.Second, Utils.GetEnumByName<Ability>(Utils.GetEnumName<Ability>(petData.Abilities[1].Type)), petData.Abilities[1].Points, petData.Abilities[1].Power, this); ThirdPetLevel = new PetLevel(AbilityType.Third, Utils.GetEnumByName<Ability>(Utils.GetEnumName<Ability>(petData.Abilities[2].Type)), petData.Abilities[2].Points, petData.Abilities[2].Power, this); Size = manager.GameData.TypeToPet[(ushort)petData.Type].Size; PetRarity = (Rarity)petData.Rarity; PetFamily = manager.GameData.TypeToPet[(ushort)petData.Type].PetFamily; MaximumLevel = petData.MaxAbilityPower; UpdateNeeded = true; } Skin = petData.SkinName; SkinId = petData.Skin; PetId = petData.InstanceId; IsPet = true; } catch (Exception e) { if (PlayerOwner != null) PlayerOwner.SendError( String.Format( "An error ocurred while loading your pet data, please report this to an Admin: {0}", e.Message)); } }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.Electric, true); } else { return; } if (level == null) { return; } double dist = GetElectricDistance(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) { continue; } if (Random.Next(0, 100) > level.Level) { break; } if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) { continue; } if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) { continue; } e.ApplyConditionEffect(new ConditionEffect { DurationMS = (int)(0.5 + level.Level * 0.035) * 1000, // This is not 100% accurate, but probably as close as production as you can get Effect = ConditionEffectIndex.Paralyzed }); e.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.ElectricFlashing, PosA = new Position { X = level.Level * 40 }, // Not sure TargetId = e.Id }, null); host.Owner.BroadcastPacket(new ShowEffectPacket { PosA = new Position { X = host.X, Y = host.Y }, EffectType = EffectType.ElectricBolts, TargetId = host.Id, }, null); e.Damage(null, time, GetElectricDamage(host as Pet, level), false, new ConditionEffect { DurationMS = (int)(0.5 + level.Level * 0.035) * 1000, Effect = ConditionEffectIndex.Paralyzed }); } cool = GetElectricCooldown(host as Pet, level) / host.Manager.TPS; } else { cool -= time.thisTickTimes; } state = cool; }
private double getDist(Pet host, PetLevel type) { return(2); }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.Savage, true); /*host.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.Flashing, * PosA = new Position { X = host.X, Y = host.Y }, * Color = new ARGB(0x00BFFF), * TargetId = host.Id, * }, null);*/ } else { return; } if (level == null) { return; } double dist = getDist(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { if (e.HasConditionEffect(ConditionEffectIndex.Invulnerable) || e.HasConditionEffect(ConditionEffectIndex.Invincible) || e.HasConditionEffect(ConditionEffectIndex.Stasis)) { continue; } if (Random.Next(0, 110) > level.Level) { break; } if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) { continue; } if (e.HasConditionEffect(ConditionEffectIndex.Invincible)) { continue; } e.ApplyConditionEffect(new ConditionEffect { DurationMS = level.Level * 25, Effect = ConditionEffectIndex.Curse }); host.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.Lightning, TargetId = e.Id, PosA = new Position { X = host.X, Y = host.Y }, PosB = new Position { X = e.X, Y = e.Y }, Color = new ARGB(0x00FFFFF0) }, null); /*host.Owner.Timers.Add(new WorldTimer(1000, (w, t) => * host.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.SavageEffect, * PosA = new Position { X = host.X, Y = host.Y }, * TargetId = host.Id * }, null) * ));*/ /*e.Owner.BroadcastPacket(new ShowEffectPacket * { * EffectType = EffectType.Flashing, * PosA = new Position { X = host.X, Y = host.Y }, * Color = new ARGB(0x00BFFF), * TargetId = host.Id, * }, null);*/ /*e.Damage(null, time, level.Level, true, new ConditionEffect * { * DurationMS = level.Level * 40, * Effect = ConditionEffectIndex.Paralyzed * });*/ } cool = getCooldown(host as Pet, level) / host.Manager.TPS; } else { cool -= time.thisTickTimes; } state = cool; }
protected override void TickCore(Entity host, RealmTime time, ref object state) { if (state == null) { return; } int cool = (int)state; if (cool <= 0) { PetLevel level = null; if (host is Pet) { Pet p = host as Pet; level = p.GetPetLevelFromAbility(Ability.Electric, true); } else { return; } if (level == null) { return; } double dist = getDist(host as Pet, level); Enemy[] targets = host.GetNearestEntities(dist).OfType <Enemy>().ToArray(); foreach (Enemy e in targets) { var vect = new Vector2(e.X - host.X, e.Y - host.Y); var distt = host.GetSpeed(0); if (vect.Length > 3) { distt = host.GetSpeed(0); } vect.Normalize(); host.UpdateCount++; if (e.HasConditionEffect(ConditionEffects.Invulnerable) || e.HasConditionEffect(ConditionEffects.Invincible)) { continue; } if (Random.Next(0, 100) > level.Level) { break; } if (e.ObjectDesc == null | !e.ObjectDesc.Enemy) { continue; } if (e.HasConditionEffect(ConditionEffects.Invincible)) { continue; } e.ApplyConditionEffect(new ConditionEffect { DurationMS = level.Level * 40, Effect = ConditionEffectIndex.Paralyzed }); e.Owner.BroadcastPacket(new ShowEffectPacket { EffectType = EffectType.ElectricFlashing, PosA = new Position { X = level.Level * 40 }, TargetId = e.Id }, null); host.Owner.BroadcastPacket(new ShowEffectPacket { PosA = new Position { X = host.X, Y = host.Y }, EffectType = EffectType.ElectricBolts, TargetId = host.Id, }, null); e.Damage(null, time, level.Level, true, new ConditionEffect { DurationMS = level.Level * 40, Effect = ConditionEffectIndex.Paralyzed }); } cool = getCooldown(host as Pet, level) / host.Manager.TPS; } else { cool -= time.thisTickTimes; } state = cool; }