Skip to content

Commit

Permalink
Add quest intro/overview dialogue interface (#557)
Browse files Browse the repository at this point in the history
* Add quest intro interface

* Refactor quest definitions

* Dump rs3 quest data

* Add missing quests

* Add quest start interface dialogue option

* Add unit tests
  • Loading branch information
GregHib authored Nov 26, 2024
1 parent e390164 commit be51145
Show file tree
Hide file tree
Showing 15 changed files with 4,261 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,20 @@ import world.gregs.voidps.cache.definition.Extra

data class QuestDefinition(
override var id: Int = -1,
var aString2211: String? = null,
var aString2202: String? = null,
var anIntArrayArray2208: Array<IntArray>? = null,
var anIntArrayArray2193: Array<IntArray>? = null,
var anIntArray2209: IntArray? = null,
var anIntArray2207: IntArray? = null,
var anIntArrayArray2210: Array<IntArray>? = null,
var anInt2188: Int = -1,
var anIntArray2200: IntArray? = null,
var anIntArray2191: IntArray? = null,
var anIntArray2199: IntArray? = null,
var aStringArray2201: Array<String?>? = null,
var anIntArray2204: IntArray? = null,
var anIntArray2195: IntArray? = null,
var anIntArray2190: IntArray? = null,
var aStringArray2198: Array<String?>? = null,
var name: String? = null,
var listName: String? = null,
var varps: Array<IntArray>? = null,
var varbits: Array<IntArray>? = null,
var subQuest: Int = -1,
var difficulty: Int = -1,
var members: Boolean = false,
var questPoints: Int = -1,
var pathStart: IntArray? = null,
var otherPathStart: Int = -1,
var questRequirements: IntArray? = null,
var skillRequirements: Array<IntArray>? = null,
var questPointRequirement: Int = 0,
var itemSprite: Int = -1,
override var stringId: String = "",
override var extras: Map<String, Any>? = null,
) : Definition, Extra {
Expand All @@ -31,61 +29,29 @@ data class QuestDefinition(
other as QuestDefinition

if (id != other.id) return false
if (aString2211 != other.aString2211) return false
if (aString2202 != other.aString2202) return false
if (anIntArrayArray2208 != null) {
if (other.anIntArrayArray2208 == null) return false
if (!anIntArrayArray2208.contentDeepEquals(other.anIntArrayArray2208)) return false
} else if (other.anIntArrayArray2208 != null) return false
if (anIntArrayArray2193 != null) {
if (other.anIntArrayArray2193 == null) return false
if (!anIntArrayArray2193.contentDeepEquals(other.anIntArrayArray2193)) return false
} else if (other.anIntArrayArray2193 != null) return false
if (anIntArray2209 != null) {
if (other.anIntArray2209 == null) return false
if (!anIntArray2209.contentEquals(other.anIntArray2209)) return false
} else if (other.anIntArray2209 != null) return false
if (anIntArray2207 != null) {
if (other.anIntArray2207 == null) return false
if (!anIntArray2207.contentEquals(other.anIntArray2207)) return false
} else if (other.anIntArray2207 != null) return false
if (anIntArrayArray2210 != null) {
if (other.anIntArrayArray2210 == null) return false
if (!anIntArrayArray2210.contentDeepEquals(other.anIntArrayArray2210)) return false
} else if (other.anIntArrayArray2210 != null) return false
if (anInt2188 != other.anInt2188) return false
if (anIntArray2200 != null) {
if (other.anIntArray2200 == null) return false
if (!anIntArray2200.contentEquals(other.anIntArray2200)) return false
} else if (other.anIntArray2200 != null) return false
if (anIntArray2191 != null) {
if (other.anIntArray2191 == null) return false
if (!anIntArray2191.contentEquals(other.anIntArray2191)) return false
} else if (other.anIntArray2191 != null) return false
if (anIntArray2199 != null) {
if (other.anIntArray2199 == null) return false
if (!anIntArray2199.contentEquals(other.anIntArray2199)) return false
} else if (other.anIntArray2199 != null) return false
if (aStringArray2201 != null) {
if (other.aStringArray2201 == null) return false
if (!aStringArray2201.contentEquals(other.aStringArray2201)) return false
} else if (other.aStringArray2201 != null) return false
if (anIntArray2204 != null) {
if (other.anIntArray2204 == null) return false
if (!anIntArray2204.contentEquals(other.anIntArray2204)) return false
} else if (other.anIntArray2204 != null) return false
if (anIntArray2195 != null) {
if (other.anIntArray2195 == null) return false
if (!anIntArray2195.contentEquals(other.anIntArray2195)) return false
} else if (other.anIntArray2195 != null) return false
if (anIntArray2190 != null) {
if (other.anIntArray2190 == null) return false
if (!anIntArray2190.contentEquals(other.anIntArray2190)) return false
} else if (other.anIntArray2190 != null) return false
if (aStringArray2198 != null) {
if (other.aStringArray2198 == null) return false
if (!aStringArray2198.contentEquals(other.aStringArray2198)) return false
} else if (other.aStringArray2198 != null) return false
if (name != other.name) return false
if (listName != other.listName) return false
if (varps != null) {
if (other.varps == null) return false
if (!varps.contentDeepEquals(other.varps)) return false
} else if (other.varps != null) return false
if (varbits != null) {
if (other.varbits == null) return false
if (!varbits.contentDeepEquals(other.varbits)) return false
} else if (other.varbits != null) return false
if (pathStart != null) {
if (other.pathStart == null) return false
if (!pathStart.contentEquals(other.pathStart)) return false
} else if (other.pathStart != null) return false
if (questRequirements != null) {
if (other.questRequirements == null) return false
if (!questRequirements.contentEquals(other.questRequirements)) return false
} else if (other.questRequirements != null) return false
if (skillRequirements != null) {
if (other.skillRequirements == null) return false
if (!skillRequirements.contentDeepEquals(other.skillRequirements)) return false
} else if (other.skillRequirements != null) return false
if (itemSprite != other.itemSprite) return false
if (stringId != other.stringId) return false
if (extras != other.extras) return false

Expand All @@ -94,27 +60,24 @@ data class QuestDefinition(

override fun hashCode(): Int {
var result = id
result = 31 * result + (aString2211?.hashCode() ?: 0)
result = 31 * result + (aString2202?.hashCode() ?: 0)
result = 31 * result + (anIntArrayArray2208?.contentDeepHashCode() ?: 0)
result = 31 * result + (anIntArrayArray2193?.contentDeepHashCode() ?: 0)
result = 31 * result + (anIntArray2209?.contentHashCode() ?: 0)
result = 31 * result + (anIntArray2207?.contentHashCode() ?: 0)
result = 31 * result + (anIntArrayArray2210?.contentDeepHashCode() ?: 0)
result = 31 * result + anInt2188
result = 31 * result + (anIntArray2200?.contentHashCode() ?: 0)
result = 31 * result + (anIntArray2191?.contentHashCode() ?: 0)
result = 31 * result + (anIntArray2199?.contentHashCode() ?: 0)
result = 31 * result + (aStringArray2201?.contentHashCode() ?: 0)
result = 31 * result + (anIntArray2204?.contentHashCode() ?: 0)
result = 31 * result + (anIntArray2195?.contentHashCode() ?: 0)
result = 31 * result + (anIntArray2190?.contentHashCode() ?: 0)
result = 31 * result + (aStringArray2198?.contentHashCode() ?: 0)
result = 31 * result + (name?.hashCode() ?: 0)
result = 31 * result + (listName?.hashCode() ?: 0)
result = 31 * result + (varps?.contentDeepHashCode() ?: 0)
result = 31 * result + (varbits?.contentDeepHashCode() ?: 0)
result = 31 * result + (pathStart?.contentHashCode() ?: 0)
result = 31 * result + (questRequirements?.contentHashCode() ?: 0)
result = 31 * result + (skillRequirements?.contentDeepHashCode() ?: 0)
result = 31 * result + itemSprite
result = 31 * result + stringId.hashCode()
result = 31 * result + (extras?.hashCode() ?: 0)
return result
}

override fun toString(): String {
return "QuestDefinition(id=$id, name=$name, listName=$listName, varps=${varps?.contentDeepToString()}, varbits=${varbits?.contentDeepToString()}, subQuest=$subQuest, difficulty=$difficulty, members=$members, questPoints=$questPoints, pathStart=${pathStart?.contentToString()}, otherPathStart=$otherPathStart, questRequirements=${questRequirements?.contentToString()}, skillRequirements=${skillRequirements?.contentDeepToString()}, questPointRequirement=$questPointRequirement, itemSprite=$itemSprite, stringId='$stringId', extras=$extras)"
}


companion object {
val EMPTY = QuestDefinition()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,75 +14,32 @@ class QuestDecoder(

override fun QuestDefinition.read(opcode: Int, buffer: Reader) {
when (opcode) {
1 -> aString2211 = buffer.readPrefixedString()
2 -> aString2202 = buffer.readPrefixedString()
3 -> anIntArrayArray2208 = readArray(buffer)
4 -> anIntArrayArray2193 = readArray(buffer)
5 -> buffer.readShort()
1 -> name = buffer.readPrefixedString()
2 -> listName = buffer.readPrefixedString()
3 -> varps = readArray(buffer)
4 -> varbits = readArray(buffer)
5 -> subQuest = buffer.readShort()
6 -> buffer.readUnsignedByte()
7 -> buffer.readUnsignedByte()
9 -> buffer.readUnsignedByte()
10 -> {
val length = buffer.readUnsignedByte()
anIntArray2209 = IntArray(length) { buffer.readInt() }
}
12 -> buffer.readInt()
13 -> {
val length = buffer.readUnsignedByte()
anIntArray2207 = IntArray(length) { buffer.readShort() }
}
14 -> {
val length = buffer.readUnsignedByte()
anIntArrayArray2210 = Array(length) { IntArray(2) { buffer.readUnsignedByte() } }
}
7 -> difficulty = buffer.readUnsignedByte()
8 -> members = true
9 -> questPoints = buffer.readUnsignedByte()
10 -> pathStart = IntArray(buffer.readUnsignedByte()) { buffer.readInt() }
12 -> otherPathStart = buffer.readInt()
13 -> questRequirements = IntArray(buffer.readUnsignedByte()) { buffer.readShort() }
14 -> skillRequirements = Array(buffer.readUnsignedByte()) { IntArray(2) { buffer.readUnsignedByte() } }
15 -> buffer.readShort()
17 -> anInt2188 = buffer.readShort()
18 -> {
val length = buffer.readUnsignedByte()
aStringArray2201 = arrayOfNulls(length)
anIntArray2200 = IntArray(length)
anIntArray2199 = IntArray(length)
anIntArray2191 = IntArray(length)
for (count in 0 until length) {
anIntArray2200!![count] = buffer.readInt()
anIntArray2191!![count] = buffer.readInt()
anIntArray2199!![count] = buffer.readInt()
aStringArray2201!![count] = buffer.readString()
}
}
19 -> {
val length = buffer.readUnsignedByte()
anIntArray2204 = IntArray(length)
aStringArray2198 = arrayOfNulls(length)
anIntArray2195 = IntArray(length)
anIntArray2190 = IntArray(length)
for (count in 0 until length) {
anIntArray2204!![count] = buffer.readInt()
anIntArray2195!![count] = buffer.readInt()
anIntArray2190!![count] = buffer.readInt()
aStringArray2198!![count] = buffer.readString()
}
}
17 -> itemSprite = buffer.readShort()
249 -> readParameters(buffer, parameters)
}
}

override fun changeValues(definitions: Array<QuestDefinition>, definition: QuestDefinition) {
if (definition.aString2202 == null) {
definition.aString2202 = definition.aString2211
if (definition.listName == null) {
definition.listName = definition.name
}
}

private fun readArray(buffer: Reader) : Array<IntArray> {
val length = buffer.readUnsignedByte()
val array = Array(length) { IntArray(3) }
for (count in 0 until length) {
array[count][0] = buffer.readShort()
array[count][1] = buffer.readInt()
array[count][2] = buffer.readInt()
}
return array
}
private fun readArray(buffer: Reader) = Array(buffer.readUnsignedByte()) { intArrayOf(buffer.readShort(), buffer.readInt(), buffer.readInt()) }

companion object {
private fun Reader.readPrefixedString(): String {
Expand Down
26 changes: 26 additions & 0 deletions data/definitions/interfaces.yml
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,32 @@ music_player:
Cancel: 3
currently_playing: 4
playlist: 9
quest_intro:
id: 178
type: main_screen
components:
start_point_field: 52
req_field: 55
items_field: 59
combat_field: 62
rewards_field: 66
start_choice_layer: 27
progress_status_layer: 28
status_field: 70
quest_field: 14
hidden_button_txt: 30
hide_show_layer: 64
text_details_layer: 65
items_hidden_button_txt: 57
items_hide_show_layer: 56
items_text_details_layer: 58
scroll_layer_rewards: 63
scroll_layer_item: 4
startyes_layer: 73
startno_layer: 74
objective_set: 75
objective_text: 76
quest_icon: 79
dialogue_macro_mime_emotes:
id: 188
type: dialogue_box
Expand Down
10 changes: 5 additions & 5 deletions data/definitions/parameters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ weapon_style: 686
special_attack: 687
spellbook_spell_inv_interface: 688
hand_cannon_warning: 690
quest_param_691: 691
quest_start_npc: 691
quest_param_692: 693
quest_journal_hints: 694
quest_param_695: 695
Expand Down Expand Up @@ -235,10 +235,10 @@ npc_contact_while_guthix_sleeps_text: 941
npc_contact_while_guthix_sleeps_model: 942
npc_contact_while_guthix_sleeps_rotation: 943
npc_contact_while_guthix_sleeps_animation: 944
quest_journal_hint_text: 948
quest_item_requirement_text: 949
quest_level_requirement_text: 950
quest_reward_text_0: 951
quest_start_point_text: 948
quest_required_items_text: 949
quest_combat_text: 950
quest_reward_text: 951
task_quest_sprite: 952
barbarian_assault_reward: 954
barbarian_assault_ticket_wave: 955
Expand Down
Loading

0 comments on commit be51145

Please sign in to comment.