public static void BuildPrefab() { if (prefab == null || !EnemyBuilder.Dictionary.ContainsKey(guid)) { //Sets up the prefab of the enemy. The spritepath, "CakeMod/Resources/DemonGuy/Idle/milton_idle_001", determines the setup sprite for your enemy. vvvv This bool right here determines whether or not an enemy has an AiShooter or not. AIShooters are necessary if you want your enemy to hold a gun for example. An example of this can be seen in here. prefab = EnemyBuilder.BuildPrefab("DemonGuy", guid, "CakeMod/Resources/DemonGuy/Idle/bullet_demon_idle_001", new IntVector2(0, 0), new IntVector2(0, 0), true); //This line extends a BraveBehavior called EnemyBehavior, this is a generic behavior I use for setting up things that can't be setup in BuildPrefab. var enemy = prefab.AddComponent <EnemyBehavior>(); //Here you can setup various things like movement speed, weight, and health. There's a lot you can do with the AiActor parameter so feel free to experiment. //For DemonGuy let's make him a flying enemy enemy.aiActor.MovementSpeed = 2f; enemy.aiActor.knockbackDoer.weight = 100; enemy.aiActor.IgnoreForRoomClear = false; enemy.aiActor.CollisionDamage = 1f; enemy.aiActor.healthHaver.ForceSetCurrentHealth(30f); enemy.aiActor.healthHaver.SetHealthMaximum(45f, null, false); //This is where you setup your animations. Most animations need specific frame names to be recognized like idle or die. //The AddAnimation lines gets sprites from the folder specified in second phrase of the this line. At the very least you need an animation that contains the word idle for the idle animations for example. //AnimationType determines what kind of animation your making. In Gungeon there are 7 different Animation Types: Move, Idle, Fidget, Flight, Hit, Talk, Other. For a majority of these animations, these play automatically, however specific animations need to be told when to play such as Attack. //DirectionType determines the amount of ways an animation can face. You'll have to change your animation names to correspond with the DirectionType. For example if you want an animation to face eight ways you'll have to name your animations something like ""attack_south_west", "attack_north_east", "attack_east", "attack_south_east", "attack_north", "attack_south", "attack_west", "attack_north_west" and change DirectionType to DirectionType.EightWayOrdinal. //I suggest looking at the sprites of base game enemies to determine the names for the different directions. prefab.AddAnimation("idle_left", "CakeMod/Resources/DemonGuy/Idle", fps: 5, AnimationType.Idle, DirectionType.FourWay); prefab.AddAnimation("idle_right", "CakeMod/Resources/DemonGuy/Idle", fps: 5, AnimationType.Idle, DirectionType.FourWay); prefab.AddAnimation("move_front_right", "CakeMod/Resources/DemonGuy/MoveFrontRight", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("move_back_right", "CakeMod/Resources/DemonGuy/MoveBackRight", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("move_front_left", "CakeMod/Resources/DemonGuy/MoveFrontLeft", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("move_back_left", "CakeMod/Resources/DemonGuy/MoveBackLeft", fps: 5, AnimationType.Move, DirectionType.FourWay); //Note that the "die"animations are only set to Move because they will be overwritten later. //tk2dSpriteAnimationClip.WrapMode.Once determines how an animation plays out. If you don't want it to loop, leave it to Once, otherwise you can change it to Loop or something. //Assign animation well, assigns an animation to an animation type. By default this is on, but since we're overwritting this set this to false. prefab.AddAnimation("die_left", "CakeMod/Resources/DemonGuy/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_right", "CakeMod/Resources/DemonGuy/Die", fps: 8, AnimationType.Move, DirectionType.TwoWayHorizontal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); //Here we create a new DirectionalAnimation for our enemy to pull from. //Make sure the AnimNames correspong to the AddAnimation names. DirectionalAnimation idle = new DirectionalAnimation() { AnimNames = new string[] { "idle_right", "idle_left" }, Flipped = new FlipType[] { FlipType.None, FlipType.None }, Type = DirectionType.TwoWayHorizontal, Prefix = string.Empty }; DirectionalAnimation die = new DirectionalAnimation() { AnimNames = new string[] { "die_right", "die_left" }, Flipped = new FlipType[] { FlipType.None, FlipType.None }, Type = DirectionType.TwoWayHorizontal, Prefix = string.Empty }; //Because Dodge Roll is Dodge Roll and there is no animation types for death, we have to assign them to the Other category. enemy.aiAnimator.AssignDirectionalAnimation("die", die, AnimationType.Other); //This is where we get into the meat and potatoes of our enemy. This is where all the behaviors of our enemy are made. //this line adds a BehaviorSpeculator to our enemy which is the base for adding behaviors on to. var bs = prefab.GetComponent <BehaviorSpeculator>(); //We're also going to duplicate the bulletbank and aishooter from the Bullet Kin. //The "762" represents the the gun id we want our enemy to hold. For a list of all gun ids, look at the items file on this github. //For now let's give him the finished gun. GameObject m_CachedGunAttachPoint = enemy.transform.Find("GunAttachPoint").gameObject; Vector2 offset = new Vector2(1f, -0.50f); m_CachedGunAttachPoint.transform.position = enemy.sprite.WorldCenter + offset; AIActor SourceEnemy = EnemyDatabase.GetOrLoadByGuid("5f3abc2d561b4b9c9e72b879c6f10c7e5f3abc2d561b4b9c9e72b879c6f10c7e"); EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, SourceEnemy.aiShooter, SourceEnemy.GetComponent <AIBulletBank>(), 476, enemy.sprite.transform); //Here we will add some basic behaviors such as TargetPlayerBehavior and SeekTargetBehavior. //You can change many things in these behaviors so feel free to go nuts. bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = true, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f, } }; //Now this is one of the most important behaviors because it allows our enemy to shoot. //If we want our enemy to shoot out of a gun, use ShootGunBehavior bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootGunBehavior() { GroupCooldownVariance = 0.2f, LineOfSight = false, //With weapon type you can determine if you want your enemy to fire the gun directly or to use a bullet script. Let's use a Bullet Script for now. For the rest of code, let's modify it to be close to the Finished Gun. WeaponType = WeaponType.BulletScript, OverrideBulletName = null, BulletScript = new CustomBulletScriptSelector(typeof(DemonGuyScript)), FixTargetDuringAttack = true, StopDuringAttack = true, LeadAmount = 0, LeadChance = 1, RespectReload = true, MagazineCapacity = 6, ReloadSpeed = 2f, EmptiesClip = true, SuppressReloadAnim = false, TimeBetweenShots = -1, PreventTargetSwitching = true, OverrideAnimation = null, OverrideDirectionalAnimation = null, HideGun = false, UseLaserSight = false, UseGreenLaser = false, PreFireLaserTime = -1, AimAtFacingDirectionWhenSafe = false, Cooldown = 0.7f, CooldownVariance = 0, AttackCooldown = 0, GlobalCooldown = 0, InitialCooldown = 0, InitialCooldownVariance = 0, GroupName = null, GroupCooldown = 0, MinRange = 0, Range = 16, MinWallDistance = 0, MaxEnemiesInRoom = 0, MinHealthThreshold = 0, MaxHealthThreshold = 1, HealthThresholds = new float[0], AccumulateHealthThresholds = true, targetAreaStyle = null, IsBlackPhantom = false, resetCooldownOnDamage = null, RequiresLineOfSight = true, MaxUsages = 0, } }; bs.MovementBehaviors = new List <MovementBehaviorBase> { new SeekTargetBehavior { StopWhenInRange = false, CustomRange = 15f, LineOfSight = false, ReturnToSpawn = false, SpawnTetherDistance = 0f, PathInterval = 0.5f, SpecifyRange = false, MinActiveRange = 0f, MaxActiveRange = 0f } }; //Adds the enemy to MTG spawn pool and spawn command Game.Enemies.Add("cak:greeddemon", enemy.aiActor); } }
public static void BuildPrefab() { bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { prefab = EnemyBuilder.BuildPrefab("Hunter Kin", guid, "Items/Enemies/Sprites/Hunter_Kin/Idle_Front_Right/hunter_kin_idle_front_right_001", new IntVector2(0, 0), new IntVector2(0, 0), true, true); var enemy = prefab.AddComponent <EnemyBehavior>(); enemy.aiActor.knockbackDoer.weight = 35; enemy.aiActor.MovementSpeed = 4f; enemy.aiActor.healthHaver.PreventAllDamage = false; enemy.aiActor.CollisionDamage = 1f; enemy.aiActor.HasShadow = false; enemy.aiActor.IgnoreForRoomClear = false; enemy.aiActor.aiAnimator.HitReactChance = 0f; enemy.aiActor.specRigidbody.CollideWithOthers = true; enemy.aiActor.specRigidbody.CollideWithTileMap = true; enemy.aiActor.PreventFallingInPitsEver = false; enemy.aiActor.healthHaver.ForceSetCurrentHealth(25f); enemy.aiActor.CollisionKnockbackStrength = 5f; enemy.aiActor.CanTargetPlayers = true; enemy.aiActor.healthHaver.SetHealthMaximum(25f, null, false); prefab.AddAnimation("idle_back_right", "Items/Enemies/Sprites/Hunter_Kin/Idle_Back_Right", fps: 5, AnimationType.Idle, DirectionType.FourWay); prefab.AddAnimation("idle_front_right", "Items/Enemies/Sprites/Hunter_Kin/Idle_Front_Right", fps: 5, AnimationType.Idle, DirectionType.FourWay); prefab.AddAnimation("idle_front_left", "Items/Enemies/Sprites/Hunter_Kin/Idle_Front_Left", fps: 5, AnimationType.Idle, DirectionType.FourWay); prefab.AddAnimation("idle_back_left", "Items/Enemies/Sprites/Hunter_Kin/Idle_Back_Left", fps: 5, AnimationType.Idle, DirectionType.FourWay); // prefab.AddAnimation("run_back_right", "Items/Enemies/Sprites/Hunter_Kin/Run_Back_Right", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("run_front_right", "Items/Enemies/Sprites/Hunter_Kin/Run_Front_Right", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("run_front_left", "Items/Enemies/Sprites/Hunter_Kin/Run_Front_Left", fps: 5, AnimationType.Move, DirectionType.FourWay); prefab.AddAnimation("run_back_left", "Items/Enemies/Sprites/Hunter_Kin/Run_Back_Left", fps: 5, AnimationType.Move, DirectionType.FourWay); // prefab.AddAnimation("die_north", "Items/Enemies/Sprites/Hunter_Kin/Die_North", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_north_east", "Items/Enemies/Sprites/Hunter_Kin/Die_North_East", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_east", "Items/Enemies/Sprites/Hunter_Kin/Die_East", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_south_east", "Items/Enemies/Sprites/Hunter_Kin/Die_South_East", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_south", "Items/Enemies/Sprites/Hunter_Kin/Die_South", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_south_west", "Items/Enemies/Sprites/Hunter_Kin/Die_South_West", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_west", "Items/Enemies/Sprites/Hunter_Kin/Die_West", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); prefab.AddAnimation("die_north_west", "Items/Enemies/Sprites/Hunter_Kin/Die_North_West", fps: 5, AnimationType.Move, DirectionType.EightWayOrdinal, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); // prefab.AddAnimation("summon", "Items/Enemies/Sprites/Hunter_Kin/Summon", fps: 7, AnimationType.Move, DirectionType.Single, tk2dSpriteAnimationClip.WrapMode.Once, assignAnimation: false); DirectionalAnimation die = new DirectionalAnimation() { AnimNames = new string[] { "die_north", "die_north_east", "die_east", "die_south_east", "die_south", "die_south_west", "die_west", "die_north_west" }, Flipped = new FlipType[] { FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, FlipType.None, }, Type = DirectionType.EightWayOrdinal, Prefix = string.Empty }; DirectionalAnimation summon = new DirectionalAnimation() { AnimNames = new string[] { "summon" }, Flipped = new FlipType[] { FlipType.None }, Type = DirectionType.Single, Prefix = string.Empty }; enemy.aiAnimator.AssignDirectionalAnimation("die", die, AnimationType.Other); enemy.aiAnimator.AssignDirectionalAnimation("summon", summon, AnimationType.Other); enemy.aiActor.specRigidbody.PixelColliders.Clear(); enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 14, ManualHeight = 24, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); enemy.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 14, ManualHeight = 24, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); enemy.aiActor.PreventBlackPhantom = false; AIAnimator aiAnimator = enemy.aiAnimator; var yah = enemy.transform.Find("GunAttachPoint").gameObject; yah.transform.position = enemy.aiActor.transform.position; yah.transform.localPosition = new Vector2(0f, .3f); AIActor SourceEnemy = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"); EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, SourceEnemy.aiShooter, SourceEnemy.GetComponent <AIBulletBank>(), 12, yah.transform); var bs = prefab.GetComponent <BehaviorSpeculator>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 45f, LineOfSight = true, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f }, }; AIActor Firecracker = EnemyDatabase.GetOrLoadByGuid("5f15093e6f684f4fb09d3e7e697216b4"); bs.AttackBehaviors = new List <AttackBehaviorBase>() { new AttackBehaviorGroup() { } }; bs.AttackBehaviorGroup.AttackBehaviors = new List <AttackBehaviorGroup.AttackGroupItem>() { new AttackBehaviorGroup.AttackGroupItem() { Probability = 1.75f, Behavior = new ShootGunBehavior() { WeaponType = WeaponType.BulletScript, BulletScript = new CustomBulletScriptSelector(typeof(HunterKinScript)), LeadAmount = 0, LeadChance = 1, AttackCooldown = 1f, RequiresLineOfSight = true, FixTargetDuringAttack = true, StopDuringAttack = true, RespectReload = true, MagazineCapacity = 5, ReloadSpeed = 1f, EmptiesClip = true, SuppressReloadAnim = false, CooldownVariance = 0, GlobalCooldown = 0, InitialCooldown = 0, InitialCooldownVariance = 0, GroupName = null, GroupCooldown = 0, MinRange = 0, Range = 7, MinWallDistance = 0, MaxEnemiesInRoom = -1, MinHealthThreshold = 0, MaxHealthThreshold = 1, HealthThresholds = new float[0], AccumulateHealthThresholds = true, targetAreaStyle = null, IsBlackPhantom = false, resetCooldownOnDamage = null, MaxUsages = 0, UseLaserSight = true, PreFireLaserTime = .5f, }, NickName = "Hunter Kin Shoot Arrow" }, new AttackBehaviorGroup.AttackGroupItem() { Probability = 1.5f, Behavior = new SummonEnemyBehavior() { DefineSpawnRadius = true, MinSpawnRadius = 3, MaxSpawnRadius = 3, MaxRoomOccupancy = 6, MaxSummonedAtOnce = 2, MaxToSpawn = -1, NumToSpawn = 2, KillSpawnedOnDeath = false, CrazeAfterMaxSpawned = false, EnemeyGuids = new List <string>() { BulletDog.guid }, SummonTime = .5f, DisableDrops = true, StopDuringAnimation = true, SummonAnim = "Summon", HideGun = true, Cooldown = 1f, RequiresLineOfSight = false, selectionType = SummonEnemyBehavior.SelectionType.Random, }, NickName = "Summon dat doggy" } }; bs.MovementBehaviors = new List <MovementBehaviorBase> { new SeekTargetBehavior { StopWhenInRange = true, CustomRange = 7f, LineOfSight = false, ReturnToSpawn = false, SpawnTetherDistance = 0f, PathInterval = 0.5f, SpecifyRange = false, MinActiveRange = 0f, MaxActiveRange = 0f } }; bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; Game.Enemies.Add("cel:hunter_kin", enemy.aiActor); } }
public static void BuildPrefab() { AIActor source = EnemyDatabase.GetOrLoadByGuid("c50a862d19fc4d30baeba54795e8cb93"); bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { prefab = EnemyBuilder.BuildPrefab("AbyssKin", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), true); var companion = prefab.AddComponent <EnemyBehavior>(); companion.aiActor.knockbackDoer.weight = 200; companion.aiActor.MovementSpeed = 3f; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = false; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.aiAnimator.HitReactChance = 0.05f; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; companion.aiActor.PreventFallingInPitsEver = true; companion.aiActor.healthHaver.ForceSetCurrentHealth(25f); companion.aiActor.CollisionKnockbackStrength = 5f; companion.aiActor.CanTargetPlayers = true; companion.aiActor.healthHaver.SetHealthMaximum(25f, null, false); companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject; companion.aiActor.PreventBlackPhantom = false; AIAnimator aiAnimator = companion.aiAnimator; prefab.AddAnimation("idle_right", "BunnyMod/Resources/AbyssEnemies/AbyssKin/IdleRight/", fps: 1, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("idle_left", "BunnyMod/Resources/AbyssEnemies/AbyssKin/IdleLeft/", fps: 1, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("move_right", "BunnyMod/Resources/AbyssEnemies/AbyssKin/MoveRight/", fps: 8, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("move_left", "BunnyMod/Resources/AbyssEnemies/AbyssKin/MoveLeft/", fps: 8, AnimationType.Move, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("death_left", "BunnyMod/Resources/AbyssEnemies/AbyssKin/DeathLeft/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); prefab.AddAnimation("death_right", "BunnyMod/Resources/AbyssEnemies/AbyssKin/DeathRight/", fps: 4, AnimationType.Idle, DirectionalAnimation.DirectionType.TwoWayHorizontal); var bs = prefab.GetComponent <BehaviorSpeculator>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("6e972cd3b11e4b429b888b488e308551").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = false, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f } }; bs.MovementBehaviors = new List <MovementBehaviorBase>() { new SeekTargetBehavior() { StopWhenInRange = true, CustomRange = 6, LineOfSight = true, ReturnToSpawn = true, SpawnTetherDistance = 0, PathInterval = 0.5f, SpecifyRange = false, MinActiveRange = 1, MaxActiveRange = 10 } }; bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootGunBehavior() { GroupCooldownVariance = 0.2f, LineOfSight = false, WeaponType = WeaponType.BulletScript, OverrideBulletName = null, BulletScript = new CustomBulletScriptSelector(typeof(AbyssKinAttack)), FixTargetDuringAttack = false, StopDuringAttack = false, LeadAmount = 0, LeadChance = 0.62f, RespectReload = true, MagazineCapacity = 2, ReloadSpeed = 4, EmptiesClip = true, SuppressReloadAnim = false, TimeBetweenShots = 0.5f, PreventTargetSwitching = false, OverrideAnimation = null, OverrideDirectionalAnimation = null, HideGun = false, UseLaserSight = false, UseGreenLaser = false, PreFireLaserTime = -1, AimAtFacingDirectionWhenSafe = false, Cooldown = 0.2f, CooldownVariance = 0, AttackCooldown = 0, GlobalCooldown = 0, InitialCooldown = 0, InitialCooldownVariance = 0, GroupName = null, GroupCooldown = 0, MinRange = 0, Range = 16, MinWallDistance = 0, MaxEnemiesInRoom = 0, MinHealthThreshold = 0, MaxHealthThreshold = 1, HealthThresholds = new float[0], AccumulateHealthThresholds = true, targetAreaStyle = null, IsBlackPhantom = false, resetCooldownOnDamage = null, RequiresLineOfSight = false, MaxUsages = 0 } }; //Tools.DebugInformation(load); AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("1a78cfb776f54641b832e92c44021cf2"); bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.PostAwakenDelay = behaviorSpeculator.PostAwakenDelay; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject; EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent <AIBulletBank>(), 45, m_CachedGunAttachPoint.transform); Game.Enemies.Add("bny:abyss_kin", companion.aiActor); } }
public static void BuildPrefab() { // bool flag = prefab != null || EnemyBuilder.Dictionary.ContainsKey(guid); bool flag2 = flag; if (!flag2) { AIActor aIActor = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5"); prefab = EnemyBuilder.BuildPrefab("DrawnKin", guid, spritePaths[0], new IntVector2(0, 0), new IntVector2(8, 9), true); var companion = prefab.AddComponent <EnemyBehavior>();; companion.aiActor.knockbackDoer.weight = 50; companion.aiActor.MovementSpeed = 2f; companion.aiActor.healthHaver.PreventAllDamage = false; companion.aiActor.CollisionDamage = 1f; companion.aiActor.HasShadow = false; companion.aiActor.IgnoreForRoomClear = false; companion.aiActor.aiAnimator.HitReactChance = 0f; companion.aiActor.specRigidbody.CollideWithOthers = true; companion.aiActor.specRigidbody.CollideWithTileMap = true; companion.aiActor.PreventFallingInPitsEver = false; companion.aiActor.healthHaver.ForceSetCurrentHealth(30f); companion.aiActor.CollisionKnockbackStrength = 5f; companion.aiActor.CanTargetPlayers = true; companion.aiActor.SetIsFlying(true, "Flying Enemy", true, true); companion.aiActor.healthHaver.SetHealthMaximum(30f, null, false); companion.aiActor.specRigidbody.PixelColliders.Clear(); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyCollider, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0 }); companion.aiActor.specRigidbody.PixelColliders.Add(new PixelCollider { ColliderGenerationMode = PixelCollider.PixelColliderGeneration.Manual, CollisionLayer = CollisionLayer.EnemyHitBox, IsTrigger = false, BagleUseFirstFrameOnly = false, SpecifyBagelFrame = string.Empty, BagelColliderNumber = 0, ManualOffsetX = 0, ManualOffsetY = 0, ManualWidth = 15, ManualHeight = 17, ManualDiameter = 0, ManualLeftX = 0, ManualLeftY = 0, ManualRightX = 0, ManualRightY = 0, }); companion.aiActor.CorpseObject = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").CorpseObject; companion.aiActor.PreventBlackPhantom = false; AIAnimator aiAnimator = companion.aiAnimator; aiAnimator.OtherAnimations = new List <AIAnimator.NamedDirectionalAnimation> { new AIAnimator.NamedDirectionalAnimation { name = "die", anim = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "die_right", "die_left" } } } }; aiAnimator.IdleAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.TwoWayHorizontal, Flipped = new DirectionalAnimation.FlipType[2], AnimNames = new string[] { "idle_front_right", "idle_front_left", "idle_back_right", "idle_back_left" } }; aiAnimator.MoveAnimation = new DirectionalAnimation { Type = DirectionalAnimation.DirectionType.FourWay, Flipped = new DirectionalAnimation.FlipType[4], AnimNames = new string[] { "run_back_right", "run_front_right", "run_front_left", "run_back_left", } }; bool flag3 = DrawnKinCollection == null; if (flag3) { DrawnKinCollection = SpriteBuilder.ConstructCollection(prefab, "DrawnKin_Collection"); UnityEngine.Object.DontDestroyOnLoad(DrawnKinCollection); for (int i = 0; i < spritePaths.Length; i++) { SpriteBuilder.AddSpriteToCollection(spritePaths[i], DrawnKinCollection); } SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 0, 3 }, "idle_back_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 1, 2 }, "idle_back_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 0, 3 }, "idle_front_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 1, 2 }, "idle_front_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 5f; SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 10, 11, 12, 13, 14, 15 }, "run_back_left", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f; SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 22, 23, 24, 25, 26, 27 }, "run_back_right", tk2dSpriteAnimationClip.WrapMode.Once).fps = 10f; SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 4, 5, 6, 7, 8, 9 }, "run_front_left", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f; SpriteBuilder.AddAnimation(companion.spriteAnimator, DrawnKinCollection, new List <int> { 16, 17, 18, 19, 20, 21 }, "run_front_right", tk2dSpriteAnimationClip.WrapMode.Loop).fps = 14f; } var bs = prefab.GetComponent <BehaviorSpeculator>(); BehaviorSpeculator behaviorSpeculator = EnemyDatabase.GetOrLoadByGuid("01972dee89fc4404a5c408d50007dad5").behaviorSpeculator; bs.OverrideBehaviors = behaviorSpeculator.OverrideBehaviors; bs.OtherBehaviors = behaviorSpeculator.OtherBehaviors; bs.TargetBehaviors = new List <TargetBehaviorBase> { new TargetPlayerBehavior { Radius = 35f, LineOfSight = true, ObjectPermanence = true, SearchInterval = 0.25f, PauseOnTargetSwitch = false, PauseTime = 0.25f } }; bs.AttackBehaviors = new List <AttackBehaviorBase>() { new ShootGunBehavior() { GroupCooldownVariance = 0.2f, LineOfSight = false, WeaponType = WeaponType.BulletScript, OverrideBulletName = null, BulletScript = new CustomBulletScriptSelector(typeof(Drawn47Script)), FixTargetDuringAttack = true, StopDuringAttack = true, LeadAmount = 0, LeadChance = 1, RespectReload = true, MagazineCapacity = 8, ReloadSpeed = 5f, EmptiesClip = true, SuppressReloadAnim = false, TimeBetweenShots = -1, PreventTargetSwitching = true, OverrideAnimation = null, OverrideDirectionalAnimation = null, HideGun = false, UseLaserSight = false, UseGreenLaser = false, PreFireLaserTime = -1, AimAtFacingDirectionWhenSafe = false, Cooldown = 0.6f, CooldownVariance = 0, AttackCooldown = 0, GlobalCooldown = 0, InitialCooldown = 0, InitialCooldownVariance = 0, GroupName = null, GroupCooldown = 0, MinRange = 0, Range = 16, MinWallDistance = 0, MaxEnemiesInRoom = 0, MinHealthThreshold = 0, MaxHealthThreshold = 1, HealthThresholds = new float[0], AccumulateHealthThresholds = true, targetAreaStyle = null, IsBlackPhantom = false, resetCooldownOnDamage = null, RequiresLineOfSight = true, MaxUsages = 0, } }; bs.MovementBehaviors = new List <MovementBehaviorBase> { new SeekTargetBehavior { StopWhenInRange = true, CustomRange = 7f, LineOfSight = false, ReturnToSpawn = false, SpawnTetherDistance = 0f, PathInterval = 0.5f, SpecifyRange = false, MinActiveRange = 0f, MaxActiveRange = 0f } }; //BehaviorSpeculator load = EnemyDatabase.GetOrLoadByGuid("206405acad4d4c33aac6717d184dc8d4").behaviorSpeculator; //Tools.DebugInformation(load); bs.InstantFirstTick = behaviorSpeculator.InstantFirstTick; bs.TickInterval = behaviorSpeculator.TickInterval; bs.RemoveDelayOnReinforce = behaviorSpeculator.RemoveDelayOnReinforce; bs.OverrideStartingFacingDirection = behaviorSpeculator.OverrideStartingFacingDirection; bs.StartingFacingDirection = behaviorSpeculator.StartingFacingDirection; bs.SkipTimingDifferentiator = behaviorSpeculator.SkipTimingDifferentiator; GameObject m_CachedGunAttachPoint = companion.transform.Find("GunAttachPoint").gameObject; EnemyBuilder.DuplicateAIShooterAndAIBulletBank(prefab, aIActor.aiShooter, aIActor.GetComponent <AIBulletBank>(), CakeIDs.Drawn47, m_CachedGunAttachPoint.transform); Game.Enemies.Add("cak:drawnkin", companion.aiActor); ItemsMod.Strings.Enemies.Set("#DRAWNKIN", "Drawn Kin"); companion.aiActor.OverrideDisplayName = "#DRAWNKIN"; companion.aiActor.ActorName = "#DRAWNKIN"; companion.aiActor.name = "#DRAWNKIN"; } }