From 3520b46f45eba1de8364d9a02c0378c4191c9839 Mon Sep 17 00:00:00 2001 From: ceikry Date: Fri, 23 Jul 2021 09:37:56 -0500 Subject: [PATCH] Combination runes + basic house door handling --- .../entity/skill/magic/CombinationRune.java | 6 ++- Server/src/main/kotlin/api/ContentAPI.kt | 19 +++++++--- .../game/content/activity/fog/FOGUtils.kt | 15 ++++++++ .../rs09/game/content/activity/fog/FOGZone.kt | 38 ++++++++++++++++++- 4 files changed, 71 insertions(+), 7 deletions(-) diff --git a/Server/src/main/java/core/game/node/entity/skill/magic/CombinationRune.java b/Server/src/main/java/core/game/node/entity/skill/magic/CombinationRune.java index a5d351c23..511c25959 100644 --- a/Server/src/main/java/core/game/node/entity/skill/magic/CombinationRune.java +++ b/Server/src/main/java/core/game/node/entity/skill/magic/CombinationRune.java @@ -1,5 +1,7 @@ package core.game.node.entity.skill.magic; +import org.rs09.consts.Items; + import java.util.ArrayList; import java.util.List; @@ -9,7 +11,9 @@ public enum CombinationRune { MIST_RUNE(4695,Runes.WATER_RUNE,Runes.AIR_RUNE), DUST_RUNE(4696, Runes.AIR_RUNE,Runes.EARTH_RUNE), SMOKE_RUNE(4697,Runes.FIRE_RUNE,Runes.AIR_RUNE), - MUD_RUNE(4698,Runes.EARTH_RUNE,Runes.WATER_RUNE); + MUD_RUNE(4698,Runes.EARTH_RUNE,Runes.WATER_RUNE), + COMBO_ELEMENTAL(Items.ELEMENTAL_RUNE_12850, Runes.FIRE_RUNE, Runes.AIR_RUNE, Runes.EARTH_RUNE, Runes.WATER_RUNE), + COMBO_CATALYTIC(Items.CATALYTIC_RUNE_12851, Runes.MIND_RUNE, Runes.BODY_RUNE, Runes.DEATH_RUNE, Runes.CHAOS_RUNE); public Runes[] types; diff --git a/Server/src/main/kotlin/api/ContentAPI.kt b/Server/src/main/kotlin/api/ContentAPI.kt index 25b4921fa..59995fab0 100644 --- a/Server/src/main/kotlin/api/ContentAPI.kt +++ b/Server/src/main/kotlin/api/ContentAPI.kt @@ -737,14 +737,10 @@ object ContentAPI { * Force an entity to walk to a given destination. * @param entity the entity to forcewalk * @param dest the Location object to walk to - * @param type the type of pathfinder to use. "smart" for the SMART pathfinder, "clip" for the noclip pathfinder, anything else for DUMB. + * @param type the type of pathfinder to use. "smart" for the SMART pathfinder, anything else for DUMB. */ @JvmStatic fun forceWalk(entity: Entity, dest: Location, type: String){ - if(type == "clip"){ - ForceMovement(entity, dest, 10, 10).run() - return - } val pathfinder = when(type){ "smart" -> Pathfinder.SMART else -> Pathfinder.DUMB @@ -753,6 +749,19 @@ object ContentAPI { path.walk(entity) } + /** + * Forces an entity to walk a certain number of steps in the desired direction. This ignores normal pathfinding rules. + * @param entity the entity to move + * @param steps the # of steps to take + * @param dir the Direction to take them in. An enum exists for this called Direction. Default is the player's currently-facing direction. + */ + @JvmStatic + fun forceWalkStep(entity: Entity, steps: Int, dir: Direction = entity.direction){ + val newLoc = entity.location.transform(dir, steps) + entity.walkingQueue.reset() + entity.walkingQueue.addPath(newLoc.x, newLoc.y) + } + /** * Interrupts a given entity's walking queue * @param entity the entity to interrupt diff --git a/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGUtils.kt b/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGUtils.kt index 969a71fe3..bf89c28be 100644 --- a/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGUtils.kt +++ b/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGUtils.kt @@ -4,6 +4,7 @@ import api.ContentAPI import core.game.node.entity.combat.DeathTask import core.game.node.entity.player.Player import core.game.world.map.Location +import core.game.world.map.zone.ZoneBorders import org.rs09.consts.Items import kotlin.math.max @@ -41,6 +42,13 @@ object FOGUtils { } } + fun isInHouse(player: Player): Boolean { + for(z in houseZones){ + if(z.insideBorder(player)) return true + } + return false + } + fun updateHuntStatus(player: Player, hunter: Boolean){ player.packetDispatch.sendInterfaceConfig(730, 25, hunter) player.packetDispatch.sendInterfaceConfig(730, 26, !hunter) @@ -71,6 +79,13 @@ object FOGUtils { player.packetDispatch.sendInterfaceConfig(730, 23, false) } + val houseZones = arrayOf( + ZoneBorders(1650, 5702, 1652, 5704), + ZoneBorders(1666, 5703, 1668, 5705), + ZoneBorders(1675, 5687, 1677, 5689), + ZoneBorders(1655, 5682, 1657, 5684) + ) + val startLocations = arrayOf( Location.create(1627, 5708, 0), Location.create(1624, 5697, 0), diff --git a/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGZone.kt b/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGZone.kt index 2a99f2c7a..7e5869f55 100644 --- a/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGZone.kt +++ b/Server/src/main/kotlin/rs09/game/content/activity/fog/FOGZone.kt @@ -6,6 +6,7 @@ import core.game.node.Node import core.game.node.entity.Entity import core.game.node.entity.player.Player import core.game.system.task.Pulse +import core.game.world.map.Direction import core.game.world.map.zone.MapZone import core.game.world.map.zone.ZoneBuilder import core.game.world.map.zone.ZoneRestriction @@ -57,6 +58,7 @@ class FOGZone : MapZone("Fist of Guthix", true, ZoneRestriction.RANDOM_EVENTS, Z override fun interact(e: Entity?, target: Node?, option: Option?): Boolean { if(e !is Player) return false + target ?: return false when(option?.name?.toLowerCase()){ "take-stone" -> { @@ -75,7 +77,41 @@ class FOGZone : MapZone("Fist of Guthix", true, ZoneRestriction.RANDOM_EVENTS, Z } "pass" -> { - ContentAPI.forceWalk(e, e.location.transform(e.direction), "clip") + ContentAPI.submitIndividualPulse(e, object : Pulse(){ + var counter = 0 + val stepDir = if(!FOGUtils.isInHouse(e)) { + when (target.asScenery().rotation) { + 0 -> Direction.WEST + 1 -> Direction.NORTH + 2 -> Direction.EAST + 3 -> Direction.SOUTH + else -> target.direction + } + } else { + when (target.asScenery().rotation) { + 0 -> Direction.EAST + 1 -> Direction.SOUTH + 2 -> Direction.WEST + 3 -> Direction.NORTH + else -> target.direction + } + } + override fun pulse(): Boolean { + when(counter++){ + 0 -> { + ContentAPI.lockInteractions(e,5) + ContentAPI.forceWalk(e, target.location, "dumb") + ContentAPI.face(e, target.location.transform(stepDir)) + } + 1 -> { + ContentAPI.forceWalkStep(e, 1, stepDir) + } + 2 -> e.unlock().also { return true } + } + return false + } + }) + return true } }