private void RandomBombSpawn(PlayerController user, int bombToSpawn) { for (int i = 0; i < 10; i++) { Vector3 positionToSpawn3 = user.CurrentRoom.GetRandomVisibleClearSpot(1, 1).ToVector3(); SpawnObjectPlayerItem bigbombPrefab = PickupObjectDatabase.GetById(bombToSpawn).GetComponent <SpawnObjectPlayerItem>(); GameObject bigbombObject = bigbombPrefab.objectToSpawn.gameObject; GameObject bigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(bigbombObject, positionToSpawn3, Quaternion.identity); tk2dBaseSprite bombsprite = bigbombObject2.GetComponent <tk2dBaseSprite>(); if (bombsprite) { bombsprite.PlaceAtPositionByAnchor(positionToSpawn3, tk2dBaseSprite.Anchor.MiddleCenter); } if (user.HasPickupID(19) || user.HasPickupID(332)) { RestoreAmmo(user, 10); SpawnObjectPlayerItem secondarybigbombPrefab = PickupObjectDatabase.GetById(bombToSpawn).GetComponent <SpawnObjectPlayerItem>(); GameObject secondarybigbombObject = secondarybigbombPrefab.objectToSpawn.gameObject; GameObject secondarybigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(secondarybigbombObject, positionToSpawn3, Quaternion.identity); tk2dBaseSprite secondarybombsprite = secondarybigbombObject2.GetComponent <tk2dBaseSprite>(); if (secondarybombsprite) { secondarybombsprite.PlaceAtPositionByAnchor(positionToSpawn3, tk2dBaseSprite.Anchor.MiddleCenter); } } } }
private void HandleFlip(FlippableCover table) { bool flag2 = base.Owner.PlayerHasActiveSynergy("Hidden Tech Landmine"); if (flag2) { SpawnObjectPlayerItem component = PickupObjectDatabase.GetById(66).GetComponent <SpawnObjectPlayerItem>(); GameObject gameObject = component.objectToSpawn.gameObject; GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, table.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite component2 = gameObject2.GetComponent <tk2dBaseSprite>(); bool flag3 = component2; if (flag3) { component2.PlaceAtPositionByAnchor(table.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } else { int num = 108; SpawnObjectPlayerItem component = PickupObjectDatabase.GetById(num).GetComponent <SpawnObjectPlayerItem>(); GameObject gameObject = component.objectToSpawn.gameObject; GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(gameObject, table.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite component2 = gameObject2.GetComponent <tk2dBaseSprite>(); bool flag4 = component2; if (flag4) { component2.PlaceAtPositionByAnchor(table.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } }
public override void OnReloadPressed(PlayerController player, Gun gun, bool bSOMETHING) { base.OnReloadPressed(player, gun, bSOMETHING); if ((gun.ClipCapacity == gun.ClipShotsRemaining) || (gun.CurrentAmmo == gun.ClipShotsRemaining)) { if (gun.CurrentAmmo >= 5) { gun.CurrentAmmo -= 5; SpawnObjectPlayerItem bigbombPrefab = PickupObjectDatabase.GetById(66).GetComponent <SpawnObjectPlayerItem>(); GameObject bigbombObject = bigbombPrefab.objectToSpawn.gameObject; GameObject bigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(bigbombObject, player.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite bombsprite = bigbombObject2.GetComponent <tk2dBaseSprite>(); if (bombsprite) { bombsprite.PlaceAtPositionByAnchor(player.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } } else if (gun.ClipShotsRemaining == 0 && gun.CurrentAmmo != 0) { if (player.PlayerHasActiveSynergy("Demolition Man")) { SpawnObjectPlayerItem bigbombPrefab = PickupObjectDatabase.GetById(66).GetComponent <SpawnObjectPlayerItem>(); GameObject bigbombObject = bigbombPrefab.objectToSpawn.gameObject; GameObject bigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(bigbombObject, player.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite bombsprite = bigbombObject2.GetComponent <tk2dBaseSprite>(); if (bombsprite) { bombsprite.PlaceAtPositionByAnchor(player.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } } }
public void PlaceBomb(Vector3 position) { SpawnObjectPlayerItem playerItem = PickupObjectDatabase.GetById(LastOwner.PlayerHasActiveSynergy("Cold as Ice") ? 109 : 108).GetComponent <SpawnObjectPlayerItem>(); GameObject bombPrefab = playerItem.objectToSpawn.gameObject; GameObject BombObject = Object.Instantiate <GameObject>(bombPrefab, position, Quaternion.identity); tk2dBaseSprite bombSprite = BombObject.GetComponent <tk2dBaseSprite>(); if (bombSprite) { bombSprite.PlaceAtPositionByAnchor(position, tk2dBaseSprite.Anchor.MiddleCenter); } }
//Add the item's functionality down here! I stole most of this from the Stuffed Star active item code! protected override void DoEffect(PlayerController user) { int bombToSpawn = 108; if (user.HasPickupID(109) || user.HasPickupID(364) || user.HasPickupID(170)) { bombToSpawn = 109; } if (user.HasPickupID(118)) { RandomBombSpawn(user, bombToSpawn); } List <AIActor> activeEnemies = user.CurrentRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.All); if (activeEnemies != null) { for (int i = 0; i < activeEnemies.Count; i++) { AIActor enemy = activeEnemies[i]; SpawnObjectPlayerItem bigbombPrefab = PickupObjectDatabase.GetById(bombToSpawn).GetComponent <SpawnObjectPlayerItem>(); GameObject bigbombObject = bigbombPrefab.objectToSpawn.gameObject; GameObject bigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(bigbombObject, enemy.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite bombsprite = bigbombObject2.GetComponent <tk2dBaseSprite>(); if (bombsprite) { bombsprite.PlaceAtPositionByAnchor(enemy.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } if (user.HasPickupID(19) || user.HasPickupID(332)) { RestoreAmmo(user, activeEnemies.Count); SpawnObjectPlayerItem secondarybigbombPrefab = PickupObjectDatabase.GetById(bombToSpawn).GetComponent <SpawnObjectPlayerItem>(); GameObject secondarybigbombObject = secondarybigbombPrefab.objectToSpawn.gameObject; GameObject secondarybigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(secondarybigbombObject, enemy.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite secondarybombsprite = secondarybigbombObject2.GetComponent <tk2dBaseSprite>(); if (secondarybombsprite) { secondarybombsprite.PlaceAtPositionByAnchor(enemy.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } } } }
public IEnumerator ExplosiveDiarrhea(PlayerController user) { Notify(null, "Explosive Diarrhea"); for (int i = 0; i < 5; i++) { SpawnObjectPlayerItem component3 = PickupObjectDatabase.GetById(108).GetComponent <SpawnObjectPlayerItem>(); GameObject gameObject3 = component3.objectToSpawn.gameObject; GameObject gameObject4 = UnityEngine.Object.Instantiate <GameObject>(gameObject3, user.specRigidbody.UnitCenter, Quaternion.identity); tk2dBaseSprite component4 = gameObject4.GetComponent <tk2dBaseSprite>(); bool flag6 = component4; if (flag6) { component4.PlaceAtPositionByAnchor(user.specRigidbody.UnitCenter, tk2dBaseSprite.Anchor.MiddleCenter); } yield return(new WaitForSeconds(1f)); } yield return(null); }
public override void Pickup(PlayerController player) { base.Pickup(player); foreach (var item in Gungeon.Game.Items.Entries) { if (item is SpawnObjectPlayerItem) { SpawnObjectPlayerItem item2 = (SpawnObjectPlayerItem)item; if (item2.objectToSpawn != null && item2.objectToSpawn.name == "BlackHole") { objectToSpawn = item2.objectToSpawn; break; } } } player.OnTableFlipped += handleFlip; }
public static void DoEffectHook(Action <SpawnObjectPlayerItem, PlayerController> baseMethod, SpawnObjectPlayerItem self, PlayerController user) { if (self.IsCigarettes) { cigarettesUsed++; float damage = 0.5f * cigarettesUsed; bool dRoom = false; bool dRun = user.HasTakenDamageThisRun; bool dFloor = user.HasTakenDamageThisFloor; if (user.CurrentRoom != null) { dRoom = user.CurrentRoom.PlayerHasTakenDamageInThisRoom; } user.healthHaver.NextDamageIgnoresArmor = true; user.healthHaver.ApplyDamage(damage, Vector2.zero, StringTableManager.GetEnemiesString("#SMOKING", -1), CoreDamageTypes.None, DamageCategory.Normal, true, null, false); user.HasTakenDamageThisRun = dRun; user.HasTakenDamageThisFloor = dFloor; if (user.CurrentRoom != null) { user.CurrentRoom.PlayerHasTakenDamageInThisRoom = dRoom; } StatModifier statModifier = new StatModifier(); statModifier.statToBoost = PlayerStats.StatType.Coolness; statModifier.modifyType = StatModifier.ModifyMethod.ADDITIVE; statModifier.amount = 1f; user.ownerlessStatModifiers.Add(statModifier); user.stats.RecalculateStats(user, false, false); self.IsCigarettes = false; baseMethod(self, user); self.IsCigarettes = true; } else { baseMethod(self, user); } }
public static bool CanBeUsedHook(Action <SpawnObjectPlayerItem, PlayerController> baseMethod, SpawnObjectPlayerItem self, PlayerController user) { //baseMethod is not called at all as I can't get its return value if (self.IsCigarettes) { if (user.characterIdentity == PlayableCharacters.Robot) { return(false); } if (user.CurrentGun && user.CurrentGun.IsReloading && user.CurrentGun.ClipShotsRemaining == 0 && !user.CurrentGun.IsHeroSword) { foreach (PassiveItem item in user.passiveItems) { if (item is CrisisStoneItem) { return(false); } } } } //calling the overridden base method: PlayerItem.CanBeUsed is actually always null but this is good practise var method = typeof(PlayerItem).GetMethod("CanBeUsed", BindingFlags.Public | BindingFlags.Instance); var ftn = method.MethodHandle.GetFunctionPointer(); var func = (Func <bool>)Activator.CreateInstance(typeof(Func <bool>), self, ftn); bool b = func(); return((!self.IsCigarettes || !user || !user.healthHaver || user.healthHaver.IsVulnerable) && (!self.RequireEnemiesInRoom || !user || user.CurrentRoom == null || user.CurrentRoom.GetActiveEnemiesCount(RoomHandler.ActiveEnemyType.All) != 0) && b); }
private void HandleHit(Projectile arg1, SpeculativeRigidbody arg2, bool arg3) { if (arg2.aiActor != null && arg2.aiActor.behaviorSpeculator && !arg2.aiActor.IsHarmlessEnemy) { PlayerController player = gun.CurrentOwner as PlayerController; if ((player.HasPickupID(131) || player.HasPickupID(239) || player.HasPickupID(815)) || (gun.DuctTapeMergedGunIDs != null)) { float value2 = UnityEngine.Random.Range(0.0f, 1.0f); if (value2 <= 0.05 && armorCount < 10) { GameManager.Instance.StartCoroutine(this.Clang()); LootEngine.SpawnItem(PickupObjectDatabase.GetById(120).gameObject, arg2.sprite.WorldBottomCenter, Vector2.up, 1f, true, false, true); armorCount += 1; } } float value = UnityEngine.Random.Range(0.0f, 1.0f); if (value <= 0.05) { GameManager.Instance.StartCoroutine(this.Clang()); // TURRET SpawnObjectPlayerItem portableturret = PickupObjectDatabase.GetById(201).GetComponent <SpawnObjectPlayerItem>(); String turretGuid = portableturret.enemyGuidToSpawn; GameObject objectToSpawn = EnemyDatabase.GetOrLoadByGuid(turretGuid).gameObject; GameObject gameObject2 = UnityEngine.Object.Instantiate <GameObject>(objectToSpawn, arg2.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite component4 = gameObject2.GetComponent <tk2dBaseSprite>(); if (component4) { component4.sprite.IsPerpendicular = true; component4.PlaceAtPositionByAnchor(arg2.sprite.WorldBottomCenter.ToVector3ZUp(component4.transform.position.z), tk2dBaseSprite.Anchor.MiddleCenter); } this.spawnedPlayerObject = gameObject2; PortableTurretController component5 = this.spawnedPlayerObject.GetComponent <PortableTurretController>(); if (component5) { component5.sourcePlayer = player; } } else { if (value <= 0.1) { GameManager.Instance.StartCoroutine(this.Clang()); //MINE SpawnObjectPlayerItem proximitymine = PickupObjectDatabase.GetById(66).GetComponent <SpawnObjectPlayerItem>(); GameObject mineObject = proximitymine.objectToSpawn.gameObject; GameObject mineObject2 = UnityEngine.Object.Instantiate <GameObject>(mineObject, arg2.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite mineSprite = mineObject2.GetComponent <tk2dBaseSprite>(); if (mineSprite) { mineSprite.IsPerpendicular = true; mineSprite.PlaceAtPositionByAnchor(arg2.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } else { if (value <= 0.15) { GameManager.Instance.StartCoroutine(this.Clang()); //TABLE FoldingTableItem foldingtable = PickupObjectDatabase.GetById(644).GetComponent <FoldingTableItem>(); GameObject tableObject = foldingtable.TableToSpawn.gameObject; GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(tableObject.gameObject, arg2.sprite.WorldBottomCenter, Quaternion.identity); SpeculativeRigidbody componentInChildren = gameObject.GetComponentInChildren <SpeculativeRigidbody>(); FlippableCover component = gameObject.GetComponent <FlippableCover>(); component.transform.position.XY().GetAbsoluteRoom().RegisterInteractable(component); component.ConfigureOnPlacement(component.transform.position.XY().GetAbsoluteRoom()); componentInChildren.Initialize(); PhysicsEngine.Instance.RegisterOverlappingGhostCollisionExceptions(componentInChildren, null, false); } } } } }
public static void RollHook(Action <RatPackItem, Projectile> orig, RatPackItem item, Projectile proj) { PlayerController player = item.LastOwner; if (player.HasPickupID(TrapCardId)) { if (cooldown == false) { float value = UnityEngine.Random.Range(0.0f, 1.0f); bool flag = value < 0.3; if (flag || player.HasPickupID(423)) { AIActor enemy = proj.Owner as AIActor; if (enemy != null) { cooldown = true; GameManager.Instance.StartCoroutine(StartCooldown()); LootEngine.DoDefaultItemPoof(enemy.sprite.WorldBottomCenter, false, true); AkSoundEngine.PostEvent("Play_OBJ_bomb_fuse_01", enemy.gameObject); if (player.HasPickupID(109) || player.HasPickupID(364) || player.HasPickupID(170)) { SpawnObjectPlayerItem icebombPrefab = PickupObjectDatabase.GetById(109).GetComponent <SpawnObjectPlayerItem>(); GameObject icebombObject = icebombPrefab.objectToSpawn.gameObject; GameObject icebombObject2 = UnityEngine.Object.Instantiate <GameObject>(icebombObject, enemy.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite icebombsprite = icebombObject2.GetComponent <tk2dBaseSprite>(); if (icebombsprite) { icebombsprite.PlaceAtPositionByAnchor(enemy.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } else if (!player.HasPickupID(109) || !player.HasPickupID(364) || !player.HasPickupID(170)) { SpawnObjectPlayerItem bigbombPrefab = PickupObjectDatabase.GetById(108).GetComponent <SpawnObjectPlayerItem>(); GameObject bigbombObject = bigbombPrefab.objectToSpawn.gameObject; GameObject bigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(bigbombObject, enemy.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite bombsprite = bigbombObject2.GetComponent <tk2dBaseSprite>(); if (bombsprite) { bombsprite.PlaceAtPositionByAnchor(enemy.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } } else { RoomHandler absoluteRoom = player.CurrentRoom; if (absoluteRoom.HasActiveEnemies(RoomHandler.ActiveEnemyType.All)) { AIActor randomActiveEnemy = absoluteRoom.GetNearestEnemy(Vector2.zero, out float nearestDistance, true, true); nearestDistance = float.MaxValue; if (randomActiveEnemy != null) { if (player.HasPickupID(109) || player.HasPickupID(364) || player.HasPickupID(170)) { SpawnObjectPlayerItem icebombPrefab = PickupObjectDatabase.GetById(109).GetComponent <SpawnObjectPlayerItem>(); GameObject icebombObject = icebombPrefab.objectToSpawn.gameObject; GameObject icebombObject2 = UnityEngine.Object.Instantiate <GameObject>(icebombObject, randomActiveEnemy.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite icebombsprite = icebombObject2.GetComponent <tk2dBaseSprite>(); if (icebombsprite) { icebombsprite.PlaceAtPositionByAnchor(randomActiveEnemy.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } else if (!player.HasPickupID(109) || !player.HasPickupID(364) || !player.HasPickupID(170)) { SpawnObjectPlayerItem bigbombPrefab = PickupObjectDatabase.GetById(108).GetComponent <SpawnObjectPlayerItem>(); GameObject bigbombObject = bigbombPrefab.objectToSpawn.gameObject; GameObject bigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(bigbombObject, randomActiveEnemy.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite bombsprite = bigbombObject2.GetComponent <tk2dBaseSprite>(); if (bombsprite) { bombsprite.PlaceAtPositionByAnchor(randomActiveEnemy.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } } } } } } } orig(item, proj); }
public static void CigarettesHook(Action <SpawnObjectPlayerItem, PlayerController> orig, SpawnObjectPlayerItem self, PlayerController user) { orig(self, user); if (self.IsCigarettes) { if (user.HasPickupID(ETGMod.Databases.Items["Invoker"].PickupObjectId)) { StatModifier statModifier = new StatModifier(); statModifier.statToBoost = PlayerStats.StatType.Coolness; statModifier.modifyType = StatModifier.ModifyMethod.ADDITIVE; statModifier.amount = 1f; user.ownerlessStatModifiers.Add(statModifier); user.stats.RecalculateStats(user, false, false); } } }
//SYNERGY WITH SPARE KEY --> "Spare Keybullet Kin" private void OnEnemyDamaged(float damage, bool fatal, HealthHaver enemy) { try { if (enemy.aiActor && enemy) { if (fatal && Owner.HasPickupID(71)) { if (UnityEngine.Random.value < 0.1f) { SpawnObjectPlayerItem bigbombPrefab = PickupObjectDatabase.GetById(71).GetComponent <SpawnObjectPlayerItem>(); GameObject bigbombObject = bigbombPrefab.objectToSpawn.gameObject; GameObject bigbombObject2 = UnityEngine.Object.Instantiate <GameObject>(bigbombObject, enemy.sprite.WorldBottomCenter, Quaternion.identity); tk2dBaseSprite bombsprite = bigbombObject2.GetComponent <tk2dBaseSprite>(); if (bombsprite) { bombsprite.PlaceAtPositionByAnchor(enemy.sprite.WorldBottomCenter, tk2dBaseSprite.Anchor.MiddleCenter); } } } float outcomeDamage = damage; if (Owner.HasPickupID(442)) { outcomeDamage *= 2; } RoomHandler absoluteRoom = base.transform.position.GetAbsoluteRoom(); List <AIActor> enemiesInRoom = new List <AIActor>(); if (absoluteRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear) != null) { foreach (AIActor m_Enemy in absoluteRoom.GetActiveEnemies(RoomHandler.ActiveEnemyType.RoomClear)) { enemiesInRoom.Add(m_Enemy); } } AIActor randomActiveEnemy = null; AIActor randomActiveOTHEREnemy = null; if (enemiesInRoom.Count > 1) { enemiesInRoom.Remove(enemy.aiActor); randomActiveEnemy = BraveUtility.RandomElement(enemiesInRoom); if (enemiesInRoom.Count > 2 && (Owner.HasPickupID(276) || Owner.HasPickupID(149) || Owner.HasPickupID(482) || Owner.HasPickupID(506) || Owner.HasPickupID(172) || Owner.HasPickupID(198) || Owner.HasPickupID(Gungeon.Game.Items["nn:spectre_bullets"].PickupObjectId))) { enemiesInRoom.Remove(randomActiveEnemy); randomActiveOTHEREnemy = BraveUtility.RandomElement(enemiesInRoom); } } if (randomActiveEnemy != null && randomActiveEnemy != enemy.aiActor && randomActiveEnemy.healthHaver && randomActiveEnemy.healthHaver.IsAlive && randomActiveEnemy.healthHaver.IsVulnerable) { if (OnCooldownVoodoo == false) { OnCooldownVoodoo = true; if (Owner.HasPickupID(527) && UnityEngine.Random.value < 0.25f) { randomActiveEnemy.gameActor.ApplyEffect(this.charmEffect, 1f, null); } randomActiveEnemy.healthHaver.ApplyDamage(outcomeDamage, Vector2.zero, "Voodoo Magic", CoreDamageTypes.None, DamageCategory.Normal, true, null, false); if ((Owner.HasPickupID(276) || Owner.HasPickupID(149) || Owner.HasPickupID(482) || Owner.HasPickupID(506) || Owner.HasPickupID(172) || Owner.HasPickupID(198) || Owner.HasPickupID(Gungeon.Game.Items["nn:spectre_bullets"].PickupObjectId)) && randomActiveOTHEREnemy != null && randomActiveOTHEREnemy != enemy.aiActor && randomActiveOTHEREnemy.healthHaver && randomActiveOTHEREnemy.healthHaver.IsAlive && randomActiveOTHEREnemy.healthHaver.IsVulnerable) { if (Owner.HasPickupID(527) && UnityEngine.Random.value < 0.25f) { randomActiveOTHEREnemy.gameActor.ApplyEffect(this.charmEffect, 1f, null); } randomActiveOTHEREnemy.healthHaver.ApplyDamage(outcomeDamage, Vector2.zero, "Voodoo Magic", CoreDamageTypes.None, DamageCategory.Normal, true, null, false); } Invoke("Cooldown", 0.01f); } } } } catch (Exception e) { ETGModConsole.Log(e.Message); ETGModConsole.Log(e.StackTrace); ETGModConsole.Log("IF YOU SEE THIS PLEASE REPORT IT TO NEVERNAMED (WITH SCREENSHOTS)"); } }