RuneScape 2 Development > Server Help

NPCs cannot hit through prayer 317 [PI]

Pages: <<< (3/3)

beale:


--- Quote from: sk8rdude461 on April 06, 2015, 04:04:43 PM ---
--- Quote from: beale on April 06, 2015, 10:37:30 AM ---
--- Quote from: sk8rdude461 on April 06, 2015, 01:08:15 AM ---You need to post more of the related code. Those 3 lines do not dictate much at all.

Just like runescape sucks said:

--- Quote from: runescape sucks on April 05, 2015, 06:05:13 PM ---For future reference, please don't put code tags inside spoiler tags.

Please post the entire method that makes this prayer work.

--- End quote ---

--- End quote ---

--- Code: --- public void applyDamage(int i) {
if(npcs[i] != null) {
if(Server.playerHandler.players[npcs[i].oldIndex] == null) {
return;
}
if (npcs[i].isDead)
return;
Client c = (Client) Server.playerHandler.players[npcs[i].oldIndex];
if (multiAttacks(i)) {
multiAttackDamage(i);
return;
}
if (c.playerIndex <= 0 && c.npcIndex <= 0)
if (c.autoRet == 1)
c.npcIndex = i;
if(c.attackTimer <= 3 || c.attackTimer == 0 && c.npcIndex == 0 && c.oldNpcIndex == 0) {
c.startAnimation(c.getCombat().getBlockEmote());
}
if(c.respawnTimer <= 0) {
int damage = 0;
if(npcs[i].attackType == 0) {
damage = Misc.random(npcs[i].maxHit);
if (10 + Misc.random(c.getCombat().calculateMeleeDefence()) > Misc.random(Server.npcHandler.npcs[i].attack)) {
damage = 0;
}
if(c.prayerActive[18] || c.curseActive[9]) { // protect from melee
damage = (int)damage / 10;
}
if (c.prayerActive[16] || c.curseActive[7] && npcs[i].npcType == 6032) {
damage = (int)damage / 2;
}
if(c.SolProtect >= 1) { // protect from melee
damage = (int)damage / 2;
}
if (c.playerEquipment[c.playerShield] == 13740) {
damage = (int)damage * 70 / 100;
}
if (c.playerEquipment[c.playerShield] == 13742) {
if(Misc.random(4) == 3) {
damage = (int)damage * 65 / 100;
}
}
if (c.playerLevel[3] - damage < 0) {
damage = c.playerLevel[3];
}
}

if(npcs[i].attackType == 1) { // range
damage = Misc.random(npcs[i].maxHit);
if (10 + Misc.random(c.getCombat().calculateRangeDefence()) > Misc.random(Server.npcHandler.npcs[i].attack)) {
damage = 0;
}
if(c.prayerActive[17] || c.curseActive[8]) { // protect from range
damage = (int)damage / 10;
}
if(c.SolProtect >= 1) { // protect from melee
damage = (int)damage / 2;
}
if (c.playerEquipment[c.playerShield] == 13740) {
damage = (int)damage * 70 / 100;
}
if (c.playerEquipment[c.playerShield] == 13742) {
if(Misc.random(4) == 3) {
damage = (int)damage * 65 / 100;
}
}
if (c.playerLevel[3] - damage < 0) {
damage = c.playerLevel[3];
}
}
--- End code ---
That is the whole method.

--- End quote ---
Please stop using spoiler tags for code. That is not the intention of them. Use code tags... Hence their name.

That also is not the entire method. You missed at least 3 end curly braces. And the part you are missing is the part we needed to see, actually. You've got the code for attackType 0 (Melee) and attackType 1 (Range). It's missing magic.

--- End quote ---

--- Code: --- if(npcs[i].attackType == 2) { // magic
damage = Misc.random(npcs[i].maxHit);
boolean magicFailed = false;
if (10 + Misc.random(c.getCombat().mageDef()) > Misc.random(Server.npcHandler.npcs[i].attack)) {
damage = 0;
magicFailed = true;
}
if(c.prayerActive[16] || c.curseActive[7]) { // protect from magic
damage = 0;
magicFailed = true;
}
if(c.SolProtect >= 1) { // protect from melee
damage = (int)damage / 2;
}
if (c.playerEquipment[c.playerShield] == 13740) {
damage = (int)damage * 70 / 100;
}
if (c.playerEquipment[c.playerShield] == 13742) {
if(Misc.random(4) == 3) {
damage = (int)damage * 65 / 100;
}
}
if (c.playerLevel[3] - damage < 0) {
damage = c.playerLevel[3];
}
if (damage == 0 && !isRFDNpc2(i)) {
c.gfx100(85);
}
if(npcs[i].endGfx > 0 && (!magicFailed || isFightCaveNpc(i))) {
c.gfx100(npcs[i].endGfx);
} else {
//c.gfx100(85);
}
}

if (npcs[i].attackType == 3) { //fire breath
int anti = c.getPA().antiFire();
if (anti == 0) {
damage = Misc.random(30) + 10;
c.sendMessage("You are badly burnt by the dragon fire!");
c.getCombat().addCharge(c);
} else if (anti == 1)
damage = Misc.random(12);

else if (anti == 2)
damage = Misc.random(6);

if (c.playerLevel[3] - damage < 0)
damage = c.playerLevel[3];
//c.gfx100(npcs[i].endGfx);
}
handleSpecialEffects(c, i, damage);
if (c.vengOn && damage > 0) {
c.getCombat().appendVengeanceNPC(i, damage);
}
c.logoutDelay = System.currentTimeMillis(); // logout delay
//c.setHitDiff(damage);
c.handleHitMask(damage);
c.playerLevel[3] -= damage;
c.getPA().refreshSkill(3);
c.updateRequired = true;
//c.setHitUpdateRequired(true);
}
}
}
--- End code ---
sorry there are the last two parts i was missing before

sk8rdude461:

.... In the code you just gave me, it literally sets the damage to 0 if the person is using protection prayers...


--- Code: Java ---                                        if(c.prayerActive[16] || c.curseActive[7]) { // protect from magic                                                damage = 0;                                                magicFailed = true;                                        }                                              
Consider setting that to damage / 2 ?

beale:


--- Quote from: sk8rdude461 on April 06, 2015, 05:13:53 PM ---.... In the code you just gave me, it literally sets the damage to 0 if the person is using protection prayers...


--- Code: Java ---                                        if(c.prayerActive[16] || c.curseActive[7]) { // protect from magic                                                damage = 0;                                                magicFailed = true;                                        }                                              
Consider setting that to damage / 2 ?

--- End quote ---
Nope, that didnt work  :confused:

sk8rdude461:

Make sure you set the npcs max hit and attack in the npc-spawn or whatever you use..

Also, add some code to debug.
Put something like:

--- Code: ---System.out.println("Damage: " + damage);
--- End code ---
After each of the if statements that modify the damage.. See where it's getting set to 0.

beale:

Is there any way I could just make it so that the players can't pray in a certain area? Because it is only happening for this custom NPC that i added.

Pages: <<< (3/3)

Go to full version