Tutorial: Adding poison for pvp.
Description: WIll add poison obviously....PvP only.
Base: Devolution/Delta ( may need to convert to your server )
Release history: Since 317 Reborn died, I decided to release it.
Note!: This is only for melee, although making it for both magic and ranging is very simple.
Code:
Step 1:
Open up your player class and add these Integers and Booleans:
Code:
public int
poisonDelay = -1,//This calculates the time to show the poison damage
minusPoison = 0,//When this reaches 0, the damage will decrease by 1
poisonDamage = 0;//How strong the poison is.
public boolean
poisonHit = false,
poisonHit2 = false;//Identifies the poison hit for appendHitUpdates
.
Now still in your player class, search for appendHitUpdate,
below you should see this:
Code:
Code:
if ((hitDiff > 0) && (newhptype == false)) {
str.writeByteA(1); // 0: red hitting - 1: blue hitting
} else if ((hitDiff > 0) && (newhptype == true)) {
str.writeByteA(hptype); // 0: red hitting - 1: blue hitting
} else {
str.writeByteA(0); // 0: red hitting - 1: blue hitting
}
Change that to this:
Code:
Code:
if (!poisonHit) {
if ((hitDiff > 0) && (newhptype == false)) {
str.writeByteA(1); // 0: red hitting - 1: blue hitting
} else if ((hitDiff > 0) && (newhptype == true)) {
str.writeByteA(hptype); // 0: red hitting - 1: blue hitting
} else {
str.writeByteA(0); // 0: red hitting - 1: blue hitting
}
} else {
str.writeByteA(2);//poison hitting
}
And below that you should see:
Code:
Code:
if(currentHealth < 0) {
Add these under it:
Code:
poisonDelay = -1;
poisonDamage = 0;
Now search for the second appendHitUpdate and do the same thing.
Step2:
Close and save that class and open your client.java.
Search for loadGame and add these:
Code:
Code:
else if (token.equals("poisonDelay")) {
poisonDelay = Integer.parseInt(token2);
if (poisonDelay > 300) {
poisonDelay = -1;
}
} else if (token.equals("poisonDamage")) {
poisonDamage = Integer.parseInt(token2);
}
Now search for playerMeleeDamage and add:
Code:
Code:
if(AttackingOn2.poisonDamage == 0 && AttackingOn2.poisonDelay == -1) {
poisonDamage(playerEquipment[playerWeapon], AttackingOn2);
}
Declare this:
Code:
Code:
public void poisonDamage(int weapon, client plr) {
if(plr == null) {//if your enemy is a null, it will not poison
return;
}
if(misc.random(100) <= 30) {
if(plr.poisonDelay != -1) {//if your enemy's poisondelay is above -1, it will not poison
return;
}
switch(weapon) {
case 5698:// dds p++
plr.sendMessage("You have been poisoned!");
plr.poisonDamage = 6;
plr.poisonDelay = 240;
plr.minusPoison = 3;
/*This make the weapon poisonous*/
break;
}
}
}
Now in your process or for devolution 2.7 users, playerProcess, paste this in:
Code:
Code:
if (poisonDelay > -1) {//This is what brings down the hit delay of the poison
poisonDelay--;
if (poisonDelay == 0 && poisonDamage > 0) {
poisonDelay = 30 + misc.random(20);//delay of hit is 30 plus an adding of a random number between 0 and 20
if (hitUpdateRequired) {//hit updates
poisonHit2 =
hitUpdateRequired2 =
updateRequired = true;
hitDiff2 = poisonDamage;
currentHealth -= hitDiff2;
minusPoison--;
} else {
hitUpdateRequired =
updateRequired =
poisonHit = true;
hitDiff = poisonDamage;
currentHealth -= hitDiff;
minusPoison--;
}
if(minusPoison == 0) {//Once minusPoison is 0, damage drops by 1
poisonDamage--;
minusPoison = 3;
}
if (poisonDamage < 1) {//once the damage is below 1, your poison will disappear
sendMessage("Your poison wears off..");
poisonDelay = -1;
}
}
}
While in your process, search for deathStage == 3 and add this:
Code:
Code:
poisonDelay = -1;
poisonDamage = 0;
minusPoison = 0;//Resets poisoning when you die
Last but not least, find saveGame and add this:
Code:
Code:
characterfile.newLine();
characterfile.write("poisonDelay = ", 0, 14);
characterfile.write(Integer.toString(poisonDelay), 0, Integer.toString(poisonDelay).length());
characterfile.newLine();
characterfile.write("poisonDamage = ", 0, 15);
characterfile.write(Integer.toString(poisonDamage), 0, Integer.toString(poisonDamage).length());
This may not be a great tutorial, although atleast it helps the majority of the people.
Credits:
-Palidino - base for poison (BS 317)
-Me - adjusting and editing
-Pimpscape - appendHitUpdates