Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • King Bosnia: Any recommendations to private servers?
      October 18, 2018, 04:47:35 PM
    • FightMexoxo: oi i have the files if anyone whats em
      October 18, 2018, 12:44:42 AM
    • The Wanderer: Whoops
      October 15, 2018, 12:56:18 AM
    • The Wanderer: Making own operating system
      October 15, 2018, 12:56:11 AM
    • Travas: no
      October 07, 2018, 04:03:36 PM
    • Saltyspade10: Server still up and running?
      October 05, 2018, 07:13:41 PM
    • Wesam: Can someone upload moparscape.jar?
      October 05, 2018, 11:43:43 AM
    • Ligoe: yo
      September 30, 2018, 12:48:15 PM
    • Ligoe: how come i can't login the game
      September 30, 2018, 12:48:03 PM
    • fuzzout: Anybody here with experience in using Luna source? I'm looking to develop something, but can't seem to get any of my clients to work with it...
      September 26, 2018, 10:47:27 AM
    • `Discardedx2`: ?
      September 21, 2018, 12:24:09 PM
    • Pookey71: ARE YOU HERE TO RECEIVE MY LIMP PENIS!?
      September 20, 2018, 11:55:24 PM
    • Pookey71: THIS IS DEMOCRACY MANIFESTO
      September 20, 2018, 11:55:07 PM
    • Vasi28: Гранд
      September 03, 2018, 07:06:22 PM
    • Rash: test
      August 30, 2018, 09:09:18 PM
    • Guruu:[link]
      August 30, 2018, 12:04:45 AM
    • Guruu: am i allowed to post links shoutbox?
      August 30, 2018, 12:03:46 AM
    • drubrkletern:[link] feedback wanted
      August 28, 2018, 03:55:17 PM
    • bugz000: Anyone got a link for the old ass silab client and cache.zip? from mopar 3.2 era :) 317
      August 25, 2018, 12:48:15 AM
    • cholland2015: Does anyone know where I can download the old moparscape client/server?
      August 24, 2018, 02:30:51 PM

    Author Topic: Taking damage from a 0?  (Read 653 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];
    }
    }
    Runescape Gambling

    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 »
    Runescape Gambling

    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.
    Runescape Gambling

    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,014
    • 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