private int ActiveProjectileScore(Player player) { int activeProjScore = 0; foreach (int index in projIndexArray) //adds up the score for all active projectiles in the list { Projectile curProj = Main.projectile[index]; //variable for cleanliness if (curProj.active && curProj.type == ModContent.ProjectileType <SlimeStaffProjectile>() && curProj.owner == player.whoAmI) //active, correct type, and correct owner { SlimeStaffProjectile curSlimeProj = curProj.modProjectile as SlimeStaffProjectile; //variable for cleanliness (only used once so...) activeProjScore += curSlimeProj.globSize; } } return(activeProjScore); }
public override void AI() { //parentItem.projIndexArray Vector2 DirectionToCursor = new Vector2(projectile.ai[0], projectile.ai[1]) - projectile.Center; projectile.velocity += Vector2.Normalize(DirectionToCursor) * 0.5f;//last float is how fast it turns projectile.velocity = projectile.velocity.Length() > maxProjSpeed? //dont question it Vector2.Normalize(projectile.velocity) * maxProjSpeed: //Case 1A projectile.velocity.Length() < maxProjSpeed ? //Case 1B projectile.velocity * 1.01f : //Case 2A projectile.velocity; //Case 2B int size = projectileSize(globSize); //variable so this only has to be called once in AI foreach (int index in parentItem.projIndexArray) //detecting collisions { Projectile curProj = Main.projectile[index]; if (index != projectile.whoAmI && curProj.active && curProj.type == ProjectileType <SlimeStaffProjectile>()) //if active, this type, and not this projectile { if (Vector2.Distance(projectile.position, curProj.position) < size && projectile.timeLeft < maxTimeleft - 60) //if 60 seconds have passed, and the distance is less than size { SlimeStaffProjectile curSlimeProj = curProj.modProjectile as SlimeStaffProjectile; int nextSize = curSlimeProj.globSize + globSize; //this projectiles size added to the selected projectile's size if (nextSize <= 3 && curSlimeProj.globSize > 0) //checks added sizes are lowerthan or equal to three { curSlimeProj.globSize = nextSize; curProj.penetrate = 2; //resets bounces curProj.Center = curProj.position; //changes position (like an explosive) projectile.Kill(); //kills this projectile break; //stops iterating to prevent extra combinings with projectiles after this one should be already dead } } } } projectile.Size = Vector2.One * size;//called after the above stuff, position in where this is called may not actually change anything if (Main.myPlayer == projectile.owner) { int currentTargetX = (int)(Main.MouseWorld.X * 10); //multiply or divide these to change precision, this seems to be enogh for multiplayer int oldTargetX = (int)(projectile.ai[0] * 10); //dividing by ten is the lowest you can go and avoid desyncs int currentTargetY = (int)(Main.MouseWorld.Y * 10); int oldTargetY = (int)(projectile.ai[1] * 10); projectile.ai[0] = Main.MouseWorld.X; projectile.ai[1] = Main.MouseWorld.Y; // This code checks if the precious velocity of the projectile is different enough from its new velocity, and if it is, syncs it with the server and the other clients in MP. // We previously multiplied the speed by 1000, then casted it to int, this is to reduce its precision and prevent the speed from being synced too much. if (currentTargetX != oldTargetX || currentTargetY != oldTargetY) { projectile.netUpdate = true; } } //Main.NewText(projectile.velocity.Length()); //vfx projectile.rotation += 0.15f; Dust.NewDustPerfect(projectile.Center, 264, Vector2.Zero, 0, new Color(globSize * 50, globSize * 50, globSize * 50), 0.4f); }