UnitedScape
July 17th, 2010, 22:51
You can’t operate it when you’re not in combat (to prevent null-pointers), you can’t operate it when it’s not charged, you need to w8 2 minutes till you can use the special again.
This includes perfect emotes/gfx/ and hits, so you need to have Graham’s eventmanager to complete the tut without any errors.
Warning: to be 100% sure that you don't mess up, take a backup of your server first
And now I’ll start the tut in the correct format.
Purpose: Adding a fully working DFS special o a 508 server
Difficulty: 3/10 you just need to copy/paste and have the ability to read
Tested On: Palidino76’s 508 server (but highly edited by me), with a little bit of Java knowledge you should be able to use it with any other source
Step one:
Open Player.java and declare these variables:
/**
*DFS special
*/
public boolean isDoingDfsSpecial = false;
public int dfsCharges = 0;
public boolean canPerformDfsSpecial = true;
public int secondsTillNextDfsSpecial = 0;
Close and save Player.java
Step two:
Open PlayerCombat.java
Find this:
if (p.combatDelay > 0) {
return;
}
Change it to this:
if (p.isDoingDfsSpecial) {
return;
}
if (p.combatDelay > 0) {
return;
}
Close and save PlayerCombat.java
Step three:
Open ItemOperate.java
Add this import with your other imports:
import Palidino76.rs2.Players.combat.*;
Now under
public class ItemOperate implements Packet {
Add this:
DfsSpecial DfsSpecial = new DfsSpecial();
Under
switch (itemId) {
Add this:
case 11284:
if (p.attackingNPC || p.attackingPlayer) {
p.frames.sendMessage(p, "Your Dragonfire Shield is not charged.");
} else {
p.frames.sendMessage(p, "You need to be in combat to operate this item.");
}
break;
case 11283:
if (p.attackingNPC) {
p.isDoingDfsSpecial = true;
DfsSpecial.dfsSpecialAttackNPC(p);
} else if (p.attackingPlayer) {
p.isDoingDfsSpecial = true;
DfsSpecial.dfsSpecialAttackPlayer(p);
} else {
p.frames.sendMessage(p, "You need to be in combat to operate this item.");
}
break;
Save and close ItemOperate.java
Step four:
Open NPCPlayerCombat.java
Add this import with your other imports:
import Palidino76.rs2.Players.combat.*;
Under
public class NPCPlayerCombat {
Add:
DfsSpecial DfsSpecial = new DfsSpecial();
Under
if (Misc.getDistance(p.absX, p.absY, n.absX, n.absY) <= 1) {
Add:
Code:
if (n.npcType == 841) {
n.requestGFX(1, 100);
p.appendHit(maxHit, 0);
if (p.equipment[5] == 11283 || p.equipment[5] == 11284) {
DfsSpecial.absorbFireBreath(p);
}
}
Save and close NPCPlayerCombat.java
Step five:
Now create a new java file called DfsSpecial.java in players/combat folder
And paste this in it:
/*
* Class DfsSpecial
*
* Version 1.0
*
* Saterday, 7 January 2009
*
*/
package Palidino76.rs2.players.combat;
import Palidino76.rs2.players.Player;
import Palidino76.rs2.*;
import Palidino76.rs2.npcs.*;
import Palidino76.rs2.util.*;
public class DfsSpecial {
public void absorbFireBreath(Player p) {
if (p.dfsCharges == 0) {
p.equipment[5] = 11283;
p.frames.setItems(p, 387, 28, 94, p.equipment, p.equipmentN);
p.updateReq = p.appearanceUpdateReq = true;
}
if (p.dfsCharges != 50) {
p.dfsCharges++;
p.requestAnim(6695, 0);
p.requestGFX(1164, 0);
updateBonuses(p);
} else {
p.frames.sendMessage(p, "You can't absorb more fire breath because your Dragonfire shield is fully charged.");
}
}
public void updateBonuses(Player p) {
if (p.dfsCharges != 50) {
p.frames.sendMessage(p, "You absord the fire breath and charge your Dragonfire shield.");
for (int i = 5; i < 10; i++) {
p.equipmentBonus[i] += 1;
}
}
}
public void dfsSpecialAttackPlayer(final Player p) {
final Player p2 = Engine.players[p.attackPlayer];
final int offsetX = (p.absX - p2.absX) * -1;
final int offsetY = (p.absY - p2.absY) * -1;
if (p.canPerformDfsSpecial) {
if (p.dfsCharges == 0) {
p.frames.sendMessage(p, "Your Dragonfire Shield is not charged.");
p.equipment[5] = 11284;
p.frames.setItems(p, 387, 28, 94, p.equipment, p.equipmentN);
p.updateReq = p.appearanceUpdateReq = true;
p.isDoingDfsSpecial = false;
} else {
p.dfsCharges--;
p.combatDelay = 6;
p.isDoingDfsSpecial = false;
p.canPerformDfsSpecial = false;
p.requestAnim(6696, 0);
p.requestGFX(1165, 0);
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.frames.createGlobalProjectile(p.absY, p.absX, offsetY, offsetX, 1166, 43, 31, 70, p2.playerId);
c.stop(); // stops the event from running
}
}, 950); // in ms (1 second = 1000 ms)
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p2.appendHit(Misc.random(25), 0);
c.stop(); // stops the event from running
}
}, 1300); // in ms (1 second = 1000 ms)
p.secondsTillNextDfsSpecial = 120;
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.secondsTillNextDfsSpecial--;
if (p.secondsTillNextDfsSpecial == 0) {
p.canPerformDfsSpecial = true;
c.stop(); // stops the event from running
}
}
}, 1000); // in ms (1 second = 1000 ms)
}
} else {
p.isDoingDfsSpecial = false;
p.frames.sendMessage(p, "You need to wait " + p.secondsTillNextDfsSpecial + " seconds till you can perform another special attack");
}
}
public void dfsSpecialAttackNPC(final Player p) {
final NPC n = Engine.npcs[p.attackNPC];
final int offsetX = (p.absX - n.absX) * -1;
final int offsetY = (p.absY - n.absY) * -1;
if (p.canPerformDfsSpecial) {
if (p.dfsCharges == 0) {
p.frames.sendMessage(p, "Your Dragonfire Shield is not charged.");
p.equipment[5] = 11284;
p.frames.setItems(p, 387, 28, 94, p.equipment, p.equipmentN);
p.updateReq = p.appearanceUpdateReq = true;
p.isDoingDfsSpecial = false;
} else {
p.combatDelay = 6;
p.isDoingDfsSpecial = false;
p.canPerformDfsSpecial = false;
p.requestAnim(6696, 0);
p.requestGFX(1165, 0);
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.frames.createGlobalProjectile(p.absY, p.absX, offsetY, offsetX, 1166, 43, 31, 70, n.npcId);
c.stop(); // stops the event from running
}
}, 950); // in ms (1 second = 1000 ms)
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
n.appendHit(Misc.random(25), 0);
c.stop(); // stops the event from running
}
}, 1300); // in ms (1 second = 1000 ms)
p.secondsTillNextDfsSpecial = 120;
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.secondsTillNextDfsSpecial--;
if (p.secondsTillNextDfsSpecial == 0) {
p.canPerformDfsSpecial = true;
c.stop(); // stops the event from running
}
}
}, 1000); // in ms (1 second = 1000 ms)
}
} else {
p.isDoingDfsSpecial = false;
p.frames.sendMessage(p, "You need to wait " + p.secondsTillNextDfsSpecial + " seconds till you can perform another special attack");
}
}
}
Step six:
Compile and run your server, have fun.
End of tutorial
Some notes:
There's no anti-leech, and it normally compile perfectly.
Fight to green dragons (id = 941) to charge your dfs.
if you don’t want to wait 2 minutes till you can do the special attack again, then just find 120 in DfsSpecial.java and lower it to another number in seconds 60 = 1 minute.
Credits To me
This includes perfect emotes/gfx/ and hits, so you need to have Graham’s eventmanager to complete the tut without any errors.
Warning: to be 100% sure that you don't mess up, take a backup of your server first
And now I’ll start the tut in the correct format.
Purpose: Adding a fully working DFS special o a 508 server
Difficulty: 3/10 you just need to copy/paste and have the ability to read
Tested On: Palidino76’s 508 server (but highly edited by me), with a little bit of Java knowledge you should be able to use it with any other source
Step one:
Open Player.java and declare these variables:
/**
*DFS special
*/
public boolean isDoingDfsSpecial = false;
public int dfsCharges = 0;
public boolean canPerformDfsSpecial = true;
public int secondsTillNextDfsSpecial = 0;
Close and save Player.java
Step two:
Open PlayerCombat.java
Find this:
if (p.combatDelay > 0) {
return;
}
Change it to this:
if (p.isDoingDfsSpecial) {
return;
}
if (p.combatDelay > 0) {
return;
}
Close and save PlayerCombat.java
Step three:
Open ItemOperate.java
Add this import with your other imports:
import Palidino76.rs2.Players.combat.*;
Now under
public class ItemOperate implements Packet {
Add this:
DfsSpecial DfsSpecial = new DfsSpecial();
Under
switch (itemId) {
Add this:
case 11284:
if (p.attackingNPC || p.attackingPlayer) {
p.frames.sendMessage(p, "Your Dragonfire Shield is not charged.");
} else {
p.frames.sendMessage(p, "You need to be in combat to operate this item.");
}
break;
case 11283:
if (p.attackingNPC) {
p.isDoingDfsSpecial = true;
DfsSpecial.dfsSpecialAttackNPC(p);
} else if (p.attackingPlayer) {
p.isDoingDfsSpecial = true;
DfsSpecial.dfsSpecialAttackPlayer(p);
} else {
p.frames.sendMessage(p, "You need to be in combat to operate this item.");
}
break;
Save and close ItemOperate.java
Step four:
Open NPCPlayerCombat.java
Add this import with your other imports:
import Palidino76.rs2.Players.combat.*;
Under
public class NPCPlayerCombat {
Add:
DfsSpecial DfsSpecial = new DfsSpecial();
Under
if (Misc.getDistance(p.absX, p.absY, n.absX, n.absY) <= 1) {
Add:
Code:
if (n.npcType == 841) {
n.requestGFX(1, 100);
p.appendHit(maxHit, 0);
if (p.equipment[5] == 11283 || p.equipment[5] == 11284) {
DfsSpecial.absorbFireBreath(p);
}
}
Save and close NPCPlayerCombat.java
Step five:
Now create a new java file called DfsSpecial.java in players/combat folder
And paste this in it:
/*
* Class DfsSpecial
*
* Version 1.0
*
* Saterday, 7 January 2009
*
*/
package Palidino76.rs2.players.combat;
import Palidino76.rs2.players.Player;
import Palidino76.rs2.*;
import Palidino76.rs2.npcs.*;
import Palidino76.rs2.util.*;
public class DfsSpecial {
public void absorbFireBreath(Player p) {
if (p.dfsCharges == 0) {
p.equipment[5] = 11283;
p.frames.setItems(p, 387, 28, 94, p.equipment, p.equipmentN);
p.updateReq = p.appearanceUpdateReq = true;
}
if (p.dfsCharges != 50) {
p.dfsCharges++;
p.requestAnim(6695, 0);
p.requestGFX(1164, 0);
updateBonuses(p);
} else {
p.frames.sendMessage(p, "You can't absorb more fire breath because your Dragonfire shield is fully charged.");
}
}
public void updateBonuses(Player p) {
if (p.dfsCharges != 50) {
p.frames.sendMessage(p, "You absord the fire breath and charge your Dragonfire shield.");
for (int i = 5; i < 10; i++) {
p.equipmentBonus[i] += 1;
}
}
}
public void dfsSpecialAttackPlayer(final Player p) {
final Player p2 = Engine.players[p.attackPlayer];
final int offsetX = (p.absX - p2.absX) * -1;
final int offsetY = (p.absY - p2.absY) * -1;
if (p.canPerformDfsSpecial) {
if (p.dfsCharges == 0) {
p.frames.sendMessage(p, "Your Dragonfire Shield is not charged.");
p.equipment[5] = 11284;
p.frames.setItems(p, 387, 28, 94, p.equipment, p.equipmentN);
p.updateReq = p.appearanceUpdateReq = true;
p.isDoingDfsSpecial = false;
} else {
p.dfsCharges--;
p.combatDelay = 6;
p.isDoingDfsSpecial = false;
p.canPerformDfsSpecial = false;
p.requestAnim(6696, 0);
p.requestGFX(1165, 0);
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.frames.createGlobalProjectile(p.absY, p.absX, offsetY, offsetX, 1166, 43, 31, 70, p2.playerId);
c.stop(); // stops the event from running
}
}, 950); // in ms (1 second = 1000 ms)
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p2.appendHit(Misc.random(25), 0);
c.stop(); // stops the event from running
}
}, 1300); // in ms (1 second = 1000 ms)
p.secondsTillNextDfsSpecial = 120;
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.secondsTillNextDfsSpecial--;
if (p.secondsTillNextDfsSpecial == 0) {
p.canPerformDfsSpecial = true;
c.stop(); // stops the event from running
}
}
}, 1000); // in ms (1 second = 1000 ms)
}
} else {
p.isDoingDfsSpecial = false;
p.frames.sendMessage(p, "You need to wait " + p.secondsTillNextDfsSpecial + " seconds till you can perform another special attack");
}
}
public void dfsSpecialAttackNPC(final Player p) {
final NPC n = Engine.npcs[p.attackNPC];
final int offsetX = (p.absX - n.absX) * -1;
final int offsetY = (p.absY - n.absY) * -1;
if (p.canPerformDfsSpecial) {
if (p.dfsCharges == 0) {
p.frames.sendMessage(p, "Your Dragonfire Shield is not charged.");
p.equipment[5] = 11284;
p.frames.setItems(p, 387, 28, 94, p.equipment, p.equipmentN);
p.updateReq = p.appearanceUpdateReq = true;
p.isDoingDfsSpecial = false;
} else {
p.combatDelay = 6;
p.isDoingDfsSpecial = false;
p.canPerformDfsSpecial = false;
p.requestAnim(6696, 0);
p.requestGFX(1165, 0);
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.frames.createGlobalProjectile(p.absY, p.absX, offsetY, offsetX, 1166, 43, 31, 70, n.npcId);
c.stop(); // stops the event from running
}
}, 950); // in ms (1 second = 1000 ms)
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
n.appendHit(Misc.random(25), 0);
c.stop(); // stops the event from running
}
}, 1300); // in ms (1 second = 1000 ms)
p.secondsTillNextDfsSpecial = 120;
EventManager.getSingleton().addEvent( new Event() {
public void execute(EventContainer c) {
p.secondsTillNextDfsSpecial--;
if (p.secondsTillNextDfsSpecial == 0) {
p.canPerformDfsSpecial = true;
c.stop(); // stops the event from running
}
}
}, 1000); // in ms (1 second = 1000 ms)
}
} else {
p.isDoingDfsSpecial = false;
p.frames.sendMessage(p, "You need to wait " + p.secondsTillNextDfsSpecial + " seconds till you can perform another special attack");
}
}
}
Step six:
Compile and run your server, have fun.
End of tutorial
Some notes:
There's no anti-leech, and it normally compile perfectly.
Fight to green dragons (id = 941) to charge your dfs.
if you don’t want to wait 2 minutes till you can do the special attack again, then just find 120 in DfsSpecial.java and lower it to another number in seconds 60 = 1 minute.
Credits To me