mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-05 00:38:14 +00:00
Reorganize project sources from src/main to src/main/java
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
import org.apollo.game.action.DistancedAction
|
||||
import org.apollo.game.message.impl.NpcActionMessage
|
||||
import org.apollo.game.message.impl.ObjectActionMessage
|
||||
import org.apollo.game.model.Position
|
||||
import org.apollo.game.model.entity.Npc
|
||||
import org.apollo.game.model.entity.Player
|
||||
import org.apollo.game.model.inter.bank.BankUtils
|
||||
import org.apollo.net.message.Message
|
||||
|
||||
val BANK_BOOTH_ID = 2213
|
||||
|
||||
|
||||
/**
|
||||
* Hook into the [ObjectActionMessage] and listen for when a bank booth's second action ("Open Bank") is selected.
|
||||
*/
|
||||
on { ObjectActionMessage::class }
|
||||
.where { option == 2 && id == BANK_BOOTH_ID }
|
||||
.then { BankAction.start(this, it, position) }
|
||||
|
||||
/**
|
||||
* Hook into the [NpcActionMessage] and listen for when a banker's second action ("Open Bank") is selected.
|
||||
*/
|
||||
on { NpcActionMessage::class }
|
||||
.where { option == 2 }
|
||||
.then {
|
||||
val npc = world.npcRepository[index]
|
||||
|
||||
if (npc.id in BANKER_NPCS) {
|
||||
BankAction.start(this, it, npc.position)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The ids of all banker [Npcs][Npc].
|
||||
*/
|
||||
val BANKER_NPCS = setOf(166, 494, 495, 496, 497, 498, 499, 1036, 1360, 1702, 2163, 2164, 2354, 2355, 2568, 2569, 2570)
|
||||
|
||||
/**
|
||||
* A [DistancedAction] that opens a [Player]'s bank when they get close enough to a booth or banker.
|
||||
*
|
||||
* @property position The [Position] of the booth/[Npc].
|
||||
*/
|
||||
class BankAction(player: Player, position: Position) : DistancedAction<Player>(0, true, player, position, DISTANCE) {
|
||||
|
||||
companion object {
|
||||
|
||||
/**
|
||||
* The distance threshold that must be reached before the bank interface is opened.
|
||||
*/
|
||||
const val DISTANCE = 1
|
||||
|
||||
/**
|
||||
* Starts a [BankAction] for the specified [Player], terminating the [Message] that triggered.
|
||||
*/
|
||||
fun start(message: Message, player: Player, position: Position) {
|
||||
player.startAction(BankAction(player, position))
|
||||
message.terminate()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun executeAction() {
|
||||
mob.turnTo(position)
|
||||
BankUtils.openBank(mob)
|
||||
stop()
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
return other is BankAction && position == other.position
|
||||
}
|
||||
|
||||
override fun hashCode(): Int {
|
||||
return position.hashCode()
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<plugin>
|
||||
<id>bank</id>
|
||||
<version>1</version>
|
||||
<name>Bank</name>
|
||||
<description>Opens the bank interface when players select 'use-quickly' on a bank booth.</description>
|
||||
<authors>
|
||||
<author>Major</author>
|
||||
</authors>
|
||||
<scripts>
|
||||
<script>bank.plugin.kts</script>
|
||||
</scripts>
|
||||
<dependencies />
|
||||
</plugin>
|
||||
@@ -0,0 +1,23 @@
|
||||
import org.apollo.game.message.impl.AddFriendMessage
|
||||
import org.apollo.game.message.impl.SendFriendMessage
|
||||
import org.apollo.game.model.entity.setting.PrivacyState
|
||||
|
||||
on { AddFriendMessage::class }
|
||||
.then { player ->
|
||||
player.addFriend(username)
|
||||
|
||||
val playerUsername = player.username
|
||||
val friend = world.getPlayer(username)
|
||||
|
||||
if (friend == null) {
|
||||
player.send(SendFriendMessage(username, 0))
|
||||
} else if (friend.friendsWith(playerUsername) || friend.friendPrivacy == PrivacyState.ON) {
|
||||
if (player.friendPrivacy != PrivacyState.OFF) {
|
||||
friend.send(SendFriendMessage(playerUsername, player.worldId))
|
||||
}
|
||||
|
||||
if (friend.friendPrivacy != PrivacyState.OFF) {
|
||||
player.send(SendFriendMessage(username, friend.worldId))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import org.apollo.game.message.impl.AddIgnoreMessage
|
||||
import org.apollo.game.message.impl.RemoveIgnoreMessage
|
||||
|
||||
on { AddIgnoreMessage::class }
|
||||
.then { player -> player.addIgnore(username) }
|
||||
|
||||
on { RemoveIgnoreMessage::class }
|
||||
.then { player -> player.removeIgnore(username) }
|
||||
@@ -0,0 +1,15 @@
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.game.model.*
|
||||
import org.apollo.game.model.entity.Npc
|
||||
|
||||
data class Spawn(val id: Int?, val name: String, val position: Position, val facing: Direction,
|
||||
val spawnAnimation: Animation? = null,
|
||||
val spawnGraphic: Graphic? = null)
|
||||
|
||||
object Spawns {
|
||||
val list = mutableListOf<Spawn>()
|
||||
}
|
||||
|
||||
fun npc_spawn(name: String, x: Int, y: Int, id: Int? = null) {
|
||||
Spawns.list.add(Spawn(id, name, Position(x, y), Direction.NORTH))
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import org.apollo.cache.def.NpcDefinition
|
||||
import org.apollo.game.model.entity.Npc
|
||||
|
||||
start {
|
||||
Spawns.list.forEach {
|
||||
val definition = if (it.id != null) NpcDefinition.lookup(it.id) else lookup_npc(it.name)
|
||||
if (definition == null) {
|
||||
throw IllegalArgumentException("Invalid NPC name or ID ${it.name}, ${it.id}")
|
||||
}
|
||||
|
||||
val npc = Npc(world, definition.id, it.position)
|
||||
npc.turnTo(it.position.step(1, it.facing))
|
||||
|
||||
if (it.spawnAnimation != null) {
|
||||
npc.playAnimation(it.spawnAnimation)
|
||||
}
|
||||
|
||||
if (it.spawnGraphic != null) {
|
||||
npc.playGraphic(it.spawnGraphic)
|
||||
}
|
||||
|
||||
world.register(npc)
|
||||
}
|
||||
}
|
||||
|
||||
stop {
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
npc_spawn("woman", id = 4, x = 3232, y = 3207)
|
||||
npc_spawn("man", id = 1, x = 3231, y = 3237)
|
||||
npc_spawn("man", id = 2, x = 3224, y = 3240)
|
||||
npc_spawn("woman", id = 5, x = 3229, y = 2329)
|
||||
|
||||
npc_spawn("hans", x = 3221, y = 3221)
|
||||
npc_spawn("father aereck", x = 3243, y = 3210)
|
||||
npc_spawn("shop keeper", x = 3212, y = 3247)
|
||||
npc_spawn("shop assistant", x = 3211, y = 3245)
|
||||
npc_spawn("lumbridge guide", x = 323, y = 3229)
|
||||
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* NOTE: This file is a stub, intended only for use within an IDE. It should be updated
|
||||
* each time [org.apollo.game.plugin.kotlin.KotlinPluginScript] has a new method added to it.
|
||||
*
|
||||
* Until IntelliJ IDEA starts to support ScriptTemplateDefinitions this is
|
||||
* required to resolve references within plugin code.
|
||||
*/
|
||||
|
||||
import org.apollo.game.model.World
|
||||
import org.apollo.game.plugin.PluginContext
|
||||
import org.apollo.game.plugin.kotlin.*
|
||||
import org.apollo.net.message.Message
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
val world: World = null!!
|
||||
var context: PluginContext = null!!
|
||||
|
||||
fun <T : Message> on(type: () -> KClass<T>): KotlinMessageHandler<T> {
|
||||
null!!
|
||||
}
|
||||
|
||||
fun start(callback: () -> Unit) {
|
||||
|
||||
}
|
||||
|
||||
fun stop(callback: () -> Unit) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import org.apollo.cache.def.*
|
||||
|
||||
fun lookup_object(name: String): ObjectDefinition? {
|
||||
val definitions = ObjectDefinition.getDefinitions()
|
||||
return definitions.filter { name.equals(it.name, true) }.firstOrNull()
|
||||
}
|
||||
|
||||
fun lookup_npc(name: String): NpcDefinition? {
|
||||
val definitions = NpcDefinition.getDefinitions()
|
||||
return definitions.filter { name.equals(it.name, true) }.firstOrNull()
|
||||
}
|
||||
|
||||
fun lookup_item(name: String): ItemDefinition? {
|
||||
val definitions = ItemDefinition.getDefinitions()
|
||||
return definitions.filter { name.equals(it.name, true) }.firstOrNull()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user