Junior Spellweaver
- Joined
- Aug 12, 2006
- Messages
- 115
- Reaction score
- 2
BEFORE YOU ATTEMPT TO TRY THIS OUT , PLEASE MAKE A BACKUP!!!
Add this to Player.java
Add this under process:
add under process:
Make a new class called PlayerAttack.java and add this in there(into players folder)
Add these to PlayerInstances:
It only does unarmed attack and godsword attacks
add this at the top of handlepacket:
add this in GameEngine:
Heres the packet
Replace case 75 with this:
THIS TUTORIAL HAS BEEN MADE BY AlexMason FROM RUNE-SERVER . ALL CREDITS TO AlexMason.
Add this to Player.java
Code:
public void applyDead()
{
if(deathDelay == 8)
{
if(faceToRequest != 65535)
{
requestFaceTo(65535);
}
requestAnim(836, 0);
}
if(deathDelay <= 1)
{
frame.sendMessage(this, "Oh dear you are dead!");
isDead = false;
attackPlayer = 0;
attackingPlayer = false;
teleportToX = 3200;
teleportToY = 3200;
for(int i = 0; i < skillLvl.length; i++)
{
skillLvl[i] = getLevelForXP(i);
frame.sendSkillLvl(this, i);
}
subtractDamage(999999);
requestAnim(-1, 0);
}
}
Code:
if(isDead && deathDelay >= 0)
{
deathDelay--;
applyDead();
}
if(attackingPlayer == true)
{
PlayerAttack pl = new PlayerAttack(this);
pl.attackPlayer();
//pl = null;
}
Code:
if (combatDelay > 0) {
combatDelay--;
}
Make a new class called PlayerAttack.java and add this in there(into players folder)
Code:
package RS2E.Players;
import RS2E.*;
public class PlayerAttack
{
public PlayerAttack(Player _p)
{
p = _p;
}
public void attackPlayer()
{
if(p == null || p.disconnected[0] || p.isDead)
{
return;
}
if(p.faceToRequest != (p.attackPlayer + 32768))
{
p.requestFaceTo(p.attackPlayer + 32768);
}
int wepId = p.equipment[3];
Player plr = GameEngine.players[p.attackPlayer];
int hitDiff = random(getMeleePower());
if(p.combatDelay <= 0) {
if(GameEngine.getDistance(plr.absX, plr.absY, p.absX, p.absY) != 1)
{
return;
}
p.requestAnim(getItemAttack(wepId), 0);
plr.killedBy[p.playerId] += hitDiff;
plr.appendHit(hitDiff, 0);
p.attackPlayer = plr.playerId;
p.attackingPlayer = true;
if (plr.attackRetaliate)
{
if(plr.faceToRequest != (plr.attackPlayer + 32768))
{
plr.requestFaceTo(plr.attackPlayer + 32768);
}
plr.attackPlayer = p.playerId;
plr.attackingPlayer = true;
}
p.combatDelay = getCombatDelay(wepId);
if(p.skillLvl[3] <= 0)
{
p.isDead = true;
p.deathDelay = 5;
if(plr.faceToRequest != 65535)
{
plr.requestFaceTo(65535);
}
}
}
}
public int getMeleePower()
{
if(p == null)
{
return 1;
}
double maxHit = 1.06 + (p.equipmentBonus[10] * p.skillLvl[2]) * 0.00178;
if(fullDharokEquipped())
{
maxHit += (p.getLevelForXP(3) - p.skillLvl[3]) / 2;
}
return (int)(maxHit += p.skillLvl[2] * 0.16);
}
public void resetAttack()
{
if(p == null)
{
return;
}
p.attackingPlayer = false;
p.attackPlayer = 0;
}
public int getItemAttack(int ID)
{
String weapon = GameEngine.item.getItemName(ID);
if (weapon.equalsIgnoreCase("Unarmed"))
{
return 422;
}
if (weapon.endsWith(" godsword")) {
return 7041;
}
return 422;
}
public int getCombatDelay(int ID)
{
String weapon = GameEngine.item.getItemName(ID);
if (weapon.equalsIgnoreCase("Unarmed"))
{
return 5;
}
if (weapon.endsWith(" godsword")) {
return 7;
}
return 5;
}
private int random(int range)
{
return (int)(Math.random() * (range + 1));
}
public boolean fullDharokEquipped()
{
if(p == null)
{
return false;
}
return (p.equipment[0] == 4716 && p.equipment[4] == 4720 && p.equipment[7] == 4722 && p.equipment[3] == 4718);
}
private Player p;
}
Code:
public boolean attackingPlayer = false;
public boolean attackRetaliate = true;
public int attackPlayer = 0;
public int combatDelay = 0;
add this at the top of handlepacket:
Code:
import RS2E.Players.PlayerAttack;
Code:
public static int getDistance(int coordX1, int coordY1, int coordX2, int coordY2)
{
int deltaX = coordX2 - coordX1;
int deltaY = coordY2 - coordY1;
return ((int)Math.sqrt(Math.pow(deltaX, 2) + Math.pow(deltaY, 2)));
}
Heres the packet
Code:
case 255: // Attack Player.
if(p == null) {
return;
}
p.attackPlayer = p.inStream.readUnsignedWordBigEndianA();
PlayerAttack pl = new PlayerAttack(p);
pl.attackPlayer();
p.attackingPlayer = true;
pl = null;
break;
Replace case 75 with this:
Code:
case 75: //Other click walk.
Walk walk = new Walk(p, packetId, packetSize);
walk = null;
p.attackingPlayer = false;
p.attackPlayer = 0;
break;
THIS TUTORIAL HAS BEEN MADE BY AlexMason FROM RUNE-SERVER . ALL CREDITS TO AlexMason.