DestroyedClone / AncientScepter

ThinkInvis' ClassicItems' Ancient Scepter Port
0 stars 6 forks source link

Rex's Scepter Skill : Special :: Tangling Growth bug? #37

Closed BTP-G closed 1 year ago

BTP-G commented 1 year ago

Using this skill will report "position not free or not find". After a period of time, the game will crash.But I'm not sure if it's the problem with this mod These are the logs that will pop up repeatedly when the skill is used. " [Error : Unity Log] NullReferenceException Stack trace: UnityEngine.Component.GetComponent[T] () (at <469e86e97fa2467ebffe49bbd6086325>:IL_0021) TPDespair.ZetItemTweaks.BensRainCoat+<>c.b__85_0 (On.RoR2.Items.ImmuneToDebuffBehavior+orig_TryApplyOverride orig, RoR2.CharacterBody body) (at <3b94607b0f5c49f38bcf61d25f504a25>:IL_0001) DMD<>?-1963911936.Hook?930613760 (RoR2.CharacterBody ) (at <45c9f675a95d4430925a265dd3ef6731>:IL_0014) RoR2.Items.ImmuneToDebuffBehavior.OverrideDebuff (RoR2.BuffDef buffDef, RoR2.CharacterBody body) (at :IL_0011) DMD?-1963911936._RoR2_CharacterBody::AddTimedBuff (RoR2.CharacterBody this, RoR2.BuffDef buffDef, System.Single duration) (at <84a37184494441dcaf7ba24e2e5bfa0f>:IL_0035) DMD<>?-1963911936.Trampoline?-439439360 (RoR2.CharacterBody , RoR2.BuffDef , System.Single ) (at <4270bb6873ba406ba307f2ad2f08df60>:IL_0020) GrooveUnsharedUtils.CartridgeMasterBehaviour.CharacterBody_AddTimedBuff_BuffDef_float (On.RoR2.CharacterBody+orig_AddTimedBuff_BuffDef_float orig, RoR2.CharacterBody self, RoR2.BuffDef buffDef, System.Single duration) (at <8e1561d7a9aa4bebbd524ce8a46f590d>:IL_000F) DMD<>?-1963911936.Hook?1132414848 (RoR2.CharacterBody , RoR2.BuffDef , System.Single ) (at <173cbe2a1fb14cc281ed8fb76f9a7e1f>:IL_000A) DMD<>?-1963911936.Trampoline?-1701695488 (RoR2.CharacterBody , RoR2.BuffDef , System.Single ) (at <14199e4f9d7d4073ac3382b6f2da051f>:IL_0020) TPDespair.ZetArtifacts.ZetDropifact.VoidBearFix_AddTimedBuff (On.RoR2.CharacterBody+orig_AddTimedBuff_BuffDef_float orig, RoR2.CharacterBody self, RoR2.BuffDef buffDef, System.Single duration) (at <8e63ed4b3dfd4258a11aa104f93a56b8>:IL_0051) DMD<>?-1963911936.Hook?-263819136 (RoR2.CharacterBody , RoR2.BuffDef , System.Single ) (at <814beb08f4ec4719af2530c07decb51a>:IL_000A) AncientScepter.TreebotFlower2_2+<>cDisplayClass25_0.b0 (RoR2.CharacterBody cb) (at :IL_00C4) System.Collections.Generic.List1[T].ForEach (System.Action1[T] action) (at <44afb4564e9347cf99a1865351ea8f4a>:IL_0024) AncientScepter.TreebotFlower2_2.O

n_TreebotFlower2RootPulse (On.EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile+orig_RootPulse orig, EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile self) (at :IL_0080) DMD<>?-1963911936.Hook?1002420224 (EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile ) (at :IL_0014) EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile.FixedUpdate () (at :IL_0059) RoR2.EntityStateMachine.FixedUpdate () (at :IL_001A)

[Error : Unity Log] NullReferenceException Stack trace: AncientScepter.TreebotFlower2_2+<>cDisplayClass25_0.b0 (RoR2.CharacterBody cb) (at :IL_005F) System.Collections.Generic.List1[T].ForEach (System.Action1[T] action) (at <44afb4564e9347cf99a1865351ea8f4a>:IL_0024) AncientScepter.TreebotFlower2_2.On_TreebotFlower2RootPulse (On.EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile+orig_RootPulse orig, EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile self) (at :IL_0080) DMD<>?-1963911936.Hook?1002420224 (EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile ) (at :IL_0014) EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile.FixedUpdate () (at :IL_0059) RoR2.EntityStateMachine.FixedUpdate () (at :IL_001A)

[Info : Unity Log] Position not free or not found. [Info : Unity Log] Position not free or not found. [Info : Unity Log] Position not free or not found. " LogOutput.log

BTP-G commented 1 year ago

Modifying the code in this way can solve this bug:

private void On_TreebotFlower2Enter(On.EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile.orig_OnEnter orig, TreebotFlower2Projectile self) {
            GameObject owner = self.outer.GetComponent<ProjectileController>().owner;
            if (owner.GetComponent<CharacterBody>().skillLocator.GetSkill(targetSlot).skillDef.skillName.EndsWith("Scepter")) {
                float origRadius = TreebotFlower2Projectile.radius;
                TreebotFlower2Projectile.radius *= 2f;
                orig(self);
                TreebotFlower2Projectile.radius = origRadius;
            } else {
                orig(self);
            }
        }

private void On_TreebotFlower2RootPulse(On.EntityStates.Treebot.TreebotFlower.TreebotFlower2Projectile.orig_RootPulse orig, TreebotFlower2Projectile self) {
            GameObject owner = self.outer.GetComponent<ProjectileController>().owner;
            if (owner.GetComponent<CharacterBody>().skillLocator.GetSkill(targetSlot).skillDef.skillName.EndsWith("Scepter")) {
                float orig_radius = TreebotFlower2Projectile.radius;
                TreebotFlower2Projectile.radius *= 2f;
                orig(self);
                TreebotFlower2Projectile.radius = orig_radius;
                self.rootedBodies?.ForEach(rooted_body => {
                    if (rooted_body != null) {
                        switch (Random.Range(1, 4)) {
                            case 1: {
                                rooted_body.AddTimedBuff(RoR2Content.Buffs.HealingDisabled, 1.5f);
                                break;
                            }
                            case 2: {
                                rooted_body.AddTimedBuff(RoR2Content.Buffs.Bleeding, 1.5f);
                                break;
                            }
                            case 3: {
                                rooted_body.AddTimedBuff(RoR2Content.Buffs.Weak, 1.5f);
                                break;
                            }
                            case 4: {
                                rooted_body.AddTimedBuff(RoR2Content.Buffs.Pulverized, 1.5f);
                                break;
                            }
                        }
                    }
                });
            } else {
                orig(self);
            }
        }
BTP-G commented 1 year ago

I hope you can refer to my code to fix the bug.