Thread: DealDamage method [HELP]

Results 1 to 6 of 6
  1. #1 DealDamage method [HELP] 
    Registered Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Hi, I'm new.

    I started doing the Dawntained Pking Base. When I tried adding the spirit shields effects in the dealdamage method, my combat system f's up.
    Because inside the dealdamage method is these codes where it lets the server know if you're opponent is at 0hp then he must do the death emote and respawn.
    So when I try adding the spirit shield effects under it. I grab 2 players to fight and test it out, but when it hits a 200 then its actually hitting 400. and once it reaches 0hp it'll stay alive. Then the next hit would be like 6344324.

    Dealdamage method in player.java
    Code:
     public void dealDamage(int damage)
            {
                    Client c = (Client) PlayerHandler.players[this.playerId];
                    if (playerLevel[3] - damage < 0)
                    {
                            damage = playerLevel[3];
                    }
                    this.subtractFromHitPoints(damage);
                    int difference = playerLevel[3] - damage;
                    if (difference <= maximumHitPoints / 10 && difference > 0)
                    {
                            appendRedemption();
                    }
                    c.getPA().refreshSkill(3);
                    if (c.playerLevel[Constants.HITPOINTS] == 0 && !c.isDead)
                    {
                            Death.getInstance().killPlayer(c);
                    }
            }
    and the code im trying to add for spirit shields
    Code:
    if(playerEquipment[playerShield] == 13740) { // Divine Spirit Shield Effect
    		    
    			if(prayerPoint >0) {
    			    if(playerLevel[3] > 4) {
    					double damageRecieved = damage * 0.7;
    					int prayerLost = (int) (damage * 0.25);
    					if(prayerPoint >= prayerLost) {
    						damage = (int) damageRecieved;
    						prayerPoint -= prayerLost;
    						if(prayerPoint < 0)
    							prayerPoint = 0;
    							gfx0(247);
    							c.sendMessage("Your shield absorbs 30% damage but your prayer drains...");
    							
    					}
    				}
    			}
    		}
    		if(playerEquipment[playerShield] == 13742) { // Elysian Spirit Shield Effect
    			if(Misc.random(9) <= 3) {
    				if(playerLevel[3] > 4) {
    					double damageRecieved = damage * 0.75;
    damage = (int) damageRecieved;
    					gfx0(247);
    					c.sendMessage("Your shield absorbs 25% of the hit...");
    				}
    			}
    		}
    		if (teleTimer <= 0){
    		    playerLevel[3] -= damage;
    		}else {
    			if (hitUpdateRequired)
    			hitUpdateRequired = false;
    			if (hitUpdateRequired2)
    			hitUpdateRequired2 = false;
    		}
    		
    	}
    I've tried many things to fix it. But when I finally got it fixed by taking out

    Code:
    }else {
    			if (hitUpdateRequired)
    			hitUpdateRequired = false;
    			if (hitUpdateRequired2)
    			hitUpdateRequired2 = false;
    		}
    My dragon claw special still hits damage on the opponent even when the hitsplat has the defence icon.

    Please, would someone help me out? Thanks!
    Reply With Quote  
     

  2. #2  
    Super Donator
    NotAlex's Avatar
    Join Date
    Mar 2012
    Posts
    268
    Thanks given
    24
    Thanks received
    28
    Rep Power
    57
    Post your entire method.
    Reply With Quote  
     

  3. #3  
    Dawntained makes it rain.

    Mgt Madness's Avatar
    Join Date
    Oct 2011
    Age
    23
    Posts
    3,337
    Thanks given
    1,369
    Thanks received
    887
    Rep Power
    1762
    Pm me the bugs next time and if i find a fix, i'll reply back.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    Quote Originally Posted by :Alex: View Post
    Post your entire method.
    I've tried mixing it up a bit and even taking out the
    Code:
     }else {
    			if (hitUpdateRequired)
    			hitUpdateRequired = false;
    			if (hitUpdateRequired2)
    			hitUpdateRequired2 = false;
    Makes it work perfectly for the death method and spirit shield effects. But when it comes to dragon clawing with it's special attack, the shield icon, you hit a 0 ofc, but still deals damage on the opposing player.
    Code:
    public void dealDamage(int damage)
            {
                    Client c = (Client) PlayerHandler.players[this.playerId];
                    if (playerLevel[3] - damage < 0)
                    {
                            damage = playerLevel[3];
                    }
                    this.subtractFromHitPoints(damage);
                    int difference = playerLevel[3] - damage;
                    if (difference <= maximumHitPoints / 10 && difference > 0)
                    {
                            appendRedemption();
                    }
                    c.getPA().refreshSkill(3);
                    if (c.playerLevel[Constants.HITPOINTS] == 0 && !c.isDead)
                    {
                            Death.getInstance().killPlayer(c);
                    }
                   if (playerEquipment[playerShield] == 13740) { // Divine Spirit Shield Effect
    		    if(prayerPoint >0) {
    			    if(playerLevel[3] > 4) {
    					double damageRecieved = damage * 0.85;
    					int prayerLost = (int) (damage * 0.3);
    					if(prayerPoint >= prayerLost) {
    						damage = (int) damageRecieved;
    						prayerPoint -= prayerLost;
    						if(prayerPoint < 0)
    							prayerPoint = 0;
    							gfx0(247);
    							c.sendMessage("Your shield absorbs 15% damage but your prayer drains...");
    					}
    				}
    			}
    		}
                    else if (playerEquipment[playerShield] == 13742) { // Elysian Spirit Shield Effect
    			if(Misc.random(9) <= 3) {
    				if(playerLevel[3] > 4) {
    					double damageRecieved = damage * 0.25;
    					damage = (int) damageRecieved;
    					gfx0(247);
    					c.sendMessage("Your shield absorbs 75% of the hit...");
    				}
    			}
    		}
    		if (teleTimer <= 0){
    		    playerLevel[3] -= damage;
    		}else {
    			if (hitUpdateRequired)
    			hitUpdateRequired = false;
    			if (hitUpdateRequired2)
    			hitUpdateRequired2 = false;
    		}
    		
    	}
    Reply With Quote  
     

  5. #5  
    Registered Member Verisimilitude's Avatar
    Join Date
    Mar 2012
    Age
    22
    Posts
    488
    Thanks given
    45
    Thanks received
    17
    Rep Power
    0
    woops, mod delete this post please.

    /requestdeletepost
    [spoil][/spoil]
    Code:
    [Today 05:35 AM] Verisimilitude: My new siggy
    [Today 05:34 AM] Verisimilitude: Ikr
    [Today 05:34 AM] a Kitty: 'there is litteraly nothing i can do to reach him, so i will just stand here and accept my fate'

    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jul 2014
    Posts
    4
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    bump
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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

Similar Threads

  1. dropItem method help?
    By Discardedx2 in forum Help
    Replies: 2
    Last Post: 09-21-2009, 10:28 PM
  2. Interface Method Help
    By Stewie in forum Help
    Replies: 2
    Last Post: 06-01-2009, 09:01 AM
  3. Switch Weapon Method - help?
    By zezarak in forum Help
    Replies: 0
    Last Post: 04-25-2009, 08:55 PM
  4. Stream Method help
    By popbob in forum Help
    Replies: 0
    Last Post: 04-13-2009, 12:54 AM
  5. Method Help.
    By The Killer18 in forum Help
    Replies: 1
    Last Post: 03-27-2009, 09:16 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
  •