예제 #1
0
        public override bool Shoot(Player player, ref Vector2 position, ref float speedX, ref float speedY, ref int type, ref int damage, ref float knockBack)
        {
            StandoPlayer pl = player.GetModPlayer <StandoPlayer>();

            if (!pl.HaveStand)
            {
                return(false);
            }

            Terraria.Utilities.UnifiedRandom rand = Main.rand;

            if (rand.Next(1000) == 239 && !player.HasBuff(ModContent.BuffType <Buffs.StarPlatinumRequiemStand>()))
            {
                pl.DeleteStand();
                player.AddBuff(ModContent.BuffType <Buffs.StarPlatinumRequiemStand>(), 239);

                return(true);
            }
            else
            {
                int k = rand.Next(stands.Length);

                while (player.HasBuff(mod.BuffType(stands[k])))
                {
                    k = rand.Next(stands.Length);
                }

                pl.DeleteStand();

                player.AddBuff(mod.BuffType(stands[k]), 239);

                return(true);
            }
        }
예제 #2
0
        public override bool UseItem(Player player)
        {
            if (player.GetModPlayer <StandoPlayer>().HaveStand)
            {
                return(true);
            }

            switch (player.name)
            {
            case "Avdol":
            case "avdol":
                player.AddBuff(ModContent.BuffType <Buffs.MagicianRedStand>(), 239);
                return(true);

            case "Jotaro":
            case "jotaro":
                player.AddBuff(ModContent.BuffType <Buffs.StarPlatinumStand>(), 239);
                return(true);

            case "Joseph":
            case "joseph":
                player.AddBuff(ModContent.BuffType <Buffs.HermitPurpleStand>(), 239);
                return(true);

            case "Kakyoin":
            case "kakyoin":
                player.AddBuff(ModContent.BuffType <Buffs.HierophantGreenStand>(), 239);
                return(true);

            ///case "Froloh":
            ///case "froloh":
            ///    player.AddBuff(ModContent.BuffType<Buffs.StarPlatinumRequiemStand>(), 239);
            ///    return true;

            case "Pornoleff":
            case "Polnoreff":
            case "Polnoref":
            case "polnoreff":
            case "polnoref":
                player.AddBuff(ModContent.BuffType <Buffs.SilverChariotStand>(), 239);
                return(true);
            }

            Terraria.Utilities.UnifiedRandom rand = Main.rand;

            if (rand.Next(1000) == 239)
            {
                player.AddBuff(ModContent.BuffType <Buffs.StarPlatinumRequiemStand>(), 239);
            }
            else
            {
                player.Hurt(Terraria.DataStructures.PlayerDeathReason.ByCustomReason(player.name + " died because was stupid"), 99, 1);
                player.AddBuff(mod.BuffType(stands[rand.Next(stands.Length)]), 239);
            }
            /// add cut scene

            return(true);
        }
예제 #3
0
        public override int ChoosePrefix(Terraria.Utilities.UnifiedRandom rand)
        {
            switch (rand.Next(24))
            {
            case 1:
                return(PrefixID.Agile);

            case 2:
                return(PrefixID.Annoying);

            case 3:
                return(PrefixID.Broken);

            case 4:
                return(PrefixID.Damaged);

            case 5:
                return(PrefixID.Deadly2);

            case 6:
                return(PrefixID.Demonic);

            case 7:
                return(PrefixID.Forceful);

            case 8:
                return(PrefixID.Godly);

            case 9:
                return(PrefixID.Hurtful);

            case 10:
                return(PrefixID.Keen);

            case 11:
                return(PrefixID.Lazy);

            case 12:
                return(PrefixID.Murderous);

            case 13:
                return(PrefixID.Nasty);

            case 14:
                return(PrefixID.Nimble);

            case 15:
                return(PrefixID.Quick);

            case 16:
                return(PrefixID.Ruthless);

            case 17:
                return(PrefixID.Shoddy);

            case 18:
                return(PrefixID.Slow);

            case 19:
                return(PrefixID.Sluggish);

            case 20:
                return(PrefixID.Strong);

            case 21:
                return(PrefixID.Superior);

            case 22:
                return(PrefixID.Unpleasant);

            case 23:
                return(PrefixID.Weak);

            default:
                return(PrefixID.Zealous);
            }
        }
예제 #4
0
        private void HookBeeType(HookIL il)
        {
            // Start the Cursor at the start
            var c = il.At(0);

            // Try to find where 566 is placed onto the stack
            if (!c.TryGotoNext(i => i.MatchLdcI4(566)))
            {
                return;                 // Patch unable to be applied
            }
            // Choose a random implementation of the patch. This is just to show different patch approaches.
            var random = new Terraria.Utilities.UnifiedRandom();
            int choice = random.Next(3);             // Main.rand is null during mod loading.

            if (choice == 0)
            {
                // Move the cursor after 566 and onto the ret op.
                c.Index++;
                // Push the Player instance onto the stack
                c.Emit(Ldarg_0);
                // Call a delegate using the int and Player from the stack.
                c.EmitDelegate <Func <int, Player, int> >((returnValue, player) =>
                {
                    // Regular c# code
                    if (player.GetModPlayer <ExamplePlayer>().strongBeesUpgrade&& Main.rand.NextBool(10) && Main.ProjectileUpdateLoopIndex == -1)
                    {
                        return(ProjectileID.Beenade);
                    }
                    return(returnValue);
                });
            }
            else if (choice == 1)
            {
                // Make a label to use later
                var label = il.DefineLabel();
                // Push the Player instance onto the stack
                c.Emit(Ldarg_0);
                // Call a delegate popping the Player from the stack and pushing a bool
                c.EmitDelegate <Func <Player, bool> >(player => player.GetModPlayer <ExamplePlayer>().strongBeesUpgrade&& Main.rand.NextBool(10) && Main.ProjectileUpdateLoopIndex == -1);
                // if the bool on the stack is false, jump to label
                c.Emit(Brfalse, label);
                // Otherwise, push ProjectileID.Beenade and return
                c.Emit(Ldc_I4, ProjectileID.Beenade);
                c.Emit(Ret);
                // Set the label to the current cursor, which is still the instruction pushing 566 (which is followed by Ret)
                c.MarkLabel(label);
            }
            else
            {
                var label = il.DefineLabel();

                // Here we simply adapt the dnSpy output. This approach is tedious but easier if you don't understand IL instructions.
                c.Emit(Ldarg_0);
                // We need to make sure to pass in FieldInfo or MethodInfo into Call instructions.
                // Here we show how to retrieve a generic version of a MethodInfo
                c.Emit(Call, typeof(Player).GetMethod("GetModPlayer", new Type[] { }).MakeGenericMethod(typeof(ExamplePlayer)));
                // nameof helps avoid spelling mistakes
                c.Emit(Ldfld, typeof(ExamplePlayer).GetField(nameof(ExamplePlayer.strongBeesUpgrade)));
                c.Emit(Brfalse_S, label);
                c.Emit(Ldsfld, typeof(Main).GetField(nameof(Main.rand)));
                // Ldc_I4_S expects an int8, aka an sbyte. Failure to cast correctly will crash the game
                c.Emit(Ldc_I4_S, (sbyte)10);
                c.Emit(Call, typeof(Utils).GetMethod("NextBool", new Type[] { typeof(Terraria.Utilities.UnifiedRandom), typeof(int) }));
                c.Emit(Brfalse_S, label);
                // You may be tempted to write c.Emit(Ldsfld, Main.ProjectileUpdateLoopIndex);, this won't work and will simply use the value of the field at patch time. That will crash.
                c.Emit(Ldsfld, typeof(Main).GetField(nameof(Main.ProjectileUpdateLoopIndex)));
                c.Emit(Ldc_I4_M1);
                c.Emit(Bne_Un_S, label);
                c.Emit(Ldc_I4, ProjectileID.Beenade);
                c.Emit(Ret);
                // As Emit has been inserting and advancing the cursor index, we are still pointing at the 566 instruction.
                // All the branches in the dnspy output jumped to this instruction, so we set the label to this instruction.
                c.MarkLabel(label);
            }
        }