private void GlobalEventManager_OnCharacterDeath(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { orig(self, damageReport); if (damageReport.attackerBody && damageReport.attackerBody == body) { GiveScrap(damageReport.victimIsElite, damageReport.victimIsBoss); } }
private void CalculateBFBuffGain(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { if (damageReport.attackerBody) { var inventoryCount = GetCount(damageReport.attackerBody); if (inventoryCount > 0) { damageReport.attackerBody.AddBuff(BFBuff); } } orig(self, damageReport); }
//private void GrantBaseShield(ILContext il) //{ // //Provided by Harb from their HarbCrate mod. Thanks Harb! // ILCursor c = new ILCursor(il); // int shieldsLoc = 33; // c.GotoNext( // MoveType.Before, // x => x.MatchLdloc(out shieldsLoc), // x => x.MatchCallvirt<CharacterBody>("set_maxShield") // ); // c.Emit(OpCodes.Ldloc, shieldsLoc); // c.EmitDelegate<Func<CharacterBody, float, float>>((self, shields) => // { // var InventoryCount = GetCount(self); // if (InventoryCount > 0) // { // shields += self.maxHealth * 0.08f; // } // return shields; // }); // c.Emit(OpCodes.Stloc, shieldsLoc); // c.Emit(OpCodes.Ldarg_0); //} private void GrantShieldReward(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, RoR2.GlobalEventManager self, RoR2.DamageReport damageReport) { if (damageReport?.attackerBody) { int inventoryCount = GetCount(damageReport.attackerBody); if (inventoryCount > 0) { var percentage = shieldPercentageRestoredPerKill + (maximumPercentageShieldRestoredPerKill - maximumPercentageShieldRestoredPerKill / (1 + additionalShieldPercentageRestoredPerKillDiminishing * (inventoryCount - 1))); damageReport.attackerBody.healthComponent.RechargeShield(damageReport.attackerBody.healthComponent.fullShield * percentage); } } orig(self, damageReport); }
//Method to allow turrets to give bonus to owner private void GlobalEventManager_OnCharacterDeath(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { var attacker = damageReport?.attackerMaster; if (attacker && TurretGivesEngineerLifeOrbs.Value && attacker.name.ToLower().Contains("turret")) { var ownerInventory = attacker.minionOwnership.ownerMaster.inventory; ownerInventory.AddInfusionBonus((uint)ownerInventory.GetItemCount(ItemIndex.Infusion)); } orig(self, damageReport); }
private void CalculateShellBuffApplications(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { orig(self, damageReport); if (damageReport.attackerBody) { var inventoryCount = GetCount(damageReport.attackerBody); var currentShellStackMax = (baseMaxArmorGain / armorOnKillAmount + ((inventoryCount - 1) * addMaxArmorGain / armorOnKillAmount)); var currentShellStack = damageReport.attackerBody.inventory.GetItemCount(shellStack); if (inventoryCount > 0 && currentShellStack < currentShellStackMax) { damageReport.attackerBody.inventory.GiveItem(shellStack); } } }
private void GlobalEventManager_OnCharacterDeath(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { var attackerBody = damageReport?.attackerBody; if (attackerBody) //if not world { int inventoryCount = GetCount(attackerBody); if (inventoryCount > 0) { var componentExists = attackerBody.GetComponent <MetronomeTrackKills>(); if (componentExists && componentExists.enabled) { componentExists.IncrementKills(); } } } orig(self, damageReport); }
private void AddDeath(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { if (base.isUserAlive && base.meetsBodyRequirement) { if (damageReport.attacker) { if (damageReport.attacker.GetComponent <CharacterBody>().master.netId != null && damageReport.attacker.GetComponent <CharacterBody>().master.netId == base.localUser.cachedMasterController.master.netId) { BreathingroomAchievementHandler component = damageReport.attacker.GetComponent <BreathingroomAchievementHandler>(); if (component) { component.AddKill(damageReport.victimBody); } } } } orig(self, damageReport); }
private static void RitualDagger_OnKill(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager gem, DamageReport damageReport) { try { if (damageReport.damageInfo.attacker) { Inventory Inv = damageReport.damageInfo.attacker.GetComponent <CharacterBody>().inventory; int RitualDaggerCount = Inv.GetItemCount(GNCItemSuite.RitualDaggerItemIndex); if (RitualDaggerCount > 0) { CharacterBody component = damageReport.damageInfo.attacker.GetComponent <CharacterBody>(); TeamComponent component2 = component.GetComponent <TeamComponent>(); TeamIndex teamIndex = component2 ? component2.teamIndex : TeamIndex.Neutral; if (component) { CharacterMaster master = component.master; if (master) { if ((RitualDaggerCount + GNCItemSuiteConfig.RitualDaggerProcChance.Value) >= UnityEngine.Random.Range(0, 100)) { ProcMissile(RitualDaggerCount, component, master, teamIndex, damageReport.damageInfo.procChainMask, null, damageReport.damageInfo); for (var i = 0; i < RitualDaggerCount; i += 2) { ProcMissile(RitualDaggerCount, component, master, teamIndex, damageReport.damageInfo.procChainMask, null, damageReport.damageInfo); } } } } } } } catch { } orig(gem, damageReport); }
private void GlobalEventManager_OnCharacterDeath(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { orig.Invoke(self, damageReport); GameObject attacker = damageReport.damageInfo.attacker; if (attacker) { CharacterBody component = attacker.GetComponent <CharacterBody>(); if (component) { GameObject masterObject = component.masterObject; if (masterObject) { PlayerCharacterMasterController component2; //Engineer Turrret Fix if (masterObject.name == "EngiTurretMaster(Clone)") { component2 = masterObject.GetComponent <Deployable>()?.ownerMaster?.GetComponent <PlayerCharacterMasterController>(); } else { component2 = masterObject.GetComponent <PlayerCharacterMasterController>(); } //Debug.Log("Killed"); bool isBoss = damageReport.victimBody.isBoss; bool isElite = damageReport.victimBody.isElite; int monsterType = isElite ? 1 : isBoss ? 2 : 0; ExampleCommandClientCustom.Invoke(x => { x.Write("Kill"); x.Write(component2.gameObject); x.Write((double)monsterType); }); } } } }
private void BulletAchievementComponentHandler(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { orig(self, damageReport); if (base.meetsBodyRequirement && base.isUserAlive) { if (damageReport.attacker) { if (damageReport.attacker.GetComponent <CharacterBody>().master.netId != null && damageReport.attacker.GetComponent <CharacterBody>().master.netId == base.localUser.cachedMasterController.master.netId) { BulletAchievementHandler component = damageReport.attacker.GetComponent <BulletAchievementHandler>(); if (!component) { component = damageReport.attacker.AddComponent <BulletAchievementHandler>(); } component.AddKill(); if (component.IsReqMet()) { base.Grant(); } } } } }
private static void GlobalEventManager_OnCharacterDeath(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { orig(self, damageReport); if (damageReport.victimBody.HasBuff(_buffIndex)) { if (ExplosivePotDeath.chargePrefab) { UnityEngine.Object.Instantiate <GameObject>(ExplosivePotDeath.chargePrefab, damageReport.victimBody.transform); if (ExplosivePotDeath.explosionEffectPrefab) { EffectManager.SpawnEffect(ExplosivePotDeath.explosionEffectPrefab, new EffectData { origin = damageReport.victimBody.transform.position, scale = ExplosivePotDeath.explosionRadius, rotation = Quaternion.identity, }, true); } new BlastAttack { attacker = damageReport.victimBody.gameObject, damageColorIndex = DamageColorIndex.Item, baseDamage = damageReport.victimBody.damage * 0.1f, radius = ExplosivePotDeath.explosionRadius, falloffModel = BlastAttack.FalloffModel.None, procCoefficient = ExplosivePotDeath.explosionProcCoefficient, teamIndex = TeamIndex.None, damageType = DamageType.ClayGoo, position = damageReport.victimBody.transform.position, baseForce = ExplosivePotDeath.explosionForce * 4f, attackerFiltering = AttackerFiltering.NeverHit }.Fire(); } } }
private void CalculateShellBuffApplications(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { orig(self, damageReport); var inventoryCount = GetCount(damageReport.attackerBody); if (inventoryCount > 0) { var shellStackTrackerComponent = damageReport.attackerBody.gameObject.GetComponent <ShellStackTracker>(); if (!shellStackTrackerComponent) { damageReport.attackerBody.gameObject.AddComponent <ShellStackTracker>(); } if (damageReport.attackerBody) { var currentShellStackMax = (baseMaxArmorGain / armorOnKillAmount + ((inventoryCount - 1) * addMaxArmorGain / armorOnKillAmount)); var currentShellStack = shellStackTrackerComponent.shellStacks; if (currentShellStack < currentShellStackMax) { shellStackTrackerComponent.shellStacks++; } } } }
private void GalaticAquaticAquarium(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport report) { //This is the entire spawning logic & by god it's a mess, but it works & I'll change it eventually, just not right now. //This starts off with if the attacker has an inventory, simple check for 90% of scenarios that enemies don't have inventories to prevent all deaths from being checked. if (report.attackerBody.inventory) { //Three variables are created, one for how many squidTurretItems the attacker has. //One for counting the chance of monster spawning, which is 5 + count of squidTurretItem in the attackers inventory. //Finally the squid team itself, 1/20 chance to become an enemy at base value, value increases for every stack the attacker has. int HowManySquidsAreInYourPocket = report.attackerBody.inventory.GetItemCount(squidTurretItem.itemIndex); int squidStackCheck = 5 + HowManySquidsAreInYourPocket; var squidTeam = Util.CheckRoll(squidStackCheck) ? TeamIndex.Monster : TeamIndex.Player; //Three if statements are created, one for checking if CharacterMaster is null, then do nothing. //One is created if DamageReport is null, then do nothing //One for if there's a victim and if there's an attacker, which is what starts the spawning itself. if (self is null) { return; } if (report is null) { return; } if (report.victimBody && report.attacker) { //A check is then performed to see if the attackers count of squidTurretItem is greater than 0 if (HowManySquidsAreInYourPocket > 0) { //A spawn card is created utilizing the SquidTurret spawn card. SpawnCard spawnCard = Resources.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/cscSquidTurret"); //A placement rule is created so that the Squid Turrets spawn on the victims body. DirectorPlacementRule placementRule = new DirectorPlacementRule { placementMode = DirectorPlacementRule.PlacementMode.Approximate, minDistance = 5f, maxDistance = 25f, spawnOnTarget = report.victimBody.transform, }; //A spawn request is generated using the aforementioned variables of Spawn Card and the Placement Rule. DirectorSpawnRequest directorSpawnRequest = new DirectorSpawnRequest(spawnCard, placementRule, RoR2Application.rng) { teamIndexOverride = squidTeam }; //A secondary spawn request is then made using the first one as a baseline //The second spawn request delagates the initial spawn request into a new Action which is Spawn Result and names it result. DirectorSpawnRequest directorSpawnRequest2 = directorSpawnRequest; directorSpawnRequest2.onSpawnedServer = (Action <SpawnCard.SpawnResult>) Delegate.Combine(directorSpawnRequest2.onSpawnedServer, new Action <SpawnCard.SpawnResult>(delegate(SpawnCard.SpawnResult result) { //A pseudo character named squidTurret which is the result of the spawned instance in the aforementioned directorSpawnRequest 2 and its Character Master is then inherited into it. //The squid is then given 15 stacks of Health Decay (Half of a regular squid) //It is also given 20 BoostAttackSpeeds which is then amplified by the amount of squidTurretItems the attacker has (Double the regular squid) CharacterMaster squidTurret = result.spawnedInstance.GetComponent <CharacterMaster>(); if (squidTeam == TeamIndex.Monster) { squidTurret.inventory.GiveItem(ItemIndex.HealthDecay, 20); squidTurret.inventory.GiveItem(ItemIndex.BoostAttackSpeed, 5 * HowManySquidsAreInYourPocket); } else { squidTurret.inventory.GiveItem(ItemIndex.HealthDecay, 45); squidTurret.inventory.GiveItem(ItemIndex.BoostAttackSpeed, 20 * HowManySquidsAreInYourPocket); } //Three variables are created here, one being the current run in order to invoke the next two. //The current fixed time is then generated & divided by 60 to turn the current chance to a 1:1 for 1% every 1 minute. //A fixed rate of base being 1%, then adding whatever the current additional chance is. float AdditionalChance = Run.instance.fixedTime; float squidSpawnAsBuffedSquidChance = 1 + (AdditionalChance / 60) + (HowManySquidsAreInYourPocket * 2); //A check is them performed to check if the squid is on the player index. //If this check if passed, a 1/100 roll is performed to see if the squid inherits a random item from the SquidItemIndex created at the top of page. //If this fails, a secondary 1/100 roll is performed to see if the squid inherits a random elite buff from the SquidBuffIndex created in "JackedSquidsGettingBuffed" method. if (squidTeam == TeamIndex.Player) { if (Util.CheckRoll(squidSpawnAsBuffedSquidChance)) { squidTurret.GetBody().AddBuff(SquidBuffIndex[UnityEngine.Random.Range(0, SquidBuffIndex.Count())]); } else if (Util.CheckRoll(squidSpawnAsBuffedSquidChance)) { squidTurret.inventory.GiveItem(SquidItemIndex[UnityEngine.Random.Range(0, SquidItemIndex.Count())]); } } //Once these checks have passed, the squidTurrets ownership is passed onto the attacker who initially spawned it. squidTurret.minionOwnership.SetOwner(report.attackerMaster); })); //Finally the squid is attempted to be spawned. if (Util.CheckRoll(25)) { DirectorCore.instance.TrySpawnObject(directorSpawnRequest); } } } } //The damage report is returned to itself, the character deaths are returned to itself and finally globaleventmanger is returned to itself. orig(self, report); }
private void GlobalEventManager_OnCharacterDeath(On.RoR2.GlobalEventManager.orig_OnCharacterDeath orig, GlobalEventManager self, DamageReport damageReport) { ignoreMugs = true; orig(self, damageReport); ignoreMugs = false; }