diff --git a/packages/junon-io/client/main.ejs b/packages/junon-io/client/main.ejs index a84f27b3..b819e2aa 100644 --- a/packages/junon-io/client/main.ejs +++ b/packages/junon-io/client/main.ejs @@ -1004,7 +1004,7 @@ $getContent $entityId - Gives the content of a sign/beacon/lamp. Ex. /chat The sign says $getContent(191) + Gives the content of a sign/beacon/lamp. Ex. /chat The sign with an id of 191 says $getContent(191) $getStructureByCoords @@ -1019,12 +1019,12 @@ $hasEffect $entityId, effectName - true if the entity, player, or building gets the specified effect. false if not. + true if the entity/player/building has the specified effect. false if not. Ex. /chat @a Mob 892's has a miasma index of: $hasEffect(892, Miasma) $getTotalMobCount None - Returns the total count of all mobs in the game sector (hostile + neutral). + Returns the total count of all mobs in the game sector (hostile + neutral). Ex. /chat @a Number of mobs in this sector: $getTotalMobCount() $getAngle @@ -1034,12 +1034,22 @@ $getUsage $itemId - Returns the usage level of an item + Returns the usage level of an item. Ex. /chat @a The usage of kuroro's item 300 is $getUsage(300) $getCapacity $itemId - Returns the usage capacity of an item + Returns the usage capacity of an item. Ex. /chat @a The capacity of kuroro's item with an id of 300 is $getCapacity(300) + + + $getRegionMemberNames + $region + Returns the member names of a region. Ex. /chat @a congrats to $getRegionMemberNames(arena) for winning our grand prize! + + + $getTeamMemberNames + $teamName + Returns the member names of a team. Ex. /chat @a congrats to $getTeamMemberNames($winningTeam) for winning our grand prize! @@ -1058,7 +1068,12 @@

/caption title $player has bought the rocket launcher!

At the end of the timer 'healthreset', loop and reset everyone's health (Timer:healthreset:end):

/timer start healthreset 10

-

/sethealth @a 100

+

/sethealth @a 100

+

At the end of the timer 'arenatimer', start the intermission and congratulate them. (Timer:arenatimer:end)

+

/chat @a Congrats to $getRegionMemberNames(arena) for winning the grand prize of a bajil-

+

/give @a[region=arena] gold 100

+

/tp @a[region=arena] (spawn coordinates)

+

/timer start intermission 30

diff --git a/packages/junon-io/server/entities/event_handler.js b/packages/junon-io/server/entities/event_handler.js index fe4bf423..2cbc9a7f 100644 --- a/packages/junon-io/server/entities/event_handler.js +++ b/packages/junon-io/server/entities/event_handler.js @@ -386,6 +386,20 @@ class EventHandler { return this.getAlivePlayerCountForRole(roleName) } + getTeamMemberNames(teamName) { + let team = this.game.getTeamByName(teamName) + if (!team) return + + return team.getMemberNamesJson(); + } + + getRegionPlayerNames(regionName) { + let region = this.sector.getRegion(regionName) + if (!region) return 0 + + return region.getMemberNamesJson() + } + getHunger(playerId) { let player = this.getPlayer(playerId) if (!player) return 0 @@ -1215,7 +1229,9 @@ class EventHandler { "$getTotalMobCount": true, "$getAngle": true, "$getUsage": true, - "$getCapacity": true + "$getCapacity": true, + "$getRegionMemberNames": true, + "$getTeamMemberNames": true } } diff --git a/packages/junon-io/server/entities/mobs/base_mob.js b/packages/junon-io/server/entities/mobs/base_mob.js index 20cfc496..58c6be5e 100644 --- a/packages/junon-io/server/entities/mobs/base_mob.js +++ b/packages/junon-io/server/entities/mobs/base_mob.js @@ -824,12 +824,14 @@ class BaseMob extends BaseEntity { } mobMount(user) { - this.game.triggerEvent("MobMount", { - entityId: this.getId(), - entityType: this.getTypeName(), - playerId: user.getId(), - player: user.getName() - }) + if (this.isMountable(user)) { + this.game.triggerEvent("MobMount", { + entityId: this.getId(), + entityType: this.getTypeName(), + playerId: user.getId(), + player: user.getName() + }) + } this.mount(user) if (user.isPlayer()) { diff --git a/packages/junon-io/server/entities/region.js b/packages/junon-io/server/entities/region.js index d304133b..ef9bf7b1 100644 --- a/packages/junon-io/server/entities/region.js +++ b/packages/junon-io/server/entities/region.js @@ -224,6 +224,15 @@ class Region extends BaseTransientEntity { return players.length } + getMemberNamesJson() { + let players = this.sector.playerTree.search(this.getBoundingBox()) + let playerNames = [] + + Object.values(players).forEach(player => playerNames.push(player.name)); + + return playerNames.join(' ') + } + getBuildings() { return this.sector.buildingTree.search(this.getBoundingBox()) } diff --git a/packages/junon-io/server/interfaces/mountable.js b/packages/junon-io/server/interfaces/mountable.js index 5914f98d..19ae2603 100644 --- a/packages/junon-io/server/interfaces/mountable.js +++ b/packages/junon-io/server/interfaces/mountable.js @@ -9,7 +9,7 @@ Mountable.prototype = { mount(user) { if (this.passenger) return - if (this.game.distanceBetween(this, user) >= this.getInteractDistance()) { + if (isTooFar(user)) { if (user.isPlayer()) { user.showError("Too far", { isWarning: true }) } @@ -32,8 +32,20 @@ Mountable.prototype = { shouldUpdatePosition() { return true - } + }, + isMountable(user) { + if (this.passenger) return false + if (!isTooFar(user)) return false + + return true + }, + + isTooFar(user) { + if (this.game.distanceBetween(this, user) >= this.getInteractDistance()) { + return true + } + } } module.exports = Mountable