/// <summary> /// /// </summary> /// <param name="id"></param> /// <param name="durability"></param> /// <param name="amount"></param> /// <param name="ammo"></param> /// <param name="fireMode"></param> public KitItemWeapon( ushort id, byte durability, byte amount, byte? ammo, EFiremode? fireMode = EFiremode.AUTO ) : base(id, durability, amount) { FireMode = fireMode; Ammo = ammo; }
private void LaserBeamFire() { if (_Firemode == EFiremode.Charge) { // Can fire & has completed charge up & hasnt finished the charge firing _IsChargeFiring = _CanFire && _ChargeAmount > _ChargeTime && _ChargeFiringAmount < _ChargeFiringTime; if (_IsChargeFiring) { // Fire raycast to simulate laser beam collisions float raycastDistance = 1000f; RaycastHit raycastHit; Physics.Raycast(_MuzzleLaunchPoint.transform.position, _MuzzleLaunchPoint.transform.forward, out raycastHit, raycastDistance); // Debug raycast if (raycastHit.transform) { if (raycastHit.collider.gameObject.tag == "Destroyable") { // Damage object raycastHit.collider.gameObject.GetComponent <Health>().Damage(MatchManager._pInstance._DamageLaserBeam); } Debug.DrawLine(_MuzzleLaunchPoint.transform.position, raycastHit.transform.position, Color.green); } else { Debug.DrawLine(_MuzzleLaunchPoint.transform.position, _MuzzleLaunchPoint.transform.forward * raycastDistance, Color.red); } // On successful hit with a damageable object if (raycastHit.collider) { if (raycastHit.collider.gameObject.CompareTag("Destroyable")) { // Apply damage to component GameObject obj = raycastHit.collider.gameObject; obj.GetComponent <Health>().Damage(MatchManager._pInstance._DamageLaserBeam); } } // Add to charge fire timer _ChargeFiringAmount += Time.deltaTime; // Controller rumble ControllerRumble(true, 1f, 1f); _RumbleTime = 0.5f; } // Completed charge firing sequence else if (_ChargeFiringAmount >= _ChargeFiringTime) { ControllerRumble(false, 0f, 0f); _ChargeFiringAmount = 0f; _ChargeAmount = 0f; _Firemode = EFiremode.SemiAuto; _MagazineSize = 1; _CanTryToFire = false; } } }
public static void SetWeaponFiremode(Item weaponItem, EFiremode firemode) { if (weaponItem.Metadata.Length < 18) { return; } weaponItem.Metadata[11] = (byte)firemode; }
public static Item AssembleItem(ushort itemId, byte clipsize, Attachment sight, Attachment tactical, Attachment grip, Attachment barrel, Attachment magazine, EFiremode firemode = EFiremode.SAFETY, byte amount = 1, byte durability = 100) { byte[] metadata = new byte[18]; if (sight != null && sight.AttachmentId != 0) { byte[] sightBytes = BitConverter.GetBytes(sight.AttachmentId); metadata[0] = sightBytes[0]; metadata[1] = sightBytes[1]; metadata[13] = sight.Durability; } if (tactical != null && tactical.AttachmentId != 0) { byte[] tacticalBytes = BitConverter.GetBytes(tactical.AttachmentId); metadata[2] = tacticalBytes[0]; metadata[3] = tacticalBytes[1]; metadata[14] = tactical.Durability; } if (grip != null && grip.AttachmentId != 0) { byte[] gripBytes = BitConverter.GetBytes(grip.AttachmentId); metadata[4] = gripBytes[0]; metadata[5] = gripBytes[1]; metadata[15] = grip.Durability; } if (barrel != null && barrel.AttachmentId != 0) { byte[] barrelBytes = BitConverter.GetBytes(barrel.AttachmentId); metadata[6] = barrelBytes[0]; metadata[7] = barrelBytes[1]; metadata[16] = barrel.Durability; } if (magazine != null && magazine.AttachmentId != 0) { byte[] magazineBytes = BitConverter.GetBytes(magazine.AttachmentId); metadata[8] = magazineBytes[0]; metadata[9] = magazineBytes[1]; metadata[17] = magazine.Durability; } metadata[10] = clipsize; metadata[11] = (byte)firemode; metadata[12] = (byte)1; return AssembleItem(itemId,amount,durability,metadata); }
private void ChangeFireMode() { // On button press if (_PreviousGamepadState.Buttons.X == ButtonState.Released && _GamepadState.Buttons.X == ButtonState.Pressed) { // Change firemode _Firemode += 1; if (_Firemode == EFiremode.Count) { _Firemode = 0; _MagazineSize = 1; } if (_Firemode == EFiremode.FullAuto) { _MagazineSize = MatchManager._pInstance._MinigunMagazineSize; } } if (_PreviousGamepadState.Buttons.B == ButtonState.Released && _GamepadState.Buttons.B == ButtonState.Pressed) { _HasShield = true; } }
public static Item AssembleItem(ushort itemId, byte clipsize, Attachment sight, Attachment tactical, Attachment grip, Attachment barrel, Attachment magazine, EFiremode firemode = EFiremode.SAFETY, byte amount = 1, byte durability = 100) { byte[] metadata = new byte[18]; if (sight != null && sight.AttachmentId != 0) { byte[] sightBytes = BitConverter.GetBytes(sight.AttachmentId); metadata[0] = sightBytes[0]; metadata[1] = sightBytes[1]; metadata[13] = sight.Durability; } if (tactical != null && tactical.AttachmentId != 0) { byte[] tacticalBytes = BitConverter.GetBytes(tactical.AttachmentId); metadata[2] = tacticalBytes[0]; metadata[3] = tacticalBytes[1]; metadata[14] = tactical.Durability; } if (grip != null && grip.AttachmentId != 0) { byte[] gripBytes = BitConverter.GetBytes(grip.AttachmentId); metadata[4] = gripBytes[0]; metadata[5] = gripBytes[1]; metadata[15] = grip.Durability; } if (barrel != null && barrel.AttachmentId != 0) { byte[] barrelBytes = BitConverter.GetBytes(barrel.AttachmentId); metadata[6] = barrelBytes[0]; metadata[7] = barrelBytes[1]; metadata[16] = barrel.Durability; } if (magazine != null && magazine.AttachmentId != 0) { byte[] magazineBytes = BitConverter.GetBytes(magazine.AttachmentId); metadata[8] = magazineBytes[0]; metadata[9] = magazineBytes[1]; metadata[17] = magazine.Durability; } metadata[10] = clipsize; metadata[11] = (byte)firemode; metadata[12] = 1; return(AssembleItem(itemId, amount, durability, metadata)); }
public void SetFiremode(EFiremode firemode) { _Firemode = firemode; }
private void CheckFire() { _CanFire = _FireDelay <= 0f && _CanTryToFire; // On trigger enter if (_GamepadState.Triggers.Right > 0f && _CanFire) { switch (_Firemode) { // Semi automatic firing mode case EFiremode.SemiAuto: { if (_MagazineSize > 0) { _IsFiring = true; _FireDelay = _FiringDelaySemiAuto; _CanTryToFire = false; Fire(); } break; } // Fully automatic firing mode case EFiremode.FullAuto: { if (_MagazineSize > 0) { _IsFiring = true; _FireDelay = _FiringDelayFullAuto; Fire(); } // Revert back to single shot mode on empty clip else { _Firemode = EFiremode.SemiAuto; _MagazineSize = 1; } break; } // Charge up firing mode case EFiremode.Charge: { if (!_IsChargeFiring) { // Charge up _ChargeAmount += Time.deltaTime; // Controller rumble ControllerRumble(true, 0.1f, 0.1f); _RumbleTime = 0.1f; } break; } default: break; } } // On trigger release else if (_GamepadState.Triggers.Right < 0.1f) { _CanTryToFire = true; _IsFiring = false; // On charge up firing mode if (_Firemode == EFiremode.Charge && _ChargeAmount >= _ChargeTime && _CanFire) { Fire(); } else if (_Firemode == EFiremode.FullAuto) { // Stop controller rumble GamePad.SetVibration(_PlayerIndex, 0f, 0f); } // Reset charge up _ChargeAmount = 0f; } LaserBeamFire(); }
public static IEnumerator CheckTrigger() { for (; ;) { yield return(new WaitForSeconds(0.1f)); bool flag = !TriggerbotOptions.Enabled || !DrawUtilities.ShouldRun() || OptimizationVariables.MainPlayer.stance.stance == EPlayerStance.SPRINT || OptimizationVariables.MainPlayer.stance.stance == EPlayerStance.CLIMB || OptimizationVariables.MainPlayer.stance.stance == EPlayerStance.DRIVING; if (flag) { TriggerbotOptions.IsFiring = false; } else { PlayerLook look = OptimizationVariables.MainPlayer.look; Useable u = OptimizationVariables.MainPlayer.equipment.useable; Useable useable = u; Useable useable2 = useable; if (useable2 == null) { TriggerbotOptions.IsFiring = false; } else { UseableGun useableGun; UseableGun gun; UseableMelee useableMelee; if ((useableGun = (useable2 as UseableGun)) != null) { gun = useableGun; ItemGunAsset PAsset = (ItemGunAsset)OptimizationVariables.MainPlayer.equipment.asset; RaycastInfo ri = RaycastUtilities.GenerateOriginalRaycast(new Ray(look.aim.position, look.aim.forward), PAsset.range, RayMasks.DAMAGE_CLIENT); if (AimbotCoroutines.LockedObject != null && AimbotCoroutines.IsAiming) { Ray r = OV_UseableGun.GetAimRay(look.aim.position, AimbotCoroutines.GetAimPosition(AimbotCoroutines.LockedObject.transform, "Skull")); ri = RaycastUtilities.GenerateOriginalRaycast(new Ray(r.origin, r.direction), PAsset.range, RayMasks.DAMAGE_CLIENT); r = default(Ray); } bool Valid = ri.player == null; if (RaycastOptions.Enabled) { Valid = RaycastUtilities.GenerateRaycast(out ri); } if (Valid) { TriggerbotOptions.IsFiring = false; continue; } EFiremode fire = (EFiremode)TriggerbotComponent.CurrentFiremode.GetValue(gun); bool flag4 = fire == EFiremode.AUTO; if (flag4) { TriggerbotOptions.IsFiring = true; continue; } TriggerbotOptions.IsFiring = !TriggerbotOptions.IsFiring; } else if ((useableMelee = (useable2 as UseableMelee)) != null) { ItemMeleeAsset MAsset = (ItemMeleeAsset)OptimizationVariables.MainPlayer.equipment.asset; RaycastInfo ri2 = RaycastUtilities.GenerateOriginalRaycast(new Ray(look.aim.position, look.aim.forward), MAsset.range, RayMasks.DAMAGE_CLIENT); bool flag5 = AimbotCoroutines.LockedObject != null && AimbotCoroutines.IsAiming; if (flag5) { Ray r2 = OV_UseableGun.GetAimRay(look.aim.position, AimbotCoroutines.GetAimPosition(AimbotCoroutines.LockedObject.transform, "Skull")); ri2 = RaycastUtilities.GenerateOriginalRaycast(new Ray(r2.origin, r2.direction), MAsset.range, RayMasks.DAMAGE_CLIENT); r2 = default(Ray); } bool Valid2 = ri2.player != null; bool enabled2 = RaycastOptions.Enabled; if (enabled2) { Valid2 = RaycastUtilities.GenerateRaycast(out ri2); } bool flag6 = !Valid2; if (flag6) { TriggerbotOptions.IsFiring = false; continue; } bool isRepeated = MAsset.isRepeated; if (isRepeated) { TriggerbotOptions.IsFiring = true; continue; } TriggerbotOptions.IsFiring = !TriggerbotOptions.IsFiring; } useable2 = null; useableGun = null; gun = null; look = null; u = null; } } } yield break; }
public static IEnumerator CheckTrigger() { while (true) { yield return(new WaitForSeconds(0.1f)); if (!TriggerbotOptions.Enabled || !DrawUtilities.ShouldRun() || OptimizationVariables.MainPlayer.stance.stance == EPlayerStance.SPRINT || OptimizationVariables.MainPlayer.stance.stance == EPlayerStance.CLIMB || OptimizationVariables.MainPlayer.stance.stance == EPlayerStance.DRIVING) { TriggerbotOptions.IsFiring = false; continue; } PlayerLook look = OptimizationVariables.MainPlayer.look; Useable u = OptimizationVariables.MainPlayer.equipment.useable; switch (u) { case null: TriggerbotOptions.IsFiring = false; continue; case UseableGun gun: { ItemGunAsset PAsset = (ItemGunAsset)OptimizationVariables.MainPlayer.equipment.asset; RaycastInfo ri = RaycastUtilities.GenerateOriginalRaycast(new Ray(look.aim.position, look.aim.forward), PAsset.range, RayMasks.DAMAGE_CLIENT); if (AimbotCoroutines.LockedObject != null && AimbotCoroutines.IsAiming) { Ray r = OV_UseableGun.GetAimRay(look.aim.position, AimbotCoroutines.GetAimPosition(AimbotCoroutines.LockedObject.transform, "Skull")); ri = RaycastUtilities.GenerateOriginalRaycast(new Ray(r.origin, r.direction), PAsset.range, RayMasks.DAMAGE_CLIENT); } bool Valid = ri.player != null; if (RaycastOptions.Enabled) { Valid = RaycastUtilities.GenerateRaycast(out ri); } if (!Valid) { TriggerbotOptions.IsFiring = false; continue; } EFiremode fire = (EFiremode)CurrentFiremode.GetValue(gun); if (fire == EFiremode.AUTO) { TriggerbotOptions.IsFiring = true; continue; } TriggerbotOptions.IsFiring = !TriggerbotOptions.IsFiring; break; } case UseableMelee _: { ItemMeleeAsset MAsset = (ItemMeleeAsset)OptimizationVariables.MainPlayer.equipment.asset; RaycastInfo ri = RaycastUtilities.GenerateOriginalRaycast(new Ray(look.aim.position, look.aim.forward), MAsset.range, RayMasks.DAMAGE_CLIENT); if (AimbotCoroutines.LockedObject != null && AimbotCoroutines.IsAiming) { Ray r = OV_UseableGun.GetAimRay(look.aim.position, AimbotCoroutines.GetAimPosition(AimbotCoroutines.LockedObject.transform, "Skull")); ri = RaycastUtilities.GenerateOriginalRaycast(new Ray(r.origin, r.direction), MAsset.range, RayMasks.DAMAGE_CLIENT); } bool Valid = ri.player != null; if (RaycastOptions.Enabled) { Valid = RaycastUtilities.GenerateRaycast(out ri); } if (!Valid) { TriggerbotOptions.IsFiring = false; continue; } if (MAsset.isRepeated) { TriggerbotOptions.IsFiring = true; continue; } TriggerbotOptions.IsFiring = !TriggerbotOptions.IsFiring; break; } } } }