Esempio n. 1
0
        /// <summary>
        ///     Progresses the user achievement.
        /// </summary>
        /// <param name="session">The session.</param>
        /// <param name="achievementGroup">The achievement group.</param>
        /// <param name="progressAmount">The progress amount.</param>
        /// <param name="fromZero">if set to <c>true</c> [from zero].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool ProgressUserAchievement(GameClient session, string achievementGroup, uint progressAmount,
                                              bool fromZero = false)
        {
            if (Achievements.ContainsKey(achievementGroup) && session?.GetHabbo() != null)
            {
                Achievement achievement = Achievements[achievementGroup];

                Habbo user = session.GetHabbo();

                // Get UserAchievementData, if the user doesn't has the Achievement, create a new.
                UserAchievement userAchievement = user.Achievements.ContainsKey(achievementGroup)
                    ? user.GetAchievementData(achievementGroup)
                    : new UserAchievement(achievementGroup, 0, 0);

                // If is a New Achievement is fromZero
                if (!user.Achievements.ContainsKey(achievementGroup))
                {
                    fromZero = true;
                }

                // If user hasn't the Achievement, after created the new, Must add in Collections.
                if (!user.Achievements.ContainsKey(achievementGroup))
                {
                    user.Achievements.Add(achievementGroup, userAchievement);
                }

                // Get Achievement
                userAchievement = user.Achievements[achievementGroup];

                // Total Levels from this Achievement
                uint achievementLevelsCount = (uint)achievement.Levels.Count;

                // Get User Achievement Level
                uint achievementCurrentLevel = userAchievement.Level;

                // Get User Achievement Progress
                uint achievementCurrentProgress = userAchievement.Progress;

                // If the next Level is the last level must set to Levels.Count (Ex: 38 Levels => .Count = 37 (Max Level in the Array, but .Count 37 == 38, Soo need put Level - 1)
                uint achievementNextLevel = achievementCurrentLevel + 1 > achievementLevelsCount
                    ? achievementLevelsCount
                    : achievementCurrentLevel + 1;

                // Set Achievement Progress
                uint achievementProgress = achievementCurrentProgress + progressAmount;

                // If he has already the Max, something is wrong.
                if (achievementCurrentLevel == achievementLevelsCount)
                {
                    return(false);
                }

                // Get Next Level Data
                AchievementLevel achievementNextLevelData = achievement.Levels[achievementNextLevel];

                // if progress isn't sufficient or, isn't new Achievement
                if (achievementProgress < achievementNextLevelData.Requirement || achievementCurrentLevel >= 1)
                {
                    fromZero = false;
                }

                // If progress is sufficient to next level, or is new Achievement
                if (achievementProgress >= achievementNextLevelData.Requirement || (achievementCurrentLevel < 1))
                {
                    fromZero = true;
                }

                // if is a new level (but level isn't 0)
                if (achievementProgress >= achievementNextLevelData.Requirement)
                {
                    achievementProgress = 0;
                }

                // If is new Level
                if (fromZero)
                {
                    // Set Level
                    userAchievement.SetLevel(achievementNextLevel);

                    // Set Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Give Reward Points
                    user.AchievementPoints += achievementNextLevelData.RewardPoints;
                    user.NotifyNewPixels(achievementNextLevelData.RewardPixels);
                    user.Duckets += achievementNextLevelData.RewardPixels;

                    // Update Points Balance
                    user.UpdateActivityPointsBalance();

                    // Remove old Badge - (Is not problem if is First Level Badge, because if the user hasn't the badg, simply, will not remove.
                    user.GetBadgeComponent()
                    .RemoveBadge(Convert.ToString($"{achievementGroup}{achievementNextLevel - 1}"), session);

                    // Give new Badge
                    user.GetBadgeComponent().GiveBadge($"{achievementGroup}{achievementNextLevel}", true, session);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementNextLevel}', '{achievementProgress}')");

                    // Send Unlocked Composer
                    session.SendMessage(AchievementUnlockedComposer.Compose(achievement, achievementNextLevel,
                                                                            achievementNextLevelData.RewardPoints, achievementNextLevelData.RewardPixels));

                    // Send Score Composer
                    session.SendMessage(AchievementScoreUpdateComposer.Compose(user.AchievementPoints));

                    // Send Progress Composer
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementNextLevel,
                                                                            achievementNextLevelData, achievementLevelsCount, userAchievement));

                    // Set Talent
                    if (
                        Yupi.GetGame()
                        .GetTalentManager()
                        .Talents.Values.Any(talent => talent.AchievementGroup == achievementGroup))
                    {
                        Yupi.GetGame()
                        .GetTalentManager()
                        .CompleteUserTalent(session,
                                            Yupi.GetGame().GetTalentManager().GetTalentData(achievementGroup));
                    }
                }
                else
                {
                    // Get Current Level Data
                    AchievementLevel achievementCurrentLevelData = achievement.Levels[achievementCurrentLevel];

                    // It's the Same Level
                    userAchievement.SetLevel(achievementCurrentLevel);

                    // But increase Progress
                    userAchievement.SetProgress(achievementProgress);

                    // Update in Database
                    using (IQueryAdapter queryReactor = Yupi.GetDatabaseManager().GetQueryReactor())
                        queryReactor.RunFastQuery(
                            $"REPLACE INTO users_achievements VALUES ('{user.Id}', '{achievementGroup}', '{achievementCurrentLevel}', '{achievementProgress}')");

                    // Compose Current Data
                    session.SendMessage(AchievementProgressComposer.Compose(achievement, achievementCurrentLevel,
                                                                            achievementCurrentLevelData, achievementLevelsCount, userAchievement));
                }

                // Send User New Data
                GameClientMessageHandler messageHandler = session.GetMessageHandler();

                messageHandler.GetResponse().Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
                messageHandler.GetResponse().AppendInteger(-1);
                messageHandler.GetResponse().AppendString(user.Look);
                messageHandler.GetResponse().AppendString(user.Gender.ToLower());
                messageHandler.GetResponse().AppendString(user.Motto);
                messageHandler.GetResponse().AppendInteger(user.AchievementPoints);

                messageHandler.SendResponse();

                return(true);
            }

            return(false);
        }
Esempio n. 2
0
        internal bool ProgressUserAchievement(GameClient Session, string AchievementGroup, int ProgressAmount)
        {
            if (!Achievements.ContainsKey(AchievementGroup))
            {
                return(false);
            }

            Achievement AchievementData = null;

            AchievementData = Achievements[AchievementGroup];

            UserAchievement UserData = Session.GetHabbo().GetAchievementData(AchievementGroup);

            if (UserData == null)
            {
                UserData = new UserAchievement(AchievementGroup, 0, 0);
                Session.GetHabbo().Achievements.Add(AchievementGroup, UserData);
            }

            int TotalLevels = AchievementData.Levels.Count;

            if (UserData != null && UserData.Level == TotalLevels)
            {
                return(false); // done, no more.
            }

            int TargetLevel = (UserData != null ? UserData.Level + 1 : 1);

            if (TargetLevel > TotalLevels)
            {
                TargetLevel = TotalLevels;
            }

            AchievementLevel TargetLevelData = AchievementData.Levels[TargetLevel];

            int NewProgress = (UserData != null ? UserData.Progress + ProgressAmount : ProgressAmount);
            int NewLevel    = (UserData != null ? UserData.Level : 0);
            int NewTarget   = NewLevel + 1;

            if (NewTarget > TotalLevels)
            {
                NewTarget = TotalLevels;
            }

            if (NewProgress >= TargetLevelData.Requirement)
            {
                NewLevel++;
                NewTarget++;

                int ProgressRemainder = NewProgress - TargetLevelData.Requirement;
                NewProgress = 0;

                Session.GetHabbo().GetBadgeComponent().GiveBadge(AchievementGroup + TargetLevel, true);

                if (NewTarget > TotalLevels)
                {
                    NewTarget = TotalLevels;
                }

                Session.GetHabbo().ActivityPoints += TargetLevelData.RewardPixels;
                Session.GetHabbo().UpdateActivityPointsBalance(false);

                Session.SendMessage(AchievementUnlockedComposer.Compose(AchievementData, TargetLevel, TargetLevelData.RewardPoints,
                                                                        TargetLevelData.RewardPixels));

                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    if (dbClient.dbType == Database_Manager.Database.DatabaseType.MySQL)
                    {
                        dbClient.setQuery("REPLACE INTO user_achievement VALUES (" + Session.GetHabbo().Id + ", @group, " + NewLevel + ", " + NewProgress + ")");
                    }
                    else
                    {
                        dbClient.setQuery("IF EXISTS (SELECT userid FROM user_achievement WHERE userid = " + Session.GetHabbo().Id + " AND group = @group) " +
                                          "	UPDATE user_achievement SET level = " + NewLevel + ", progress = " + NewProgress + " WHERE userid = " + Session.GetHabbo().Id + " AND group = @group " +
                                          "ELSE" +
                                          "	INSERT INTO user_achievement VALUES (" + Session.GetHabbo().Id + ",@group," + NewLevel + "," + NewProgress + ")");
                    }
                    dbClient.addParameter("group", AchievementGroup);
                    dbClient.runQuery();
                }


                UserData.Level    = NewLevel;
                UserData.Progress = NewProgress;

                Session.GetHabbo().AchievementPoints += TargetLevelData.RewardPoints;
                Session.GetHabbo().ActivityPoints    += TargetLevelData.RewardPixels;
                Session.GetHabbo().UpdateActivityPointsBalance(false);
                Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));


                AchievementLevel NewLevelData = AchievementData.Levels[NewTarget];
                Session.SendMessage(AchievementProgressComposer.Compose(AchievementData, NewTarget, NewLevelData,
                                                                        TotalLevels, Session.GetHabbo().GetAchievementData(AchievementGroup)));

                return(true);
            }
            else
            {
                UserData.Level    = NewLevel;
                UserData.Progress = NewProgress;
                using (IQueryAdapter dbClient = ButterflyEnvironment.GetDatabaseManager().getQueryreactor())
                {
                    if (dbClient.dbType == Database_Manager.Database.DatabaseType.MySQL)
                    {
                        dbClient.setQuery("REPLACE INTO user_achievement VALUES (" + Session.GetHabbo().Id + ", @group, " + NewLevel + ", " + NewProgress + ")");
                    }
                    else
                    {
                        dbClient.setQuery("IF EXISTS (SELECT userid FROM user_achievement WHERE userid = " + Session.GetHabbo().Id + " AND group = @group) " +
                                          "	UPDATE user_achievement SET level = " + NewLevel + ", progress = " + NewProgress + " WHERE userid = " + Session.GetHabbo().Id + " AND group = @group " +
                                          "ELSE" +
                                          "	INSERT INTO user_achievement VALUES (" + Session.GetHabbo().Id + ",@group," + NewLevel + "," + NewProgress + ")");
                    }
                    dbClient.addParameter("group", AchievementGroup);
                    dbClient.runQuery();
                }

                Session.SendMessage(AchievementProgressComposer.Compose(AchievementData, TargetLevel, TargetLevelData,
                                                                        TotalLevels, Session.GetHabbo().GetAchievementData(AchievementGroup)));
            }

            return(false);
        }
Esempio n. 3
0
        public static void ExecuteAttack(GameClient Session, GameClient TargetSession, Room Room, RoomUser RoomUser, RoomUser Target)
        {

            #region Global Variables
            string WeaponName = WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].DisplayName;
            int Damage = CombatManager.DamageCalculator(Session, true);
            #endregion

            #region RPG
            if (Session.GetRoleplay().Equiped.Contains("rpg"))
            {
                if (!Target.CurrentEffect.Equals(175) && !Target.CurrentEffect.Equals(176))
                {
                    Session.SendWhisper("This user is not using a plane!");
                    return;
                }
                else
                {
                    Session.Shout("*Fires their RPG at " + TargetSession.GetHabbo().UserName + "'s plane, causing it to plummet to the ground*");
                    TargetSession.GetRoleplay().MultiCoolDown["plane_cooldown"] = 300;
                    TargetSession.GetRoleplay().CheckingMultiCooldown = true;
                    TargetSession.GetRoleplay().usingPlane = false;
                    TargetSession.GetRoleplay().planeUsing = 0;
                    Target.ApplyEffect(25);
                    return;
                }
            }
            #endregion

            else
            {

                #region Increment / Decrement Values
                if (TargetSession.GetRoleplay().Armor >= 1)
                {
                    TargetSession.GetRoleplay().Armor -= Damage;
                    #region Armor Broken?
                    if (TargetSession.GetRoleplay().Armor <= 0 && TargetSession.GetRoleplay().Armored == true)
                    {
                        TargetSession.GetRoleplay().Armored = false;
                        TargetSession.GetRoleplay().ArmoredFigSet = false;
                        Target.LastBubble = 3;
                        TargetSession.Shout("*Body-armor shatters*");
                        Target.LastBubble = 0;
                    }
                    #endregion
                }
                else
                {
                    TargetSession.GetRoleplay().CurHealth -= Damage;
                }


                Session.GetRoleplay().Energy -= WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Need_Energy;
                Session.GetRoleplay().Bullets -= 1;
                Session.GetRoleplay().SaveQuickStat("bullets", "" + Session.GetRoleplay().Bullets);
                Session.GetRoleplay().GunShots++;
                #endregion

                if (TargetSession.GetRoleplay().CurHealth <= 0)
                {

                    int score = new Random().Next(0, 20);

                    if (!WeaponManager.WeaponsData.ContainsKey(Session.GetRoleplay().Equiped.ToLower()))
                    {
                        return;
                    }

                        Session.Shout("*Shoots their " + WeaponName + " at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage and killing them! [-" + WeaponManager.WeaponsData[Session.GetRoleplay().Equiped.ToLower()].Need_Energy + " Energy, +" + score + " PTS]*");
                    

                    #region Gang Rewards

                    if (Session.GetRoleplay().GangId > 0 && HabboHotel.Roleplay.Gangs.GangManager.validGang(Session.GetRoleplay().GangId, Session.GetRoleplay().GangRank))
                    {

                        Random _s = new Random();
                        using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                        {
                            bool HasGang = false;
                            int gangpts = _s.Next((TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR) * 1 - (int)Math.Round((double)(TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR) / 3, 0), (TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR)* 2);
                            HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Kills++;
                            HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Points += gangpts;

                            if (TargetSession.GetRoleplay().GangId > 0 && HabboHotel.Roleplay.Gangs.GangManager.validGang(TargetSession.GetRoleplay().GangId, TargetSession.GetRoleplay().GangRank))
                            {
                                HasGang = true;
                            }

                            if (HasGang)
                            {
                                if (!Session.GetHabbo().HasFuse("fuse_owner"))
                                {
                                    HabboHotel.Roleplay.Gangs.GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths++;
                                }
                                dbClient.RunFastQuery("UPDATE rp_gangs SET deaths = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths + " WHERE id = " + TargetSession.GetRoleplay().GangId + "");
                            }

                            dbClient.RunFastQuery("UPDATE rp_gangs SET kills = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Kills + ", points = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Points + " WHERE id = " + Session.GetRoleplay().GangId + "");

                        }
                    }

                    #endregion

                    RoomUser.LastBubble = 3;
                    /*if (Session.GetRoleplay().LastKilled != TargetSession.GetHabbo().UserName)
                    {*/
                    Session.GetHabbo().AchievementPoints += score;
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.GetRoleplay().Kills++;
                    Session.GetRoleplay().GunKills++;
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
                    /*}
                    if (Session.GetRoleplay().LastKilled == TargetSession.GetHabbo().UserName)
                    {
                        Misc.Shout(Session, "*Shoots their " + WeaponName + " at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage and killing them! [-" + weaponManager.WeaponsData[Session.GetRoleplay().Equiped].Need_Energy + " Energy]*");
                        Session.SendWhisper("The last person you killed is this same person!");
                    }*/
                    RoomUser.LastBubble = 0;
                    if (!Session.GetHabbo().HasFuse("fuse_owner"))
                    {
                        TargetSession.GetRoleplay().Deaths++;
                    }
                    TargetSession.SendNotif("You were shot dead by " + Session.GetHabbo().UserName + ", and are being transported to the hospital.");

                    if (TargetSession.GetRoleplay().Working)
                    {
                        TargetSession.GetRoleplay().StopWork();
                    }

                    if (!Session.GetRoleplay().Equiped.Contains("police"))
                    {

                        #region Handle Death & Robbery
                        TargetSession.GetRoleplay().DeadFigSet = false;
                        TargetSession.GetRoleplay().DeadSeconds = 60;
                        TargetSession.GetRoleplay().DeadTimer = 2;
                        TargetSession.GetRoleplay().Dead = true;
                        if (TargetSession.GetRoleplay().usingCar == true)
                        {
                            TargetSession.GetRoleplay().usingCar = false;
                            Target.FastWalking = false;
                        }

                        RoleplayManager.HandleDeath(TargetSession);

                        int lol = new Random().Next(1, 25);
                        if (TargetSession.GetHabbo().Credits > lol && Session.GetRoleplay().LastKilled != TargetSession.GetHabbo().UserName)
                        {
                            RoleplayManager.GiveMoney(Session, +lol);
                            Session.Shout("*Steals $" + lol + " from " + TargetSession.GetHabbo().UserName + "'s wallet*");
                            RoleplayManager.GiveMoney(TargetSession, -lol);
                            TargetSession.SendNotif(Session.GetHabbo().UserName + " stole $" + lol + " from you");
                        }

                        #endregion

                        Misc.Bounties.CheckBounty(Session, TargetSession.GetHabbo().UserName);
                        Plus.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Fighter", 1);
                        Plus.GetGame().GetAchievementManager().ProgressUserAchievement(TargetSession, "ACH_Death", 1);

                    }
                    else
                    {

                        #region Handle Arrest
                        int Time = 5;
                        if (RoleplayManager.WantedListData.ContainsKey(TargetSession.GetHabbo().UserName.ToLower()))
                        {
                            string Data = RoleplayManager.WantedListData[TargetSession.GetHabbo().UserName.ToLower()];
                            foreach (KeyValuePair<string, string> User in RoleplayManager.WantedListData)
                            {

                                string Name = User.Key;

                                if (Name != TargetSession.GetHabbo().UserName.ToLower())
                                {
                                    continue;

                                }

                                string[] Split = User.Value.Split('|');

                                Time = Convert.ToInt32(Split[0]);
                            }
                        }
                        else
                        {
                            Time = 10;
                        }

                        TargetSession.SendNotif("You have been arrested by " + Session.GetHabbo().UserName + " for " + Time + " minute(s)");
                        TargetSession.GetRoleplay().JailFigSet = false;
                        TargetSession.GetRoleplay().JailedSeconds = 60;
                        TargetSession.GetRoleplay().JailTimer = Time;
                        TargetSession.GetRoleplay().Jailed = true;
                        TargetSession.GetRoleplay().Arrested++;
                        TargetSession.GetRoleplay().UpdateStats++;

                        Session.GetRoleplay().Arrests++;
                        Session.GetRoleplay().UpdateStats++;
                        #endregion

                    }
                }
                else
                {

                    CombatManager.HandleGun(Session, TargetSession, Room, RoomUser, Target, WeaponName, Damage);

                    #region Increment Values / Cooldown
                    Session.GetRoleplay().CoolDown = 3;
                    Session.GetRoleplay().LastKilled = TargetSession.GetHabbo().UserName;
                    TargetSession.GetRoleplay().UpdateStats++;
                    Session.GetRoleplay().UpdateStats++;
                    #endregion
                }

            }
        }
Esempio n. 4
0
        /// <summary>
        /// Actualiza el progreso una recompensa.
        /// </summary>
        /// <param name="Session"></param>
        /// <param name="UserId"></param>
        /// <param name="AchievementGroup"></param>
        /// <param name="ProgressAmount"></param>
        /// <returns></returns>
        public bool ProgressUserAchievement(uint UserId, string AchievementGroup, int ProgressAmount)
        {
            Habbo Habbo = UsersCache.getHabboCache(UserId);

            if (Habbo == null)
            {
                return(false);
            }

            GameClient Session = Habbo.GetClient();

            Achievement AchievementData = GetAchievementByName(AchievementGroup);

            if (AchievementData == null)
            {
                return(false);
            }

            UserAchievement UserData = Habbo.GetAchievementData(AchievementGroup);

            if (UserData == null)
            {
                UserData = new UserAchievement(AchievementGroup, 0, 0);
                Habbo.Achievements.Add(AchievementGroup, UserData);
            }

            uint TotalLevels = (uint)AchievementData.Levels.Length;

            if (UserData.Level == TotalLevels)
            {
                return(false); // ya está todo completado
            }

            uint TargetLevel = UserData.Level + 1;

            if (TargetLevel > TotalLevels)
            {
                TargetLevel = TotalLevels;
            }

            uint TargetRequeriment = AchievementData.Levels[TargetLevel - 1];

            UserData.Progress += ProgressAmount;

            if (UserData.Progress >= TargetRequeriment)
            {
                UserData.Level++;

                if (TargetLevel == 1)
                {
                    Habbo.GetBadgeComponent().GiveBadge(AchievementGroup + TargetLevel);
                }
                else
                {
                    Habbo.GetBadgeComponent().UpdateBadge(AchievementGroup + TargetLevel);
                }

                Habbo.AchievementPoints += AchievementData.Reward;

                if (Session != null)
                {
                    Session.SendMessage(AchievementUnlockedComposer.Compose(AchievementData, TargetLevel, AchievementData.Reward));
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Habbo.AchievementPoints));
                }
            }

            if (Session != null)
            {
                Session.SendMessage(AchievementProgressComposer.Compose(AchievementData, UserData));
            }

            using (IQueryAdapter dbClient = OtanixEnvironment.GetDatabaseManager().getQueryreactor())
            {
                dbClient.setQuery("REPLACE INTO user_achievements VALUES (" + Habbo.Id + ", @group, " + UserData.Level + ", " + UserData.Progress + ")");
                dbClient.addParameter("group", AchievementGroup);
                dbClient.runQuery();
            }

            if (Session == null)
            {
                Habbo.SaveBadges();
            }

            return(true);
        }
Esempio n. 5
0
        public static void ExecuteAttack(GameClient Session, GameClient TargetSession)
        {
            //int Damage = Gun_weaponCombat.CalculateDamage(Session, TargetSession);
            int Damage = new Random().Next(1, 18);

            if (TargetSession.GetRoleplay().Armor >= 1)
            {
                TargetSession.GetRoleplay().Armor -= Damage;
                #region Armor Broken?
                if (TargetSession.GetRoleplay().Armor <= 0 && TargetSession.GetRoleplay().Armored == true)
                {
                    TargetSession.GetRoleplay().Armored               = false;
                    TargetSession.GetRoleplay().ArmoredFigSet         = false;
                    TargetSession.GetHabbo().GetRoomUser().LastBubble = 3;
                    Misc.RoleplayManager.Shout(TargetSession, "*Body-armor shatters!*");
                    TargetSession.GetHabbo().GetRoomUser().LastBubble = 0;
                }
                #endregion
            }
            else
            {
                TargetSession.GetRoleplay().CurHealth -= Damage;
            }
            Session.GetRoleplay().Energy -= 4;
            Session.GetRoleplay().Bombs  -= 1;
            Session.GetRoleplay().SaveQuickStat("bombs", "" + Session.GetRoleplay().Bombs);
            Session.GetRoleplay().GunShots++;

            if (TargetSession.GetRoleplay().CurHealth <= 0)
            {
                #region Gang Rewards

                if (Session.GetRoleplay().GangId > 0 && HabboHotel.Roleplay.Gangs.GangManager.validGang(Session.GetRoleplay().GangId, Session.GetRoleplay().GangRank))
                {
                    Random _s = new Random();
                    using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                    {
                        bool HasGang = false;
                        int  gangpts = _s.Next(TargetSession.GetRoleplay().Strength * 1 - (int)Math.Round((double)TargetSession.GetRoleplay().Strength / 3, 0), TargetSession.GetRoleplay().Strength * 2);
                        HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Kills++;
                        HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Points += gangpts;

                        if (TargetSession.GetRoleplay().GangId > 0 && HabboHotel.Roleplay.Gangs.GangManager.validGang(TargetSession.GetRoleplay().GangId, TargetSession.GetRoleplay().GangRank))
                        {
                            HasGang = true;
                        }

                        if (HasGang)
                        {
                            if (!Session.GetHabbo().HasFuse("fuse_owner"))
                            {
                                HabboHotel.Roleplay.Gangs.GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths++;
                            }
                            dbClient.RunFastQuery("UPDATE rp_gangs SET deaths = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths + " WHERE id = " + TargetSession.GetRoleplay().GangId + "");
                        }

                        dbClient.RunFastQuery("UPDATE rp_gangs SET kills = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Kills + ", points = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Points + " WHERE id = " + Session.GetRoleplay().GangId + "");
                    }
                }

                #endregion

                Session.GetHabbo().GetRoomUser().LastBubble = 3;

                /*if (Session.GetRoleplay().LastKilled != TargetSession.GetHabbo().UserName)
                 * {*/
                int score = new Random().Next(0, 20);
                Session.GetHabbo().AchievementPoints += score;
                Session.GetHabbo().UpdateActivityPointsBalance();
                Session.GetRoleplay().Kills++;
                Session.GetRoleplay().BombKills++;
                Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
                RoleplayManager.Shout(Session, "*Joga minha granada em " + TargetSession.GetHabbo().UserName + ", causando " + Damage + " dano e matando ! [-4 Energia, +" + score + " PTS]*");

                /*}
                 * if (Session.GetRoleplay().LastKilled == TargetSession.GetHabbo().UserName)
                 * {
                 *  Misc.Shout(Session, "*Bombs " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage and killing them ! [-2 Energy]*");
                 *  Session.SendWhisper("The last person you killed is this same person!");
                 * }*/
                Session.GetHabbo().GetRoomUser().LastBubble = 0;
                if (!Session.GetHabbo().HasFuse("fuse_owner"))
                {
                    TargetSession.GetRoleplay().Deaths++;
                }

                /*string rekt = "";
                 *
                 * rekt += "Hello, \n\nYou have been bombed to death by " + Session.GetHabbo().UserName + ", and are being transported to the hospital.";*/

                TargetSession.SendNotif("Você foi bombardeado até a morte por " + Session.GetHabbo().UserName + ", e estão sendo transportados para o hospital.");

                if (TargetSession.GetRoleplay().Working)
                {
                    TargetSession.GetRoleplay().StopWork();
                }

                #region Handle Death & Robbery
                TargetSession.GetRoleplay().DeadFigSet  = false;
                TargetSession.GetRoleplay().DeadSeconds = 60;
                TargetSession.GetRoleplay().DeadTimer   = 2;
                TargetSession.GetRoleplay().Dead        = true;
                if (TargetSession.GetRoleplay().usingCar == true)
                {
                    TargetSession.GetRoleplay().usingCar = false;
                    TargetSession.GetHabbo().GetRoomUser().FastWalking = false;
                }

                RoleplayManager.HandleDeath(TargetSession);

                int lol = new Random().Next(1, 25);
                if (TargetSession.GetHabbo().Credits > lol)
                {
                    RoleplayManager.GiveMoney(Session, +lol);
                    RoleplayManager.Shout(Session, "*Steals $" + lol + " from " + TargetSession.GetHabbo().UserName + "'s wallet*");
                    RoleplayManager.GiveMoney(TargetSession, -lol);
                    TargetSession.SendNotif(Session.GetHabbo().UserName + " stole $" + lol + " from you");
                }

                #endregion

                Misc.Bounties.CheckBounty(Session, TargetSession.GetHabbo().UserName);
                Plus.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Fighter", 1);
                Plus.GetGame().GetAchievementManager().ProgressUserAchievement(TargetSession, "ACH_Death", 1);
            }
            else
            {
                Session.GetHabbo().GetRoomUser().LastBubble       = 3;
                TargetSession.GetHabbo().GetRoomUser().LastBubble = 3;

                RoleplayManager.Shout(Session, "*Joga uma granada em " + TargetSession.GetHabbo().UserName + ", causando " + Damage + " dano [-4 Energia]*", 3);
                if (TargetSession.GetRoleplay().Armor >= 1)
                {
                    Misc.RoleplayManager.commandShout(TargetSession, "*[" + TargetSession.GetRoleplay().Armor + "AP Left!]*");
                }
                else
                {
                    Misc.RoleplayManager.commandShout(TargetSession, "*[" + TargetSession.GetRoleplay().CurHealth + "/" + TargetSession.GetRoleplay().MaxHealth + "]*");
                }
                TargetSession.GetHabbo().GetRoomUser().ApplyEffect(25);

                Session.GetHabbo().GetRoomUser().LastBubble       = 0;
                TargetSession.GetHabbo().GetRoomUser().LastBubble = 0;
            }

            Session.GetRoleplay().CoolDown   = 3;
            Session.GetRoleplay().LastKilled = TargetSession.GetHabbo().UserName;
            TargetSession.GetRoleplay().UpdateStats++;
            Session.GetRoleplay().UpdateStats++;
        }
Esempio n. 6
0
        public static bool ProgressUserAchievement(SqlDatabaseClient MySqlClient, Session Session, string AchievementGroup, int ProgressAmount)
        {
            if (!mAchievements.ContainsKey(AchievementGroup))
            {
                return(false);
            }

            Achievement AchievementData = null;

            lock (mSyncRoot)
            {
                AchievementData = mAchievements[AchievementGroup];
            }

            UserAchievement UserData = Session.AchievementCache.GetAchievementData(AchievementGroup);

            int TotalLevels = AchievementData.Levels.Count;

            if (UserData != null && UserData.Level == TotalLevels)
            {
                return(false); // done, no more.
            }

            int TargetLevel = (UserData != null ? UserData.Level + 1 : 1);

            if (TargetLevel > TotalLevels)
            {
                TargetLevel = TotalLevels;
            }

            AchievementLevel TargetLevelData = AchievementData.Levels[TargetLevel];

            int NewProgress = (UserData != null ? UserData.Progress + ProgressAmount : ProgressAmount);
            int NewLevel    = (UserData != null ? UserData.Level : 0);
            int NewTarget   = NewLevel + 1;

            if (NewTarget > TotalLevels)
            {
                NewTarget = TotalLevels;
            }

            if (NewProgress >= TargetLevelData.Requirement)
            {
                NewLevel++;
                NewTarget++;

                int ProgressRemainder = NewProgress - TargetLevelData.Requirement;
                NewProgress = 0;

                Badge BadgeData = RightsManager.GetBadgeByCode(AchievementGroup + TargetLevel);

                if (NewTarget > TotalLevels)
                {
                    NewTarget = TotalLevels;
                }

                Session.BadgeCache.UpdateAchievementBadge(MySqlClient, AchievementGroup, BadgeData);
                Session.NewItemsCache.MarkNewItem(MySqlClient, 4, BadgeData.Id);
                Session.SendData(InventoryNewItemsComposer.Compose(4, BadgeData.Id));

                Session.CharacterInfo.UpdateActivityPointsBalance(MySqlClient, TargetLevelData.PixelReward);
                Session.SendData(ActivityPointsBalanceComposer.Compose(Session.CharacterInfo.ActivityPointsBalance,
                                                                       TargetLevelData.PixelReward));

                Session.SendData(AchievementUnlockedComposer.Compose(AchievementData, TargetLevel, TargetLevelData.PointsReward,
                                                                     TargetLevelData.PixelReward));

                Session.AchievementCache.AddOrUpdateData(MySqlClient, AchievementGroup, NewLevel, NewProgress);

                Session.CharacterInfo.UpdateScore(MySqlClient, TargetLevelData.PointsReward);
                Session.SendData(AchievementScoreUpdateComposer.Compose(Session.CharacterInfo.Score));

                AchievementLevel NewLevelData = AchievementData.Levels[NewTarget];
                Session.SendData(AchievementProgressComposer.Compose(AchievementData, NewTarget, NewLevelData,
                                                                     TotalLevels, Session.AchievementCache.GetAchievementData(AchievementGroup)));

                Session.SendInfoUpdate();

                Session.MessengerFriendCache.BroadcastToFriends(MessengerFriendEventComposer.Compose(Session.CharacterId,
                                                                                                     MessengerFriendEventType.AchievementUnlocked, BadgeData.Code));

                RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId);

                if (Instance != null)
                {
                    Instance.BroadcastMessage(RoomUserBadgesComposer.Compose(Session.CharacterId,
                                                                             Session.BadgeCache.EquippedBadges));
                }

                if (ProgressRemainder > 0)
                {
                    ProgressUserAchievement(MySqlClient, Session, AchievementGroup, ProgressRemainder);
                }

                return(true);
            }

            Session.AchievementCache.AddOrUpdateData(MySqlClient, AchievementGroup, NewLevel, NewProgress);
            Session.SendData(AchievementProgressComposer.Compose(AchievementData, TargetLevel, TargetLevelData,
                                                                 TotalLevels, Session.AchievementCache.GetAchievementData(AchievementGroup)));
            return(false);
        }
Esempio n. 7
0
        /// <summary>
        /// Progresses the user achievement.
        /// </summary>
        /// <param name="Session">The session.</param>
        /// <param name="AchievementGroup">The achievement group.</param>
        /// <param name="ProgressAmount">The progress amount.</param>
        /// <param name="FromZero">if set to <c>true</c> [from zero].</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        internal bool ProgressUserAchievement(GameClient Session, string AchievementGroup, int ProgressAmount, bool FromZero = false)
        {
            if (!this.Achievements.ContainsKey(AchievementGroup) || Session == null)
            {
                return(false);
            }
            Achievement achievement = null;

            achievement = this.Achievements[AchievementGroup];
            UserAchievement userAchievement = Session.GetHabbo().GetAchievementData(AchievementGroup);

            if (userAchievement == null)
            {
                userAchievement = new UserAchievement(AchievementGroup, 0, 0);
                Session.GetHabbo().Achievements.Add(AchievementGroup, userAchievement);
            }
            int count = achievement.Levels.Count;

            if (userAchievement != null && userAchievement.Level == count)
            {
                return(false);
            }

            {
                int num = (userAchievement != null) ? (userAchievement.Level + 1) : 1;
                if (num > count)
                {
                    num = count;
                }
                AchievementLevel targetLevelData = achievement.Levels[num];
                int num2 = 0;
                if (FromZero)
                {
                    num2 = ProgressAmount;
                }
                else
                {
                    num2 = ((userAchievement != null) ? (userAchievement.Progress + ProgressAmount) : ProgressAmount);
                }
                int num3 = (userAchievement != null) ? userAchievement.Level : 0;
                int num4 = num3 + 1;
                if (num4 > count)
                {
                    num4 = count;
                }
                if (num2 >= targetLevelData.Requirement)
                {
                    num3++;
                    num4++;
                    int argE60 = num2 - targetLevelData.Requirement;
                    num2 = 0;
                    if (num == 1)
                    {
                        Session.GetHabbo().GetBadgeComponent().GiveBadge(string.Format("{0}{1}", AchievementGroup, num), true, Session, false);
                    }
                    else
                    {
                        Session.GetHabbo().GetBadgeComponent().RemoveBadge(Convert.ToString(string.Format("{0}{1}", AchievementGroup, num - 1)), Session);
                        Session.GetHabbo().GetBadgeComponent().GiveBadge(string.Format("{0}{1}", AchievementGroup, num), true, Session, false);
                    }
                    if (num4 > count)
                    {
                        num4 = count;
                    }
                    Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
                    Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.SendMessage(AchievementUnlockedComposer.Compose(achievement, num, targetLevelData.RewardPoints, targetLevelData.RewardPixels));
                    using (IQueryAdapter queryReactor = Plus.GetDatabaseManager().GetQueryReactor())
                    {
                        queryReactor.SetQuery(string.Concat(new object[]
                        {
                            "REPLACE INTO users_achievements VALUES (",
                            Session.GetHabbo().Id,
                            ", @group, ",
                            num3,
                            ", ",
                            num2,
                            ")"
                        }));
                        queryReactor.AddParameter("group", AchievementGroup);
                        queryReactor.RunQuery();
                    }
                    userAchievement.Level    = num3;
                    userAchievement.Progress = num2;
                    Session.GetHabbo().AchievementPoints += targetLevelData.RewardPoints;
                    Session.GetHabbo().NotifyNewPixels(targetLevelData.RewardPixels);
                    Session.GetHabbo().ActivityPoints += targetLevelData.RewardPixels;
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
                    AchievementLevel targetLevelData2 = achievement.Levels[num4];
                    Session.SendMessage(AchievementProgressComposer.Compose(achievement, num4, targetLevelData2, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));
                    Talent talent = null;
                    if (Plus.GetGame().GetTalentManager().TryGetTalent(AchievementGroup, out talent))
                    {
                        Plus.GetGame().GetTalentManager().CompleteUserTalent(Session, talent);
                    }
                    return(true);
                }
                userAchievement.Level    = num3;
                userAchievement.Progress = num2;
                using (IQueryAdapter queryreactor2 = Plus.GetDatabaseManager().GetQueryReactor())
                {
                    queryreactor2.SetQuery(string.Concat(new object[]
                    {
                        "REPLACE INTO users_achievements VALUES (",
                        Session.GetHabbo().Id,
                        ", @group, ",
                        num3,
                        ", ",
                        num2,
                        ")"
                    }));
                    queryreactor2.AddParameter("group", AchievementGroup);
                    queryreactor2.RunQuery();
                }
                Session.SendMessage(AchievementProgressComposer.Compose(achievement, num, targetLevelData, count, Session.GetHabbo().GetAchievementData(AchievementGroup)));
                Session.GetMessageHandler().GetResponse().Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer"));
                Session.GetMessageHandler().GetResponse().AppendInteger(-1);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Look);
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Gender.ToLower());
                Session.GetMessageHandler().GetResponse().AppendString(Session.GetHabbo().Motto);
                Session.GetMessageHandler().GetResponse().AppendInteger(Session.GetHabbo().AchievementPoints);
                Session.GetMessageHandler().SendResponse();
                return(false);
            }
        }
Esempio n. 8
0
        public static void ExecuteAttack(GameClient Session, GameClient TargetSession)
        {
            {
                int    Damage     = MeleeCombat.CalculateDamage(Session, TargetSession);
                string WeaponName = WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Name;
                if (TargetSession.GetRoleplay().Armor >= 1)
                {
                    TargetSession.GetRoleplay().Armor -= Damage;
                    #region Armor Broken?
                    if (TargetSession.GetRoleplay().Armor <= 0 && TargetSession.GetRoleplay().Armored == true)
                    {
                        TargetSession.GetRoleplay().Armored               = false;
                        TargetSession.GetRoleplay().ArmoredFigSet         = false;
                        TargetSession.GetHabbo().GetRoomUser().LastBubble = 3;
                        Misc.RoleplayManager.Shout(TargetSession, "*Body-armor shatters!*");
                        TargetSession.GetHabbo().GetRoomUser().LastBubble = 0;
                    }
                    #endregion
                }
                else
                {
                    TargetSession.GetRoleplay().CurHealth -= Damage;
                }
                Session.GetRoleplay().Energy -= WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Need_Energy;

                if (TargetSession.GetRoleplay().CurHealth <= 0)
                {
                    #region Gang Rewards

                    if (Session.GetRoleplay().GangId > 0 && HabboHotel.Roleplay.Gangs.GangManager.validGang(Session.GetRoleplay().GangId, Session.GetRoleplay().GangRank))
                    {
                        Random _s = new Random();
                        using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                        {
                            bool HasGang = false;
                            int  gangpts = _s.Next((TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR) * 1 - (int)Math.Round((double)(TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR) / 3, 0), (TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR) * 2);
                            HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Kills++;
                            HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Points += gangpts;

                            if (TargetSession.GetRoleplay().GangId > 0 && HabboHotel.Roleplay.Gangs.GangManager.validGang(TargetSession.GetRoleplay().GangId, TargetSession.GetRoleplay().GangRank))
                            {
                                HasGang = true;
                            }

                            if (HasGang)
                            {
                                if (!Session.GetHabbo().HasFuse("fuse_owner"))
                                {
                                    HabboHotel.Roleplay.Gangs.GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths++;
                                }
                                dbClient.RunFastQuery("UPDATE rp_gangs SET deaths = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths + " WHERE id = " + TargetSession.GetRoleplay().GangId + "");
                            }

                            dbClient.RunFastQuery("UPDATE rp_gangs SET kills = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Kills + ", points = " + HabboHotel.Roleplay.Gangs.GangManager.GangData[Session.GetRoleplay().GangId].Points + " WHERE id = " + Session.GetRoleplay().GangId + "");
                        }
                    }

                    #endregion

                    Session.GetHabbo().GetRoomUser().LastBubble = 3;

                    /*if (Session.GetRoleplay().LastKilled != TargetSession.GetHabbo().UserName)
                     * {*/
                    int score = new Random().Next(0, 20);
                    Session.GetHabbo().AchievementPoints += score;
                    Session.GetHabbo().UpdateActivityPointsBalance();
                    Session.GetRoleplay().Kills++;
                    Session.GetRoleplay().MeleeKills++;
                    Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
                    RoleplayManager.Shout(Session, "*Swings their " + WeaponName + " at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage and killing them! [-" + WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Need_Energy + " Energy] [+" + score + " PTS]*");

                    /*}
                     * if (Session.GetRoleplay().LastKilled == TargetSession.GetHabbo().UserName)
                     * {
                     *  Misc.Shout(Session, "*Swings their " + WeaponName + " at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage and killing them! [-" + weaponManager.WeaponsData[Session.GetRoleplay().Equiped].Need_Energy + " Energy]*");
                     *  Session.SendWhisper("The last person you killed is this same person!");
                     * }*/
                    Session.GetHabbo().GetRoomUser().LastBubble = 0;
                    if (!Session.GetHabbo().HasFuse("fuse_owner"))
                    {
                        TargetSession.GetRoleplay().Deaths++;
                    }
                    TargetSession.SendNotif("You were meleed to death by " + Session.GetHabbo().UserName + ", and are being transported to the hospital.");

                    if (TargetSession.GetRoleplay().Working)
                    {
                        TargetSession.GetRoleplay().StopWork();
                    }

                    if (!Session.GetRoleplay().Equiped.Contains("police"))
                    {
                        #region Handle Death & Robbery
                        TargetSession.GetRoleplay().DeadFigSet  = false;
                        TargetSession.GetRoleplay().DeadSeconds = 60;
                        TargetSession.GetRoleplay().DeadTimer   = 2;
                        TargetSession.GetRoleplay().Dead        = true;
                        if (TargetSession.GetRoleplay().usingCar == true)
                        {
                            TargetSession.GetRoleplay().usingCar = false;
                            TargetSession.GetHabbo().GetRoomUser().FastWalking = false;
                        }

                        RoleplayManager.HandleDeath(TargetSession);

                        int lol = new Random().Next(1, 25);
                        if (TargetSession.GetHabbo().Credits > lol && Session.GetRoleplay().LastKilled != TargetSession.GetHabbo().UserName)
                        {
                            RoleplayManager.GiveMoney(Session, +lol);
                            RoleplayManager.Shout(Session, "*Steals $" + lol + " from " + TargetSession.GetHabbo().UserName + "'s wallet*");
                            RoleplayManager.GiveMoney(TargetSession, -lol);
                            TargetSession.SendNotif(Session.GetHabbo().UserName + " stole $" + lol + " from you");
                        }

                        #endregion

                        Misc.Bounties.CheckBounty(Session, TargetSession.GetHabbo().UserName);
                        Plus.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Fighter", 1);
                        Plus.GetGame().GetAchievementManager().ProgressUserAchievement(TargetSession, "ACH_Death", 1);
                    }
                    else
                    {
                        #region Handle Arrest
                        int Time = 5;
                        if (RoleplayManager.WantedListData.ContainsKey(TargetSession.GetHabbo().UserName.ToLower()))
                        {
                            string Data = RoleplayManager.WantedListData[TargetSession.GetHabbo().UserName.ToLower()];
                            foreach (KeyValuePair <string, string> User in RoleplayManager.WantedListData)
                            {
                                string Name = User.Key;

                                if (Name != TargetSession.GetHabbo().UserName.ToLower())
                                {
                                    continue;
                                }

                                string[] Split = User.Value.Split('|');

                                Time = Convert.ToInt32(Split[0]);
                            }
                        }
                        else
                        {
                            Time = 10;
                        }

                        TargetSession.SendNotif("You have been arrested by " + Session.GetHabbo().UserName + " for " + Time + " minute(s)");
                        TargetSession.GetRoleplay().JailFigSet    = false;
                        TargetSession.GetRoleplay().JailedSeconds = 60;
                        TargetSession.GetRoleplay().JailTimer     = Time;
                        TargetSession.GetRoleplay().Jailed        = true;
                        TargetSession.GetRoleplay().Arrested++;
                        TargetSession.GetRoleplay().UpdateStats++;

                        Session.GetRoleplay().Arrests++;
                        Session.GetRoleplay().UpdateStats++;
                        #endregion
                    }
                }
                else
                {
                    Session.GetHabbo().GetRoomUser().LastBubble       = 3;
                    TargetSession.GetHabbo().GetRoomUser().LastBubble = 3;

                    if (WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Speech == null || WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Speech == "")
                    {
                        RoleplayManager.Shout(Session, "*Swings their " + WeaponName + " at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage [-" + WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Need_Energy + " Energy]*");
                    }
                    else
                    {
                        string finalspeech = WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Speech.Replace("%energy%", Convert.ToString(WeaponManager.WeaponsData[Session.GetRoleplay().Equiped].Need_Energy));
                        Session.Shout(finalspeech);
                    }

                    if (TargetSession.GetRoleplay().Armor >= 1)
                    {
                        Misc.RoleplayManager.commandShout(TargetSession, "*[" + TargetSession.GetRoleplay().Armor + "AP Left!]*");
                    }
                    else
                    {
                        Misc.RoleplayManager.commandShout(TargetSession, "*[" + TargetSession.GetRoleplay().CurHealth + "/" + TargetSession.GetRoleplay().MaxHealth + "]*");
                    }
                    Session.GetHabbo().GetRoomUser().LastBubble       = 0;
                    TargetSession.GetHabbo().GetRoomUser().LastBubble = 0;
                }

                Session.GetRoleplay().CoolDown   = 3;
                Session.GetRoleplay().LastKilled = TargetSession.GetHabbo().UserName;
                TargetSession.GetRoleplay().UpdateStats++;
                Session.GetRoleplay().UpdateStats++;
            }
        }
Esempio n. 9
0
 private static void GetUserInfo(Session Session, ClientMessage Message)
 {
     Session.SendData(UserObjectComposer.Compose(Session));
     Session.SendData(AchievementScoreUpdateComposer.Compose(Session.CharacterInfo.Score));
 }
Esempio n. 10
0
        public static void ExecuteAttack(GameClient Session, GameClient TargetSession)
        {
            if (CombatManager.CanAttack(Session, TargetSession))
            {
                bool Boxed  = false;
                int  Damage = CombatManager.DamageCalculator(Session);

                if (TargetSession.GetRoleplay().Armor >= 1 && TargetSession.GetRoleplay().inColourWars == false)
                {
                    TargetSession.GetRoleplay().Armor -= Damage;
                    #region Armor Broken?
                    if (TargetSession.GetRoleplay().Armor <= 0 && TargetSession.GetRoleplay().Armored == true)
                    {
                        TargetSession.GetRoleplay().Armored       = false;
                        TargetSession.GetRoleplay().ArmoredFigSet = false;
                        Session.GetRoleplay().ApplySpecialStatus("armored");
                        TargetSession.GetHabbo().GetRoomUser().LastBubble = 3;
                        RoleplayManager.Shout(TargetSession, "*Body-armor shatters*");
                        TargetSession.GetHabbo().GetRoomUser().LastBubble = 0;
                    }
                    #endregion
                }
                else
                {
                    TargetSession.GetRoleplay().CurHealth -= Damage;
                }

                if (!Session.GetRoleplay().inColourWars&& Session.GetRoleplay().InMafiaWars == false)
                {
                    Session.GetRoleplay().Energy -= 2;
                }

                Session.GetRoleplay().Punches++;

                if (TargetSession.GetRoleplay().CurHealth <= 0)
                {
                    if (TargetSession.GetRoleplay().IsBoxing)
                    {
                        if (TargetSession == Session)
                        {
                            Session.GetRoleplay().CurHealth = 1;
                            Session.SendWhisper("You cannot kill yourself!");
                            return;
                        }

                        if (Session.GetRoleplay().BoxingRoom != null && Session.GetRoleplay().BoxingRoom.SoloQueue != null)
                        {
                            RoleplayManager.Shout(Session, "*Swings my fist at " + TargetSession.GetHabbo().UserName + ", knocking them out winning the round!*");

                            Boxed = true;
                            Session.GetRoleplay().BoxingRoom.SoloQueue.EndMatch(Session.GetHabbo().UserName, true);
                        }
                    }
                    if (TargetSession.GetRoleplay().inColourWars)
                    {
                        if (TargetSession == Session)
                        {
                            Session.GetRoleplay().CurHealth = 1;
                            Session.SendWhisper("You cannot kill yourself!");
                            return;
                        }
                        Session.GetHabbo().GetRoomUser().LastBubble = 3;
                        Session.GetRoleplay().GiveColorWarPoints(ColourManager.KillPoints);

                        Session.Shout("*Clecnhes my fist, swinging it hard and fast at " + TargetSession.GetHabbo().UserName + ", Landing a blow on their face causing " + Damage + " damage, sending them back to the graveyard! [+ " + ColourManager.KillPoints + " Color Wars Pts]*");

                        TargetSession.GetRoleplay().Transport(ColourManager.GraveYardID, 2);
                        TargetSession.GetRoleplay().CurHealth = 100;
                        TargetSession.GetRoleplay().Energy    = 100;
                        TargetSession.GetRoleplay().Hunger    = 0;

                        new DeadTimer(TargetSession);

                        // Add color points
                    }

                    if (TargetSession.GetRoleplay().InMafiaWars)
                    {
                        if (TargetSession == Session)
                        {
                            Session.GetRoleplay().CurHealth = 1;
                            Session.SendWhisper("You cannot kill yourself!");
                            return;
                        }
                        Session.GetHabbo().GetRoomUser().LastBubble = 3;

                        Session.GetRoleplay().GiveMafiaWarPoints(MafiaWarManager.KillPoints);
                        RoleplayManager.Shout(Session, "*Swings my fist at " + TargetSession.GetHabbo().UserName + ", Landing a blow on their face causing " + Damage + " damage, sending them back to the start! [+ " + MafiaWarManager.KillPoints + " Mafia Wars Pts]*");


                        TargetSession.GetRoleplay().Transport(Plus.GetGame().MafiaWars.GraveYardID, 2);
                        TargetSession.GetRoleplay().CurHealth = 100;
                        TargetSession.GetRoleplay().Energy    = 100;
                        TargetSession.GetRoleplay().Hunger    = 0;
                    }

                    if (TargetSession.GetRoleplay().Brawl == true)
                    {
                        Session.GetRoleplay().GiveColorWarPoints(1);
                        Session.GetHabbo().GetRoomUser().LastBubble = 3;

                        RoleplayManager.Shout(Session, "*Swings at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage, and kicking them out of brawl! [+5BP]*");

                        Session.GetHabbo().GetRoomUser().LastBubble = 0;

                        Session.GetRoleplay().Brawl_Pts += 5;
                        Session.GetRoleplay().SaveQuickStat("brawl_pts", Session.GetRoleplay().Brawl_Pts + "");
                        TargetSession.GetRoleplay().Brawl   = false;
                        TargetSession.GetRoleplay().inBrawl = false;
                        if (TargetSession.GetRoleplay().Working)
                        {
                            TargetSession.GetRoleplay().StopWork();
                        }

                        TargetSession.GetRoleplay().DeadFigSet  = false;
                        TargetSession.GetRoleplay().DeadSeconds = 60;
                        TargetSession.GetRoleplay().DeadTimer   = 2;
                        TargetSession.GetRoleplay().Dead        = true;
                        if (TargetSession.GetRoleplay().usingCar == true)
                        {
                            TargetSession.GetRoleplay().usingCar = false;
                            TargetSession.GetHabbo().GetRoomUser().FastWalking = false;
                        }


                        RoomUser User1 = null;
                        User1 = TargetSession.GetHabbo().GetRoomUser();

                        RoleplayManager.HandleDeath(TargetSession);
                    }
                    else if (TargetSession.GetRoleplay().Brawl == false && TargetSession.GetRoleplay().inColourWars == false && !TargetSession.GetRoleplay().InMafiaWars&& Boxed == false)
                    {
                        #region Gang Rewards

                        if (Session.GetRoleplay().GangId > 0 && GangManager.validGang(Session.GetRoleplay().GangId, Session.GetRoleplay().GangRank))
                        {
                            Random _s = new Random();
                            using (IQueryAdapter dbClient = Plus.GetDatabaseManager().GetQueryReactor())
                            {
                                bool HasGang = false;
                                int  gangpts = _s.Next((TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR) * 1 - (int)Math.Round((double)(TargetSession.GetRoleplay().Strength + TargetSession.GetRoleplay().savedSTR) / 3, 0), TargetSession.GetRoleplay().Strength * 2);
                                GangManager.GangData[Session.GetRoleplay().GangId].Kills++;
                                GangManager.GangData[Session.GetRoleplay().GangId].Points += gangpts;

                                if (TargetSession.GetRoleplay().GangId > 0 && GangManager.validGang(TargetSession.GetRoleplay().GangId, TargetSession.GetRoleplay().GangRank))
                                {
                                    HasGang = true;
                                }

                                if (HasGang)
                                {
                                    if (!Session.GetHabbo().HasFuse("fuse_owner"))
                                    {
                                        GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths++;
                                    }
                                    dbClient.RunFastQuery("UPDATE rp_gangs SET deaths = " + GangManager.GangData[TargetSession.GetRoleplay().GangId].Deaths + " WHERE id = " + TargetSession.GetRoleplay().GangId + "");
                                }

                                dbClient.RunFastQuery("UPDATE rp_gangs SET kills = " + GangManager.GangData[Session.GetRoleplay().GangId].Kills + ", points = " + GangManager.GangData[Session.GetRoleplay().GangId].Points + " WHERE id = " + Session.GetRoleplay().GangId + "");
                            }
                        }

                        #endregion

                        Session.GetHabbo().GetRoomUser().LastBubble = 3;

                        /*if (Session.GetRoleplay().LastKilled != TargetSession.GetHabbo().UserName)
                         * {*/
                        int score = new Random().Next(0, 20);
                        Session.GetHabbo().AchievementPoints += score;
                        Session.GetHabbo().UpdateActivityPointsBalance();
                        Session.GetRoleplay().Kills++;
                        Session.GetRoleplay().PunchKills++;
                        Session.SendMessage(AchievementScoreUpdateComposer.Compose(Session.GetHabbo().AchievementPoints));
                        Session.Shout("*Lands a final blow to their face " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage sending them to hospital! [-2 Energy, +" + score + " PTS]*");

                        /*}
                         * if (Session.GetRoleplay().LastKilled == TargetSession.GetHabbo().UserName)
                         * {
                         *  Shout(Session, "*Swings at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage and knocking them out! [-2 Energy]*");
                         *  Session.SendWhisper("The last person you killed is this same person!");
                         * }*/
                        Session.GetHabbo().GetRoomUser().LastBubble = 0;
                        if (!Session.GetHabbo().HasFuse("fuse_owner"))
                        {
                            TargetSession.GetRoleplay().Deaths++;
                        }
                        TargetSession.SendNotif("You were knocked out by " + Session.GetHabbo().UserName + ", and being transported to the hospital!");

                        if (TargetSession.GetRoleplay().Working)
                        {
                            TargetSession.GetRoleplay().StopWork();
                        }

                        TargetSession.GetRoleplay().DeadFigSet  = false;
                        TargetSession.GetRoleplay().DeadSeconds = 60;
                        TargetSession.GetRoleplay().DeadTimer   = 2;
                        TargetSession.GetRoleplay().Dead        = true;
                        if (TargetSession.GetRoleplay().usingCar == true)
                        {
                            TargetSession.GetRoleplay().usingCar = false;
                            TargetSession.GetHabbo().GetRoomUser().FastWalking = false;
                        }


                        RoomUser User = null;
                        User = TargetSession.GetHabbo().GetRoomUser();

                        RoleplayManager.HandleDeath(TargetSession);

                        Bounties.CheckBounty(Session, TargetSession.GetHabbo().UserName);
                        Plus.GetGame().GetAchievementManager().ProgressUserAchievement(Session, "ACH_Fighter", 1);
                        Plus.GetGame().GetAchievementManager().ProgressUserAchievement(TargetSession, "ACH_Death", 1);
                    }
                }
                else
                {
                    Session.GetHabbo().GetRoomUser().LastBubble       = 3;
                    TargetSession.GetHabbo().GetRoomUser().LastBubble = 3;

                    Session.Shout("*Swings at " + TargetSession.GetHabbo().UserName + ", causing " + Damage + " damage [-2 Energy]*");
                    if (TargetSession.GetRoleplay().Armor >= 1 && TargetSession.GetRoleplay().inColourWars == false)
                    {
                        RoleplayManager.commandShout(TargetSession, "*[" + TargetSession.GetRoleplay().Armor + "AP Left!]*", 3);
                    }
                    else
                    {
                        RoleplayManager.commandShout(TargetSession, "*[" + TargetSession.GetRoleplay().CurHealth + "/" + TargetSession.GetRoleplay().MaxHealth + "]*", 3);
                    }

                    Session.GetHabbo().GetRoomUser().LastBubble       = 0;
                    TargetSession.GetHabbo().GetRoomUser().LastBubble = 0;
                }

                Session.GetRoleplay().CoolDown   = 3;
                Session.GetRoleplay().LastKilled = TargetSession.GetHabbo().UserName;
                TargetSession.GetRoleplay().UpdateStats++;
                Session.GetRoleplay().UpdateStats++;
            }
            else
            {
                return;
            }
        }