Skip to content

rift.entities

fun Entity.grantXp(
skill: Skill,
amount: Double
): Unit
Example
on_object_option(Assets.WorldObject.poordoor, "Pick-lock") { player ->
val thieving = player.allComponents().filterIsInstance<Skill>().firstOrNull { it.name == "thieving" }
if (thieving != null) player.grantXp(thieving, 15.0)
player.message("You pick the lock.")
}
fun Actor.inGroup(name: String): Boolean
Example
on_login { player ->
if (player.inGroup("admin")) player.message("Admin tools are on.")
if (player.inGroup("event_team")) player.teleport(Tile4.global(3222, 3218))
}
fun Actor.isOnline(): Boolean
Example
on_input<DeveloperCommandInput> { player ->
if (name != "seen") return@on_input
val other = World.findPlayer(argv.lastOrNull() ?: return@on_input)
player.message(if (other?.isOnline() == true) "They are online." else "They are not online.")
}
fun Actor.isPlayer(): Boolean
Example
on_player_option("Trade") { player ->
if (!target.isPlayer()) player.message("That one is a bot: it does not trade.")
}
fun Actor.isUserControlled(): Boolean
Example
on_player_option("Follow") { player ->
if (!target.isUserControlled()) player.message("Nobody is at the controls of that character.")
}
val Component.actor: Actor?
Example
fun healToFull(hp: Hitpoints) {
hp.current = hp.max
hp.actor?.message("You feel much better.")
}
val Actor.groups: Set<String>
Example
on_login { player ->
if (player.groups.isNotEmpty()) player.message("Your groups: ${player.groups.joinToString()}.")
}
val Component.npc: Npc?
Example
fun healToFull(hp: Hitpoints) {
hp.current = hp.max
hp.npc?.speak("I feel much better!")
}
val Component.projectile: Projectile?
Example
fun whereItFlies(settings: ProjectileSettings) {
val projectile = settings.projectile ?: return
Logger.info("a projectile in flight at ${projectile.tile4}")
}
var Entity.shard: Int
Example
on_input<DeveloperCommandInput> { player ->
when (name) {
"alone" -> player.shard = World.createParallelWorld()
"together" -> player.shard = WorldSpatialIndex.GLOBAL
}
}
val Entity.shardId: Int
Example
node<Npc>()
on_self_spawn { npc ->
if (npc.shardId != WorldSpatialIndex.GLOBAL) Logger.info("made in shard ${npc.shardId}")
}
val Component.worldItem: WorldItem?
Example
fun describe(settings: WorldItemSettings): String {
val item = settings.worldItem ?: return "not a world item"
return "${item.quantity} x ${item.stack.name} at ${item.tile}"
}
val Component.worldObject: WorldObject?
Example
fun closeDoor(settings: WorldObjectSettings) {
settings.worldObject?.replaceWith(Assets.WorldObject.poordoor)
}
val Component.worldSound: WorldSound?
Example
fun whereItPlays(settings: WorldSoundSettings) {
val sound = settings.worldSound ?: return
Logger.info("a sound playing at ${sound.tile4}")
}