[Project Insanity]Critical Hits

Results 1 to 2 of 2
  1. #1
    Novice uncalled is offline
    MemberRank
    Jul 2011 Join Date
    AmericaLocation
    3Posts

    [Project Insanity]Critical Hits

    Critical Hits


    Hey everyone, we're going to be adding critical hits to our Project Insanity source today!
    It will make you hit a whole lot harder then what you would have done, we aren't going to add the orange hit splatters because we are trying to add this for new coders. If you are advanced with the Java language and don't know how to add this, then you must not have worked with combat very much.
    Enough talk, lets get started!


    First:
    Go into your CombatAssistant.java (server > src > models > player > CombatAssistant.java) and add this code somewhere:
    Code:
    public boolean CalculateCriticalDamage(Client c) {
    		int CriticalDamage = Misc.random(100);
    		if (CriticalDamage > 99)
    			return true;
    		else
    			return false;
    	}
    This is the boolean that you will use with a true-false statement into other calculations on here. This code is what your other ranged and melee attack will be depending on to receive a critical strike. So you will absolutely need this code if you want to add this.
    Code:
    		int CriticalDamage = Misc.random(100);
    That gives it a 1-100% chance of actually hitting the critical.
    Code:
    		if (CriticalDamage > 99)
    This makes it a 1% chance of actually getting that critical hit to go through.


    Second:
    Still in CombatAssistant.java add this:
    Code:
    	public int CalculateCriticalDamage(Client c, int Damage, String type) {
    		return Damage += Damage;
    	}
    This is what will add the damage applied. It's not a very big code, so I cannot explain it thoroughly like I have with the other codes I put and am putting. But; this applies the damage necessary for your critical strikes. If you cease to leave this code snippet out, you will not see any differences in your hits.


    Third:
    Still in your CombatAssistant.java you will need to add this:
    Code:
    	public void sendCriticalDamageGloating(Client c, String CombatStyle) {
    		if (CombatStyle == "Ranged") {
    			c.forcedText = "Ranged Critical!";
    			c.forcedChatUpdateRequired = true;
    			c.updateRequired = true;
    		}
    
    		if (CombatStyle == "Melee") {
    			c.forcedText = "Melee Critical!";
    			c.forcedChatUpdateRequired = true;
    			c.updateRequired = true;
    		}
    	}
    Now, this code is actually redundant; it makes you gloat about your critical hit. It will make you say either "Melee Critical!" or "Ranged Critical!" Either way, I still added this more as proof that the person hit a critical, instead of using a sendMessage code saying he did then your player could simply say, "I just hit a critical." But with this code, they really cannot lie about hitting a critical.
    So that's why this code is in here, and it's not that complicated to add, just something extra I though you guys might like.


    Fourth:
    Still in CombatAssistant class, search for this:
    Code:
    int MeleeDamage = (int) Math.floor(maxHit);
    Under it, add this:
    Code:
    int MeleeDamage = (int) Math.floor(maxHit);
    		CalculateCriticalDamage(c);
    		if (CalculateCriticalDamage(c)) {
    			sendCriticalDamageGloating(c, "Melee");
    			return CalculateCriticalDamage(c, MeleeDamage, "Melee");
    		} else
    			return (int) Math.floor(maxHit);
    	}
    This is actually applying the critical damage when it happens.
    Code:
    			sendCriticalDamageGloating(c, "Melee");
    Is sending your gloating, so the person will say "Melee Critical!" once a critical hit happens.
    Code:
    			return CalculateCriticalDamage(c, MeleeDamage, "Melee");
    This is applying the critical damage that happens. Now when you hit a critical, this is the code that will actually apply the damage.


    Fifth:
    Yet again, in CombatAssistant class search for:
    Code:
    int RangedDamage = (int) max;
    Under that, add this:
    Code:
    		CalculateCriticalDamage(c);
    		if (CalculateCriticalDamage(c)) {
    			sendCriticalDamageGloating(c, "Ranged");
    			return CalculateCriticalDamage(c, RangedDamage, "Ranged");
    		} else
    			return (int) max;
    	}
    This is actually applying the critical damage when it happens.
    Code:
    			sendCriticalDamageGloating(c, "Ranged");
    Is sending your gloating, so the person will say "Ranged Critical!" once a critical hit happens.
    Code:
    			return CalculateCriticalDamage(c, MeleeDamage, "Ranged");
    This is applying the critical damage that happens. Now when you hit a critical, this is the code that will actually apply the damage.


    You've successfully added critical hits to your Project Insanity! If you have any errors at all, please post it below. I am a pretty friendly guy and I'm only here to help, so again; any errors, post them. I will try to help you out through all your problems. I could usually figure out all of them, but if I can't, then I'm very sorry. But I will give it my best, so please post all your errors!


  2. #2
    Apprentice freddy123 is offline
    MemberRank
    May 2010 Join Date
    12Posts

    Re: [Project Insanity]Critical Hits

    xvrrrrrrrrrrrrrrrrrrrrrrrrrrrr

    ---------- Post added at 07:23 PM ---------- Previous post was at 07:17 PM ----------

    your speak spanish? help me

    ---------- Post added at 07:25 PM ---------- Previous post was at 07:23 PM ----------

    your speak spanish? help me



Advertisement