private void baseDoFunction(GameLocation location, int x, int y, int power, Farmer who)
 {
     this.lastUser = who;
     Game1.recentMultiplayerRandom = new Random((int)(short)Game1.random.Next((int)short.MinValue, 32768));
     ToolFactory.getIndexFromTool(this);
     if (who.FarmerSprite.currentAnimationIndex <= 0)
     {
         return;
     }
     MeleeWeapon.timedHitTimer = 500;
 }
Example #2
0
        public virtual void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.lastUser = who;
            short seed = (short)Game1.random.Next((int)short.MinValue, 32768);

            if (Game1.IsClient && who.Equals((object)Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                ToolDescription indexFromTool = ToolFactory.getIndexFromTool(this);
                Game1.client.sendMessage((byte)7, new object[7]
                {
                    (object)indexFromTool.index,
                    (object)indexFromTool.upgradeLevel,
                    (object)(short)x,
                    (object)(short)y,
                    (object)location.name,
                    (object)(byte)who.FacingDirection,
                    (object)seed
                });
            }
            else if (Game1.IsServer && who.Equals((object)Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                MultiplayerUtility.broadcastToolAction(this, x, y, location.name, (byte)who.FacingDirection, seed, who.uniqueMultiplayerID);
            }
            if (this.isHeavyHitter() && !(this is MeleeWeapon))
            {
                Rumble.rumble(0.1f + (float)(Game1.random.NextDouble() / 4.0), (float)(100 + Game1.random.Next(50)));
                location.damageMonster(new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), this.upgradeLevel + 1, (this.upgradeLevel + 1) * 3, false, who);
            }
            if (!(this is MeleeWeapon) || who.UsingTool && Game1.mouseClickPolling < 50 && ((this as MeleeWeapon).type != 1 && (this as MeleeWeapon).initialParentTileIndex != 47) && (MeleeWeapon.timedHitTimer <= 0 && who.FarmerSprite.indexInCurrentAnimation == 5 && (double)who.FarmerSprite.timer < (double)who.FarmerSprite.interval / 4.0))
            {
                return;
            }
            if ((this as MeleeWeapon).type == 2 && (this as MeleeWeapon).isOnSpecial)
            {
                (this as MeleeWeapon).doClubFunction(who);
            }
            else
            {
                if (who.FarmerSprite.indexInCurrentAnimation <= 0)
                {
                    return;
                }
                MeleeWeapon.timedHitTimer = 500;
            }
        }
        // Token: 0x060007B1 RID: 1969 RVA: 0x000A8560 File Offset: 0x000A6760
        public virtual void DoFunction(GameLocation location, int x, int y, int power, Farmer who)
        {
            this.lastUser = who;
            short seed = (short)Game1.random.Next(-32768, 32768);

            if (Game1.IsClient && who.Equals(Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                ToolDescription t = ToolFactory.getIndexFromTool(this);
                Game1.client.sendMessage(7, new object[]
                {
                    t.index,
                    t.upgradeLevel,
                    (short)x,
                    (short)y,
                    location.name,
                    (byte)who.FacingDirection,
                    seed
                });
            }
            else if (Game1.IsServer && who.Equals(Game1.player))
            {
                Game1.recentMultiplayerRandom = new Random((int)seed);
                MultiplayerUtility.broadcastToolAction(this, x, y, location.name, (byte)who.FacingDirection, seed, who.uniqueMultiplayerID);
            }
            if (this.isHeavyHitter() && !(this is MeleeWeapon))
            {
                Rumble.rumble(0.1f + (float)(Game1.random.NextDouble() / 4.0), (float)(100 + Game1.random.Next(50)));
                location.damageMonster(new Rectangle(x - Game1.tileSize / 2, y - Game1.tileSize / 2, Game1.tileSize, Game1.tileSize), this.upgradeLevel + 1, (this.upgradeLevel + 1) * 3, false, who);
            }
            if (this is MeleeWeapon && (!who.UsingTool || Game1.mouseClickPolling >= 50 || (this as MeleeWeapon).type == 1 || (this as MeleeWeapon).initialParentTileIndex == 47 || MeleeWeapon.timedHitTimer > 0 || who.FarmerSprite.indexInCurrentAnimation != 5 || who.FarmerSprite.timer >= who.FarmerSprite.interval / 4f))
            {
                if ((this as MeleeWeapon).type == 2 && (this as MeleeWeapon).isOnSpecial)
                {
                    (this as MeleeWeapon).doClubFunction(who);
                    return;
                }
                if (who.FarmerSprite.indexInCurrentAnimation > 0)
                {
                    MeleeWeapon.timedHitTimer = 500;
                }
            }
        }
Example #4
0
 private static void baseDoFunction(Tool __instance, GameLocation location, int x, int y, int power, Farmer who, ref Farmer ___lastUser)
 {
     ___lastUser = who;
     Game1.recentMultiplayerRandom = new Random(( short )Game1.random.Next(-32768, 32768));
     ToolFactory.getIndexFromTool(__instance);
     if (__instance.isHeavyHitter() && !(__instance is MeleeWeapon))
     {
         Rumble.rumble(0.1f + ( float )(Game1.random.NextDouble() / 4.0), 100 + Game1.random.Next(50));
         location.damageMonster(new Rectangle(x - 32, y - 32, 64, 64), ( int )__instance.upgradeLevel + 1, (( int )__instance.upgradeLevel + 1) * 3, isBomb: false, who);
     }
     if (__instance is MeleeWeapon && (!who.UsingTool || Game1.mouseClickPolling >= 50 || ( int )(__instance as MeleeWeapon).type == 1 || (__instance as MeleeWeapon).InitialParentTileIndex == 47 || MeleeWeapon.timedHitTimer > 0 || who.FarmerSprite.currentAnimationIndex != 5 || !(who.FarmerSprite.timer < who.FarmerSprite.interval / 4f)))
     {
         if (( int )(__instance as MeleeWeapon).type == 2 && (__instance as MeleeWeapon).isOnSpecial)
         {
             (__instance as MeleeWeapon).triggerClubFunction(who);
         }
         else if (who.FarmerSprite.currentAnimationIndex > 0)
         {
             MeleeWeapon.timedHitTimer = 500;
         }
     }
 }
        public static void broadcastToolAction(Tool t, int tileX, int tileY, string location, byte facingDirection, short seed, long whichPlayer)
        {
            ToolDescription indexFromTool = ToolFactory.getIndexFromTool(t);

            foreach (KeyValuePair <long, Farmer> current in Game1.otherFarmers)
            {
                if (current.Value.currentLocation.name.Equals(location) && whichPlayer != current.Value.uniqueMultiplayerID)
                {
                    current.Value.multiplayerMessage.Add(new object[]
                    {
                        7,
                        indexFromTool.index,
                        indexFromTool.upgradeLevel,
                        (short)tileX,
                        (short)tileY,
                        location,
                        facingDirection,
                        seed,
                        whichPlayer
                    });
                }
            }
        }