Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • puta loca: or what section can i ask this
      Today at 05:45:08 AM
    • puta loca: does someoen has platinum ps v2 files?
      Today at 05:44:59 AM
    • w azza 3: server down??
      Today at 05:07:47 AM
    • charmie: rippppppppppppppppppppppppppppppppppppppppppppppp
      May 20, 2018, 09:03:41 PM
    • Tesco Value: eco reset? :o
      May 20, 2018, 08:54:27 PM
    • Tesco Value: aw is server down? :P
      May 20, 2018, 08:54:03 PM
    • mandmgalaxy: is the game down?
      May 20, 2018, 08:05:07 PM
    • bliss death: i believe 95% of the community disliked this change heavily as it came out of nowhere. and the fact you clear ironmen banks as well. terrible change. disappointed.
      May 20, 2018, 06:08:36 PM
    • bliss death: just wondering when the server is gonna be fixed and reverted
      May 20, 2018, 06:07:36 PM
    • Saltyspade10: I'll be back ;)
      May 15, 2018, 04:43:53 PM
    • Nunubuffs:[link]
      May 15, 2018, 12:06:25 PM
    • Nunubuffs: .info god
      May 15, 2018, 12:05:40 PM
    • Nunubuffs: Www.scaperune
      May 15, 2018, 12:05:25 PM
    • Nunubuffs: Www.scaperune
      May 15, 2018, 12:05:18 PM
    • Wilkooo: Meep meep
      May 15, 2018, 04:49:58 AM
    • FoHammer: Checkout my thread here we're now live: [link]
      May 14, 2018, 08:26:59 PM
    • FoHammer: Beemonumerouno
      May 14, 2018, 08:26:25 PM
    • DeathsChaos9::|
      May 14, 2018, 07:46:09 PM
    • Service.Man: Hi guys. I've just made a new account and downloaded the server - Still can't log in. Any tips?
      May 14, 2018, 01:37:43 AM
    • beemonumerouno: where can i ask if someone has a good custom server for free?
      May 11, 2018, 04:00:25 PM

    Author Topic: Taking damage from a 0?  (Read 614 times)

    0 Members and 1 Guest are viewing this topic.

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Taking damage from a 0?
    « on: January 15, 2016, 10:59:39 PM »
    I can't understand why i'm taking damage when an npc hits a 0 on me even with prayer on.. i'm pretty sure this coding is correct.
    "if npc is using melee, take damage 0 if melee prayer active still take 0 damage but if damage is over 0 take damage to hitpoints"

    Code: [Select]
    if (npcs[i].attackType == 0) {
    damage = Misc.random(npcs[i].maxHit);
    if (10 + Misc.random(c.getCombat().calculateMeleeDefence()) > Misc
    .random(NPCHandler.npcs[i].attack)) {
    damage = 0;
    }
    if (c.prayerActive[18]) { // protect from melee
    damage = 0;
    }
    if (c.playerLevel[3] - damage < 0) {
    damage = c.playerLevel[3];
    }
    }
    RS2Ad banner

    OfflineArbe

    • Member
    • ****
    • Posts: 970
    • Thanks: +0/-0
      • View Profile
    Re: Taking damage from a 0?
    « Reply #1 on: January 16, 2016, 12:34:54 AM »
    Check to see if the prayer is on first before dealing the damage. I can see in this code you're not doing that.

    Code: Java
    1. if(c.prayerActive[18]){// protect from melee
    2.                                                 damage =0;
    3.                                         }
    4.  

    Put that under
    Code: Java
    1. if(npcs[i].attackType==0){
    2.  

    So the full code should be;

    Code: Java
    1. if(npcs[i].attackType==0){
    2.                                         if(c.prayerActive[18]){// protect from melee
    3.                                                 damage =0;
    4.                                         }
    5.                                          damage = Misc.random(npcs[i].maxHit);
    6.                                         if(10+ Misc.random(c.getCombat().calculateMeleeDefence())> Misc
    7.                                                         .random(NPCHandler.npcs[i].attack)){
    8.                                                 damage =0;
    9.                                         }
    10.                                         if(c.playerLevel[3]- damage <0){
    11.                                                 damage = c.playerLevel[3];
    12.                                         }
    13.                                 }
    14.  
    I'm not sure if it will work, but it seems only logical.
    « Last Edit: January 16, 2016, 12:37:03 AM by Arbe »
    RS2Ad banner

    Offlinetank nation

    • Member
    • ****
    • Posts: 483
    • Thanks: +0/-0
      • View Profile
    Re: Taking damage from a 0?
    « Reply #2 on: January 16, 2016, 02:07:46 AM »
    Check to see if the prayer is on first before dealing the damage. I can see in this code you're not doing that.

    Code: Java
    1. if(c.prayerActive[18]){// protect from melee
    2.                                                 damage =0;
    3.                                         }
    4.  

    Put that under
    Code: Java
    1. if(npcs[i].attackType==0){
    2.  

    So the full code should be;

    Code: Java
    1. if(npcs[i].attackType==0){
    2.                                         if(c.prayerActive[18]){// protect from melee
    3.                                                 damage =0;
    4.                                         }
    5.                                          damage = Misc.random(npcs[i].maxHit);
    6.                                         if(10+ Misc.random(c.getCombat().calculateMeleeDefence())> Misc
    7.                                                         .random(NPCHandler.npcs[i].attack)){
    8.                                                 damage =0;
    9.                                         }
    10.                                         if(c.playerLevel[3]- damage <0){
    11.                                                 damage = c.playerLevel[3];
    12.                                         }
    13.                                 }
    14.  
    I'm not sure if it will work, but it seems only logical.

    Still having same problem.. This ain't making any sense.
    RS2Ad banner

    Offlinesk8rdude461

    • MOPARSCAPE WAS HACKED
    • Member
    • ****
    • *
    • Posts: 12,471
    • Thanks: +0/-0
      • View Profile
    Re: Taking damage from a 0?
    « Reply #3 on: January 16, 2016, 03:34:49 AM »
    Odd way of handing combat..

    Arbe, your code is wrong.
    This is why:
    Code: Java
    1.                                         if(c.prayerActive[18]){// protect from melee
    2.                                                 damage =0;// Lets set the value of damage to 0
    3.                                         }
    4.                                          damage = Misc.random(npcs[i].maxHit);// Oh now we're setting it to the max hit for the npc.. oops
    "Better" code:
    Code: Java
    1. if(npcs[i].attackType==0){
    2.         damage = Misc.random(npcs[i].maxHit);
    3.         if((Misc.random(c.getCombat().calculateMeleeDefence())+10)> Misc.random(NPCHandler.npcs[i].attack)
    4.                         || c.prayerActive[18]){
    5.                 damage =0;
    6.         }
    7.         if(damage > c.playerLevel[3]){
    8.                 damage = c.playerLevel[3];
    9.         }
    10. }
    ^Same logic.

    If you want to figure out what's causing the damage to hit.. I suggest you actually print out the value of "damage" every time it's modified or used. See where it gets set to the value that you get hit.

    Ex:
    Code: Java
    1. if(npcs[i].attackType==0){
    2.         damage = Misc.random(npcs[i].maxHit);
    3.         System.out.println("Dmg1: "+ damage);
    4.         if((Misc.random(c.getCombat().calculateMeleeDefence())+10)> Misc.random(NPCHandler.npcs[i].attack)
    5.                         || c.prayerActive[18]){
    6.                 damage =0;
    7.         }
    8.         System.out.println("Dmg2: "+ damage);
    9.         if(damage > c.playerLevel[3]){
    10.                 damage = c.playerLevel[3];
    11.         }
    12.         System.out.println("Dmg3: "+ damage);
    13. }
    Now if Dmg1 is set to 45, and then it's still that at Dmg3, then the value never changed by any of the if statements. If it's no longer 45, it was changed.

    Offlinematzie

    • Member
    • ****
    • Posts: 1,013
    • Thanks: +0/-0
      • View Profile
    Re: Taking damage from a 0?
    « Reply #4 on: January 17, 2016, 12:50:35 AM »
    The problem is the part handling prayer is called later in the sequence than the part that handles dealing damage. But the part that handles the packets is later, it relies on the value you sent.

    so it goes:

    hitPlayer();
    setDamageFromProtMelee();
    sendPlayerUpdateUsingTheDamageValue();
    smart phones are dumb
    people are smart phones.

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal