From 417db14d5cc56522d04d6f3234e090e9d091e48c Mon Sep 17 00:00:00 2001 From: zsrv Date: Sun, 9 Jul 2023 03:54:31 +0000 Subject: [PATCH] Implemented split combat levels A split combat level (e.g. 50+5) will be displayed for a player when the player is on a PvP world and does not have a summoning pouch or a familiar summoned. A split combat level will also be shown if the player is on a world with wilderness PvP enabled, the player is in the wilderness, and does not have a summoning pouch or a familiar summoned. If the world is a PvP world, display other players' combat levels in white if they are outside of combat range, or shades of green/yellow/orange/red if they are within combat range. If the world is not a PvP world, always display other players' combat levels in shades of green/yellow/orange/red. --- .../skill/summoning/familiar/Familiar.java | 4 +-- .../summoning/familiar/FamiliarManager.java | 4 +-- .../container/impl/InventoryListener.java | 2 +- .../game/node/entity/impl/Properties.java | 10 +++++-- .../game/world/update/flag/PlayerFlags530.kt | 26 ++++++++++++++++--- 5 files changed, 33 insertions(+), 13 deletions(-) diff --git a/Server/src/main/content/global/skill/summoning/familiar/Familiar.java b/Server/src/main/content/global/skill/summoning/familiar/Familiar.java index bdf989ef1..4a20aed33 100644 --- a/Server/src/main/content/global/skill/summoning/familiar/Familiar.java +++ b/Server/src/main/content/global/skill/summoning/familiar/Familiar.java @@ -607,9 +607,7 @@ public abstract class Familiar extends NPC implements Plugin { setVarp(owner, 1176, 0); setVarp(owner, 1175, 182986); setVarp(owner, 1174, -1); - if (owner.getSkullManager().isWilderness()) { - owner.getAppearance().sync(); - } + owner.getAppearance().sync(); owner.getInterfaceManager().setViewedTab(3); } diff --git a/Server/src/main/content/global/skill/summoning/familiar/FamiliarManager.java b/Server/src/main/content/global/skill/summoning/familiar/FamiliarManager.java index 56903511b..c33c8c697 100644 --- a/Server/src/main/content/global/skill/summoning/familiar/FamiliarManager.java +++ b/Server/src/main/content/global/skill/summoning/familiar/FamiliarManager.java @@ -178,9 +178,7 @@ public final class FamiliarManager { } else { familiar.refreshTimer(); } - if (player.getSkullManager().isWilderness()) { - player.getAppearance().sync(); - } + player.getAppearance().sync(); } /** diff --git a/Server/src/main/core/game/container/impl/InventoryListener.java b/Server/src/main/core/game/container/impl/InventoryListener.java index 33ffa5b19..4ef874f4a 100644 --- a/Server/src/main/core/game/container/impl/InventoryListener.java +++ b/Server/src/main/core/game/container/impl/InventoryListener.java @@ -45,7 +45,7 @@ public final class InventoryListener implements ContainerListener { } } player.getFamiliarManager().setHasPouch(pouch); - if (hadPouch != pouch && player.getSkullManager().isWilderness()) { + if (hadPouch != pouch) { player.getAppearance().sync(); } } diff --git a/Server/src/main/core/game/node/entity/impl/Properties.java b/Server/src/main/core/game/node/entity/impl/Properties.java index ab6044614..9c002f1ac 100644 --- a/Server/src/main/core/game/node/entity/impl/Properties.java +++ b/Server/src/main/core/game/node/entity/impl/Properties.java @@ -10,7 +10,9 @@ import core.game.node.entity.combat.equipment.WeaponInterface; import core.game.node.entity.npc.NPC; import core.game.node.entity.player.Player; import core.game.node.item.Item; +import core.game.world.GameWorld; import core.game.world.map.Location; +import core.game.world.update.flag.EntityFlag; import core.game.world.update.flag.context.Animation; import core.game.world.update.flag.context.Graphics; import core.game.node.entity.combat.CombatPulse; @@ -231,8 +233,12 @@ public final class Properties { public int getCurrentCombatLevel() { if (entity instanceof Player) { Player player = (Player) entity; - if (player.getFamiliarManager().isUsingSummoning() || !player.getSkullManager().isWilderness()) { - return player.getFamiliarManager().getSummoningCombatLevel() + combatLevel; + if ((GameWorld.getSettings().isPvp() || (GameWorld.getSettings().getWild_pvp_enabled() && player.getSkullManager().isWilderness())) + && !player.getFamiliarManager().isUsingSummoning()) { + //TODO: Split combat levels should also be used for Bounty Hunter + return combatLevel; + } else { + return combatLevel + player.getFamiliarManager().getSummoningCombatLevel(); } } return combatLevel; diff --git a/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt b/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt index 49717e333..bcc1e3356 100644 --- a/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt +++ b/Server/src/main/core/game/world/update/flag/PlayerFlags530.kt @@ -9,6 +9,7 @@ import core.game.node.entity.impl.ForceMovement import core.game.node.entity.player.Player import core.tools.* import core.api.* +import core.game.world.GameWorld import java.nio.charset.StandardCharsets import kotlin.reflect.* @@ -74,7 +75,7 @@ sealed class PlayerFlags530 (p: Int, o: Int, f: EntityFlag) : EFlagProvider (530 val appearance = context.appearance appearance.prepareBodyData(context) var settings = appearance.gender.toByte().toInt() - val nonPvp = context.skullManager.isWilderness && context.skullManager.isWildernessDisabled + val nonPvp = context.skullManager.isWilderness && context.skullManager.isWildernessDisabled //nonPvp is always false if (context.size() > 1) settings += (context.size() - 1) shl 3 if (nonPvp) @@ -107,9 +108,26 @@ sealed class PlayerFlags530 (p: Int, o: Int, f: EntityFlag) : EFlagProvider (530 buffer.p1 (context.properties.currentCombatLevel) //with summoning buffer.p2 (context.skills.getTotalLevel()) } else { - buffer.p1 (context.properties.currentCombatLevel) //without summoning - buffer.p1 (context.properties.combatLevel) //with summoning - buffer.p1 (context.skullManager.level) //combat range + //client-side code determines how the combat level will be displayed, based on + //the combat level values that are sent + if ((GameWorld.settings!!.isPvp || (GameWorld.settings!!.wild_pvp_enabled && context.skullManager.isWilderness)) + && !context.familiarManager.isUsingSummoning) { + //client will display separate base and summoning combat levels (e.g. "50+5") + //TODO: Split combat levels should also be used for Bounty Hunter + buffer.p1 (context.properties.combatLevel) //without summoning + buffer.p1 (context.properties.combatLevel + context.familiarManager.summoningCombatLevel) //with summoning + } else { + //client will display a combined combat level (e.g. "55") + buffer.p1 (context.properties.currentCombatLevel) //with summoning + buffer.p1 (context.properties.currentCombatLevel) //with summoning + } + if (GameWorld.settings!!.isPvp) { + //displays a player's combat level in white if the player is not within combat range + buffer.p1 (context.skullManager.level) //combat range + } else { + //disables the client code that makes combat levels white + buffer.p1 (-1) //combat range + } } buffer.p1 (0) //this is the sound radius, and if set, 4 shorts need to be set as well which include the sound IDs //to play to everyone in that radius when the player is rendered onscreen for the first time.