mirror of
https://gitlab.com/2009scape/2009scape.git
synced 2025-12-09 16:45:44 -07:00
Pushed start of Fist of Guthix work
This commit is contained in:
parent
8d76c54ae3
commit
baafb941a3
10 changed files with 1841 additions and 319 deletions
|
|
@ -1,91 +0,0 @@
|
||||||
package core.game.content.activity.fog;
|
|
||||||
|
|
||||||
import core.cache.def.impl.SceneryDefinition;
|
|
||||||
import core.game.content.activity.ActivityPlugin;
|
|
||||||
import core.game.interaction.OptionHandler;
|
|
||||||
import core.game.node.Node;
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
import core.game.world.map.Location;
|
|
||||||
import core.game.world.map.zone.ZoneBorders;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
import rs09.plugin.PluginManager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the fist of guthix activity.
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
public class FOGActivityPlugin extends ActivityPlugin {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The maximum amount of players in a game.
|
|
||||||
*/
|
|
||||||
public static final int MAX_PLAYERS = 250;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The waiting interface id.
|
|
||||||
*/
|
|
||||||
public static final int WAITING_INTERFACE = 731;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The current fist of guthix round.
|
|
||||||
*/
|
|
||||||
private int round;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code FOGActivityPlugin} {@code Object}
|
|
||||||
*/
|
|
||||||
public FOGActivityPlugin() {
|
|
||||||
super("Fist of Guthix", false, true, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ActivityPlugin newInstance(Player p) throws Throwable {
|
|
||||||
return new FOGActivityPlugin();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Location getSpawnLocation() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configure() {
|
|
||||||
PluginManager.definePlugin(new FOGLobbyZone());
|
|
||||||
PluginManager.definePlugin(new FOGWaitingZone());
|
|
||||||
PluginManager.definePlugin(new OptionHandler() {
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
SceneryDefinition.forId(30204).getHandlers().put("option:enter", this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean handle(Player player, Node node, String option) {
|
|
||||||
switch (node.getId()) {
|
|
||||||
case 30204:
|
|
||||||
player.teleport(Location.create(1675, 5599, 0));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
register(new ZoneBorders(1625, 5638, 1715, 5747));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the round.
|
|
||||||
* @return the round
|
|
||||||
*/
|
|
||||||
public int getRound() {
|
|
||||||
return round;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the round.
|
|
||||||
* @param round the round to set.
|
|
||||||
*/
|
|
||||||
public void setRound(int round) {
|
|
||||||
this.round = round;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
||||||
package core.game.content.activity.fog;
|
|
||||||
|
|
||||||
import core.game.component.Component;
|
|
||||||
import core.game.interaction.Option;
|
|
||||||
import core.game.node.Node;
|
|
||||||
import core.game.node.entity.Entity;
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
import core.game.world.map.Location;
|
|
||||||
import core.game.world.map.zone.MapZone;
|
|
||||||
import core.game.world.map.zone.ZoneBuilder;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a zone where players can prepare for a game.
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
public class FOGLobbyZone extends MapZone implements Plugin<Object> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code FOGHallZone} {@code Object}
|
|
||||||
*/
|
|
||||||
public FOGLobbyZone() {
|
|
||||||
super("Fog Lobby", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
ZoneBuilder.configure(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean enter(Entity e) {
|
|
||||||
if (e.isPlayer()) {
|
|
||||||
sendInterface(e.asPlayer());
|
|
||||||
}
|
|
||||||
return super.enter(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean interact(Entity e, Node target, Option option) {
|
|
||||||
if (!e.isPlayer()) {
|
|
||||||
return super.interact(e, target, option);
|
|
||||||
}
|
|
||||||
Player player = e.asPlayer();
|
|
||||||
switch (target.getId()) {
|
|
||||||
case 30203:
|
|
||||||
player.teleport(Location.create(3242, 3574, 0));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return super.interact(e, target, option);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends the fist of guthix lobby interface.
|
|
||||||
* @param player the player.
|
|
||||||
*/
|
|
||||||
private void sendInterface(Player player) {
|
|
||||||
player.getInterfaceManager().openOverlay(new Component(FOGActivityPlugin.WAITING_INTERFACE));
|
|
||||||
player.getPacketDispatch().sendInterfaceConfig(FOGActivityPlugin.WAITING_INTERFACE, 17, true);
|
|
||||||
player.getPacketDispatch().sendInterfaceConfig(FOGActivityPlugin.WAITING_INTERFACE, 26, true);
|
|
||||||
player.getPacketDispatch().sendString("Rating: " + player.getSavedData().getActivityData().getFogRating(), FOGActivityPlugin.WAITING_INTERFACE, 7);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object fireEvent(String identifier, Object... args) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configure() {
|
|
||||||
super.registerRegion(6743);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,104 +0,0 @@
|
||||||
package core.game.content.activity.fog;
|
|
||||||
|
|
||||||
import core.game.node.entity.player.Player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a fist of guthix player.
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
public class FOGPlayer {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The player instance.
|
|
||||||
*/
|
|
||||||
private final Player player;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The target FOG player.
|
|
||||||
*/
|
|
||||||
private final FOGPlayer target;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* If the player is hunted or a hunter.
|
|
||||||
*/
|
|
||||||
private boolean hunted;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The amount of fist of guthix charges.
|
|
||||||
*/
|
|
||||||
private int charges;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code FOGPlayer} {@code Object}
|
|
||||||
* @param player the player.
|
|
||||||
* @param oponent the other player.
|
|
||||||
*/
|
|
||||||
public FOGPlayer(Player player, FOGPlayer oponent) {
|
|
||||||
this.player = player;
|
|
||||||
this.target = oponent;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Switches the roles of the player.
|
|
||||||
*/
|
|
||||||
public void switchRoles() {
|
|
||||||
hunted = !hunted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Increments the energy charges.
|
|
||||||
* @param increment the number to increment.
|
|
||||||
*/
|
|
||||||
public void incrementCharges(int increment) {
|
|
||||||
charges += increment;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the hunted.
|
|
||||||
* @return the hunted
|
|
||||||
*/
|
|
||||||
public boolean isHunted() {
|
|
||||||
return hunted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the hunted.
|
|
||||||
* @param hunted the hunted to set.
|
|
||||||
*/
|
|
||||||
public void setHunted(boolean hunted) {
|
|
||||||
this.hunted = hunted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the charges.
|
|
||||||
* @return the charges
|
|
||||||
*/
|
|
||||||
public int getCharges() {
|
|
||||||
return charges;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the charges.
|
|
||||||
* @param charges the charges to set.
|
|
||||||
*/
|
|
||||||
public void setCharges(int charges) {
|
|
||||||
this.charges = charges;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the player.
|
|
||||||
* @return the player
|
|
||||||
*/
|
|
||||||
public Player getPlayer() {
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the target.
|
|
||||||
* @return the target
|
|
||||||
*/
|
|
||||||
public FOGPlayer getTarget() {
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -1,49 +0,0 @@
|
||||||
package core.game.content.activity.fog;
|
|
||||||
|
|
||||||
import core.game.interaction.Option;
|
|
||||||
import core.game.node.Node;
|
|
||||||
import core.game.node.entity.Entity;
|
|
||||||
import core.game.world.map.zone.MapZone;
|
|
||||||
import core.game.world.map.zone.ZoneBuilder;
|
|
||||||
import core.plugin.Plugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents the zone where players wait for a match.
|
|
||||||
* @author Vexia
|
|
||||||
*/
|
|
||||||
public class FOGWaitingZone extends MapZone implements Plugin<Object> {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs a new {@code FOGLobbyZone} {@code Object}
|
|
||||||
*/
|
|
||||||
public FOGWaitingZone() {
|
|
||||||
super("Fog Waiting Room", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Plugin<Object> newInstance(Object arg) throws Throwable {
|
|
||||||
ZoneBuilder.configure(this);
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean enter(Entity e) {
|
|
||||||
return super.enter(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean interact(Entity e, Node target, Option option) {
|
|
||||||
return super.interact(e, target, option);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Object fireEvent(String identifier, Object... args) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void configure() {
|
|
||||||
super.registerRegion(6487);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,110 @@
|
||||||
|
package rs09.game.content.activity.fog
|
||||||
|
|
||||||
|
import api.ContentAPI
|
||||||
|
import core.game.node.entity.player.Player
|
||||||
|
import core.game.world.map.Location
|
||||||
|
import core.tools.RandomFunction
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
|
||||||
|
class FOGSession(val playerA: Player, val playerB: Player) {
|
||||||
|
|
||||||
|
var hunter = playerA
|
||||||
|
var hunted = playerB
|
||||||
|
var isActive = true
|
||||||
|
|
||||||
|
var winner: Player? = null
|
||||||
|
var loser: Player? = null
|
||||||
|
|
||||||
|
var playerAScore = 0
|
||||||
|
var playerBScore = 0
|
||||||
|
|
||||||
|
var round = 1
|
||||||
|
|
||||||
|
var roundTimer = 0
|
||||||
|
|
||||||
|
fun start(){
|
||||||
|
playerA.setAttribute("fog-session",this)
|
||||||
|
playerA.logoutListeners["fog-logout"] = { player -> ContentAPI.teleport(player, Location.create(1714, 5599, 0)); isActive = false }
|
||||||
|
playerB.setAttribute("fog-session",this)
|
||||||
|
playerB.logoutListeners["fog-logout"] = { player -> ContentAPI.teleport(player, Location.create(1714, 5599, 0)); isActive = false }
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun tick() {
|
||||||
|
roundTimer++
|
||||||
|
playerA.varpManager.get(FOGUtils.TIMER_VARP).setVarbit(4, roundTimer).send(playerA)
|
||||||
|
playerB.varpManager.get(FOGUtils.TIMER_VARP).setVarbit(4, roundTimer).send(playerB)
|
||||||
|
|
||||||
|
if(FOGUtils.carryingStone(hunted) && roundTimer % 5 == 0){
|
||||||
|
FOGUtils.incrementHuntedScore(this, FOGUtils.getTickScore(hunted))
|
||||||
|
} else if (!ContentAPI.inInventory(hunted, Items.STONE_OF_POWER_12845)){
|
||||||
|
FOGUtils.showStoneNotice(hunted)
|
||||||
|
}
|
||||||
|
|
||||||
|
if((roundTimer == 1000 || getCurrentHuntedScore() >= 5000) && isActive){
|
||||||
|
changeRounds()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getCurrentHuntedScore(): Int {
|
||||||
|
return when(round){
|
||||||
|
1 -> playerBScore
|
||||||
|
2 -> playerAScore
|
||||||
|
else -> -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun changeRounds(){
|
||||||
|
if(round == 2){
|
||||||
|
finishGame()
|
||||||
|
} else {
|
||||||
|
round = 2
|
||||||
|
hunted = playerA
|
||||||
|
hunter = playerB
|
||||||
|
FOGUtils.updateHuntStatus(playerA, playerA == hunter)
|
||||||
|
FOGUtils.updateHuntStatus(playerB, playerB == hunter)
|
||||||
|
hunted.properties.teleportLocation = FOGUtils.getRandomStartLocation()
|
||||||
|
hunter.properties.teleportLocation = FOGUtils.getRandomStartLocation()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun finishGame(){
|
||||||
|
if(playerAScore > playerBScore){
|
||||||
|
winner = playerA
|
||||||
|
loser = playerB
|
||||||
|
} else if (playerBScore > playerAScore){
|
||||||
|
winner = playerB
|
||||||
|
loser = playerA
|
||||||
|
}
|
||||||
|
|
||||||
|
if(winner == null) {
|
||||||
|
//draw
|
||||||
|
rewardLoss(playerA)
|
||||||
|
rewardLoss(playerB)
|
||||||
|
} else {
|
||||||
|
rewardLoss(loser!!)
|
||||||
|
rewardVictory(winner!!)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getScore(player: Player): Int{
|
||||||
|
return when(player){
|
||||||
|
playerA -> playerAScore
|
||||||
|
playerB -> playerBScore
|
||||||
|
else -> 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun rewardLoss(player: Player){
|
||||||
|
ContentAPI.addItemOrDrop(player, Items.FIST_OF_GUTHIX_TOKEN_12852, RandomFunction.random(1,3))
|
||||||
|
ContentAPI.sendMessage(player, "You lost and were given some tokens for your effort.")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun rewardVictory(player: Player){
|
||||||
|
var tokens = getScore(player) / 200.0
|
||||||
|
tokens += player.skills.totalLevel / 100.0
|
||||||
|
|
||||||
|
ContentAPI.addItemOrDrop(player, Items.FIST_OF_GUTHIX_TOKEN_12852, tokens.toInt())
|
||||||
|
ContentAPI.sendMessage(player, "Guthix smiles upon your victory and rewards you.")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,129 @@
|
||||||
|
package rs09.game.content.activity.fog
|
||||||
|
|
||||||
|
import api.ContentAPI
|
||||||
|
import core.game.node.entity.combat.DeathTask
|
||||||
|
import core.game.node.entity.player.Player
|
||||||
|
import core.game.world.map.Location
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
import kotlin.math.max
|
||||||
|
|
||||||
|
object FOGUtils {
|
||||||
|
|
||||||
|
const val TIMER_VARP = 1215
|
||||||
|
|
||||||
|
fun getRandomStartLocation(): Location {
|
||||||
|
return startLocations.random()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getSession(player: Player): FOGSession? {
|
||||||
|
return player.getAttribute("fog-session")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun carryingStone(player: Player): Boolean {
|
||||||
|
return ContentAPI.inEquipment(player, Items.STONE_OF_POWER_12845)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isHunted(player: Player): Boolean {
|
||||||
|
val session = getSession(player) ?: return false
|
||||||
|
return session.hunted == player
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isHunter(player: Player): Boolean {
|
||||||
|
return !isHunted(player)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun incrementHuntedScore(session: FOGSession, amount: Int){
|
||||||
|
if(DeathTask.isDead(session.hunted)) return
|
||||||
|
|
||||||
|
when(session.round){
|
||||||
|
1 -> session.playerBScore += amount
|
||||||
|
2 -> session.playerAScore += amount
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun updateHuntStatus(player: Player, hunter: Boolean){
|
||||||
|
player.packetDispatch.sendInterfaceConfig(730, 25, hunter)
|
||||||
|
player.packetDispatch.sendInterfaceConfig(730, 26, !hunter)
|
||||||
|
if(hunter){
|
||||||
|
player.packetDispatch.sendString(getSession(player)?.hunted?.name ?: "AAAAA", 730, 18)
|
||||||
|
} else {
|
||||||
|
player.packetDispatch.sendString(getSession(player)?.hunter?.name ?: "AAAAA", 730, 18)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getTickScore(player: Player): Int {
|
||||||
|
return max(50 - player.location.getDistance(getClosestCentralTile(player)).toInt(), 10)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun getClosestCentralTile(player: Player): Location{
|
||||||
|
var closest = centralTiles.first()
|
||||||
|
for(loc in centralTiles){
|
||||||
|
if(player.location.getDistance(loc) < player.location.getDistance(closest)) closest = loc
|
||||||
|
}
|
||||||
|
return closest
|
||||||
|
}
|
||||||
|
|
||||||
|
fun hideStoneNotice(player: Player){
|
||||||
|
player.packetDispatch.sendInterfaceConfig(730, 23, true)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun showStoneNotice(player: Player){
|
||||||
|
player.packetDispatch.sendInterfaceConfig(730, 23, false)
|
||||||
|
}
|
||||||
|
|
||||||
|
val startLocations = arrayOf(
|
||||||
|
Location.create(1627, 5708, 0),
|
||||||
|
Location.create(1624, 5697, 0),
|
||||||
|
Location.create(1626, 5692, 0),
|
||||||
|
Location.create(1629, 5685, 0),
|
||||||
|
Location.create(1631, 5680, 0),
|
||||||
|
Location.create(1635, 5672, 0),
|
||||||
|
Location.create(1642, 5665, 0),
|
||||||
|
Location.create(1648, 5660, 0),
|
||||||
|
Location.create(1655, 5657, 0),
|
||||||
|
Location.create(1660, 5657, 0),
|
||||||
|
Location.create(1666, 5658, 0),
|
||||||
|
Location.create(1673, 5660, 0),
|
||||||
|
Location.create(1681, 5663, 0),
|
||||||
|
Location.create(1687, 5665, 0),
|
||||||
|
Location.create(1692, 5669, 0),
|
||||||
|
Location.create(1695, 5674, 0),
|
||||||
|
Location.create(1700, 5681, 0),
|
||||||
|
Location.create(1701, 5685, 0),
|
||||||
|
Location.create(1703, 5690, 0),
|
||||||
|
Location.create(1697, 5697, 0),
|
||||||
|
Location.create(1694, 5706, 0),
|
||||||
|
Location.create(1690, 5713, 0),
|
||||||
|
Location.create(1687, 5717, 0),
|
||||||
|
Location.create(1681, 5724, 0),
|
||||||
|
Location.create(1675, 5727, 0),
|
||||||
|
Location.create(1669, 5729, 0),
|
||||||
|
Location.create(1663, 5732, 0),
|
||||||
|
Location.create(1656, 5730, 0),
|
||||||
|
Location.create(1647, 5727, 0),
|
||||||
|
Location.create(1637, 5723, 0),
|
||||||
|
Location.create(1634, 5719, 0),
|
||||||
|
Location.create(1627, 5712, 0),
|
||||||
|
Location.create(1624, 5704, 0),
|
||||||
|
Location.create(1624, 5695, 0),
|
||||||
|
Location.create(1628, 5686, 0),
|
||||||
|
Location.create(1633, 5678, 0),
|
||||||
|
Location.create(1636, 5670, 0),
|
||||||
|
Location.create(1642, 5665, 0),
|
||||||
|
Location.create(1648, 5660, 0),
|
||||||
|
Location.create(1655, 5657, 0),
|
||||||
|
Location.create(1633, 5718, 0),
|
||||||
|
Location.create(1644, 5727, 0),
|
||||||
|
Location.create(1656, 5731, 0),
|
||||||
|
Location.create(1667, 5731, 0),
|
||||||
|
Location.create(1682, 5722, 0),
|
||||||
|
Location.create(1691, 5711, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
val centralTiles = arrayOf(
|
||||||
|
Location.create(1663, 5695, 0),
|
||||||
|
Location.create(1664, 5695, 0),
|
||||||
|
Location.create(1664, 5696, 0),
|
||||||
|
Location.create(1663, 5696, 0)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package rs09.game.content.activity.fog
|
||||||
|
|
||||||
|
import api.ContentAPI
|
||||||
|
import core.game.node.entity.player.Player
|
||||||
|
import core.game.system.task.Pulse
|
||||||
|
|
||||||
|
object FOGWaitingArea {
|
||||||
|
val currentlyWaiting = ArrayList<Player>()
|
||||||
|
val activeSessions = ArrayList<FOGSession>()
|
||||||
|
|
||||||
|
val pulse = object : Pulse(10){
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
if(currentlyWaiting.size < 4) return false
|
||||||
|
|
||||||
|
val sortedByCombat = currentlyWaiting.sortedBy { it.properties.currentCombatLevel }.toMutableList()
|
||||||
|
if(sortedByCombat.size % 2 != 0) sortedByCombat.removeLast()
|
||||||
|
|
||||||
|
var previousPlayer: Player? = null
|
||||||
|
|
||||||
|
for(player in sortedByCombat){
|
||||||
|
if(previousPlayer == null) previousPlayer = player
|
||||||
|
else{
|
||||||
|
val session = FOGSession(previousPlayer, player)
|
||||||
|
session.start()
|
||||||
|
activeSessions.add(session)
|
||||||
|
previousPlayer = null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun register(player: Player): Boolean {
|
||||||
|
if(!pulse.isRunning) ContentAPI.submitWorldPulse(pulse)
|
||||||
|
return currentlyWaiting.add(player)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clear(player: Player): Boolean {
|
||||||
|
return currentlyWaiting.remove(player)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun isFull(): Boolean {
|
||||||
|
return activeSessions.size >= 125
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,87 @@
|
||||||
|
package rs09.game.content.activity.fog
|
||||||
|
|
||||||
|
import api.ContentAPI
|
||||||
|
import core.game.interaction.Option
|
||||||
|
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.zone.MapZone
|
||||||
|
import core.game.world.map.zone.ZoneBuilder
|
||||||
|
import core.game.world.map.zone.ZoneRestriction
|
||||||
|
import core.plugin.Initializable
|
||||||
|
import core.plugin.Plugin
|
||||||
|
import org.rs09.consts.Items
|
||||||
|
|
||||||
|
@Initializable
|
||||||
|
class FOGZone : MapZone("Fist of Guthix", true, ZoneRestriction.RANDOM_EVENTS, ZoneRestriction.CANNON, ZoneRestriction.FIRES), Plugin<Any> {
|
||||||
|
override fun newInstance(arg: Any?): Plugin<Any> {
|
||||||
|
ZoneBuilder.configure(this)
|
||||||
|
ContentAPI.submitWorldPulse(pulse)
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun configure() {
|
||||||
|
registerRegion(6488)
|
||||||
|
registerRegion(6489)
|
||||||
|
registerRegion(6745)
|
||||||
|
registerRegion(6744)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun fireEvent(identifier: String?, vararg args: Any?): Any {
|
||||||
|
return Unit
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun enter(e: Entity?): Boolean {
|
||||||
|
if(e is Player){
|
||||||
|
ContentAPI.openOverlay(e, 730)
|
||||||
|
}
|
||||||
|
return super.enter(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun leave(e: Entity?, logout: Boolean): Boolean {
|
||||||
|
if(e is Player) {
|
||||||
|
ContentAPI.closeOverlay(e)
|
||||||
|
}
|
||||||
|
return super.leave(e, logout)
|
||||||
|
}
|
||||||
|
|
||||||
|
val pulse = object : Pulse(){
|
||||||
|
override fun pulse(): Boolean {
|
||||||
|
for(session in FOGWaitingArea.activeSessions){
|
||||||
|
session.tick()
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun interact(e: Entity?, target: Node?, option: Option?): Boolean {
|
||||||
|
if(e !is Player) return false
|
||||||
|
|
||||||
|
when(option?.name?.toLowerCase()){
|
||||||
|
"take-stone" -> {
|
||||||
|
if(FOGUtils.getSession(e)?.hunted != e){
|
||||||
|
ContentAPI.sendMessage(e, "You can't take that right now.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if(FOGUtils.carryingStone(e) || ContentAPI.inInventory(e, Items.STONE_OF_POWER_12845)){
|
||||||
|
ContentAPI.sendMessage(e, "You already have a stone.")
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
ContentAPI.addItem(e, Items.STONE_OF_POWER_12845)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
"pass" -> {
|
||||||
|
ContentAPI.forceWalk(e, e.location.transform(e.direction), "clip")
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.interact(e, target, option)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
package rs09.game.interaction.region.fog
|
||||||
|
|
||||||
|
import api.ContentAPI
|
||||||
|
import core.game.world.map.Location
|
||||||
|
import rs09.game.content.activity.fog.FOGWaitingArea
|
||||||
|
import rs09.game.interaction.InteractionListener
|
||||||
|
|
||||||
|
class FOGLobbyListeners : InteractionListener(){
|
||||||
|
|
||||||
|
val FOG_WAITING_ROOM = Location.create(1653, 5600, 0)
|
||||||
|
val FOG_ARENA = Location.create(1663, 5695, 0)
|
||||||
|
|
||||||
|
val WAITING_ROOM_ENTRANCE = 30224
|
||||||
|
|
||||||
|
override fun defineListeners() {
|
||||||
|
on(WAITING_ROOM_ENTRANCE, SCENERY, "go-through"){player, node ->
|
||||||
|
if(FOGWaitingArea.isFull()){
|
||||||
|
ContentAPI.sendMessage(player, "The game is currently full. Please wait.")
|
||||||
|
return@on true
|
||||||
|
}
|
||||||
|
ContentAPI.teleport(player, FOG_WAITING_ROOM)
|
||||||
|
FOGWaitingArea.register(player)
|
||||||
|
return@on true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
1442
dumps/530/coords
Normal file
1442
dumps/530/coords
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue