From 4039c0123b903bda726e4b6938a707e570b6450f Mon Sep 17 00:00:00 2001 From: Oven Bread Date: Sat, 1 Feb 2025 13:12:58 +0000 Subject: [PATCH] Correctly limited quest log and achievement diary scrolling --- .../asgarnia/taverley/quest/WolfWhistle.java | 2 ++ .../kandarin/quest/templeofikov/TempleOfIkov.kt | 5 +++-- .../digsite/quest/thedigsite/TheDigSite.kt | 2 ++ .../varrock/quest/allfiredup/AllFiredUp.kt | 6 ++++-- .../CreatureOfFenkenstrain.kt | 2 ++ .../player/link/diary/AchievementDiary.java | 7 +++---- .../game/node/entity/player/link/quest/Quest.java | 15 ++++++++++++++- 7 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Server/src/main/content/region/asgarnia/taverley/quest/WolfWhistle.java b/Server/src/main/content/region/asgarnia/taverley/quest/WolfWhistle.java index 04b8a788f..cb1c137e2 100644 --- a/Server/src/main/content/region/asgarnia/taverley/quest/WolfWhistle.java +++ b/Server/src/main/content/region/asgarnia/taverley/quest/WolfWhistle.java @@ -37,6 +37,7 @@ public class WolfWhistle extends Quest { if(stage == 0){ line(player, "I can begin this quest by talking to !!Pikkupstix??, who lives in", line++, false); line(player, "!!Taverly??.", line++, false); + limitScrolling(player, line, true); } else { if (stage >= 10) { line(player, "Having spoken to !!Pikkupstix??, it seems that all I have to do", line++, stage >= 20); @@ -146,6 +147,7 @@ public class WolfWhistle extends Quest { line(player, "275 gold charms", line++); line(player, "and 276 Summoning XP", line++); } + limitScrolling(player, line, false); } } diff --git a/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkov.kt b/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkov.kt index 0edb793e8..632710b24 100644 --- a/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkov.kt +++ b/Server/src/main/content/region/kandarin/quest/templeofikov/TempleOfIkov.kt @@ -1,8 +1,8 @@ package content.region.kandarin.quest.templeofikov import core.api.* -import core.game.node.entity.player.link.quest.Quest import core.game.node.entity.player.Player +import core.game.node.entity.player.link.quest.Quest import core.game.node.entity.skill.Skills import core.plugin.Initializable import org.rs09.consts.Items @@ -59,6 +59,7 @@ class TempleOfIkov : Quest("Temple of Ikov", 121, 120, 1,26, 0, 1, 80 /* 80 or 9 line(player, "Level 42 !!Thieving??", line++, hasLevelStat(player, Skills.THIEVING, 42)) line(player, "Level 40 !!Ranged??", line++, hasLevelStat(player, Skills.RANGE, 40)) line(player, "Ability to defeat a level 84 enemy with Ranged.", line++, false) + limitScrolling(player, line, true) } else { if (stage >= 2) { line(player, "Lucien has asked me to retrieve the !!Staff of Armadyl?? from", line++, true) @@ -165,8 +166,8 @@ class TempleOfIkov : Quest("Temple of Ikov", 121, 120, 1,26, 0, 1, 80 /* 80 or 9 line++ line(player,"QUEST COMPLETE!", line) } + limitScrolling(player, line, false) } - } override fun reset(player: Player) { diff --git a/Server/src/main/content/region/misthalin/digsite/quest/thedigsite/TheDigSite.kt b/Server/src/main/content/region/misthalin/digsite/quest/thedigsite/TheDigSite.kt index 8e15ec769..be91947b9 100644 --- a/Server/src/main/content/region/misthalin/digsite/quest/thedigsite/TheDigSite.kt +++ b/Server/src/main/content/region/misthalin/digsite/quest/thedigsite/TheDigSite.kt @@ -93,6 +93,7 @@ class TheDigSite : Quest("The Dig Site", 47, 46, 2, 131, 0, 1, 9) { line(player, "Level 10 Agility", line++, hasLevelStat(player, Skills.AGILITY, 10)) line(player, "Level 10 Herblore", line++, hasLevelStat(player, Skills.HERBLORE, 10)) line(player, "Level 25 Thieving", line++, hasLevelStat(player, Skills.THIEVING, 25)) + limitScrolling(player, line, true) } else { line(player, "I should speak to an examiner about taking Earth Science", line++, true) line(player, "Exams.", line++, true) @@ -362,6 +363,7 @@ class TheDigSite : Quest("The Dig Site", 47, 46, 2, 131, 0, 1, 9) { line++ line(player,"QUEST COMPLETE!", line) } + limitScrolling(player, line, false) } } diff --git a/Server/src/main/content/region/misthalin/varrock/quest/allfiredup/AllFiredUp.kt b/Server/src/main/content/region/misthalin/varrock/quest/allfiredup/AllFiredUp.kt index b97a4fd07..f3e992ffc 100644 --- a/Server/src/main/content/region/misthalin/varrock/quest/allfiredup/AllFiredUp.kt +++ b/Server/src/main/content/region/misthalin/varrock/quest/allfiredup/AllFiredUp.kt @@ -1,13 +1,13 @@ package content.region.misthalin.varrock.quest.allfiredup +import content.minigame.allfiredup.AFUBeacon +import core.api.setVarbit import core.game.node.entity.player.Player import core.game.node.entity.player.link.quest.Quest import core.game.node.entity.skill.Skills import core.game.node.item.Item import core.plugin.Initializable import org.rs09.consts.Items -import content.minigame.allfiredup.AFUBeacon -import core.api.* /** * Represents the "All Fired Up" quest. @@ -30,6 +30,7 @@ class AllFiredUp : Quest("All Fired Up", 157, 156, 1){ line(player, "To start this quest, I require:", line++) line(player, "!!43 Firemaking??", line++, player.skills.getLevel(Skills.FIREMAKING) >= 43) line(player, "!!Completion of Priest in Peril??", line++, player.questRepository.isComplete("Priest in Peril")) + limitScrolling(player, line, true) } else { line(player, "I have agreed to help King Roald test the beacon network", line++, true) line(player, "that he hopes will serve as an early warning system,", line++, true) @@ -133,6 +134,7 @@ class AllFiredUp : Quest("All Fired Up", 157, 156, 1){ line++ line(player,"QUEST COMPLETE!", line) } + limitScrolling(player, line, false) } } diff --git a/Server/src/main/content/region/morytania/quest/creatureoffenkenstrain/CreatureOfFenkenstrain.kt b/Server/src/main/content/region/morytania/quest/creatureoffenkenstrain/CreatureOfFenkenstrain.kt index 4b35fb36b..0959d87e6 100644 --- a/Server/src/main/content/region/morytania/quest/creatureoffenkenstrain/CreatureOfFenkenstrain.kt +++ b/Server/src/main/content/region/morytania/quest/creatureoffenkenstrain/CreatureOfFenkenstrain.kt @@ -58,6 +58,7 @@ class CreatureOfFenkenstrain : Quest("Creature of Fenkenstrain", 41, 40, 2, 399, line(player, "I also need to have completed the following quests:", line++, false) line(player, "Priest in Peril", line++, isQuestComplete(player, "Priest in Peril")) line(player, "Restless Ghost", line++, isQuestComplete(player, "The Restless Ghost")) + limitScrolling(player, line, true) } else { line(player, "I read the signpost in Canifis, which tells of a butler", line++, true) line(player, "position that is available at the castle to the northeast.", line++, true) @@ -123,6 +124,7 @@ class CreatureOfFenkenstrain : Quest("Creature of Fenkenstrain", 41, 40, 2, 399, line++ line(player,"QUEST COMPLETE!", line) } + limitScrolling(player, line, false) } } diff --git a/Server/src/main/core/game/node/entity/player/link/diary/AchievementDiary.java b/Server/src/main/core/game/node/entity/player/link/diary/AchievementDiary.java index 81b80bd7b..ddcdddeaf 100644 --- a/Server/src/main/core/game/node/entity/player/link/diary/AchievementDiary.java +++ b/Server/src/main/core/game/node/entity/player/link/diary/AchievementDiary.java @@ -114,13 +114,12 @@ public class AchievementDiary { } child++; } - // sendString(player, builder.toString(), 11); - //Changes the size of the scroll bar - //player.getPacketDispatch().sendRunScript(1207, "i", new Object[] { 330 }); - //sendString(player, builder.toString(), 11); if (!player.getInterfaceManager().isOpened()) { player.getInterfaceManager().open(new Component(DIARY_COMPONENT)); } + // Changes the size of the scroll bar (see 1207.cs2 for more) + // (args1: 1 is to start from top of scroll) (args0: child-12 lines to display) + player.getPacketDispatch().sendRunScript(1207, "ii", 1, child - 10); } /** diff --git a/Server/src/main/core/game/node/entity/player/link/quest/Quest.java b/Server/src/main/core/game/node/entity/player/link/quest/Quest.java index 8b50bdac2..b4fab393c 100644 --- a/Server/src/main/core/game/node/entity/player/link/quest/Quest.java +++ b/Server/src/main/core/game/node/entity/player/link/quest/Quest.java @@ -1,6 +1,5 @@ package core.game.node.entity.player.link.quest; -import core.game.component.CloseEvent; import core.game.component.Component; import core.game.node.entity.player.Player; import core.plugin.Plugin; @@ -215,6 +214,20 @@ public abstract class Quest implements Plugin { player.getPacketDispatch().sendString(crossed ? "" + send + "" : send, JOURNAL_COMPONENT, line); } + /** + * Limits the quest log scroll to the number of lines minus 9. + * Assumes that you start at line = 11 or line = 12. + * Call this function at the end of the drawJournal function like: limitScroll(player, line); + * @param player The player. + * @param line The number of lines to scroll. Due to sendRunScript, it handles less than 12 lines pretty well. + * @param startFromTop Whether to open the log at the top, defaults to opening the log at the very bottom. + */ + public void limitScrolling(Player player, int line, boolean startFromTop) { + // sendRunScript reverses the objects you pass in + // (args1: 0 is to start from bottom of scroll) (args0: child-12 lines to display) + player.getPacketDispatch().sendRunScript(1207, "ii", startFromTop ? 1 : 0, line - 9); // -9 to give text some padding instead of line - 11 or 12 + } + /** * Draws text on the quest reward component. * @param player The player.