public override bool OnUse(EquipmentSlot equipmentSlot) { MicrophoneSoundwaveLauncher component = equipmentSlot.GetComponent <MicrophoneSoundwaveLauncher>(); if (!component) { component = equipmentSlot.gameObject.AddComponent <MicrophoneSoundwaveLauncher>(); } component.ammo++; component.aimRay = equipmentSlot.GetAimRay(); return(true); }
protected override bool PerformEquipmentAction(EquipmentSlot slot) { var cpt = slot.characterBody.GetComponent <PackBoxTracker>(); if (!cpt) { cpt = slot.characterBody.gameObject.AddComponent <PackBoxTracker>(); } if (cpt.packedObject == null) { if (slot.currentTarget.rootObject && validObjectNames.Contains(slot.currentTarget.rootObject.name)) { var shopcpt = slot.currentTarget.rootObject.GetComponent <ShopTerminalBehavior>(); if (shopcpt && shopcpt.serverMultiShopController) { slot.currentTarget.rootObject = shopcpt.serverMultiShopController.transform.root.gameObject; } var pbh = slot.currentTarget.rootObject.GetComponent <PackBoxHandler>(); if (!pbh) { pbh = slot.currentTarget.rootObject.AddComponent <PackBoxHandler>(); } pbh.TryPackServer(cpt); return(false); } } else { var pbh = cpt.packedObject.GetComponent <PackBoxHandler>(); if (!pbh) { TinkersSatchelPlugin._logger.LogError("PackBoxTracker contains GameObject with no PackBoxHandler"); return(false); } if (TryGetBoxablePlacePos(slot.GetAimRay(), out Vector3 placeLoc, out _)) { var didPlace = pbh.TryPlaceServer(cpt, placeLoc); if (Compat_ClassicItems.enabled) { if (didPlace && Util.CheckRoll(Mathf.Pow(0.5f, Compat_ClassicItems.CheckEmbryoProc(slot, equipmentDef)) * 100f)) { return(false); } } return(didPlace); }
protected override bool PerformEquipmentAction(EquipmentSlot slot) { CharacterBody body = slot.characterBody; GameObject gameObject = slot.gameObject; if (!gameObject || !body) { return(false); } var angle = Util.QuaternionSafeLookRotation(slot.inputBank ? slot.GetAimRay().direction : gameObject.transform.forward); FireBomb(body, gameObject, angle); return(true); }
private void EquipmentSlot_UpdateTargets(On.RoR2.EquipmentSlot.orig_UpdateTargets orig, EquipmentSlot self, EquipmentIndex targetingEquipmentIndex, bool userShouldAnticipateTarget) { if (targetingEquipmentIndex != catalogIndex || self.subcooldownTimer > 0f || self.stock == 0) { orig(self, targetingEquipmentIndex, userShouldAnticipateTarget); if (targetingEquipmentIndex == catalogIndex) { self.targetIndicator.active = false; } return; } var res = FindNearestRerollable(self.gameObject, self.GetAimRay(), 10f, 20f, false); Transform tsf = null; if (res) { tsf = res.transform; } self.currentTarget = new EquipmentSlot.UserTargetInfo { transformToIndicateAt = tsf, pickupController = null, hurtBox = null, rootObject = res }; if (self.currentTarget.rootObject != null) { var purch = res.GetComponent <PurchaseInteraction>(); if (!res.GetComponent <RecombobulatorFlag>() && (!purch || purch.available)) { self.targetIndicator.visualizerPrefab = LegacyResourcesAPI.Load <GameObject>("Prefabs/RecyclerIndicator"); } else { self.targetIndicator.visualizerPrefab = LegacyResourcesAPI.Load <GameObject>("Prefabs/RecyclerBadIndicator"); } self.targetIndicator.active = true; self.targetIndicator.targetTransform = self.currentTarget.transformToIndicateAt; } else { self.targetIndicator.active = false; } }
public void ConfigureTargetFinderBase(EquipmentSlot self) { if (TargetFinder == null) { TargetFinder = new BullseyeSearch(); } TargetFinder.teamMaskFilter = TeamMask.allButNeutral; TargetFinder.teamMaskFilter.RemoveTeam(self.characterBody.teamComponent.teamIndex); TargetFinder.sortMode = BullseyeSearch.SortMode.Angle; TargetFinder.filterByLoS = true; float num; Ray ray = CameraRigController.ModifyAimRayIfApplicable(self.GetAimRay(), self.gameObject, out num); TargetFinder.searchOrigin = ray.origin; TargetFinder.searchDirection = ray.direction; TargetFinder.maxAngleFilter = 10f; TargetFinder.viewer = self.characterBody; }
protected override bool ActivateEquipment(EquipmentSlot slot) { CharacterBody body = slot.characterBody; if (!body) { return(false); } GameObject gameObject = slot.gameObject; Util.PlaySound(FireMines.throwMineSoundString, gameObject); var damageMult = 1f; var angle = Util.QuaternionSafeLookRotation(slot.inputBank ? slot.GetAimRay().direction : gameObject.transform.forward); FireMolotov(body, gameObject, angle, damageMult); return(true); }
////// Hooks ////// protected override bool PerformEquipmentAction(EquipmentSlot slot) { var aimRay = slot.GetAimRay(); var aimRot = Quaternion.LookRotation(aimRay.direction); ProjectileManager.instance.FireProjectile(new FireProjectileInfo { projectilePrefab = this.projectilePrefab, crit = slot.characterBody.RollCrit(), damage = slot.characterBody.damage * damageFrac, damageColorIndex = DamageColorIndex.Item, force = 100f, owner = slot.gameObject, position = aimRay.origin, rotation = aimRot }); return(true); }
public void FixedUpdate() { if (!NetworkServer.active) { return; } interval -= Time.fixedDeltaTime; if (interval <= 0f && ammo > 0) { interval = intervalMax; ammo--; var characterBody = equipmentSlot.characterBody; if (characterBody) { if (!characterBody.characterMotor || !characterBody.characterMotor.isGrounded) { var height = boostDistance.Value; var mass = characterBody.characterMotor ? characterBody.characterMotor.mass : (characterBody.rigidbody ? characterBody.rigidbody.mass : 1f); var ySpeed = Trajectory.CalculateInitialYSpeedForHeight(height, -characterBody.acceleration); var force = -ySpeed *mass *equipmentSlot.GetAimRay().direction; if (characterBody.characterMotor) { characterBody.characterMotor.ApplyForce(force, false, false); } else if (characterBody.rigidbody) { characterBody.rigidbody.AddForce(force, ForceMode.Impulse); } } } Vector3 position = transform.position; for (int i = 0; i < shotsPerCast; i++) { ProjectileManager.instance.FireProjectile(waveProjectilesScaled[i], position + (10f * (float)i) * aimRay.direction.normalized, Util.QuaternionSafeLookRotation(aimRay.direction), equipmentSlot.gameObject, 0f, 0f, false, DamageColorIndex.Default, null, -1f); } PointSoundManager.EmitSoundServer(sound.index, position); } }
private void EquipmentSlot_UpdateTargets(On.RoR2.EquipmentSlot.orig_UpdateTargets orig, EquipmentSlot self, EquipmentIndex targetingEquipmentIndex, bool userShouldAnticipateTarget) { if (targetingEquipmentIndex != catalogIndex || self.subcooldownTimer > 0f || self.stock == 0) { orig(self, targetingEquipmentIndex, userShouldAnticipateTarget); if (targetingEquipmentIndex == catalogIndex) { self.targetIndicator.active = false; } return; } var cpt = self.characterBody.GetComponent <PackBoxTracker>(); if (!cpt) { cpt = self.characterBody.gameObject.AddComponent <PackBoxTracker>(); } GameObject indPrefab; if (cpt.packedObject) { indPrefab = placeIndicatorPrefab; bool didPlace = TryGetBoxablePlacePos(self.GetAimRay(), out Vector3 loc, out bool didHitGround); if (didPlace || didHitGround) { if (!didPlace) { indPrefab = placeIndicatorBadPrefab; } cpt.groundTarget.transform.position = loc; self.currentTarget = new EquipmentSlot.UserTargetInfo { transformToIndicateAt = cpt.groundTarget, pickupController = null, hurtBox = null, rootObject = cpt.groundTarget.gameObject }; //todo: on-ground indicator like engi blueprints, will need to track separately? } else { self.currentTarget = new EquipmentSlot.UserTargetInfo { transformToIndicateAt = null, pickupController = null, hurtBox = null, rootObject = null } }; } else { indPrefab = packIndicatorPrefab; var res = FindNearestBoxable(self.gameObject, self.GetAimRay(), 10f, 20f, false); Transform tsf = null; if (res) { tsf = res.transform; } self.currentTarget = new EquipmentSlot.UserTargetInfo { transformToIndicateAt = tsf, pickupController = null, hurtBox = null, rootObject = res }; } if (self.currentTarget.rootObject != null) { self.targetIndicator.visualizerPrefab = indPrefab; self.targetIndicator.active = true; self.targetIndicator.targetTransform = self.currentTarget.transformToIndicateAt; } else { self.targetIndicator.active = false; } }
public override bool OnUse(EquipmentSlot equipmentSlot) { CharacterMaster master = equipmentSlot.characterBody.master; if (master) { ArchaicMaskSummonLimit summonLimit = master.GetComponent <ArchaicMaskSummonLimit>(); if (!summonLimit) { summonLimit = master.gameObject.AddComponent <ArchaicMaskSummonLimit>(); } MysticsRisky2UtilsEquipmentTarget targetInfo = equipmentSlot.GetComponent <MysticsRisky2UtilsEquipmentTarget>(); if (targetInfo && targetInfo.obj) { HurtBox targetHB = targetInfo.obj.GetComponent <CharacterBody>().mainHurtBox; if (targetHB) { DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest((SpawnCard)LegacyResourcesAPI.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscArchWisp"), new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.NearestNode, spawnOnTarget = targetHB.transform }, RoR2Application.rng) { summonerBodyObject = equipmentSlot.characterBody.gameObject }; directorSpawnRequest.onSpawnedServer += (spawnResult) => { GameObject wispMasterObject = spawnResult.spawnedInstance; CharacterMaster wispMaster = wispMasterObject.GetComponent <CharacterMaster>(); wispMaster.inventory.GiveItem(RoR2Content.Items.HealthDecay, (int)duration.Value); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostDamage, (int)(wispDamage.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostHp, (int)(wispHealth.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.AlienHead, (int)(wispCDR.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostAttackSpeed, (int)(wispAttackSpeed.Value - 100f) / 10); wispMaster.GetComponent <RoR2.CharacterAI.BaseAI>().currentEnemy.gameObject = targetHB.healthComponent.gameObject; wispMaster.GetComponent <RoR2.CharacterAI.BaseAI>().currentEnemy.bestHurtBox = targetHB; summonLimit.Add(wispMasterObject); }; DirectorCore.instance.TrySpawnObject(directorSpawnRequest); targetInfo.Invalidate(); return(true); } } { DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest((SpawnCard)LegacyResourcesAPI.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscArchWisp"), new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.NearestNode, position = equipmentSlot.GetAimRay().origin }, RoR2Application.rng) { summonerBodyObject = equipmentSlot.characterBody.gameObject }; directorSpawnRequest.onSpawnedServer += (spawnResult) => { GameObject wispMasterObject = spawnResult.spawnedInstance; CharacterMaster wispMaster = wispMasterObject.GetComponent <CharacterMaster>(); wispMaster.inventory.GiveItem(RoR2Content.Items.HealthDecay, (int)duration.Value); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostDamage, (int)(wispDamage.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostHp, (int)(wispHealth.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.AlienHead, (int)(wispCDR.Value - 100f) / 10); wispMaster.inventory.GiveItem(RoR2Content.Items.BoostAttackSpeed, (int)(wispAttackSpeed.Value - 100f) / 10); summonLimit.Add(wispMasterObject); }; DirectorCore.instance.TrySpawnObject(directorSpawnRequest); return(true); } } return(false); }