mirror of
https://github.com/2006-Scape/2006Scape.git
synced 2026-12-06 11:17:17 +00:00
- Updated NpcFirstClickEvent to include npcIndex for better handling of NPC interactions. - Enhanced Npc and NpcHandler classes to support new interaction logic and ensure NPCs face players correctly. - Refined packet handling for NPC clicks and button actions to integrate new dialogue and interaction flows.
48 lines
1.8 KiB
Kotlin
48 lines
1.8 KiB
Kotlin
package plugin.area.alkharid
|
|
|
|
import com.rs2.event.EventContext
|
|
import com.rs2.event.EventSubscriber
|
|
import com.rs2.event.SubscribesTo
|
|
import com.rs2.event.impl.NpcFirstClickEvent
|
|
import com.rs2.game.npcs.NpcHandler
|
|
import com.rs2.game.players.Player
|
|
import plugin.area.alkharid.AlKharidGateUtil.BORDER_GUARD_1
|
|
import plugin.area.alkharid.AlKharidGateUtil.BORDER_GUARD_2
|
|
import plugin.area.alkharid.AlKharidGateUtil.hasCompletedPrinceAli
|
|
|
|
@SubscribesTo(NpcFirstClickEvent::class)
|
|
class BorderGuardFirstClick : EventSubscriber<NpcFirstClickEvent> {
|
|
|
|
override fun subscribe(context: EventContext, player: Player, event: NpcFirstClickEvent) {
|
|
val npcId = event.npc
|
|
if (npcId != BORDER_GUARD_1 && npcId != BORDER_GUARD_2) {
|
|
return
|
|
}
|
|
|
|
val guardIndex = if (event.npcIndex > 0) event.npcIndex else player.npcClickIndex
|
|
|
|
val guard = if (guardIndex in 1 until NpcHandler.npcs.size) NpcHandler.npcs[guardIndex] else null
|
|
if (guard != null) {
|
|
val playerOnLumbridgeSide = player.absX <= 3267
|
|
val guardOnLumbridgeSide = guard.absX <= 3267
|
|
if (playerOnLumbridgeSide != guardOnLumbridgeSide) {
|
|
player.packetSender.sendMessage("I can't reach that.")
|
|
player.stopMovement()
|
|
guard.facePlayer(null)
|
|
guard.dirUpdateRequired = false
|
|
guard.updateRequired = false
|
|
return
|
|
}
|
|
guard.facePlayer(player)
|
|
}
|
|
|
|
if (player.hasCompletedPrinceAli()) {
|
|
player.talkingNpc = npcId
|
|
player.dialogueHandler.sendPlayerChat("Can I come through this gate?")
|
|
player.nextChat = 1030 // "You may pass, friend of Al-Kharid."
|
|
} else {
|
|
player.dialogueHandler.sendDialogues(1018, npcId)
|
|
}
|
|
}
|
|
}
|