public static void SpawnProjectileSkill(ProjectileSkill _projectile, int _byPlayer) { using (Packet _packet = new Packet((int)ServerPackets.spawnProjectileSkill)) { _packet.Write(_projectile.id); _packet.Write(_projectile.transform.position); SendTCPDataToAll(_packet); } }
private void ProcessTargets(Creature creature, Skill skill) { if (skill.TargetingList == null) { return; } for (int i = 0; i < skill.TargetingList.Count; i++) { if (skill.TargetingList[i].ProjectileSkillList != null && skill.TargetingList[i].ProjectileSkillList.Count > 0) { for (int k = 0; k < skill.TargetingList[i].ProjectileSkillList.Count; k++) { ProjectileSkill projectileSkill = skill.TargetingList[i].ProjectileSkillList[k]; try { new DelayedAction(() => ProcessProjectileSkillList(creature, projectileSkill), (int)(skill.TargetingList[i].Time / skill.TimeRate)); } catch (Exception ex) { Logger.WriteLine(LogState.Exception, "SkillEngine: ProcessTargets: " + ex); } } } if (skill.TargetingList[i].AreaList == null) { continue; } for (int j = 0; j < skill.TargetingList[i].AreaList.Count; j++) { if (skill.TargetingList[i].AreaList[j].Type == TargetingAreaType.PvP) { continue; } ProcessArea(creature, skill, skill.TargetingList[i], skill.TargetingList[i].AreaList[j]); } } }
private static ProjectileSkill ParseProjectileSkill(Dictionary <string, object> data) { ProjectileSkill skill = new ProjectileSkill(); skill.Id = int.Parse(data["id"].ToString()); skill.DetachAngle = float.Parse(data["detachAngle"].ToString()); skill.DetachDistance = float.Parse(data["detachDistance"].ToString(), CultureInfo.InvariantCulture); skill.DetachHeight = float.Parse(data["detachHeight"].ToString(), CultureInfo.InvariantCulture); skill.FlyingDistance = float.Parse(data["flyingDistance"].ToString()); if (data.ContainsKey("shootAngle")) { skill.ShootAngle = float.Parse(data["shootAngle"].ToString()); } return(skill); }
public Projectile(Creature.Creature owner, ProjectileSkill projectileSkill) { Player.Player player = owner as Player.Player; Npc.Npc npc = owner as Npc.Npc; Parent = owner; if (npc != null) { TargetPosition = new WorldPosition(); npc.Target.Position.CopyTo(TargetPosition); } else { TargetPosition = owner.Attack.Args.TargetPosition; } Position = new WorldPosition { Heading = owner.Position.Heading, X = owner.Position.X, Y = owner.Position.Y, Z = owner.Position.Z + projectileSkill.DetachHeight, }; double angle = Position.Heading * Math.PI / 32768; Position.X += projectileSkill.DetachDistance * (float)Math.Cos(angle); Position.Y += projectileSkill.DetachDistance * (float)Math.Sin(angle); Instance = owner.Instance; ProjectileSkill = projectileSkill; GameStats = new CreatureBaseStats { HpBase = 1 }; if (player != null) { Skill = Data.Skills[0][player.TemplateId][ProjectileSkill.Id]; SkillId = Skill.Id; } else if (npc != null) { Skill = Data.Skills[npc.NpcTemplate.HuntingZoneId][npc.NpcTemplate.Id][ProjectileSkill.Id]; SkillId = Skill.Id + 0x40000000 + (npc.NpcTemplate.HuntingZoneId << 16); } Lifetime = Skill.ProjectileData.LifeTime != 0 ? Skill.ProjectileData.LifeTime : 1000; if (projectileSkill.FlyingDistance <= 0f) { TargetPosition = null; } else if (Skill != null) { if (TargetPosition.IsNull()) { TargetPosition = Position.Clone(); TargetPosition.X += projectileSkill.FlyingDistance * (float)Math.Cos(angle); TargetPosition.Y += projectileSkill.FlyingDistance * (float)Math.Sin(angle); } Speed = (int)(projectileSkill.FlyingDistance * 1000 / Lifetime); } if (Skill != null) { if (Skill.TargetingList != null) { for (int i = 0; i < Skill.TargetingList.Count; i++) { if (Skill.TargetingList[i].AreaList == null) { continue; } for (int j = 0; j < Skill.TargetingList[i].AreaList.Count; j++) { if (Skill.TargetingList[i].AreaList[j].MaxRadius > AttackDistance) { AttackDistance = Skill.TargetingList[i].AreaList[j].MaxRadius; return; } } } } } }
public override void Release() { base.Release(); ProjectileSkill = null; TargetPosition = null; }
private void ProcessProjectileSkillList(Creature creature, ProjectileSkill projectileSkill) { Projectile projectile = new Projectile(creature, projectileSkill); CreatureLogic.CreateProjectile(creature, projectile); }