Correctly limited quest log and achievement diary scrolling

This commit is contained in:
Oven Bread 2025-02-01 13:12:58 +00:00 committed by Ryan
parent 27f2d457ea
commit 4039c0123b
7 changed files with 30 additions and 9 deletions

View file

@ -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);
}
}

View file

@ -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,"<col=FF0000>QUEST COMPLETE!</col>", line)
}
limitScrolling(player, line, false)
}
}
override fun reset(player: Player) {

View file

@ -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,"<col=FF0000>QUEST COMPLETE!</col>", line)
}
limitScrolling(player, line, false)
}
}

View file

@ -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,"<col=FF0000>QUEST COMPLETE!</col>", line)
}
limitScrolling(player, line, false)
}
}

View file

@ -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,"<col=FF0000>QUEST COMPLETE!</col>", line)
}
limitScrolling(player, line, false)
}
}

View file

@ -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);
}
/**

View file

@ -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<Object> {
player.getPacketDispatch().sendString(crossed ? "<str>" + send + "</str>" : 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.