Thread: Stats doubles on death

Page 1 of 2 12 LastLast
Results 1 to 10 of 15
  1. #1 Stats doubles on death 
    Registered Member Kairon's Avatar
    Join Date
    Feb 2017
    Posts
    202
    Thanks given
    54
    Thanks received
    45
    Rep Power
    33
    Hey

    I followed this tutorial https://www.rune-server.ee/runescape...ml#post5496377
    I manged to fix that error when you wear something, and log out then it sets all stats to 0

    Now I'm having issue when an player dies it will double your stats
    Example: I'm @ fight pits, I died to mobs which means I failed minigame and I didn't lose anything so I kept all my items on etc, then it doubles my stats. After I relog stats will be fine once again depends what you wear.

    If an staff dies to wilderness (He wont lose anything) and also keeps his items on when he dies, stats will double.
    That's the issue I'm having right now

    Death methods

    OSR Base

    Code:
     /** The main part of the death process where the killer is found for the character. */
        @Override
        public void death() {
            Mob killer = mob.getCombat().getDamageCache().calculateProperKiller().orElse(null);
    
            if (mob.inActivity() && Activity.evaluate(mob, Activity::safe)) {
                safe = true;
                return;
            }
    
            if (Area.inZulrah(mob)) {
                safe = true;
                return;
            }
    
            if (Area.inEventArena(mob)) {
                safe = true;
                return;
            }
    
            if (!PlayerRight.isPriviledged(mob)) {
                Pets.onDeath(mob);
                calculateDropItems(mob, killer);
            }
    
            if (killer == null)
                return;
    
            switch (killer.getType()) {
                case PLAYER:
                    Player playerKiller = killer.getPlayer();
    
                    if (mob.isBot) {
                        playerKiller.pkPoints += 1;
                        playerKiller.message("<col=295EFF>You were rewarded with 1 point for that bot kill. You now have: " + Utility.formatDigits(playerKiller.pkPoints) + ".");
                        return;
                    }
    
                    if (!PlayerKilling.contains(playerKiller, mob.lastHost)) {
                        AchievementHandler.activate(playerKiller, AchievementKey.KILLER, 1);
                        playerKiller.send(new SendMessage(Utility.randomElement(DEATH_MESSAGES).replace("$VICTIM", mob.getName())));
                        PlayerKilling.handle(playerKiller, mob);
                    } else {
                        playerKiller.message("<col=FF0019>You have recently killed " + mob.getName() + " and therefore were not rewarded. You must kill ", "<col=FF0019>3 new players to reset this!");
                    }
    
                    EventDispatcher.execute(playerKiller, new OnKillEvent(mob));
                    break;
                case NPC:
                    break;
                default:
                    break;
            }
    
        }
    
        /** The last part of the death process where the character is reset. */
        @Override
        public void postDeath(Mob killer) {
            if (mob.isBot) {
                ((PlayerBot) mob).postDeath();
                return;
            }
    
            mob.runEnergy = 100;
            mob.skulling.unskull();
            mob.skills.restoreAll();
            mob.inventory.refresh();
            mob.equipment.login();
            mob.action.reset();
            mob.playerAssistant.reset();
            mob.interfaceManager.close();
            mob.setSpecialActivated(false);
            mob.getCombat().getDamageCache().clear();
            mob.send(new SendRunEnergy());
            CombatSpecial.restore(mob, 100);
            mob.movement.reset();
            mob.teleblockTimer.set(0);
    
            if (mob.inActivity()) {
                Activity.forActivity(mob, it -> it.onDeath(mob));
                return;
            }
    
            mob.move(Config.DEFAULT_POSITION);
            mob.send(new SendMessage("Oh dear, you are dead!"));
    
            if (mob.presetManager.deathOpen) {
                World.schedule(1, mob.presetManager::open);
            }
    
            if (!safe) {
                if (killer != null && killer.isPlayer() && !mob.equals(killer)) {
                    mob.killstreak.end(killer.getName());
                }
                if (mob.right == PlayerRight.HARDCORE_IRONMAN) {
                    mob.right = PlayerRight.IRONMAN;
                    mob.updateFlags.add(UpdateFlag.APPEARANCE);
                    mob.send(new SendMessage("You have lost your hardcore iron man status since you died! Sucks to suck."));
                    World.sendMessage("<icon=1> <col=FF0000>OSR: <col=" + mob.right.getColor() + ">" + mob.getName() + "</col>'s hardcore iron man account was lost!");
                }
            }
    
            InterfaceWriter.write(new InformationWriter(mob));
        }

    SOLVED!
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Jul 2012
    Age
    25
    Posts
    122
    Thanks given
    16
    Thanks received
    21
    Rep Power
    15
    mob.equipment.login();
    In this method start with setting the current bonus to zero.
    Reply With Quote  
     

  3. #3  
    Registered Member Kairon's Avatar
    Join Date
    Feb 2017
    Posts
    202
    Thanks given
    54
    Thanks received
    45
    Rep Power
    33
    Code:
    public void login() {
            for (int index = 0; index < getItems().length; index++) {
                set(index, get(index), false);
            }
    
            WeaponInterface.execute(player, getWeapon());
            updateWeight();
            updateBonus();
            refresh();
        }

    It seems like it sets already it to 0
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jul 2012
    Age
    25
    Posts
    122
    Thanks given
    16
    Thanks received
    21
    Rep Power
    15
    Quote Originally Posted by Kairon View Post
    Code:
    public void login() {
            for (int index = 0; index < getItems().length; index++) {
                set(index, get(index), false);
            }
    
            WeaponInterface.execute(player, getWeapon());
            updateWeight();
            updateBonus();
            refresh();
        }

    It seems like it sets already it to 0
    No it isn't. Does the weapon bonus and weight also double?
    Reply With Quote  
     

  5. #5  
    Registered Member Kairon's Avatar
    Join Date
    Feb 2017
    Posts
    202
    Thanks given
    54
    Thanks received
    45
    Rep Power
    33
    Yes, lets say mah maxhit is like 39 with wearing elder, after I died it stacks so it goes to something like 70, so yeah.
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jul 2012
    Age
    25
    Posts
    122
    Thanks given
    16
    Thanks received
    21
    Rep Power
    15
    Quote Originally Posted by Kairon View Post
    Yes, lets say mah maxhit is like 39 with wearing elder, after I died it stacks so it goes to something like 70, so yeah.
    In that class, is there a reset method? Else you'd want to create one. What happens is that each time you die, your bonuses gets readded, because generally items are dequipped, so this wouldn't be a problem. You'd want to set them to zero before adding them.
    Reply With Quote  
     

  7. #7  
    Registered Member Kairon's Avatar
    Join Date
    Feb 2017
    Posts
    202
    Thanks given
    54
    Thanks received
    45
    Rep Power
    33
    Theres just refresh method which basically is refreshing interface only

    Code:
    public void clear() {
            super.clear();
            Arrays.fill(player.getBonuses(), 0);
        }
    Also this as clear method, but it also clears all what you equipped and those items will be lost.

    When I have stacked bonuses and if relog, it will set bonuses back to original(Not stacked anymore) just when you die it stacks.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Jul 2012
    Age
    25
    Posts
    122
    Thanks given
    16
    Thanks received
    21
    Rep Power
    15
    Quote Originally Posted by Kairon View Post
    Theres just refresh method which basically is refreshing interface only

    Code:
    public void clear() {
            super.clear();
            Arrays.fill(player.getBonuses(), 0);
        }
    Also this as clear method, but it also clears all what you equipped and those items will be lost.
    Does it really? Try putting it at the top of the login method.
    You can also try just putting
    Code:
    Arrays.fill(player.getBonuses(), 0);
    at the top of the login method.
    Reply With Quote  
     

  9. #9  
    Registered Member Kairon's Avatar
    Join Date
    Feb 2017
    Posts
    202
    Thanks given
    54
    Thanks received
    45
    Rep Power
    33
    Code:
    public void login() {
        	Arrays.fill(player.getBonuses(), 0);
            for (int index = 0; index < getItems().length; index++) {
                set(index, get(index), false);
            }
    
            WeaponInterface.execute(player, getWeapon());
            updateWeight();
            updateBonus();
            refresh();
        }
    So something like tht?
    Reply With Quote  
     

  10. #10  
    Registered Member
    Join Date
    Jul 2012
    Age
    25
    Posts
    122
    Thanks given
    16
    Thanks received
    21
    Rep Power
    15
    Quote Originally Posted by Kairon View Post
    Code:
    public void login() {
        	Arrays.fill(player.getBonuses(), 0);
            for (int index = 0; index < getItems().length; index++) {
                set(index, get(index), false);
            }
    
            WeaponInterface.execute(player, getWeapon());
            updateWeight();
            updateBonus();
            refresh();
        }
    So something like tht?
    Yes.
    If the clear method does in fact remove the gear.
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Replies: 13
    Last Post: 11-25-2012, 04:55 AM
  2. Replies: 7
    Last Post: 07-17-2008, 01:28 AM
  3. Changing where you spawn on death
    By Pointzero in forum Tutorials
    Replies: 2
    Last Post: 03-17-2008, 03:03 PM
  4. On-Death Insurance Plan
    By Daniel in forum Tutorials
    Replies: 20
    Last Post: 02-13-2008, 10:33 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •