public override void AI() { Player p = Main.player[projectile.owner]; p.heldProj = projectile.whoAmI; GItem.ArmsTowardsMouse(p); if (p.whoAmI != Main.myPlayer) { return; //mp check (hopefully) } if (p.channel) //Use turn functionality { p.direction = Main.MouseWorld.X >= p.MountedCenter.X ? 1 : -1; } projectile.rotation = Vector2.Normalize(p.MountedCenter - Main.MouseWorld).ToRotation() - MathHelper.Pi; //So it looks like the player is holding it properly _charge++; //Increase charge timer... projectile.timeLeft++; //...and dont die if (_endCharge == -1) //Wait until the player has fired to let go & set position { p.itemTime = p.HeldItem.useTime; p.itemAnimation = p.HeldItem.useAnimation; projectile.Center = p.Center - (Vector2.Normalize(p.MountedCenter - Main.MouseWorld) * 27) + new Vector2(21, 12 + p.gfxOffY); } else { projectile.Center = p.Center - (new Vector2(1, 0).RotatedBy(_finalRotation) * 27) + new Vector2(21, 12 + p.gfxOffY); } if (!p.channel && _endCharge == -1) //the player has stopped shooting { _endCharge = _charge; _finalRotation = (Vector2.Normalize(p.MountedCenter - Main.MouseWorld) * 27).ToRotation(); _endCharge += p.HeldItem.useAnimation; _effect = Main.MouseWorld.X >= p.MountedCenter.X ? SpriteEffects.None : SpriteEffects.FlipHorizontally; } if (_charge > _endCharge && _endCharge != -1) //Kill projectile when done shooting { projectile.Kill(); } if (_charge > ChargeUp && (_charge - ChargeUp) % p.HeldItem.useTime == 1) { Fire(p); } }
public override void AI() { Player p = Main.player[projectile.owner]; p.heldProj = projectile.whoAmI; GItem.ArmsTowardsMouse(p); if (p.whoAmI != Main.myPlayer) { return; //mp check (hopefully) } if (!p.channel && _endCharge == -1) //Fire (if possible) { _endCharge = _charge; _finalRotation = (Vector2.Normalize(p.MountedCenter - Main.MouseWorld) * 27).ToRotation(); if (_endCharge >= MinimumCharge) { Fire(p); } } if (p.channel) //Use turn functionality { p.direction = Main.MouseWorld.X >= p.MountedCenter.X ? 1 : -1; } if (_charge > _endCharge && _endCharge != -1) //Kill projectile when done shooting - does nothing special but allowed for a cooldown timer before polish { projectile.active = false; } _charge++; //Increase charge timer... projectile.timeLeft++; //...and dont die if (_endCharge == -1) //Wait until the player has fired to let go & set position { p.itemTime = p.HeldItem.useTime; p.itemAnimation = p.HeldItem.useAnimation; projectile.Center = p.Center - (Vector2.Normalize(p.MountedCenter - Main.MouseWorld) * 27) + new Vector2(21, 12); } else { projectile.Center = p.Center - (new Vector2(1, 0).RotatedBy(_finalRotation) * 27) + new Vector2(21, 12); } projectile.rotation = Vector2.Normalize(p.MountedCenter - Main.MouseWorld).ToRotation() - MathHelper.Pi; //So it looks like the player is holding it properly }