/// <summary> /// Handles projectile creation. /// </summary> private void OnNewProjectile(object sender, ProjectileNewArgs e) { if (!PvPModifier.Config.EnablePlugin) { return; } var projectile = Main.projectile[e.Identity]; if (projectile.active && projectile.type == e.Type) { return; } if ((TShock.Players[e.Owner]?.TPlayer?.hostile ?? false) && PvPUtils.IsModifiedProjectile(e.Type)) { e.Args.Handled = true; DbProjectile proj = Cache.Projectiles[e.Type]; projectile.SetDefaults(proj.Shoot != -1 ? proj.Shoot : e.Type); projectile.velocity = e.Velocity * proj.VelocityMultiplier; projectile.damage = proj.Damage != -1 ? proj.Damage : e.Damage; projectile.active = true; projectile.identity = e.Identity; projectile.owner = e.Owner; projectile.position = e.Position; NetMessage.SendData(27, -1, -1, null, e.Identity); } e.Attacker.ProjTracker.InsertProjectile(e.Identity, e.Type, e.Owner, e.Weapon); e.Attacker.ProjTracker.Projectiles[e.Type].PerformProjectileAction(); }
/// <summary> /// Checks whether a projectile was modified in the database. /// </summary> public static bool IsModifiedProjectile(int type) { DbProjectile proj = Cache.Projectiles[type]; return(proj.Shoot != type || proj.VelocityMultiplier != 1 || proj.Damage != -1); }