Skip to content

Commit b27f285

Browse files
authored
Merge pull request #28 from cthill/release_1.4
Release 1.4
2 parents b4f2ba3 + 6c9de98 commit b27f285

File tree

20 files changed

+731
-448
lines changed

20 files changed

+731
-448
lines changed

docs/commands.md

Lines changed: 83 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,86 @@
1-
# Admin Commands
2-
Invoke admin commands by typing `!` followed by the command name in the chat box.
1+
# In Game Commands
2+
Invoke commands by typing `!` followed by the command name in the chat box. Access to commands is granted by using the player's admin_level as a bitmask.
33

4-
Available commands:
4+
### Available commands:
55

6-
Name | Usage | Example | Description | Admin Required
6+
Name | Usage | Example | Description | Command Group
77
---|---|---|---|---
8-
`help`|`!help [cmd_name]`|`!help item`| Show list of commands or usage of a given command.|No
9-
`item`|`!item <item_id>`|`!item 23`| Obtain an item of a given item_id. Item is added to inventory on disconnect.|No
10-
`level`|`!level <level>`|`!level 10`|Set level to given value. Will reset stats and disconnect player.|No
11-
`godmode`|`!godmode`|`!godmode`| Toggle god mode.|No
12-
`setspawn`|`!setspawn <location_num>`|`!setspawn 1`|Set spawn point to given location (1 to 8). Will disconnect player.|No
13-
`spawn`|`!spawn <mob_id> [amount]`|`!spawn 0 10`| Spawn a mob of a given mob_id. The amount parameter is optional.|Yes
14-
`spawnall`|`spawnall [amount]`|`!spawnall`| Spawn all mobs in the game.|Yes
15-
`hurt`|`!hurt`|`!hurt`| Set all nearby mobs to 1 HP.|Yes
16-
`hurtall`|`!hurtall`|`!hurtall`| Set all mobs in the world to 1 HP.|Yes
17-
`kill`|`!kill`|`!kill`| Kill all nearby mobs.|Yes
18-
`killall`|`!killall`|`!killall`| Kill all mobs in the world.|Yes
19-
`kick`|`!kick <name>`|`!kick user1`| Kick a player.|Yes
20-
`ban`|`!ban <name>`|`!ban user1`| Ban a player.|Yes
21-
`unban`|`!unban <name>`|`!unban user1`| Unban a player.|Yes
22-
`setadmin`|`!setadmin <name> <true false>`|`!setadmin user1 true`| Grant or revoke admin access. This will disconnect the target user.|Yes
8+
`help`|`!help [cmd_name]`|`!help item`| Show list of commands or usage of a given command.| Unrestricted
9+
`setspawn`|`!setspawn <location_num>`|`!setspawn 1`|Set spawn point to given location (1 to 8). Will disconnect player.|All
10+
`statreset`|`!statreset`|`!statreset`|Reset all stats. Will disconnect player.|All
11+
`item`|`!item <item_id>`|`!item 23`| Obtain an item of a given item_id. Item is added to inventory on disconnect.|Group 1
12+
`godmode`|`!godmode`|`!godmode`| Toggle god mode.|Group 1
13+
`level`|`!level <level>`|`!level 10`|Set level to given value. Will reset stats and disconnect player.|Group 2
14+
`spawn`|`!spawn <mob_id> [amount]`|`!spawn 0 10`| Spawn a mob of a given mob_id. The amount parameter is optional.|Group 3
15+
`spawnall`|`spawnall [amount]`|`!spawnall`| Spawn all mobs in the game.|Group 3
16+
`hurt`|`!hurt`|`!hurt`| Set all nearby mobs to 1 HP.|Group 3
17+
`kill`|`!kill`|`!kill`| Kill all nearby mobs.|Group 3
18+
`hurtall`|`!hurtall`|`!hurtall`| Set all mobs in the world to 1 HP.|Group 4
19+
`killall`|`!killall`|`!killall`| Kill all mobs in the world.|Group 4
20+
`kick`|`!kick <name>`|`!kick user1`| Kick a player.|Group 5
21+
`ban`|`!ban <name>`|`!ban user1`| Ban a player.|Group 5
22+
`unban`|`!unban <name>`|`!unban user1`| Unban a player.|Group 5
23+
`setadmin`|`!setadmin <name> <admin_level>`|`!setadmin user1 190`| Grant or revoke admin access. This will disconnect the target user.|Admin
24+
25+
### Groups and Bitmasks
26+
27+
Access to commands is granted using the player's admin_level (class) as a bitmask.
28+
The admin_level is a byte with 2 unused bits, thus allowing for 6 commands groups.
29+
30+
```text
31+
bit 0 = unused
32+
bit 1 = group 1 commands
33+
bit 2 = unused
34+
bit 3 = group 2 commands
35+
bit 4 = group 3 commands
36+
bit 5 = group 4 commands
37+
bit 6 = group 5 commands
38+
bit 7 = admin commands
39+
```
40+
41+
```python
42+
BITMASK_ALL = 0b00000000
43+
BITMASK_NONE = 0b00000101
44+
BITMASK_GROUP_1 = 0b00000010
45+
BITMASK_GROUP_2 = 0b00001000
46+
BITMASK_GROUP_3 = 0b00010000
47+
BITMASK_GROUP_4 = 0b00100000
48+
BITMASK_GROUP_5 = 0b01000000
49+
BITMASK_ADMIN = 0b10000000
50+
```
51+
52+
Admin Level | Unrestricted Commands | Group 1 | Group 2 | Group 3 | Group 4 | Group 5 | Admin Commands
53+
---|---|---|---|---|---|---|---
54+
0|✔️|-|-|-|-|-|-
55+
2|✔️|✔️|-|-|-|-|-
56+
8|✔️|-|✔️|-|-|-|-
57+
10|✔️|✔️|✔️|-|-|-|-
58+
16|✔️|-|-|✔️|-|-|-
59+
18|✔️|✔️|-|✔️|-|-|-
60+
24|✔️|-|✔️|✔️|-|-|-
61+
26|✔️|✔️|✔️|✔️|-|-|-
62+
32|✔️|-|-|-|✔️|-|-
63+
34|✔️|✔️|-|-|✔️|-|-
64+
40|✔️|-|✔️|-|✔️|-|-
65+
42|✔️|✔️|✔️|-|✔️|-|-
66+
48|✔️|-|-|✔️|✔️|-|-
67+
50|✔️|✔️|-|✔️|✔️|-|-
68+
56|✔️|-|✔️|✔️|✔️|-|-
69+
58|✔️|✔️|✔️|✔️|✔️|-|-
70+
64|✔️|-|-|-|-|✔️|-
71+
66|✔️|✔️|-|-|-|✔️|-
72+
72|✔️|-|✔️|-|-|✔️|-
73+
74|✔️|✔️|✔️|-|-|✔️|-
74+
80|✔️|-|-|✔️|-|✔️|-
75+
82|✔️|✔️|-|✔️|-|✔️|-
76+
88|✔️|-|✔️|✔️|-|✔️|-
77+
90|✔️|✔️|✔️|✔️|-|✔️|-
78+
96|✔️|-|-|-|✔️|✔️|-
79+
98|✔️|✔️|-|-|✔️|✔️|-
80+
104|✔️|-|✔️|-|✔️|✔️|-
81+
106|✔️|✔️|✔️|-|✔️|✔️|-
82+
112|✔️|-|-|✔️|✔️|✔️|-
83+
114|✔️|✔️|-|✔️|✔️|✔️|-
84+
120|✔️|-|✔️|✔️|✔️|✔️|-
85+
122|✔️|✔️|✔️|✔️|✔️|✔️|-
86+
250|✔️|✔️|✔️|✔️|✔️|✔️|✔️

docs/mobs.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# ID's of game mobs:
2+
0. Blob
3+
1. Rock Demon
4+
2. Big Blob Boss
5+
3. Bandit
6+
4. Gift Box
7+
5. Bunny
8+
6. Easter Egg
9+
7. Bonehead
10+
8. Sand Fiend
11+
9. Cacti
12+
10. Dark Sage
13+
11. Black Bunny
14+
12. Rock Beast
15+
13. Jacko Fiend
16+
14. Ghost
17+
15. Deluxe Gift Box
18+
16. Sand Fiend
19+
17. Bandit Assassin
20+
18. Snowman

server/config.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
"ingame_motd": "Welcome to LocalSO! Current rates are 2x spawn rate and 2x player damage.",
1313
"menu_motd": "Welcome to LocalSO! Current rates are 2x spawn rate and 2x player damage.",
1414

15+
"non_admin_max_mob_spawn": 25,
16+
1517
"register_closed": false,
1618
"sqlite_db_file": "data/stickonline.db",
1719
"sqlite_db_init_file": "data/init.sql",

server/cradle.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
until python src/main.py;
4+
do
5+
echo "Cradle: non-zero exit code..."
6+
while [[ $(netstat --inet -natp | grep ":3104\|:3105" | grep "TIME_WAIT") ]]; do
7+
echo "Cradle: waiting for socket close..."
8+
sleep 5
9+
done
10+
echo "Cradle: restarting server..."
11+
done

server/data/mob_spawn.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868
{
6969
"mob_type": 3,
7070
"special_spawn_type": 17,
71-
"special_spawn_chance": 45,
72-
"max_of_type": 10,
71+
"special_spawn_chance": 245,
72+
"max_of_type": 5,
7373
"base_interval": 950,
7474
"random_interval": 225,
7575
"x_min": 25424,
@@ -79,7 +79,7 @@
7979
{
8080
"mob_type": 3,
8181
"special_spawn_type": 17,
82-
"special_spawn_chance": 45,
82+
"special_spawn_chance": 245,
8383
"max_of_type": 5,
8484
"base_interval": 950,
8585
"random_interval": 225,

server/src/client/client.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def __init__(self, game_server, world, socket, id, client_data):
5959
self.add_items_on_disconnect = LockList()
6060
self.set_stats_on_disconnect = None
6161
self.set_spawn_x_on_disconnect = None
62+
self.reset_stats_on_disconnect = None
6263

6364
def send_tcp_message(self, data):
6465
self.send_mail_message(mail_header.MSG_CLIENT_SEND_TCP, data)
@@ -176,6 +177,10 @@ def _post_disconnect_event(self):
176177
self.logger.info('setting spawn_x %s' % self.set_spawn_x_on_disconnect)
177178
self.game_server.stick_online_server.db.set_spawn_x(self.id, self.set_spawn_x_on_disconnect)
178179

180+
if self.reset_stats_on_disconnect:
181+
self.logger.info('resetting stats')
182+
self.game_server.stick_online_server.db.reset_stats(self.id)
183+
179184
def disconnect(self):
180185
self.terminated = True
181186
try:
@@ -256,7 +261,7 @@ def _handle_packet(self, data):
256261
chat_type = read_byte(data, offset)
257262

258263
if message.strip().startswith('!'):
259-
command.handle_admin_command(self, message)
264+
command.process_command(self, message)
260265
return
261266

262267
buff = [packet.RESP_CHAT]
@@ -321,7 +326,7 @@ def _handle_packet(self, data):
321326
x = read_uint(data, 5) / 10.0
322327
y = read_short(data, 9) / 10.0
323328
# self.logger.info('Client %s wants to spawn %s at (%s,%s)' % (self, mob_type, x, y))
324-
self.world.send_mail_message(mail_header.MSG_ADD_MOB, (mob_type, x, y, None, self.world))
329+
self.world.send_mail_message(mail_header.MSG_ADD_MOB, (mob_type, x, y, self.get_mob_spawn(), self.world))
325330

326331
elif header == packet.MSG_LEVEL_UP:
327332
new_level = read_byte(data, 2)
@@ -357,6 +362,16 @@ def update_position(self, x, y):
357362
self.x = x
358363
self.y = y
359364

365+
if self.x < 0:
366+
self.x = 0
367+
elif self.x >= config.WORLD_WIDTH:
368+
self.x = config.WORLD_WIDTH - 1
369+
370+
if self.y < 0:
371+
self.y = 0
372+
elif self.y - config.PLAYER_OFFSET_Y > config.WORLD_HEIGHT + 300:
373+
self.y = config.PLAYER_OFFSET_Y + config.WORLD_HEIGHT + 300
374+
360375
old_section = self.section
361376
new_section = self.world.find_section_index(int(round(x)))
362377

@@ -376,6 +391,8 @@ def interpolate_state(self):
376391
self.x += self.x_speed
377392
self.y += self.y_speed
378393

394+
self.update_position(self.x, self.y)
395+
379396
bbox = self.get_bbox()
380397
touching = self.world.get_solid_blocks_at(bbox)
381398

@@ -412,6 +429,9 @@ def kick_with_reason(self, reason):
412429
self.send_tcp_message(buff)
413430
scheduler.schedule_event(self.disconnect, 5)
414431

432+
def get_mob_spawn(self):
433+
return self.world.get_client_mob_spawn(self)
434+
415435
def handle_udp_packet(self, data):
416436
self.last_recv_timestamp = datetime.now()
417437

0 commit comments

Comments
 (0)