Skip to content

Commit

Permalink
Add gnome agility courses (#572)
Browse files Browse the repository at this point in the history
* Rename emote to renderEmote

* Add basic gnome stronghold agility course

* Add advanced gnome course

* Add gnome trainers

* Add integration tests

* Handle logout during obstacles
  • Loading branch information
GregHib authored Dec 29, 2024
1 parent 5ae1b8f commit 56bcaa6
Show file tree
Hide file tree
Showing 15 changed files with 626 additions and 6 deletions.
7 changes: 7 additions & 0 deletions data/definitions/animations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1801,3 +1801,10 @@ gudrun_hugging: 14733
restless_ghost_ascends: 4018
restless_ghost_awakens: 4019
restless_ghost_warlock_spawn: 1552
climb_through_pipe: 10580
gnome_wall_run: 2922
gnome_run_up: 11784
gnome_jump: 11785
gnome_swing: 11789
gnome_jump_barrier: 2923
gnome_pipe_land: 2924
6 changes: 6 additions & 0 deletions data/definitions/npcs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2347,3 +2347,9 @@ suit_of_armour:
weapon_style: sword
race: human
examine: "A dusty old suit of armour."
gnome_trainer:
id: 162
race: gnome
large_head: true
wander_radius: 4
examine: "He can advise on training."
41 changes: 40 additions & 1 deletion data/definitions/objects.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11888,4 +11888,43 @@ coffin_restless_ghost_2:
examine: "Ooooh! Spooky!"
railing_wizards_tower:
id: 37668
examine: "A sturdy metal railing."
examine: "A sturdy metal railing."
gnome_log_balance:
id: 2295
examine: "A slippery log I can walk across."
gnome_obstacle_net:
id: 2285
examine: "This must be climbed over."
gnome_tree_branch_up:
id: 35970
examine: "I can climb up this."
gnome_tree_branch_down:
id: 2314
examine: "I can climb down this."
gnome_balancing_rope:
id: 2312
examine: "I can balance on this rope."
gnome_balancing_rope_end:
id: 4059
examine: "I can balance on this rope."
gnome_obstacle_net_free_standing:
id: 2286
examine: "This must be climbed over."
gnome_obstacle_pipe_east:
id: 43543
examine: "A pipe I can squeeze through."
gnome_obstacle_pipe_west:
id: 43544
examine: "A pipe I can squeeze through."
gnome_tree_branch_advanced:
id: 43528
examine: "I can climb up this."
gnome_sign_post_advanced:
id: 43581
examine: "It doesn't look finished, but the material is tough enough to grip hold of."
gnome_pole_advanced:
id: 43529
examine: "A long metal pole."
gnome_barrier_advanced:
id: 43539
examine: "It might be possible to vault over it."
3 changes: 2 additions & 1 deletion data/definitions/render-emotes.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
human_stand: 1426
dororan_stand: 1880
dororan_stand: 1880
rope_balance: 155
12 changes: 12 additions & 0 deletions data/definitions/variables-custom.yml
Original file line number Diff line number Diff line change
Expand Up @@ -475,5 +475,17 @@ equip_crossbow:
persist: true
format: boolean
flagstaff_runefest:
persist: true
format: boolean
gnome_course_stage:
persist: true
format: int
gnome_course_laps:
persist: true
format: int
gnome_course_advanced_laps:
persist: true
format: int
gnome_course_reward_claimed:
persist: true
format: boolean
12 changes: 12 additions & 0 deletions data/spawns/npc-spawns.yml
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,18 @@
- { id: butterfly_1, x: 2437, y: 3425, members: true }
- { id: butterfly_1, x: 2438, y: 3422, members: true }
- { id: butterfly_1, x: 2450, y: 3419, members: true }
- { id: gnome_trainer, x: 2469, y: 3423, members: true }
- { id: gnome_trainer, x: 2469, y: 3434, members: true }
- { id: gnome_trainer, x: 2470, y: 3426, members: true }
- { id: gnome_trainer, x: 2477, y: 3426, members: true }
- { id: gnome_trainer, x: 2479, y: 3427, members: true }
- { id: gnome_trainer, x: 2482, y: 3422, members: true }
- { id: gnome_trainer, x: 2489, y: 3423, members: true }
- { id: gnome_trainer, x: 2489, y: 3427, members: true }
- { id: gnome_trainer, x: 2490, y: 3435, members: true }
- { id: gnome_trainer, x: 2475, y: 3422, level: 1, members: true }
- { id: gnome_trainer, x: 2475, y: 3421, level: 2, members: true }
- { id: gnome_trainer, x: 2474, y: 3419, level: 3, members: true }
# 9782
- { id: butterfly_5, x: 2448, y: 3469, members: true }
- { id: butterfly_5, x: 2447, y: 3467, members: true }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ interface TargetStrategy {
is Tile -> TileTargetStrategy(entity)
is GameObject -> when (entity.id) {
"archery_target" -> TileTargetStrategy(entity.tile.addX(5))
"gnome_obstacle_pipe_east", "gnome_obstacle_pipe_west" -> TileTargetStrategy(entity.tile.addY(-1))
"lumbridge_church_bell" -> TileTargetStrategy(entity.tile.addY(-1))
else -> ObjectTargetStrategy(entity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@ var Player.headIcon: Int
headIcon = value
}

var Player.emote: String
var Player.renderEmote: String
get() = get<RenderEmoteDefinitions>().get(appearance.emote).stringId
set(value) = flag {
appearance.emote = get<RenderEmoteDefinitions>().get(value).id
emote = get<RenderEmoteDefinitions>().get(value).id
}

fun Player.clearRenderEmote() = flag {
emote = 1426
}

var Player.name: String
get() = this["display_name", accountName]
set(value) = flag {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package world.gregs.voidps.world.activity.skill.agility.course

import world.gregs.voidps.engine.client.message
import world.gregs.voidps.engine.client.variable.start
import world.gregs.voidps.engine.entity.character.clearAnimation
import world.gregs.voidps.engine.entity.character.exactMove
import world.gregs.voidps.engine.entity.character.face
import world.gregs.voidps.engine.entity.character.move.tele
import world.gregs.voidps.engine.entity.character.npc.NPCs
import world.gregs.voidps.engine.entity.character.player.chat.ChatType
import world.gregs.voidps.engine.entity.character.player.skill.Skill
import world.gregs.voidps.engine.entity.character.player.skill.exp.exp
import world.gregs.voidps.engine.entity.character.player.skill.level.Level.has
import world.gregs.voidps.engine.entity.character.setAnimation
import world.gregs.voidps.engine.entity.obj.objectApproach
import world.gregs.voidps.engine.entity.obj.objectOperate
import world.gregs.voidps.engine.inject
import world.gregs.voidps.engine.queue.strongQueue
import world.gregs.voidps.engine.suspend.approachRange
import world.gregs.voidps.engine.suspend.delay
import world.gregs.voidps.engine.suspend.pause
import world.gregs.voidps.type.Direction
import world.gregs.voidps.type.Tile
import world.gregs.voidps.type.Zone

val npcs: NPCs by inject()

objectOperate("Climb-up", "gnome_tree_branch_advanced") {
if (!player.has(Skill.Agility, 85)) {
return@objectOperate
}
npcs.gnomeTrainer("Terrorbirds could climb faster than that!", Zone(9263413))
player.message("You climb the tree...", ChatType.Filter)
player.setAnimation("climb_up")
player.start("input_delay", 2)
player.strongQueue("branch", 2) {
player.message("... to an even higher platform.", ChatType.Filter)
player.gnomeStage(4)
player.tele(player.tile.add(y = -1, level = 1))
player.exp(Skill.Agility, 25.0)
}
}

objectApproach("Run-across", "gnome_sign_post_advanced") {
npcs.gnomeTrainer("Come on! I'd be over there by now.", Zone(13457717))
player.approachRange(1)
// Pausing for 2 ticks to ensure we're in the correct spot.
// arriveDelay() wouldn't work as objectApproach is called before Movement.tick where "last_movement" is set
pause(2)
player.face(Direction.EAST)
player.setAnimation("gnome_wall_run")
player.start("input_delay", 4)
player.strongQueue("wall-run", 1) {
player.exactMove(Tile(2484, 3418, 3), 60, Direction.EAST)
pause(2)
player.gnomeStage(5)
player.exp(Skill.Agility, 25.0)
player.clearAnimation()
}
}

objectApproach("Swing-to", "gnome_pole_advanced") {
var tile = player.tile
if (player.tile.x == 2484) {
tile = Tile(2485, 3418, 3)
}
player.steps.clear()
player.face(Direction.NORTH)
player.start("input_delay", 14)
player.strongQueue("run-up", 1) {
onCancel = {
player.tele(Tile(2486, 3418, 3))
}
player.setAnimation("gnome_run_up")
player.exactMove(tile.copy(y = 3421), 60, Direction.NORTH)
pause(2)
player.setAnimation("gnome_jump")
player.exactMove(tile.copy(y = 3425), 30, Direction.NORTH)
pause(1)
player.setAnimation("gnome_swing")
pause(4)
player.exactMove(tile.copy(y = 3429), 30, Direction.NORTH)
pause(5)
player.exactMove(tile.copy(y = 3432), 30, Direction.NORTH)
delay(2)
player.gnomeStage(6)
player.exp(Skill.Agility, 25.0)
}
}

objectOperate("Jump-over", "gnome_barrier_advanced") {
player.setAnimation("gnome_jump_barrier")
player.start("input_delay", 4)
player.strongQueue("branch", 1) {
player.exactMove(Tile(2485, 3434, 3), 30, Direction.NORTH)
pause(2)
player.tele(2485, 3436, 0)
player.setAnimation("gnome_pipe_land")
if (player.gnomeStage == 6) {
player.gnomeStage = 0
player.inc("gnome_course_advanced_laps")
player.exp(Skill.Agility, 605.0)
}
player.exp(Skill.Agility, 25.0)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package world.gregs.voidps.world.activity.skill.agility.course

import world.gregs.voidps.engine.entity.character.forceChat
import world.gregs.voidps.engine.entity.character.npc.NPCs
import world.gregs.voidps.engine.entity.character.player.Player
import world.gregs.voidps.type.Zone
import world.gregs.voidps.type.random

internal fun Player.gnomeStage(stage: Int) {
if (stage == gnomeStage + 1) {
gnomeStage = stage
}
}

internal var Player.gnomeStage: Int
get() = this["gnome_course_stage", 0]
set(value) {
this["gnome_course_stage"] = value
}

internal fun NPCs.gnomeTrainer(message: String, zone: Zone) {
val trainer = get(zone).randomOrNull(random) ?: return
trainer.forceChat = message
}

internal fun NPCs.gnomeTrainer(message: String, zones: List<Zone>) {
for (zone in zones) {
val trainer = get(zone).randomOrNull(random) ?: continue
trainer.forceChat = message
break
}
}
Loading

0 comments on commit 56bcaa6

Please sign in to comment.