Merge remote-tracking branch 'agaspace/general-devel' into general-devel

This commit is contained in:
Lucas Nicodemus 2021-11-27 17:15:44 -08:00
commit 0751f0cb5a
3 changed files with 67 additions and 2 deletions

View file

@ -945,6 +945,7 @@ namespace TShockAPI
byte owner = args.Owner;
short type = args.Type;
int index = args.Index;
float[] ai = args.Ai;
if (index > Main.maxProjectiles)
{
@ -1082,6 +1083,21 @@ namespace TShockAPI
return;
}
if (
(Projectile_MaxValuesAI.ContainsKey(type) &&
(Projectile_MaxValuesAI[type] < ai[0] || Projectile_MinValuesAI[type] > ai[0])) ||
(Projectile_MaxValuesAI2.ContainsKey(type) &&
(Projectile_MaxValuesAI2[type] < ai[1] || Projectile_MinValuesAI2[type] > ai[1]))
)
{
TShock.Log.ConsoleDebug("Bouncer / OnNewProjectile rejected from bouncer modified AI from {0}.", args.Player.Name);
args.Player.RemoveProjectile(ident, owner);
args.Handled = true;
return;
}
if (!args.Player.HasPermission(Permissions.ignoreprojectiledetection))
{
if (type == ProjectileID.CrystalShard && TShock.Config.Settings.ProjIgnoreShrapnel) // Ignore crystal shards
@ -2498,5 +2514,45 @@ namespace TShockAPI
{ ProjectileID.GoldShortswordStab, ItemID.GoldShortsword },
{ ProjectileID.PlatinumShortswordStab, ItemID.PlatinumShortsword }
};
private Dictionary<short, float> Projectile_MinValuesAI = new Dictionary<short, float> {
{ 611, -1 },
{ 950, 0 }
};
private Dictionary<short, float> Projectile_MaxValuesAI = new Dictionary<short, float> {
{ 611, 1 },
{ 950, 0 }
};
private Dictionary<short, float> Projectile_MinValuesAI2 = new Dictionary<short, float> {
{ 405, 0f },
{ 410, 0f },
{ 424, 0.5f },
{ 425, 0.5f },
{ 426, 0.5f },
{ 612, 0.4f },
{ 953, 0.85f },
{ 756, 0.5f },
{ 522, 0 }
};
private Dictionary<short, float> Projectile_MaxValuesAI2 = new Dictionary<short, float> {
{ 405, 1.2f },
{ 410, 1.2f },
{ 424, 0.8f },
{ 425, 0.8f },
{ 426, 0.8f },
{ 612, 0.7f },
{ 953, 2 },
{ 756, 1 },
{ 522, 40f }
};
}
}

View file

@ -689,12 +689,17 @@ namespace TShockAPI
/// ???
/// </summary>
public int Index { get; set; }
/// <summary>
/// The special meaning of the projectile.
/// </summary>
public float[] Ai { get; set; }
}
/// <summary>
/// NewProjectile - Called when a client creates a new projectile
/// </summary>
public static HandlerList<NewProjectileEventArgs> NewProjectile = new HandlerList<NewProjectileEventArgs>();
private static bool OnNewProjectile(MemoryStream data, short ident, Vector2 pos, Vector2 vel, float knockback, short dmg, byte owner, short type, int index, TSPlayer player)
private static bool OnNewProjectile(MemoryStream data, short ident, Vector2 pos, Vector2 vel, float knockback, short dmg, byte owner, short type, int index, TSPlayer player, float[] ai)
{
if (NewProjectile == null)
return false;
@ -711,6 +716,7 @@ namespace TShockAPI
Type = type,
Index = index,
Player = player,
Ai = ai
};
NewProjectile.Invoke(null, args);
return args.Handled;
@ -2788,7 +2794,7 @@ namespace TShockAPI
var index = TShock.Utils.SearchProjectile(ident, owner);
if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, index, args.Player))
if (OnNewProjectile(args.Data, ident, pos, vel, knockback, dmg, owner, type, index, args.Player, ai))
return true;
lock (args.Player.RecentlyCreatedProjectiles)