Skip to content

Commit 095f4c0

Browse files
authored
Merge branch 'master' into master
2 parents 1373622 + a80e97f commit 095f4c0

File tree

5 files changed

+121
-14
lines changed

5 files changed

+121
-14
lines changed

README.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# sanctuary [![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-success.svg)](https://github.com/Picoseconds/sanctuary/graphs/commit-activity) [![Written in TypeScript](https://img.shields.io/badge/types-typescript-success)](https://github.com/microsoft/TypeScript/)
2+
Sanctuary is a private server implementation for the game MooMoo.io.
3+
4+
## Features
5+
See [Issue #16](https://github.com/Picoseconds/sanctuary/issues/16) for a list of current features supported.
6+
7+
## Getting started
8+
1. Clone the repo
9+
```
10+
git clone https://github.com/Picoseconds/sanctuary.git
11+
```
12+
2. Compile with `npm run build` **OR** `yarn build` depending on your package manager of choice.
13+
3. Run the server with `npm start`/`yarn start`
14+
15+
## Project Scope
16+
The goal of the Sanctuary project is to create a customizable, modular private server for MooMoo.io. This means that some features will be implemented differently to support configuration using environment variables.
17+
18+
See [Environment Variables](#environment-variables).
19+
20+
### Environment variables
21+
| Variable name | Effect |
22+
| ------------------------ | ------------------------------------------------------------------------------------------------------------------------- |
23+
| PORT | The port that the server binds on, defaults to 3000. |
24+
| MAX_CPS | The CPS cap to use, defaults to 25. |
25+
| PLAYER_NEARBY_RADIUS | The radius that players can see other players in. |
26+
| GAMEOBJECT_NEARBY_RADIUS | The radius that players can see structures (this includes trees, bushes and all other naturally generated structures) in. |
27+
| MODERATOR_PASSWORD | See [Password Login System](#password-login-system) |
28+
29+
This project utilises .env files with the `dotenv` module for configuration. Simply make a file named `.env` in the root of the cloned repo, and populate it with environment variables.
30+
31+
A .env file is similar to a Unix shell file, and uses the same syntax for assigning environment variables.
32+
Sample .env file:
33+
```bash
34+
PORT=8080
35+
MAX_CPS=20
36+
MODERATOR_PASSWORD=password123
37+
```
38+
39+
## Moderation Commands
40+
| Command | Use |
41+
| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
42+
| set \<player id> \<health/food/wood/stone/kills/xp/gold> \<number> | Sets the specified numerical attribute of a player to the specified number. |
43+
| tp \<destination player id> | Teleports you to the player specified. |
44+
| invisible | Toggles invisibility. You can see yourself, but others cannot see you. |
45+
| invincible | Toggles invincibility. |
46+
| promote \<player id> | Makes someone else a moderator. |
47+
| ban \<player id> | Bans someone by IP address. Moderators cannot be banned. |
48+
| kick \<player id> | Kicks a user. |
49+
| broadcast \<message> | Displays a message in the top left of everyone's screen (including yours). |
50+
| restart | Stops the server. |
51+
| speed \<speed multiplier> | Changes your speed. |
52+
| weaponVariant \<ruby/gold/diamond/normal> [player id (defaults to yourself)] | Changes the variant of the currently selected weapon of the player. |
53+
| login \<password> | See [Password Login System](#password-login-system) |
54+
55+
Commands can be called from the terminal that Sanctuary is run from, and from chat.
56+
57+
While Sanctuary doesn't enforce this with chat commands, with the normal MooMoo.io client, chat has a 15 character limit.
58+
When called from chat, commands must be prefixed with a `/` (slash) to differentiate them from normal chat.
59+
60+
The player ID can be found from the API, or by the number beside the player's name.
61+
62+
## Password Login System
63+
Sanctuary provides an additional login system for cases where not all moderators can be fully trusted. In this scheme, a password is used. The password is set with the environment variable `MODERATOR_PASSWORD`.
64+
Admins utilize the `/login` command to log in. A major problem with this system's current implementation is that these temporary "admins" are able to use `/promote` to become permanent admins, so this system is not quite ready for production.
65+
66+
## REST API
67+
Sanctuary implements a rudimentary REST API, with only two endpoints:
68+
### `/api/v1/players`
69+
Lists the currently connected clients. Output takes the following format (as a TypeScript type):
70+
```ts
71+
{
72+
'type': 'success' | 'error',
73+
'clients': { playerName: string = 'unknown', playerID: number = -1, clientIPHash: string }[] | undefined,
74+
'message': string | undefined
75+
}
76+
```
77+
78+
### `/api/v1/playerCount`
79+
Reports the amount of currently connected clients. Output takes the following format (as a TypeScript type):
80+
```ts
81+
{
82+
'type': 'success' | 'error',
83+
'playerCount': number | undefined,
84+
'message': string | undefined
85+
}
86+
```

docs/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
_site
2+
.sass-cache
3+
.jekyll-metadata

src/items/items.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ const Weapons = {
3838
type Weapons = PrimaryWeapons | SecondaryWeapons
3939

4040
function getHitTime(weapon: Weapons) {
41-
return weapons[weapon].speed || -1;
41+
let speed = weapons[weapon].speed || -1;
42+
if (speed != -1) speed += 150;
43+
return speed;
4244
}
4345

4446
function isRangedWeapon(weapon: Weapons) {

src/moomoo/Game.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,8 @@ export default class Game {
645645
player.lastDot = now;
646646
}
647647

648-
if (
649-
player.isAttacking &&
650-
player.selectedWeapon != Weapons.Shield &&
651-
player.buildItem == -1
652-
) {
653-
if (now - player.lastHitTime >= player.getWeaponHitTime() + 120) {
648+
if (player.isAttacking && player.selectedWeapon != Weapons.Shield && player.buildItem == -1) {
649+
if (now - player.lastHitTime >= player.getWeaponHitTime()) {
654650
player.lastHitTime = now;
655651

656652
if (isRangedWeapon(player.selectedWeapon)) {
@@ -929,9 +925,12 @@ export default class Game {
929925
* A manual attack
930926
* @param player the player doing the attacking
931927
*/
932-
normalAttack(player: Player) {
928+
normalAttack(player: Player, angle: number | undefined) {
929+
player.angle = angle || player.angle;
930+
933931
if (player.buildItem != -1) {
934-
let item = player.buildItem;
932+
let item = player.buildItem;
933+
935934
if (player.useItem(item, this.state, this.getNextGameObjectID())) {
936935
if (getPlaceable(item)) {
937936
player
@@ -1152,7 +1151,7 @@ export default class Game {
11521151

11531152
client.lastAttackTime = Date.now();
11541153

1155-
this.normalAttack(client.player);
1154+
this.normalAttack(client.player, packet.data[1]);
11561155
} else {
11571156
client.player.isAttacking = false;
11581157
}

src/moomoo/Physics.ts

+21-4
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ function collideRectangles(x1: number, y1: number, w1: number, x2: number, y2: n
2121
}
2222

2323
function moveTowards(player: Player, angle: number, speed: number, deltaTime: number, state: GameState) {
24-
tryMovePlayer(player,
25-
deltaTime / 170,
26-
Math.cos(angle) * speed * 60, Math.sin(angle) * speed * 60,
24+
/* tryMovePlayer(player,
25+
deltaTime,
26+
Math.cos(angle) * speed * 0.1528, Math.sin(angle) * speed * 0.1528,
2727
state
28-
);
28+
); */
29+
player.velocity.add(Math.cos(angle) * speed * .0016 * deltaTime, Math.sin(angle) * speed * .0016 * deltaTime);
2930
}
3031

3132
/**
@@ -123,6 +124,21 @@ function tryMovePlayer(player: Player, delta: number, xVel: number, yVel: number
123124
player.inTrap = inTrap;
124125
if (inTrap) return;
125126

127+
// River
128+
if (player.location.y > 6850 && player.location.y < 7550) {
129+
if (getHat(player.hatID)?.watrImm) {
130+
xVel *= .75;
131+
yVel *= .75;
132+
133+
player.velocity.add(0.0011 * 0.4 * delta * (1 / .75), 0);
134+
} else {
135+
xVel *= .33;
136+
yVel *= .33;
137+
138+
player.velocity.add(0.0011 * delta * (1 / .33), 0);
139+
}
140+
}
141+
126142
newLocation.clamp(new Vec2(0 + 35, 0 + 35), new Vec2(14400 - 35, 14400 - 35));
127143
player.location = newLocation.add(delta * xVel, delta * yVel);
128144
}
@@ -133,6 +149,7 @@ function movePlayer(player: Player, delta: number, state: GameState) {
133149
if (player.velocity.x || player.velocity.y) {
134150
player.velocity = player.velocity.multiply(0.993 ** delta, 0.993 ** delta);
135151
}
152+
136153
for (let p of player.getNearbyPlayers(state)) {
137154
if (collideCircles(p.location, 30, player.location, 30)) {
138155
let dis = player.location.distance(p.location);

0 commit comments

Comments
 (0)