Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
更新: EconomicsAPI 尝试解决所谓的AI问题与持续时间
  • Loading branch information
Controllerdestiny committed Jul 15, 2024
commit ab86d31c4066b15b017453bc5ee19c0040a1ce79
29 changes: 15 additions & 14 deletions EconomicsAPI/Utils/SpawnProjectile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@ public static int NewProjectile(IEntitySource spawnSource, Vector2 position, Vec
return NewProjectile(spawnSource, position.X, position.Y, velocity.X, velocity.Y, Type, Damage, KnockBack, Owner, ai0, ai1, ai2, timeLeft);
}


public static int NewProjectile(IEntitySource spawnSource, float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float KnockBack, int Owner = -1, float ai0 = 0f, float ai1 = 0f, float ai2 = 0f, int timeLeft = -1)
public static int NewProjectile(IEntitySource spawnSource, float X, float Y, float SpeedX, float SpeedY, int Type, int Damage, float KnockBack, int Owner = -1, float ai0 = 0f, float ai1 = 0f, float ai2 = 0, int timeLeft = -1)
{
if (Owner == -1)
{
Owner = Main.myPlayer;
}
int num = 1000;
for (int i = 1000; i >= 0; i--)
for (int i = 9999; i > 0; i--)
{
if (!Main.projectile[i].active)
{
Expand All @@ -30,12 +29,12 @@ public static int NewProjectile(IEntitySource spawnSource, float X, float Y, flo
}
if (num == 1000)
{
num = Projectile.FindOldestProjectile();
num = Terraria.Projectile.FindOldestProjectile();
}
Projectile projectile = Main.projectile[num];
projectile.SetDefaults(Type);
projectile.position.X = X - projectile.width * 0.5f;
projectile.position.Y = Y - projectile.height * 0.5f;
projectile.position.X = X - (float)projectile.width * 0.5f;
projectile.position.Y = Y - (float)projectile.height * 0.5f;
projectile.owner = Owner;
projectile.velocity.X = SpeedX;
projectile.velocity.Y = SpeedY;
Expand All @@ -44,7 +43,6 @@ public static int NewProjectile(IEntitySource spawnSource, float X, float Y, flo
projectile.identity = num;
projectile.gfxOffY = 0f;
projectile.stepSpeed = 1f;
projectile.active = true;
projectile.wet = Collision.WetCollision(projectile.position, projectile.width, projectile.height);
if (projectile.ignoreWater)
{
Expand All @@ -53,7 +51,7 @@ public static int NewProjectile(IEntitySource spawnSource, float X, float Y, flo
projectile.honeyWet = Collision.honey;
projectile.shimmerWet = Collision.shimmer;
Main.projectileIdentity[Owner, num] = num;
Projectile.FindBannerToAssociateTo(spawnSource, projectile);
Terraria.Projectile.FindBannerToAssociateTo(spawnSource, projectile);
if (projectile.aiStyle == 1)
{
while (projectile.velocity.X >= 16f || projectile.velocity.X <= -16f || projectile.velocity.Y >= 16f || projectile.velocity.Y < -16f)
Expand All @@ -69,17 +67,17 @@ public static int NewProjectile(IEntitySource spawnSource, float X, float Y, flo
switch (Type)
{
case 206:
projectile.ai[0] = Main.rand.Next(-100, 101) * 0.0005f;
projectile.ai[1] = Main.rand.Next(-100, 101) * 0.0005f;
projectile.ai[0] = (float)Main.rand.Next(-100, 101) * 0.0005f;
projectile.ai[1] = (float)Main.rand.Next(-100, 101) * 0.0005f;
break;
case 335:
projectile.ai[1] = Main.rand.Next(4);
break;
case 358:
projectile.ai[1] = Main.rand.Next(10, 31) * 0.1f;
projectile.ai[1] = (float)Main.rand.Next(10, 31) * 0.1f;
break;
case 406:
projectile.ai[1] = Main.rand.Next(10, 21) * 0.1f;
projectile.ai[1] = (float)Main.rand.Next(10, 21) * 0.1f;
break;
default:
projectile.ai[0] = ai0;
Expand Down Expand Up @@ -119,7 +117,7 @@ public static int NewProjectile(IEntitySource spawnSource, float X, float Y, flo
int num3 = 0;
int num4 = 0;
int num5 = 99999999;
for (int j = 0; j < 1000; j++)
for (int j = 999; j > 0; j--)
{
if (Main.projectile[j].active && ProjectileID.Sets.IsAGolfBall[Main.projectile[j].type] && Main.projectile[j].owner == Owner && Main.projectile[j].damage <= 0)
{
Expand Down Expand Up @@ -265,11 +263,14 @@ public static int NewProjectile(IEntitySource spawnSource, float X, float Y, flo
{
Main.player[Owner].TryUpdateChannel(projectile);
}
if (timeLeft == 0)
{
projectile.Kill();
}
if (timeLeft > 0)
{
projectile.timeLeft = timeLeft;
}
return num;
}

}
2 changes: 1 addition & 1 deletion ServerTools/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public partial class Plugin : TerrariaPlugin

public override string Name => "ServerTools";// 插件名字

public override Version Version => new(1, 1, 7, 1);// 插件版本
public override Version Version => new(1, 1, 7, 2);// 插件版本

private static Config Config = new();

Expand Down