Skip to content

Commit

Permalink
Fixed hotspot teleportation cost calculation
Browse files Browse the repository at this point in the history
Thanks to Yayaya for the tip.
Tests showed that HiPass effects (like from the buff "Administrator's Boon") don't lower the price to 1 Kinah.
  • Loading branch information
neon-dev committed Jun 8, 2024
1 parent c1f6af1 commit cb3cd89
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import java.util.HashMap;
import java.util.Map;

import org.slf4j.LoggerFactory;

import com.aionemu.gameserver.dataholders.DataManager;
import com.aionemu.gameserver.model.Race;
import com.aionemu.gameserver.model.TaskId;
Expand All @@ -11,8 +13,8 @@
import com.aionemu.gameserver.network.aion.serverpackets.SM_BIND_POINT_TELEPORT;
import com.aionemu.gameserver.network.aion.serverpackets.SM_SYSTEM_MESSAGE;
import com.aionemu.gameserver.services.item.ItemPacketService;
import com.aionemu.gameserver.skillengine.model.Effect;
import com.aionemu.gameserver.utils.PacketSendUtility;
import com.aionemu.gameserver.utils.PositionUtil;
import com.aionemu.gameserver.utils.ThreadPoolManager;
import com.aionemu.gameserver.utils.audit.AuditLogger;

Expand Down Expand Up @@ -41,7 +43,7 @@ public static void teleport(Player player, int locId, long kinah) {
PacketSendUtility.sendPacket(player, SM_SYSTEM_MESSAGE.STR_CANNOT_MOVE_TO_AIRPORT_NO_ROUTE());
return;
}
final long price = computePrice(player, hotspot, kinah);
long price = calculateTeleportationPrice(player, hotspot, kinah);

if (!checkRequirements(player, hotspot, price))
return;
Expand Down Expand Up @@ -76,11 +78,17 @@ public static void cancelTeleport(Player player, int locId) {
}
}

private static long computePrice(Player player, HotspotTemplate hotspot, long kinah) {
long price = kinah > hotspot.getPrice() ? kinah : hotspot.getPrice();
if (price < 1 || player.getEffectController().hasAbnormalEffect(Effect::isHiPass))
price = 1;
return price;
private static long calculateTeleportationPrice(Player player, HotspotTemplate hotspot, long priceSentByGameClient) {
double distance = PositionUtil.getDistance(player, hotspot.getX(), hotspot.getY(), hotspot.getZ());
long basePrice = hotspot.getPrice();
long distanceCost = (long) (basePrice * distance / 1000d);
long price = Math.max(1, basePrice + distanceCost);
if (price != priceSentByGameClient) {
LoggerFactory.getLogger(BindPointTeleportService.class).warn("Hotspot teleport {} prices don't match: {} vs. {}", hotspot.getId(), price, priceSentByGameClient);
if (priceSentByGameClient > price)
price = priceSentByGameClient;
}
return price;
}

private static boolean checkRequirements(Player player, HotspotTemplate hotspot, long price) {
Expand Down

0 comments on commit cb3cd89

Please sign in to comment.