-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/python3 | ||
|
||
import argparse | ||
import sqlite3 | ||
import sys | ||
|
||
def _create_parser(): | ||
parser = argparse.ArgumentParser(description='Edit your 1.11p MMUD character in MBBSEmu.') | ||
parser.add_argument('--username', help='Username to edit', required=True) | ||
parser.add_argument('--experience', help='Experience value to set', type=int) | ||
|
||
return parser.parse_args() | ||
|
||
def _main(): | ||
args = _create_parser() | ||
|
||
conn = sqlite3.connect('WCCUSERS.DB') | ||
|
||
c = conn.cursor() | ||
t = (args.username,) | ||
c.execute('SELECT data FROM data_t WHERE key_0=?', t) | ||
|
||
data = c.fetchone() | ||
if data is None: | ||
print('Username not found in WCCUSERS.DB') | ||
return | ||
|
||
b = bytearray(data[0]) | ||
|
||
#exp | ||
if args.experience is not None: | ||
#print('Experience is {}'.format(args.experience)) | ||
b[0x46F] = args.experience & 0xFF # low byte is validated | ||
b[0x470] = ((args.experience >> 8) & 0xFF) | ||
b[0x471] = ((args.experience >> 16) & 0xFF) | ||
b[0x472] = ((args.experience >> 24) & 0xFF) | ||
|
||
# copper farthings (32-bit int) low-byte @ 0x60F | ||
# silver low-byte @ 0x60B | ||
# gold low-byte @ 0x607 | ||
# platinum low-byte @ 0x603 | ||
# runic low-byte @ 0x5FF | ||
|
||
# and write it back | ||
t = (sqlite3.Binary(b), args.username,) | ||
c = conn.cursor() | ||
c.execute('UPDATE data_t SET data=? WHERE key_0=?', t) | ||
conn.commit() | ||
|
||
if __name__ == '__main__': | ||
_main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Helper Scripts | ||
|
||
MBBSEmu includes various scripts to help maintain your configuration. | ||
|
||
## mmud_edit.py | ||
|
||
**mmud_edit.py** is a [Python3](http://www.python.org) script to edit player data from within **WCCUSERS.DB**. It supports MajorMUD 1.11p and should not be used with any other versions. It should be run when your system is offline because it won't be able to access the sqlite3 database at the same time as MBBSEmu. | ||
|
||
### Usage | ||
|
||
``` | ||
mmud_edit.py --username=USERNAME [--experience=EXPERIENCE] | ||
``` | ||
|
||
> **Note:** **mmud_edit.py** should be run from the same directory that **WCCUSERS.DB** resides. | ||