Fixed Jatizso gates
This commit is contained in:
@@ -22,6 +22,7 @@ import core.game.node.item.GroundItem
|
|||||||
import core.game.node.item.GroundItemManager
|
import core.game.node.item.GroundItemManager
|
||||||
import core.game.node.item.Item
|
import core.game.node.item.Item
|
||||||
import core.game.system.task.Pulse
|
import core.game.system.task.Pulse
|
||||||
|
import core.game.world.map.Direction
|
||||||
import core.game.world.map.Location
|
import core.game.world.map.Location
|
||||||
import core.game.world.map.RegionManager
|
import core.game.world.map.RegionManager
|
||||||
import core.game.world.map.path.Pathfinder
|
import core.game.world.map.path.Pathfinder
|
||||||
@@ -254,13 +255,50 @@ object ContentAPI {
|
|||||||
* @param toReplace the GameObject instance we are replacing
|
* @param toReplace the GameObject instance we are replacing
|
||||||
* @param with the ID of the GameObject we wish to replace toReplace with
|
* @param with the ID of the GameObject we wish to replace toReplace with
|
||||||
* @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent.
|
* @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent.
|
||||||
|
* @param loc the location to move the new object to if necessary. Defaults to null.
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int) {
|
fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, loc: Location? = null) {
|
||||||
|
val newLoc = when(loc){
|
||||||
|
null -> toReplace.location
|
||||||
|
else -> loc
|
||||||
|
}
|
||||||
if (for_ticks == -1) {
|
if (for_ticks == -1) {
|
||||||
SceneryBuilder.replace(toReplace, toReplace.transform(with))
|
SceneryBuilder.replace(toReplace, toReplace.transform(with,toReplace.rotation,newLoc))
|
||||||
} else {
|
} else {
|
||||||
SceneryBuilder.replace(toReplace, toReplace.transform(with), for_ticks)
|
SceneryBuilder.replace(toReplace, toReplace.transform(with,toReplace.rotation, newLoc), for_ticks)
|
||||||
|
}
|
||||||
|
toReplace.isActive = false
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Replace an object with the given revert timer with the given rotation
|
||||||
|
* @param toReplace the GameObject instance we are replacing
|
||||||
|
* @param with the ID of the GameObject we wish to replace toReplace with
|
||||||
|
* @param for_ticks the number of ticks the object should be replaced for. Use -1 for permanent.
|
||||||
|
* @Param rotation the Direction of the rotation it should use. Direction.NORTH, Direction.SOUTH, etc
|
||||||
|
* @param loc the location to move the new object to if necessary. Defaults to null.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun replaceScenery(toReplace: Scenery, with: Int, for_ticks: Int, rotation: Direction, loc: Location? = null){
|
||||||
|
val newLoc = when(loc){
|
||||||
|
null -> toReplace.location
|
||||||
|
else -> loc
|
||||||
|
}
|
||||||
|
val rot = when(rotation){
|
||||||
|
Direction.NORTH_WEST -> 0
|
||||||
|
Direction.NORTH -> 1
|
||||||
|
Direction.NORTH_EAST -> 2
|
||||||
|
Direction.EAST -> 4
|
||||||
|
Direction.SOUTH_EAST -> 7
|
||||||
|
Direction.SOUTH -> 6
|
||||||
|
Direction.SOUTH_WEST -> 5
|
||||||
|
Direction.WEST -> 3
|
||||||
|
}
|
||||||
|
if (for_ticks == -1) {
|
||||||
|
SceneryBuilder.replace(toReplace, toReplace.transform(with,rot, newLoc))
|
||||||
|
} else {
|
||||||
|
SceneryBuilder.replace(toReplace, toReplace.transform(with,rot,newLoc), for_ticks)
|
||||||
}
|
}
|
||||||
toReplace.isActive = false
|
toReplace.isActive = false
|
||||||
}
|
}
|
||||||
@@ -493,6 +531,26 @@ object ContentAPI {
|
|||||||
return Repository.findNPC(id)
|
return Repository.findNPC(id)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the spawned scenery from the world map using the given coordinates
|
||||||
|
* @param x the X coordinate to use
|
||||||
|
* @param y the Y coordinate to use
|
||||||
|
* @param z the Z coordinate to use
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun getScenery(x: Int, y: Int, z: Int): Scenery?{
|
||||||
|
return RegionManager.getObject(z,x,y)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the spawned scenery from the world map using the given Location object.
|
||||||
|
* @param loc the Location object to use.
|
||||||
|
*/
|
||||||
|
@JvmStatic
|
||||||
|
fun getScenery(loc: Location): Scenery?{
|
||||||
|
return RegionManager.getObject(loc)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets an NPC within render distance of the refLoc that matches the given ID
|
* Gets an NPC within render distance of the refLoc that matches the given ID
|
||||||
* @param refLoc the Location to find the closes NPC to
|
* @param refLoc the Location to find the closes NPC to
|
||||||
|
|||||||
@@ -0,0 +1,42 @@
|
|||||||
|
package rs09.game.interaction.region
|
||||||
|
|
||||||
|
import api.ContentAPI
|
||||||
|
import core.game.world.map.Direction
|
||||||
|
import core.game.world.map.zone.ZoneBorders
|
||||||
|
import rs09.game.interaction.InteractionListener
|
||||||
|
|
||||||
|
class JatizsoListeners : InteractionListener() {
|
||||||
|
val GATES_CLOSED = intArrayOf(21403,21405)
|
||||||
|
val NORTH_GATE_ZONE = ZoneBorders(2414,3822,2417,3825)
|
||||||
|
val WEST_GATE_ZONE = ZoneBorders(2386,3797,2390,3801)
|
||||||
|
override fun defineListeners() {
|
||||||
|
on(GATES_CLOSED, SCENERY, "open"){player, node ->
|
||||||
|
if(NORTH_GATE_ZONE.insideBorder(player)){
|
||||||
|
if(node.id == GATES_CLOSED.first()){
|
||||||
|
val other = ContentAPI.getScenery(node.location.transform(1, 0, 0)) ?: return@on true
|
||||||
|
ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.EAST)
|
||||||
|
ContentAPI.replaceScenery(other.asScenery(), other.id - 1, -1, Direction.SOUTH)
|
||||||
|
} else {
|
||||||
|
val other = ContentAPI.getScenery(node.location.transform(-1, 0, 0)) ?: return@on true
|
||||||
|
ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.SOUTH)
|
||||||
|
ContentAPI.replaceScenery(other.asScenery(), other.id, -1, Direction.EAST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentAPI.playAudio(player, ContentAPI.getAudio(81))
|
||||||
|
} else if(WEST_GATE_ZONE.insideBorder(player)){
|
||||||
|
if(node.id == GATES_CLOSED.first()){
|
||||||
|
val other = ContentAPI.getScenery(node.location.transform(0, 1, 0)) ?: return@on true
|
||||||
|
ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.WEST)
|
||||||
|
ContentAPI.replaceScenery(other.asScenery(), other.id + 1, -1, Direction.NORTH)
|
||||||
|
} else {
|
||||||
|
val other = ContentAPI.getScenery(node.location.transform(0, -1, 0)) ?: return@on true
|
||||||
|
ContentAPI.replaceScenery(node.asScenery(), node.id + 1, -1, Direction.NORTH)
|
||||||
|
ContentAPI.replaceScenery(other.asScenery(), other.id + 1, -1, Direction.WEST)
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentAPI.playAudio(player, ContentAPI.getAudio(81))
|
||||||
|
}
|
||||||
|
return@on true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user