public void TryShoot(Vec3f start, Vec3f end) { if (Host.IsDead || !Host.IsAiming()) { return; } if (start.GetDistance(end) > 500000) // just in case { end = start + 500000 * (end - start).Normalise(); } var drawnWeapon = Host.GetDrawnWeapon(); if (drawnWeapon == null || !drawnWeapon.IsWepRanged) { return; } ItemInst ammo = drawnWeapon.ItemType == ItemTypes.WepBow ? Host.GetRightHand() : Host.GetLeftHand(); if (ammo == null || !ammo.IsAmmo) { return; } ProjInst inst = new ProjInst(ProjDef.Get <ProjDef>("arrow")) { Item = new ItemInst(ammo.Definition), Damage = drawnWeapon.Damage, Velocity = 0.0004f, Model = ammo.ModelDef }; end = end - (end - start).Normalise() * (ammo.ItemType == ItemTypes.AmmoBow ? 40 : 10); // so arrows' bodies aren't 90% inside walls Host.DoShoot(start, end, inst); int ammoCount = ammo.Amount - 1; if (ammoCount <= 0) { Host.UnequipItem(ammo); } ammo.SetAmount(ammo.Amount - 1); }