[Help] Modifying how PvP Works
So I've been trying to mess with my getNearestPvPChar method to change it from being able to only attack one character at a time to
everyone within range. So far, all my attempts have ended up in failure. Think anyone can lead me to the right direction?
For anyone who wants to see my getNearestPvPChar method~
PHP Code:
public Collection<MapleCharacter> getNearestPvPChar(Point attacker, double maxRange, double maxHeight, Collection<MapleCharacter> chr) {
Collection<MapleCharacter> character = new LinkedList<MapleCharacter>();
for (MapleCharacter a : characters) {
if (chr.contains(a.getClient().getPlayer())) {
Point attackedPlayer = a.getPosition();
MaplePortal Port = a.getMap().findClosestSpawnpoint(a.getPosition());
Point nearestPort = Port.getPosition();
double safeDis = attackedPlayer.distance(nearestPort);
double distanceX = attacker.distance(attackedPlayer.getX(), attackedPlayer.getY());
if (MaplePvP.isLeft) {
if (attacker.x > attackedPlayer.x && distanceX < maxRange && distanceX > 2 && attackedPlayer.y >= attacker.y - maxHeight && attackedPlayer.y <= attacker.y + maxHeight && safeDis > 2) {
character.add(a);
}
}
if (MaplePvP.isRight) {
if (attacker.x < attackedPlayer.x && distanceX < maxRange && distanceX > 2 && attackedPlayer.y >= attacker.y - maxHeight && attackedPlayer.y <= attacker.y + maxHeight && safeDis > 2) {
character.add(a);
}
}
}
}
return character;
}
Re: [Help] Modifying how PvP Works
Re: [Help] Modifying how PvP Works
Quote:
Originally Posted by
Nmb1Gamer
So I've been trying to mess with my getNearestPvPChar method to change it from being able to only attack one character at a time to
everyone within range.
Few ways that you could do this
- Just add a break after you've added the character into the list since you only want one. (Basically just a "break;" after "character.add(a);")
- Another method is to modify the function to return only one character
PHP Code:
public MapleCharacter getNearestPvPChar(Point attacker, double maxRange, double maxHeight, Collection<MapleCharacter> chr) {
for (MapleCharacter a : characters) {
if (chr.contains(a.getClient().getPlayer())) {
Point attackedPlayer = a.getPosition();
MaplePortal Port = a.getMap().findClosestSpawnpoint(a.getPosition());
Point nearestPort = Port.getPosition();
double safeDis = attackedPlayer.distance(nearestPort);
double distanceX = attacker.distance(attackedPlayer.getX(), attackedPlayer.getY());
if (MaplePvP.isLeft) {
if (attacker.x > attackedPlayer.x && distanceX < maxRange && distanceX > 2 && attackedPlayer.y >= attacker.y - maxHeight && attackedPlayer.y <= attacker.y + maxHeight && safeDis > 2) {
return a;
}
}
if (MaplePvP.isRight) {
if (attacker.x < attackedPlayer.x && distanceX < maxRange && distanceX > 2 && attackedPlayer.y >= attacker.y - maxHeight && attackedPlayer.y <= attacker.y + maxHeight && safeDis > 2) {
return a;
}
}
}
}
return null; // remember to add a null check just incase if the range does not have any players
}
Re: [Help] Modifying how PvP Works
Quote:
Originally Posted by
AuroX
Few ways that you could do this
- Just add a break after you've added the character into the list since you only want one. (Basically just a "break;" after "character.add(a);")
- Another method is to modify the function to return only one character
PHP Code:
public MapleCharacter getNearestPvPChar(Point attacker, double maxRange, double maxHeight, Collection<MapleCharacter> chr) {
for (MapleCharacter a : characters) {
if (chr.contains(a.getClient().getPlayer())) {
Point attackedPlayer = a.getPosition();
MaplePortal Port = a.getMap().findClosestSpawnpoint(a.getPosition());
Point nearestPort = Port.getPosition();
double safeDis = attackedPlayer.distance(nearestPort);
double distanceX = attacker.distance(attackedPlayer.getX(), attackedPlayer.getY());
if (MaplePvP.isLeft) {
if (attacker.x > attackedPlayer.x && distanceX < maxRange && distanceX > 2 && attackedPlayer.y >= attacker.y - maxHeight && attackedPlayer.y <= attacker.y + maxHeight && safeDis > 2) {
return a;
}
}
if (MaplePvP.isRight) {
if (attacker.x < attackedPlayer.x && distanceX < maxRange && distanceX > 2 && attackedPlayer.y >= attacker.y - maxHeight && attackedPlayer.y <= attacker.y + maxHeight && safeDis > 2) {
return a;
}
}
}
}
return null; // remember to add a null check just incase if the range does not have any players
}
I think you misunderstood me. I'm trying to change it to allow you to attack as many players that are in range as possible, kinda like with mobs. It already only allows me to attack one player at a time.
Re: [Help] Modifying how PvP Works
Go to pvp java
PHP Code:
private static void DamageBalancer(AbstractDealDamageHandler.AttackInfo attack) {
scroll down and change the
maxDis = 130;
maxHeight = 45;
add skills under
PHP Code:
private static boolean isRangeAttack(AbstractDealDamageHandler.AttackInfo attack) {
or whatever