Beispiel #1
0
        public static bool CanAttack(GameClient User1, GameClient User2, bool Weapon = false)
        {
            #region Fundamental Null Checks
            if (User2 == null)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }

            if (User2.GetHabbo() == null)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }

            if (User2.GetHabbo().CurrentRoom == null)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }

            if (User2.GetHabbo().CurrentRoom != User1.GetHabbo().CurrentRoom)
            {
                User1.SendWhisper("This user was not found in this room!");
                return(false);
            }
            #endregion

            Room     Room      = User1.GetHabbo().CurrentRoom;
            RoomUser RoomUser1 = User1.GetHabbo().GetRoomUser();
            RoomUser RoomUser2 = User2.GetHabbo().GetRoomUser();

            Vector2D Pos1 = new Vector2D(RoomUser1.X, RoomUser1.Y);
            Vector2D Pos2 = new Vector2D(RoomUser2.X, RoomUser2.Y);

            #region Cooldown Checks
            if (!Weapon)
            {
                if (User1.GetRoleplay().CoolDown > 0)
                {
                    User1.SendWhisper("You are cooling down! [" + User1.GetRoleplay().CoolDown + "/3]");
                    return(false);
                }
            }
            #endregion

            #region Game Checks
            if (User2.GetRoleplay().inColourWars&& !User1.GetRoleplay().inColourWars)
            {
                Room mRoom = RoleplayManager.GenerateRoom(ColourManager.MainLobby);
                User1.GetRoleplay().RequestedTaxi_Arrived      = false;
                User1.GetRoleplay().RecentlyCalledTaxi         = true;
                User1.GetRoleplay().RecentlyCalledTaxi_Timeout = 10;
                User1.GetRoleplay().RequestedTaxiDestination   = mRoom;
                User1.GetRoleplay().RequestedTaxi = true;
                User1.GetRoleplay().taxiTimer     = new taxiTimer(User1);
                User1.SendNotif("You cannot attack this person as they are in color wars! Please taxi out of the color wars room.");
                return(false);
            }
            if (User1.GetRoleplay().inColourWars&& !User2.GetRoleplay().inColourWars)
            {
                User1.SendNotif("You cannot attack this person as they are not in color wars!");
                return(false);
            }
            #endregion

            #region Special Checks
            if (User1.GetRoleplay().RayFrozen)
            {
                User1.SendWhisper("You cannot do this as you are frozen!");
                return(false);
            }
            #endregion

            if (!Weapon)
            {
                #region Fundamental Checks
                if (Room.RoomData.Description.Contains("NOHIT") && RoleplayManager.PurgeTime == false)
                {
                    User1.SendWhisper("Sorry, but this is a no hitting zone!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                #endregion

                #region Secondary Checks

                if (Room.RoomData.Description.Contains("SAFEZONE"))
                {
                    User1.SendWhisper("Sorry, but this is a safezone!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (Room.RoomData.Description.Contains("BRAWL") && !User1.GetRoleplay().inBrawl&& !User1.GetRoleplay().Brawl)
                {
                    User1.SendWhisper("You are not in a brawl, so you cannot do this!");
                    return(false);
                }
                if (User2.GetRoleplay().usingPlane)
                {
                    User1.SendWhisper("You cannot hit this user as they are in the sky!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (User1.GetRoleplay().Energy <= 0 && !User1.GetRoleplay().inColourWars)
                {
                    User1.SendWhisper("You do not have enough energy to do this!");
                    return(false);
                }
                if (User1.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action while you are dead!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (User1.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action while you are jailed!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (User2.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action as this user is dead!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (User2.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action as this user is jailed!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }

                if (RoomUser1.Stunned)
                {
                    User1.SendWhisper("Cannot complete this action while you are stunned!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (RoomUser2.IsAsleep)
                {
                    User1.SendWhisper("Cannot complete this action as this user is AFK!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                if (User1.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA"))
                {
                    if (!User1.GetRoleplay().NoobWarned)
                    {
                        User1.SendNotif("If you choose to do this again your temporary God Protection will be disabled!");
                        User1.GetRoleplay().NoobWarned = true;
                        return(false);
                    }
                    else
                    {
                        using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunFastQuery("UPDATE rp_stats SET is_noob = 0 WHERE id = '" + User1.GetHabbo().Id + "'");
                        }

                        User1.SendWhisper("Your god protection has been disabled!");
                        User1.GetRoleplay().IsNoob = false;
                        User1.GetRoleplay().SaveQuickStat("is_noob", "0");
                    }
                }

                if (User2.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("NPA"))
                {
                    User1.SendWhisper("Cannot complete this action as this user is under God Protection!");
                    return(false);
                }
                #endregion

                #region Final Checks
                if (RoleplayManager.WithinAttackDistance(RoomUser1, RoomUser2))
                {
                }
                else if (RoleplayManager.Distance(Pos1, Pos2) > 2 && RoleplayManager.Distance(Pos1, Pos2) <= 4)
                {
                    RoomUser1.LastBubble = 3;

                    User1.Shout("*Swings at " + User2.GetHabbo().UserName + ", but misses*");
                    User1.GetRoleplay().CoolDown = 3;

                    RoomUser1.LastBubble = 0;
                    return(false);
                }
                else if (RoleplayManager.Distance(Pos1, Pos2) >= 5)
                {
                    User1.SendWhisper("You are too far away!");
                    User1.GetRoleplay().CoolDown = 3;
                    return(false);
                }
                #endregion
            }
            else if (Weapon)
            {
                #region Fundamental Checks
                if (User1.GetRoleplay().Energy < WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Need_Energy)
                {
                    User1.SendWhisper("You do not have enough energy to do this!");
                    return(false);
                }
                if (User1.GetRoleplay().inBrawl == true)
                {
                    User1.SendWhisper("Cannot do this in a Brawl");
                    return(false);
                }

                if (User1.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action while you are dead!");
                    return(false);
                }

                if (User1.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action while you are jailed!");
                    return(false);
                }

                if (User2.GetRoleplay().Dead)
                {
                    User1.SendWhisper("Cannot complete this action as this user is dead!");
                    return(false);
                }

                if (User2.GetRoleplay().Jailed)
                {
                    User1.SendWhisper("Cannot complete this action as this user is jailed!");
                    return(false);
                }

                if (RoomUser1.Stunned)
                {
                    User1.SendWhisper("Cannot complete this action while you are stunned!");
                    return(false);
                }
                if (RoomUser2.IsAsleep)
                {
                    User1.SendWhisper("Cannot complete this action as this user is AFK!");
                    return(false);
                }
                if (RoomUser1.IsAsleep)
                {
                    User1.SendWhisper("Cannot complete this action as this user is AFK!");
                    return(false);
                }
                if (User1.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA"))
                {
                    if (!User1.GetRoleplay().NoobWarned)
                    {
                        User1.SendNotif("If you choose to do this again your temporary God Protection will be disabled!");
                        User1.GetRoleplay().NoobWarned = true;
                        return(false);
                    }
                    else
                    {
                        using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                        {
                            dbClient.RunFastQuery("UPDATE rp_stats SET is_noob = 0 WHERE id = '" + User1.GetHabbo().Id + "'");
                        }

                        User1.SendWhisper("Your god protection has been disabled!");
                        User1.GetRoleplay().IsNoob = false;
                        User1.GetRoleplay().SaveQuickStat("is_noob", "0");
                    }
                }

                if (User2.GetRoleplay().IsNoob&& !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("COLOR") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("MAFIA") && !User1.GetHabbo().CurrentRoom.RoomData.Description.Contains("NPA"))
                {
                    User1.SendWhisper("Cannot complete this action as this user is under God Protection!");
                    return(false);
                }
                #endregion

                #region Secondary Checks
                if (Room.RoomData.Description.Contains("NOSHOOT") && RoleplayManager.PurgeTime == false)
                {
                    User1.SendWhisper("Sorry, but this is a non shooting zone!");
                    return(false);
                }
                if (Room.RoomData.Description.Contains("SAFEZONE"))
                {
                    User1.SendWhisper("Sorry, but this is a safe zone!");
                    return(false);
                }
                if (User1.GetRoleplay().Equiped == null)
                {
                    User1.SendWhisper("You have not equiped a weapon!");
                    return(false);
                }
                if (!WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Type.ToLower().Contains("gun"))
                {
                    User1.SendWhisper("The weapon you have equiped is not a gun!");
                    return(false);
                }
                if (User2.GetRoleplay().usingPlane&& !WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Name.ToLower().Contains("rpg"))
                {
                    User1.Shout("*Attempts to shoot " + User2.GetHabbo().UserName + ", but misses as they are in a plane*");
                    User1.GetRoleplay().GunShots++;
                    return(false);
                }
                int MyJobId   = User1.GetRoleplay().JobId;
                int MyJobRank = User1.GetRoleplay().JobRank;
                if (User1.GetRoleplay().Bullets <= 0 && (!JobManager.JobRankData[MyJobId, MyJobRank].hasRights("army") && !User1.GetRoleplay().Working))
                {
                    User1.SendWhisper("You do not have any bullets!");
                    return(false);
                }
                if (User1.GetRoleplay().Intelligence < WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Min_Intel)
                {
                    User1.SendWhisper("You must have an intelligence level of at least " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Min_Intel + " to use this weapon!");
                    return(false);
                }
                if (User1.GetRoleplay().Strength + User1.GetRoleplay().savedSTR < WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Need_Str)
                {
                    User1.SendWhisper("You must have a strength level of at least " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Need_Str + " to use this weapon!");
                    return(false);
                }
                if (User1.GetRoleplay().GunShots >= WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Reload_Time)
                {
                    RoomUser1.LastBubble = 3;

                    User1.Shout("*Reloads their " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].DisplayName + ", and loads more bullets*");

                    RoomUser1.LastBubble = 0;
                    ServerMessage message = new ServerMessage(LibraryParser.OutgoingRequest("FloodFilterMessageComposer"));
                    message.AppendInteger(5);
                    RoomUser1.IsGunReloaded    = true;
                    RoomUser1.ReloadExpiryTime = Plus.GetUnixTimeStamp() + 5;
                    User1.SendMessage(message);

                    User1.GetRoleplay().GunShots = 0;
                    // will re-inplement this later -> HabboHotel.Misc.ChatCommandHandler.Parse(User1, ":shoot " + TargetUser1.GetHabbo().UserName);
                    return(false);
                }
                #endregion

                #region Final Checks
                if (RoleplayManager.Distance(Pos1, Pos2) > WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Range)
                {
                    /*if (Misc.Distance(Pos1, Pos2) > weaponManager.WeaponsData[User1.GetRoleplay().Equiped].Range + 4)
                     * {
                     *  User1.SendWhisper("You must be closer to do this!");
                     *  return false;
                     * }*/

                    RoomUser1.LastBubble = 3;

                    User1.Shout("*Shoots their " + WeaponManager.WeaponsData[User1.GetRoleplay().Equiped].Name + " at " + User2.GetHabbo().UserName + ", but misses*");

                    RoomUser1.LastBubble = 0;
                    User1.GetRoleplay().GunShots++;
                    return(false);
                }
                #endregion
            }

            return(true);
        }
Beispiel #2
0
        internal static bool ExecuteAttackBot(GameClient User1, RoomUser RoomUser2, Pet Pet, RoomBot BotData)
        {
            Room     Room      = User1.GetHabbo().CurrentRoom;
            RoomUser RoomUser1 = User1.GetHabbo().GetRoomUser();

            Vector2D Pos1      = new Vector2D(RoomUser1.X, RoomUser1.Y);
            Vector2D Pos2      = new Vector2D(RoomUser2.X, RoomUser2.Y);
            bool     canattack = false;

            #region Cooldown
            if (User1.GetRoleplay().CoolDown > 0)
            {
                User1.SendWhisper("Cooling down [" + User1.GetRoleplay().CoolDown + "/3]");
                return(false);
            }
            #endregion

            #region Distance
            if (RoleplayManager.WithinAttackDistance(RoomUser1, RoomUser2))
            {
                canattack = true;
            }
            else if (RoleplayManager.Distance(Pos1, Pos2) > 1 && RoleplayManager.Distance(Pos1, Pos2) <= 4)
            {
                User1.Shout("*Swings at " + BotData.Name + ", but misses*");
                return(false);
            }
            else if (RoleplayManager.Distance(Pos1, Pos2) >= 5)
            {
                User1.SendWhisper("You are too far away!");
                return(false);
            }
            #endregion

            #region Status Conditions

            if (Room.RoomData.Description.Contains("NOHIT") && RoleplayManager.PurgeTime == false)
            {
                User1.SendWhisper("Sorry, but this is a no hitting zone!");
                User1.GetRoleplay().CoolDown = 3;
                return(false);
            }
            if (Room.RoomData.Description.Contains("SAFEZONE"))
            {
                User1.SendWhisper("Sorry, but this is a safezone!");
                User1.GetRoleplay().CoolDown = 3;
                return(false);
            }
            if (User1.GetRoleplay().Energy <= 0)
            {
                User1.SendWhisper("You do not have enough energy to do this!");
                return(false);
            }
            if (User1.GetRoleplay().Dead)
            {
                User1.SendWhisper("Cannot complete this action while you are dead!");
                User1.GetRoleplay().CoolDown = 3;
                return(false);
            }

            if (User1.GetRoleplay().Jailed)
            {
                User1.SendWhisper("Cannot complete this action while you are jailed!");
                User1.GetRoleplay().CoolDown = 3;
                return(false);
            }

            if (RoomUser1.Stunned)
            {
                User1.SendWhisper("Cannot complete this action while you are stunned!");
                User1.GetRoleplay().CoolDown = 3;
                return(false);
            }

            #endregion


            if (canattack)
            {
                GameClient Session = User1;

                int Damage = CombatManager.DamageCalculator(User1);

                BotData.cur_Health -= Damage;

                if (BotData.cur_Health <= 0)
                {
                    if (RoomUser2.BotData != null && RoomUser2.BotData._Boss)
                    {
                        Session.GetRoleplay().GiveMafiaWarPoints(MafiaWarManager.BossKillPoints);
                        User1.Shout("*Swings at " + BotData.Name + ", causing " + Damage + " damage and killing them and winning the Game! [+ " + MafiaWarManager.BossKillPoints + " Mafia Wars Pts]*");
                    }
                    else if (!RoomUser2.BotData._Boss)
                    {
                        Session.GetRoleplay().GiveMafiaWarPoints(MafiaWarManager.ThugKillPoints);
                        User1.Shout("*Swings at " + BotData.Name + ", causing " + Damage + " damage and killing them! [+ " + MafiaWarManager.ThugKillPoints + " Mafia Wars Pts]*");
                    }

                    RoomUser2.Chat(null, "*Passes out*", true, 1);
                    User1.GetHabbo().GetRoomUser().Attacker = null;
                    RoomUser2.BotAI._Victim = null;

                    if (RoomUser2.IsPet)
                    {
                        if (RoomUser2.FollowingOwner != null)
                        {
                            RoomUser2.FollowingOwner.GetClient().GetMessageHandler().PickUpPet(RoomUser2.FollowingOwner.GetClient(), RoomUser2.PetData.PetId, true);
                            return(true);
                        }
                        else
                        {
                            Room.GetRoomUserManager().RemoveBot(RoomUser2.VirtualId, true);
                        }
                    }
                    else
                    {
                        Room.GetRoomUserManager().RemoveBot(RoomUser2.VirtualId, true);
                    }

                    if (RoomUser2.BotData != null && RoomUser2.BotData._Boss)
                    {
                        Session.GetRoleplay().GiveMafiaWarPoints(MafiaWarManager.BossKillPoints);

                        if (RoomUser2.BotData._Team.TeamName == "Green")
                        {
                            Plus.GetGame().MafiaWars.TeamWon("Blue");
                        }
                        else
                        {
                            Plus.GetGame().MafiaWars.TeamWon("Green");
                        }
                    }
                }
                else
                {
                    User1.Shout("*Swings at " + BotData.Name + ", causing " + Damage + " damage*");
                    RoomUser2.Chat(null, "[" + BotData.cur_Health + "/" + BotData.max_Health + "]", true, 1);

                    if (User1.GetHabbo().GetRoomUser().Attacker != null)
                    {
                        User1.GetHabbo().GetRoomUser().Attacker = null;
                        RoomUser2.BotAI._Victim = User1.GetHabbo().GetRoomUser();
                    }

                    User1.GetRoleplay().LastHitBot = RoomUser2;
                }

                Session.GetRoleplay().CoolDown = 3;
            }

            return(true);
        }