Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions packages/junon-io/client/main.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,7 +1004,7 @@
<tr>
<td class='function_name'>$getContent</td>
<td>$entityId</td>
<td>Gives the content of a sign/beacon/lamp. Ex. /chat The sign says $getContent(191)</td>
<td>Gives the content of a sign/beacon/lamp. Ex. /chat The sign with an id of 191 says $getContent(191)</td>
</tr>
<tr>
<td class='function_name'>$getStructureByCoords</td>
Expand All @@ -1019,12 +1019,12 @@
<tr>
<td class='function_name'>$hasEffect</td>
<td>$entityId, effectName</td>
<td>true if the entity, player, or building gets the specified effect. false if not.</td>
<td>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)</td>
</tr>
<tr>
<td class='function_name'>$getTotalMobCount</td>
<td>None</td>
<td>Returns the total count of all mobs in the game sector (hostile + neutral).</td>
<td>Returns the total count of all mobs in the game sector (hostile + neutral). Ex. /chat @a Number of mobs in this sector: $getTotalMobCount()</td>
</tr>
<tr>
<td class='function_name'>$getAngle</td>
Expand All @@ -1034,12 +1034,22 @@
<tr>
<td class="function_name">$getUsage</td>
<td>$itemId</td>
<td>Returns the usage level of an item</td>
<td>Returns the usage level of an item. Ex. /chat @a The usage of kuroro's item 300 is $getUsage(300)</td>
</tr>
<tr>
<td class="function_name">$getCapacity</td>
<td>$itemId</td>
<td>Returns the usage capacity of an item</td>
<td>Returns the usage capacity of an item. Ex. /chat @a The capacity of kuroro's item with an id of 300 is $getCapacity(300)</td>
</tr>
<tr>
<td class="function_name">$getRegionMemberNames</td>
<td>$region</td>
<td>Returns the member names of a region. Ex. /chat @a congrats to $getRegionMemberNames(arena) for winning our grand prize!</td>
</tr>
<tr>
<td class="function_name">$getTeamMemberNames</td>
<td>$teamName</td>
<td>Returns the member names of a team. Ex. /chat @a congrats to $getTeamMemberNames($winningTeam) for winning our grand prize!</td>
</tr>
</table>
</div>
Expand All @@ -1058,7 +1068,12 @@
<p><span class='code'>/caption title $player has bought the rocket launcher!</span></p>
<p>At the end of the timer 'healthreset', loop and reset everyone's health (Timer:healthreset:end):</p>
<p><span class='code'>/timer start healthreset 10</span></p>
<p><span class='code'>/sethealth @a 100</span></p>
<p><span class='code'>/sethealth @a 100</span></p>
<p>At the end of the timer 'arenatimer', start the intermission and congratulate them. (Timer:arenatimer:end)</p>
<p><span class='code'>/chat @a Congrats to $getRegionMemberNames(arena) for winning the grand prize of a bajil-</span></p>
<p><span class='code'>/give @a[region=arena] gold 100</span></p>
<p><span class='code'>/tp @a[region=arena] (spawn coordinates)</span></p>
<p><span class='code'>/timer start intermission 30</span></p>
</div>
</div>
</div>
Expand Down
18 changes: 17 additions & 1 deletion packages/junon-io/server/entities/event_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -1215,7 +1229,9 @@ class EventHandler {
"$getTotalMobCount": true,
"$getAngle": true,
"$getUsage": true,
"$getCapacity": true
"$getCapacity": true,
"$getRegionMemberNames": true,
"$getTeamMemberNames": true
}
}

Expand Down
14 changes: 8 additions & 6 deletions packages/junon-io/server/entities/mobs/base_mob.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
9 changes: 9 additions & 0 deletions packages/junon-io/server/entities/region.js
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down
16 changes: 14 additions & 2 deletions packages/junon-io/server/interfaces/mountable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
}
Expand All @@ -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