server tested: devolution 7.0
difficulty: 8/10
purpose: to shorten your special codes.
files modified: player.java, client.java
features: smaller specials, neater, easier to add new weapons, does not over hit, proper placing of gfx, shows special bar for weapons that only have it, properly timed damaged delays.
credits:
20% to delta for his special.java file.
80% to me for writing the tutorial and the scripts.
note: i will not show how it works with your attacking methods, you guys got to experiment, but i will give a small demonstration.
step 1) ADDING METHODS
ok lets go ahead and declare these in client.java
Code:
public void checkWeaponForSpecial()
{
if (playerEquipment[playerWeapon] == 5698)
{
doubleHit = true;
getWeaponSpecialInformation(5698,1062, 25, 252);
}
if (playerEquipment[playerWeapon] == 5680) //dragon dagger p+
{
doubleHit = true;
getWeaponSpecialInformation(5680,1062, 25, 252);
}
if (playerEquipment[playerWeapon] == 1231) //dragon dagger p
{
doubleHit = true;
getWeaponSpecialInformation(1231,1062, 25, 252);
}
if (playerEquipment[playerWeapon] == 1215) //dragon dagger
{
doubleHit = true;
getWeaponSpecialInformation(1215,1062, 25, 252);
}
if (playerEquipment[playerWeapon] == 1305) // dragon long
{
getWeaponSpecialInformation(1305,1058, 25, 248);
}
if (playerEquipment[playerWeapon] == 1434) // dragon mace
{
getWeaponSpecialInformation(1434,1060, 25, 251);
}
}
in our attacking methods you must add checkWeaponForSpecial(); right under specOn or usingSpecial.
its extremely important to make it look like
Code:
if (usingSpecial || specOn)
{
checkWeaponForSpecial();
} else {
//your normal attack part here
}
now we need to add the method that actually tells the server to know what its doing, so we add.
Code:
long lastRegain = 0;
long damageDelay4 = 0;
long rehit = 0;
public boolean reHit = false;
public boolean doubleHit = false;
public void getWeaponSpecialInformation(int weapon, int animation99, int drain, int doGFX)
{
arrowPullBack(doGFX);
weapon = playerEquipment[playerWeapon];
doActionSpecial(animation99);
if (specialAmount >= drain)
{
specialAmount -= drain;
} else {
specOn = false;
sendMessage("You do not have enough special attack to use this.");
ResetAttackNPC();
}
}
now once we add that we can see what each one of these does.
now we add
Code:
public void doActionSpecial(int i) {
startSpecialAnimations(i);
}
public void damageNPC()
{
int EnemyX = server.npcHandler.npcs[attacknpc].absX;
int EnemyY = server.npcHandler.npcs[attacknpc].absY;
int EnemyHP = server.npcHandler.npcs[attacknpc].HP;
int MAXHIT = misc.random(playerMaxHit);
if (MAXHIT > EnemyHP)
{
MAXHIT = EnemyHP;
}
if (EnemyHP < 1 )
{
server.npcHandler.npcs[attacknpc].hitDiff = 0;
}
server.npcHandler.npcs[attacknpc].Killing[playerId] += MAXHIT;
server.npcHandler.npcs[attacknpc].StartKilling = localId;
server.npcHandler.npcs[attacknpc].IsUnderAttack = true;
server.npcHandler.npcs[attacknpc].RandomWalk = false;
server.npcHandler.npcs[attacknpc].hitDiff = MAXHIT;
server.npcHandler.npcs[attacknpc].hit = true;
server.npcHandler.npcs[attacknpc].updateRequired = true;
server.npcHandler.npcs[attacknpc].hitUpdateRequired = true;
addSkillXP(MAXHIT * 200, SkillID);
addSkillXP(MAXHIT * 66, playerHitpoints);
}
this tells the server to start the animation of the special (this will also time the damages)
in the process we add
Code:
if (System.currentTimeMillis() - lastRegain > 120000) {
lastRegain = System.currentTimeMillis();
if (specialAmount >= 100) {
specialAmount += 0;
} else {
specialAmount += 25;
}
}
server.special.loginSpec(this, playerEquipment[playerWeapon]);
if (specialAttack && (System.currentTimeMillis() - lastDamage4 > 0))
{
if(doubleHit){
rehit = System.currentTimeMillis();
doubleHit = true;
}
specialAttack = false;
specOn = false;
specAttack();
damageNPC();
}
if (doubleHit && (System.currentTimeMillis() - rehit > 50)){
doubleHit = false;
damageNPC();
}
now find you login messages like "welcome to blahblah"
and add
Code:
specAttack();
server.special.loginSpec(this, playerEquipment[playerWeapon]);
this tells the server if the weapon is actually a weapon that has a special bar
and it updates the special bar.
now add these
Code:
public void specAttack() {
server.special.specialAttacks(playerId);
server.special.specialAttacks2(playerId);
server.special.specialAttacks3(playerId);
server.special.specialAttacks4(playerId);
server.special.specialAttacks5(playerId);
server.special.specialAttacks6(playerId);
specialAmount = specialAmount;
}
public void removeSpec(int id) {
outStream.createFrame(171);
outStream.writeByte(1);
outStream.writeWord(id);
flushOutStream();
}
now got to case 185: and under switch (actionButtonId) { add these
Code:
case 29113://bows
case 33033://halberds
case 29163://swords
case 29138://dds
case 48023://whip
try {
if (specialAmount < 25) {
specOn = false;
}
if (specOn == true) {
specOn = false;
} else if (specOn == false) {
specOn = true;
}
specAttack();
} catch (Exception popo) {
}
break;
now close client.java and open player.java
add all these
Code:
long lastDamage4 = 0;
public boolean specialAttack = false;
public boolean specOn = false;
public int specialAmount = 100;
public void arrowPullBack(int gfx) {
mask100var1 = gfx;
mask100var2 = 6553600;
mask100update = true;
updateRequired = true;
}
public void startSpecialAnimations(int animIdx)
{
animationRequest = animIdx;
animationWaitCycles = 0;
specialAttack = true;
lastDamage4 = System.currentTimeMillis();
}
now close player.java and open server.java
in server.java add this
Code:
public static special special = null;
then find
Code:
playerHandler = new PlayerHandler();
under that
^
add
Code:
special = new special();
now close that.
download my attachment and add it with the other server files
then compile and it should work, post any errors apart from the 100 error messages, that just means you fail at copy and pasting
other things - adding more weapon for the special attacks, in this method
Code:
public void checkWeaponForSpecial()
{
if (playerEquipment[playerWeapon] == 5698)
{
doubleHit = true;
getWeaponSpecialInformation(5698,1062, 25, 252);
}
}
we add our weapons, example
Code:
if (playerEquipment[playerWeapon] == 5698) //dds
{
doubleHit = true; //if you want it to double hit or not
//(weapon id)(animation)(specamount)(gfx)
getWeaponSpecialInformation(5698,1062, 25, 252);
}
its that simple.