Compare commits

...

32 Commits

Author SHA1 Message Date
Ponk
df0c7f8b46 Merge pull request #232 from P0nk/cleanup/remove-buyback #minor
Remove custom sounds in Sound.wz, add devtest command
2024-05-21 22:54:59 +02:00
P0nk
9fe6ba4483 Add new wz files zip (reduced size by ~400mb)
Removed: Base.wz, Effect.wz, Morph.wz, Sound.wz, TamingMob.wz
2024-05-21 22:47:47 +02:00
P0nk
dee8651e61 Add DevtestCommand to easily test without restarting server 2024-05-21 21:36:54 +02:00
P0nk
948a9de667 Remove Spirit of Rock die sound 2024-05-21 20:23:34 +02:00
P0nk
d55437ddf3 Remove subway whistle 2024-05-21 19:56:09 +02:00
P0nk
98fd8c13d4 Remove brazil anthem 2024-05-21 19:54:30 +02:00
P0nk
04a92fe0c1 Remove buyback custom feature 2024-05-21 19:44:25 +02:00
Ponk
5754b60ca0 Merge pull request #231 from P0nk/feat/project-update #minor
Upgrade Java version and dependencies
2024-05-10 22:29:51 +02:00
P0nk
dc1a712f52 Re-add section about running from jar 2024-05-10 22:26:04 +02:00
P0nk
7a6d3e1b68 Add feature request issue template 2024-05-10 21:29:09 +02:00
P0nk
970fb3155f Complement pom.xml 2024-05-09 22:29:15 +02:00
P0nk
0eb78e2d9e Use root db user by default 2024-05-09 22:08:28 +02:00
P0nk
7d42870abd Fix sql script not being runnable on newer versions of MySQL 2024-05-09 21:26:09 +02:00
P0nk
c7b9e0eee3 Major rewrite of README 2024-05-09 21:11:53 +02:00
P0nk
c5089881b3 Tidy pom
mvn tidy:pom
2024-05-09 14:24:03 +02:00
P0nk
9c1406f75d Update pull request template 2024-05-09 12:33:50 +02:00
P0nk
92226483be Merge branch 'refs/heads/master' into feat/project-update 2024-05-09 12:30:14 +02:00
Ponk
21ecfeef17 Add pull request template 2024-05-09 12:20:08 +02:00
Ponk
d5be9130aa Add bug report issue template 2024-05-09 11:53:54 +02:00
P0nk
f61fee829a Upgrade Java version and dependencies 2024-05-09 11:45:16 +02:00
Ponk
b5871c7be2 Merge pull request #219 from Silwhoon/mobskill-prop-handling #patch
Mob Skills now have a success rate
2024-02-07 06:49:24 +01:00
Silwhoon
f9b328b432 Mob Skills now have a success rate
This was only used for MAGIC_IMMUNITY and WEAPON_IMMUNITY for some reason? A lot of other MobSkills also have a 'prop' node in the WZ files such as; Darkness and Seduce
2024-02-05 17:58:43 +00:00
Ponk
830df4e5ca Merge pull request #218 from Silwhoon/makecharinfo #minor
Utilize the MakeCharInfo.img data in the WZ files
2024-02-05 18:09:12 +01:00
Silwhoon
6f68f4edfd Addressed nitpicks and removed unused item ID constants 2024-02-05 17:00:18 +00:00
Silwhoon
a7931c3e4d New characters now utilise the MakeCharInfo.img data in the WZ files 2024-02-05 16:03:41 +00:00
Ponk
799cb97564 Merge pull request #217 from P0nk/fix/210-clean-slate-scroll #minor
Fix able to gain infinite slots with clean slate scroll
2024-02-05 08:39:25 +01:00
P0nk
851b57e8ef Fix able to gain infinite slots with clean slate scroll
And remove a GM config option.
Thanks Crabo for the suggested solution.
2024-02-05 08:34:36 +01:00
Ponk
ceb2866aa1 Merge pull request #214 from leevccc/master #patch
fix: item lock cant extend lock time
2024-02-04 14:22:00 +01:00
Ponk
11c1e4655e Merge pull request #213 from yuzumika/ppq-npc-fix #patch
Fix bug in PPQ where non-party leader can get stuck in an NPC dialogue loop
2024-02-04 12:09:33 +01:00
leevccc
08b089d9be fix: seal lock cant extend lock time 2024-01-14 22:13:16 +08:00
leevccc
8b254a294e fix: item lock cant extend lock time 2024-01-14 18:15:48 +08:00
yuzumika
7004de6e71 ppq: fix bug where non-party leader can get stuck in an npc dialogue loop 2024-01-04 14:30:59 -08:00
38 changed files with 1034 additions and 884 deletions

23
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,23 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
---
**Describe the bug**
A clear and concise description of what the bug is.
**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. See error
**Expected behavior**
A clear and concise description of what you expected to happen.
**Screenshots**
If applicable, add screenshots to help explain your problem.

View File

@@ -0,0 +1,15 @@
---
name: Feature request
about: Suggest an idea for this project, such as a missing gameplay feature
title: ''
labels: ''
assignees: ''
---
**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
**Describe the solution you'd like**
A clear and concise description of what you want to happen.

11
.github/pull_request_template.md vendored Normal file
View File

@@ -0,0 +1,11 @@
## Description
<!-- Describe your changes in detail -->
## Checklist before requesting a review
<!-- Mark with "x" inside the square brackets -->
- [ ] I have performed a self-review of my code
- [ ] I have tested my changes
- [ ] I have added unit tests that prove my changes work
## Screenshots
<!-- If applicable, add screenshots to help explain your changes -->

View File

@@ -11,10 +11,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
java-version: '21'
distribution: 'corretto'
- name: Build with Maven (compile -> test -> package)
run: mvn -B package --file pom.xml

View File

@@ -4,15 +4,21 @@
#
# Cosmic JAR creation stage
#
FROM maven:3.9.1-eclipse-temurin-17 AS jar
FROM maven:3.9.6-amazoncorretto-21 AS jar
# Build in a separated location which won't have permissions issues.
WORKDIR /opt/cosmic
# Any changes to the pom will affect the entire build, so it should be copied first.
COPY pom.xml ./pom.xml
# Grab all the dependencies listed in the pom early, since it prevents changes to source code from requiring a complete re-download.
# Skip compiling tests since we don't want all the dependecies to be downloaded.
RUN mvn -f ./pom.xml clean dependency:go-offline -Dmaven.test.skip -T 1C
# Skip compiling tests since we don't want all the dependencies to be downloaded.
# RUN mvn -f ./pom.xml clean dependency:go-offline -Dmaven.test.skip -T 1C
# TODO: The above command stopped working as of Java 21 upgrade due to:
# Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:3.6.1:go-offline (default-cli) on project Cosmic: org.eclipse.aether.resolution.DependencyResolutionException: The following artifacts could
# not be resolved: io.netty:netty-tcnative:jar:${os.detected.classifier}:2.0.65.Final (absent): Could not find artifact io.netty:netty-tcnative:jar:${os.detected.classifier}:2.0.65.Final in central (https://repo.maven.apache.org/maven2) -> [Help 1]
# Source code changes may not change dependencies, so it can go last.
# Skip compiling tests since we don't want all the dependecies to be downloaded for plugins.
COPY src ./src
@@ -21,7 +27,7 @@ RUN mvn -f ./pom.xml clean package -Dmaven.test.skip -T 1C
#
# Server creation stage
#
FROM eclipse-temurin:17.0.6_10-jre
FROM amazoncorretto:21
# Host the server in a location that won't have permissions issues.
WORKDIR /opt/server

364
README.md
View File

@@ -1,303 +1,181 @@
# Cosmic - MapleStory v83 server
# Cosmic
Cosmic is a server emulator for Global MapleStory (GMS) version 83.
## Introduction
Cosmic launched as a successor to HeavenMS on March 21st 2021.
HeavenMS is archived, ie. it receives no further updates. This project aims to continue its development; mainly by improving code quality and make getting into PS development as easy as possible.
Cosmic launched on March 2021. It is based on code from a long line of server emulators spanning over a decade - starting with OdinMS (2008) and ending with HeavenMS (2019).
This is an open source project. Anyone may contribute by opening a pull request.
This is mainly a Java based project, but there are also a bunch of scripts written in JavaScript.
Only the server side is maintained. The client is directly copied from HeavenMS.
Head developer and maintainer: __Ponk__.\
Contributors: a lot of people over the years, and hopefully more to come. Big thanks to everyone who has contributed so far!
Join the Discord server where most of the discussions take place: https://discord.gg/JU5aQapVZK
Beware - ***This server emulator is not production ready.***
It can be useful for testing things locally or for trying out ideas, but launching a new private server based on this and opening it up to the public
without knowing what you're doing is not recommended.
### Goals
What we are working towards.
* __Vanilla gameplay__ - stay as close to the original game as possible (within reason).
* __Ease of use__ - getting started should be frictionless and contributing to the project straightforward.
* __Reduce technical debt__ - making changes should be easy without causing unintended side effects.
* __Modern tools & technologies__ - stay appealing by continuously improving the code and the project as a whole.
### Non-goals
Explicitly excluded from the scope of the project.
* __Custom gameplay features__ - existing custom features will be removed over time and new ones are unlikely to be added.
* __Client development__ - this project is focused on the server. Please go elsewhere for client related questions.
* __Public server__ - there will not be an official Cosmic server open to the public. Feel free to launch your own server __at your own risk__. No support will be provided.
## Development information
## Project setup
### Status (updated 2022-10-16)
### Contribute
You may contribute to the project in various ways, mainly through GitHub:
* Providing improvements to the code through a [Pull Request](https://github.com/P0nk/Cosmic/pulls) from your own fork.
* Reporting a bug by creating an [Issue](https://github.com/P0nk/Cosmic/issues).
* Providing information to existing issues or reviewing pull requests that others have made.
* ...and in other ways that I haven't thought of!
Development is currently <span style="color:Yellow">**sporadic**</span>.
### Continuous integration
A GitHub Actions pipeline is set up to run the build automatically when a new pull request is opened or commits are pushed to an existing one. This ensures that the code compiles and all the tests pass.
My time is very limited nowadays, but I try to keep up with the submitted pull requests. I may submit some stuff of my own, once in a while.
Once a pull request is merged, a tag with the new version is automatically created.
### Ways to contribute
* Submit a Pull Request (fork -> commit -> PR). If you don't know where to start, have a look at the issues on GitHub.
* Report a bug (preferably as an Issue on GitHub, as reports on Discord may be forgotten or lost)
* Spread the word about Cosmic
### Working with GitHub
Anyone with a GitHub account can contribute by making some changes in a branch and opening up a PR.
All activity on the GitHub repo (opening PR, commenting, creating issue, etc.) is automatically pushed (via webhook) to a public Discord channel for visibility.
Issues is the main place where bugs, issues or general improvements are tracked. Feel free to submit a new issue, but please keep it in English. By providing a good description, you increase the chance of a bug being fixed.
Tasks (past, present and future) are kept in the Cosmic project, which you get to via the "Projects" tab. This gives you an idea of where the project is moving.
### Discord integration
Most GitHub activity is pushed to a Discord channel for visibility. This works by leveraging a webhook. The activity includes (but is not limited to): merged commits, created PRs, comments, and new tags.
### Versioning
The project follows the [SemVer](https://semver.org/) versioning scheme using git tags.
As a pull request gets merged, a new version is automatically created.
Bug fixes result in bumped patch version: 1.2.__3__ -> 1.2.__4__
General improvements result in bumped minor version: 1.__2__.3 -> 1.__3__.3
Major changes result in bumped major version: __1__.2.3 -> __2__.2.3
### Cosmic
- GitHub: https://github.com/P0nk/Cosmic
- Discord: https://discord.gg/JU5aQapVZK
### HeavenMS
- GitHub: https://github.com/ronancpl/HeavenMS
- Discord: https://discord.gg/Q7wKxHX
## Tools / downloads
* **Java 17 SDK** - Needed to compile and run Java code. Install manually or through IntelliJ depending on how you prefer to launch the server. Not required for launching with Docker.
* Link: https://jdk.java.net/17/
* **IntelliJ IDEA** - Java IDE and your main tool for working with the source code. Community edition is good enough.
* Link: https://www.jetbrains.com/idea/
* **MySQL Community Server 8** - Database for game data.
* Link: https://dev.mysql.com/downloads/mysql/
* **MySQL Workbench 8** - Client for interacting with the database. Other clients do exist.
* Link: https://dev.mysql.com/downloads/workbench/
* **Docker Desktop** (optional) - For launching the game locally with less hassle.
* Link: https://www.docker.com/products/docker-desktop
* **Client files and general tools**
* Link: https://drive.google.com/drive/folders/1hgnb92MGL6xqEp9szEMBh0K9pSJcJ6IT?usp=sharing
* This is Ponk's own Google Drive, similar to how Ronan provides files for HeavenMS.
### MapleStory client
- Latest localhost client: https://hostr.co/amuX5SLeeVZx
**Important note about localhost clients**: these executables are red-flagged by antivirus tools as __potentially malicious software__,
this happens due to the reverse engineering methods that were applied onto these software artifacts.
Those depicted here have been put to use for years already and posed no harm so far, so they are soundly assumed to be safe.
The project follows the [semantic versioning](https://semver.org/) scheme using git tags.
* *Bug fixes* are treated as PATCH: 1.2.__3__ -> 1.2.__4__
* *General changes or improvements* are treated as MINOR: 1.__2__.3 -> 1.__3.0__
* *Major changes* are treated as MAJOR: __1__.2.3 -> __2.0.0__
## Getting started
The localhost MapleStory client needs to be installed, as well as the server that will host the game.
Follow along as I go through the steps to play the game on your local computer from start to finish. I won't go into extreme detail, so if you don't have prior experience with Java or git, you might struggle.
### Installing the client
We will set up the following:
- Database - the database is used by the server to store game data such as accounts, characters and inventory items.
- Server - the server is the "brain" and routes network traffic between the clients.
- Client - the client is the application used to _play the game_, i.e. MapleStory.exe.
1. Install MapleStory with "MapleGlobal-v83-setup.exe" in your folder of choice (e.g. "C:\Nexon\MapleStory") and follow their instructions.
2. Once done, erase these files: "HShield" (folder), "ASPLnchr.exe", "MapleStory.exe" and "Patcher.exe".
3. Extract into the client folder the "HeavenMS-localhost-WINDOW.exe" (from now on referred to as "localhost.exe") from the provided link.
4. Overwrite the original WZ files with the ones provided on the Google Drive: "CosmicWZ-v1-2021.05.10.zip"
- This is currently identical to the latest HeavenMS WZ files (except for the file name): "commit397_wz-20210321T173600Z-001.zip"
### 1 - Database
You will start by installing the database server and client, and then run some scripts to prepare it for the server.
#### Editing localhost IP target
#### Steps
If you are not using "localhost" as the target IP on the server's config file, you will need to HEX-EDIT localhost.exe to fetch your IP. Track down all IP locations by searching for "Type: String" "127.0.0.1", and applying the changes wherever it fits.
1. Download and install [MySQL Community Server 8+](https://dev.mysql.com/downloads/mysql/). You will have to set a root password, make sure you don't lose it because you will need it later.
2. Download and install [HeidiSQL](https://www.heidisql.com/download.php).
3. Open HeidiSQL and connect to the database ("New" -> "Session in root folder" -> fill in password -> "Open").
4. Run all four scripts located in database/sql in order. Starting with ``1-db_database.sql`` and ending with ``4-db-admin.sql``. In HeidiSQL: "File" -> "Run SQL File...".
5. The database is ready!
To hex-edit, install the Neo Hex Editor from "free-hex-editor-neo.exe" and follow their instructions. Once done, open localhost.exe for editing and overwrite the IP values under the 3 addresses. Save the changes and exit the editor.
### 2 - Server
You will start by cloning the repository, then configure the database properties and lastly start the server.
(TODO: find suitable alternative to Neo Hex Editor)
#### Prerequisites
* Java 21+ (I recommend [Amazon Corretto](https://aws.amazon.com/corretto))
* IDE (I recommend [IntelliJ IDEA](https://www.jetbrains.com/idea/))
#### Testing the localhost
#### Steps
Open the "localhost.exe" client.
If by any means the program did not open, and checking the server log your ping has been listened by the server
and you are using Windows 8, 10 or 11, it is probably some compatibility issue.
1. Clone Cosmic into a new project. In IntelliJ, you would create a new project from version control.
2. Open _config.yaml_. Find "DB_PASS" and set it to your database root user password.
3. Start the server. The main method is located in `net.server.Server`.
4. If you see "Cosmic is now online" in the console, it means the server is online and ready to serve traffic. Yay!
In some cases it helps to spam click the exe a few times (2-3 times usually works for me on W10).
Below, I list other ways of running the server which are completely optional.
In that case, extract "lolwut.exe" from "lolwut-v0.01.rar" and place it on the MapleStory client folder ("C:\Nexon\MapleStory").
Your "localhost.exe" property settings must follow these:
#### Docker
Support for Docker is also provided out of the box, as an alternative to running straight in the IDE. If you have [Docker Desktop](https://www.docker.com/products/docker-desktop/) installed it's as easy as running `docker compose up`.
Note: "lolwut.exe" is currently not available in the Google Drive.
Making changes becomes a bit more tedious though as you have to rebuild the server image via `docker compose up --build`.
* Run in compatibility mode: Windows 7;
* Unchecked reduced color mode;
* 640 x 480 resolution;
* Unchecked disable display on high DPI settings;
* Run as an administrator;
* Opening "lolwut.exe", use Fraysa's method.
On the first launch, the database container will run the scripts which may take so long that the server fails to start. In that case, just wait until the database is done running the scripts and then retry (Ctrl+C and re-run the command).
Important: should the client be refused a connection to the game server, it may be because of firewall issues. Head to the end of this file to proceed in allowing this connection through the computer's firewall. Alternatively, one can deactivate the firewall and try opening the client again.
You can also search the server logs (/logs/cosmic-log.log) if any connection attempts have been made to ease debugging.
#### Jar
Another option is to start the server from a terminal by running a jar file. You first need to build the jar file from source which requires [Maven](https://maven.apache.org/).
---
### Installing the server
1. Configure the project
2. Set up the database
3. Launch the server
Building the jar file is as easy as running ``mvn clean package``. The project is configured to produce a "fat" jar which contains all dependencies (by utilizing the _maven-assembly-plugin_). Note that the WZ XML files are __not__ included in the jar.
If you are using Docker (quick start):
1. Configure the project
2. Launch the server
To run the jar, a ``launch.bat`` file is provided for convenience. Simply double-click it and the server will start in a new terminal window.
#### Configuring the project
Alternatively, run the jar file from the terminal. Just remember to provide the `wz-path` system property pointing to your wz directory.
The easiest way to set up your project is to clone the repository directly into a new IntelliJ project.
### 3 - Client
You will start by installing the game with the old installer, then overwrite some WZ files with our custom ones, and lastly get the localhost executable in place.
1. Install IntelliJ
2. Create a new "Project from Version Control..."
3. Enter the URL to this GitHub repository: "https://github.com/P0nk/Cosmic.git"
4. Click on "Clone". A new project will now be created with all the files from the repository.
#### Steps
#### Setting up the database
1. Download _MapleGlobal-v83-setup.exe_ from my [Google Drive](https://drive.google.com/drive/folders/1hgnb92MGL6xqEp9szEMBh0K9pSJcJ6IT). This is the official installer from back then.
2. Install it in a directory of your choice.
3. Delete the following files from the installation directory: _HShield_ (entire directory), _ASPLnchr.exe_, _MapleStory.exe_, and _Patcher.exe_.
4. Download _CosmicWZ-2024-05-21-v0.13.0.zip_ from my [Google Drive](https://drive.google.com/drive/folders/1hgnb92MGL6xqEp9szEMBh0K9pSJcJ6IT).
5. Unzip it and copy all .wz-files into the installation directory. Replace the existing ones.
6. Download _HeavenMS-localhost-WINDOW.exe_ from [hostr.co](https://hostr.co/amuX5SLeeVZx). This is a client modified to connect to your localhost instead of Nexon's server (along with some fixes and custom changes).
- Your antivirus will likely detect the file as a trojan or similar and automatically delete it. To prevent this from happening, add your _Downloads_ directory and the installation directory as exclusions in your antivirus software. On W11, this is under "Virus & threat protection settings" -> "Add or remove exclusions".
7. Move _HeavenMS-localhost-WINDOW.exe_ into the installation directory.
8. Done! Double-click the exe and the game should start.
- The client may be a bit fiddly. Sometimes it won't start, but if you see "Client connected" in the server console it's a good indication. Try spam-clicking it like 10+ times, that usually works for me.
1. Install MySQL Server 8 and MySQL Workbench 8.
2. Using Workbench, create a new user with username "cosmic_server" and password "snailshell".
This the default configuration in Cosmic.
* (Optional) Restrict the Schema Privileges for this new user for improved security.
Add a new entry with "Schemas matching pattern: cosmic" and only select "SELECT", "INSERT", "UPDATE", "DELETE" under "Object Rights"
3. Run the sql scripts in the "database/sql" directory of the project in the order indicated by their names.
* Make sure you are connected to the database with the "root" user to be able to run the scripts.
* Run scripts one by one through the menu: "File" -> "Run SQL Script" -> select the script file to run -> "Run"
* The 3rd script "3-db_shopupdate" is optional. It adds custom shop items for certain NPCs.
* The 4th script "4-db_admin" is also optional, but recommended if you are new. It adds an admin account to simplify the setup.
**Important note about localhost clients**: these executables are red-flagged by antivirus tools as potentially malicious software.
This happens due to the reverse engineering methods that were applied onto these software artifacts.
The one provided here has been in use for years already and posed no harm so far, so it is assumed to be safe.
Use this info when you connect to MySQL Server for the first time:
* Server Host: localhost
* Port: 3306
* Username: root
* Password: <whatever password you set during MySQL Server installation>
### 4 - Getting into the game
The client has started, and you're looking at the login screen.
At the end of the execution of these sql scripts, you should have installed a database schema named "cosmic".
REGISTER YOUR FIRST ACCOUNT to be used in-game by **manually creating** an entry in the table "accounts" in the database with a username and password.
### Running the server
Configure the IP you want to use for your MapleStory server in "config.yaml" file, or set it as "localhost" if you want to run it only on your machine.
Alternatively, you can use the IP given by Hamachi to use on a Hamachi network, or you can use a non-Hamachi method of port-forwarding. Neither will be approached here.
To launch the server, you may either:
* Launch inside IntelliJ
* Launch a built jar file
* Launch with Docker
#### Run inside IntelliJ
1. Open the file src/main/java/net/server/Server.java.
2. Click the green arrow to the left of the class definition "public class Server", and then "Run Cosmic".
* Alternatively (recommended), create a new Configuration that points to "net.server.Server".
3. The server launches in a terminal window inside IntelliJ.
#### Run from a jar file
1. Create the jar file
* The jar file is created by the Maven assembly plugin in the package lifecycle.
* If you already have Maven installed, simply run the command "mvn clean install" to create the jar file.
* IntelliJ also comes with built-in Maven support. Open a new terminal window inside IntelliJ, type "mvn clean install" (your command should now be marked green), then Ctrl+Enter to build the jar file.
2. Launch the jar file
* Double click on "launch.bat" (need to have Java 17 installed)
#### Run as containers with Docker
1. Start Docker
2. Run the command "docker compose up" at the root of the project.
* If you make any changes to the code, make sure you append the "--build" option at the end of the command to force rebuild the server image.
---
### Getting into the game
If you ran the admin sql script, there already exists an account in the database with an admin character on it (GM level 6).
Log in using these credentials:
#### Logging in
At this point, you can log in to the admin account using the following credentials:
* Username: "admin"
* Password: "admin"
* Pin: "0000"
* Pic: "000000"
Admin characters have "hide" mode enabled by default. This means your character will be translucent on your screen, and completely invisible to others.
It will also prevent you from controlling mobs (making them stand still). To toggle this mode on and off, type "@hide" in the in-game chat.
Or create a regular account by typing in your desired username & password and attempting to log in. This "automatic registration" feature lets you create new accounts to play around with. It is enabled by default (see _config.yaml_).
By default, the server source is set to allow AUTO-REGISTERING. This means that, by simply typing in a "Login ID" and a "Password", you're able to create a new account.
#### Entering the game
Create a new character as you normally would, and then select it to enter the game. Hooray, finally we're in!
After creating a character, experiment typing in all-chat "@commands".
This will display all available commands for the current GM level your character has.
If you log in to the "Admin" character, you'll notice that the character looks almost invisible. This is hide mode, which is enabled by default when you log in to a GM character. You won't be visible to normal players and no mobs will move if you're alone on the map. Toggle hide mode on or off by typing "@hide" in the in-game chat.
To change a character's GM level, make sure that character is not logged in, then:
Hide is one of many commands available to players, type "@commands" to see the full list. Higher ranked GMs have access to more powerful commands.
1. Open MySQL Workbench;
2. Expand "cosmic" schema;
3. Expand "Tables";
4. Right-click "characters" and click "Select Rows"
5. Find your character in Result Grid. Scroll to the right and find the "gm" column.
6. Edit your character's gm value and click "Apply", and then "Apply" again in the window that appeared, then "Finish".
* 0 is what ordinary players start with, and 6 is the highest gm value. Higher level gms have access to more commands in game.
That's it, have fun playing around in game!
---
### Some notes about WZ/WZ.XML EDITING
Brief introduction to WZ files: they are the asset/data files required by the client and server. The client can read the .wz files directly, but the server requires them in XML format.
The server also does not make use of any of the sprites, which is where different kinds of exporting comes into the picture. HaRepacker allows you to export to Private server XML, which is the .img files packaged in the .wz stripped of sprites and converted to XML.
## Advanced concepts
Some slightly more advanced concepts that might be useful once you're up and running.
Link to HaRepacker-resurrected, the standard tool for handling WZ files: https://github.com/lastbattle/Harepacker-resurrected
### Host on remote server
You don't have to host the server on your local machine to play. It's possible to host on a remote server such as a VPS or even a dedicated server.
NOTE: Be extremely wary when using server-side's XMLs data being reimported into the client's WZ, as some means of synchronization between the server and client modules, this action COULD generate some kind of bugs afterwards. Client-to-server data reimporting seems to be fine, though.
I leave it to you to figure out the server hosting part, but once you have that running you'll need to edit the client exe to point to your remote server ip.
#### Editing the v83 WZ's:
#### Edit client ip
1. Download and install a hex editor: [HxD](https://mh-nexus.de/en/hxd/)
2. Start HxD and open your client exe (I recommend making a copy of it first). At this point you should see a bunch of hex codes and a "Decoded text" column to the right of it.
3. Ctrl+f and search for Text-string "127.0.0.1". You should find three occurrences right above each other.
4. Place your cursor before the first "127" and start typing the desired ip, overwriting what is already there. Do the same on the other two and click on Save.
5. Done! Now the client will attempt to connect to that ip address instead when you launch it.
### WZ files
WZ files are the asset/data files required by the client and server. Typically, [HaRepacker-resurrected](https://github.com/lastbattle/Harepacker-resurrected) is used to handle (view, edit, export) the .wz files.
* Use the HaRepacker-resurrected 4.2.4 editor, encryption "GMS (old)".
* Open the desired WZ for editing and use the node hierarchy to make the desired changes (copy/pasting nodes may be unreliable in rare scenarios).
* Save the changed WZ, **overwriting the original content** at the client folder.
* Finally, **RE-EXPORT (using the "Private Server..." exporting option) the changed XMLs into the server's WZ.XML files**, overwriting the old contents.
The client can read the .wz files directly, but the server requires them in XML format. The server also does not make use of the sprites, which is the motivation for different kinds of exporting.
HaRepacker allows you to export to "Private server", which is the .img files packaged in the .wz stripped of sprites and converted to XML. This takes much less disk space.
**These steps are IMPORTANT, to maintain synchronization** between the server and client modules.
This server requires custom .wz files (unfortunately), as you may have noted during installation of the client. The intention is for these to be removed eventually and to solely run on vanilla .wz files.
---
### Portforwarding the SERVER
#### WZ editing
* Use the HaRepacker-resurrected editor, encryption "GMS (old)".
* Open the desired .wz for editing and use the node hierarchy to make the desired changes (copy/pasting nodes may be unreliable in rare scenarios).
* Save the changed .wz, overwriting the original content at the client folder.
* Finally, re-export (using the "Private Server" exporting option) the changed XMLs into the server's .wz XML files (found in the "wz" directory), overwriting the old contents.
To use portforward, you will need to have permission to change things on the LAN router. Access your router using the Internet browser. URLs vary accordingly with the manufacturer. To discover it, open the command prompt and type "ipconfig" and search for the "default gateway" field. The IP shown there is the URL needed to access the router. Also, look for the IP given to your machine (aka "IPv4 address" field), which will be the server one.
Make sure to always export from the client .wz files to the server XML, and not the other way around.
The default login/password also varies, so use the link http://www.routerpasswords.com/ as reference. Usually, login as "admin" and password as "password" completes the task well.
Editing the client .wz without exporting to the server may lead to strange behavior.
Now you have logged in the router system, search for anything related to portforwarding. Should the system prompt you between portforwarding and portriggering, pick the first, it is what we will be using.
### Client features
For more information about the client and its features, see [HeavenMS on GitHub](https://github.com/ronancpl/HeavenMS#download-items).
Now, it is needed to enable the right ports for the Internet. For Cosmic, it is basically needed to open ports 7575 to 7575 + (number of channels) and port 8484. Create a new custom service which enables that range of ports for the server's channel and opt to use TCP/UDP protocols. Finally, create a custom service now for using port 8484.
Optionally, if you want to host a webpage, portforward the port 80 (the HTTP port) as well.
It is not done yet, sometimes the firewalls will block connections between the LAN and the Internet. To overcome this, it is needed to create some rules for the firewall to permit these connections. Search for the advanced options with firewalls on your computer and, with it open, create two rules (one outbound and one inbound).
These rules must target "one application", "enable connections" and must target your MapleStory client (aka localhost).
After all these steps, the portforwarding process should now be complete.
---
### Client changelog
The following list, in bottom-up chronological order,
holds information regarding all changes that were applied from the starting localhost used in this development.
Some lines have a link attached, that will lead you to a snapshot of the localhost at that version of the artifact.
Naturally, later versions holds all previous changes along with the proposed changes.
**Change log:**
* Fixed Monster Magnet crashing the caster when trying to pull fixed mobs, credits to Shavit. https://gofile.io/?c=BW7dVM (dead link)
* Cleared need for administrator privileges (OS) to play the game, credits to Ubaware.
* Set a higher cap for AP assigning with AP Reset, credits to Ubaware.
* Fixed Monster Magnet crashing the caster when trying to pull bosses. Drawback: Dojo HPBar becomes unavailable. https://hostr.co/SvnSKrGzXhG0
* Fixed some 'rn' problems with quest icons & removed "tab" from party leader changed message. https://hostr.co/tsYsQzzV6xT0
* Removed block on applying attack-based strengthening gems on non-weapon equipments. https://hostr.co/m2bVtnizCtmD
* Set a higher cap for SPEED.
* Removed the AP assigning block for beginners below level 10. https://hostr.co/AHAHzneCti9B
* Removed block on party for beginners level 10 or below. https://hostr.co/JZq53mMtToCz
* Removed block on MTS entering in some maps, rendering the buyback option available.
* Removed "AP excess" popup and limited actions on Admin/MWLB, credits to kevintjuh93.
* Removed "You've gained a level!" popup, credits to PrinceReborn.
* Removed caps for WATK, WDEF, MDEF, ACC, AVOID.
* 'n' problem fixed.
* Fraysa's https://hostr.co/gJbLZITRVHmv
* Eric's MapleSilver starting on window-mode.
Some notable features:
* Opens in window mode by default
* Uncapped max speed

View File

@@ -161,8 +161,8 @@ server:
#Database Configuration
DB_URL_FORMAT: "jdbc:mysql://%s:3306/cosmic" # If the docker ENV for DB_HOST is anything but "db", this string format should be changed from 3306 to 3307 (or whichever port it was changed to in docker)
DB_HOST: "localhost"
DB_USER: "cosmic_server"
DB_PASS: "snailshell"
DB_USER: "root"
DB_PASS: ""
INIT_CONNECTION_POOL_TIMEOUT: 90 # Seconds
#Login Configuration
@@ -220,7 +220,6 @@ server:
USE_MTS: false
USE_CPQ: true #Renders the CPQ available or not.
USE_AUTOHIDE_GM: true #When enabled, GMs are automatically hidden when joining. Thanks to Steven Deblois (steven1152).
USE_BUYBACK_SYSTEM: false #Enables the HeavenMS-builtin buyback system, to be used by dead players when clicking the MTS button.
USE_FIXED_RATIO_HPMP_UPDATE: false #Enables the HeavenMS-builtin HPMP update based on the current pool to max pool ratio.
USE_FAMILY_SYSTEM: true
USE_DUEY: true
@@ -347,7 +346,6 @@ server:
USE_PERFECT_SCROLLING: false #Scrolls doesn't use slots upon failure.
USE_ENHANCED_CHSCROLL: false #Equips even more powerful with chaos upgrade.
USE_ENHANCED_CRAFTING: false #Apply chaos scroll on every equip crafted.
USE_ENHANCED_CLNSLATE: false #Clean slates can be applied to recover successfully used slots as well.
SCROLL_CHANCE_ROLLS: 1 #Number of rolls for success on a scroll, set 1 for default.
CHSCROLL_STAT_RATE: 1 #Number of rolls of stat upgrade on a successfully applied chaos scroll, set 1 for default.
CHSCROLL_STAT_RANGE: 6 #Stat upgrade range (-N, N) on chaos scrolls.
@@ -448,14 +446,6 @@ server:
WEDDING_GIFT_LIMIT: 1 #Max number of gifts per person to same wishlist on marriage instances.
WEDDING_BLESSER_SHOWFX: true #Pops bubble sprite effect on players blessing the couple. Setting this false shows the blessing effect on the couple instead.
#Buyback Configuration
USE_BUYBACK_WITH_MESOS: true #Enables usage of either mesos or NX for the buyback fee.
BUYBACK_FEE: 77.70 #Sets the base amount needed to buyback (level 30 or under will use the base value).
BUYBACK_LEVEL_STACK_FEE: 85.47 #Sets the level-stacking portion of the amount needed to buyback (fee will sum up linearly until level 120, when it reaches the peak).
BUYBACK_MESO_MULTIPLIER: 1000 #Sets a multiplier for the fee when using meso as the charge unit.
BUYBACK_RETURN_MINUTES: 1 #Sets the maximum amount of time the player can wait before decide to buyback.
BUYBACK_COOLDOWN_MINUTES: 7 #Sets the time the player must wait before using buyback again.
# Login timeout by shavit
TIMEOUT_DURATION: 3600000 # Kicks clients who don't send any packet to the game server in due time (in millisseconds).

View File

@@ -1,9 +1,4 @@
#EXECUTE THIS FIRST, THEN NEXT SQL: 'db_drops.sql'
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
@@ -21510,4 +21505,4 @@ ALTER TABLE `skills`
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

View File

@@ -21,12 +21,11 @@ services:
DB_HOST: "db" ## Remember if this is present it will OVERRIDE the host in the config.yaml, if you put here anything other than db, you'll need to change the config.yaml jdbc string to port 3307, and not port 3306
db:
image: mysql:8.0.23
image: mysql:8.4.0
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: "cosmic"
MYSQL_USER: "cosmic_server"
MYSQL_PASSWORD: "snailshell"
MYSQL_ROOT_PASSWORD: ""
MYSQL_ALLOW_EMPTY_PASSWORD: yes
ports:
- "3307:3306"
volumes:

View File

@@ -302,10 +302,10 @@ Localhost:
* Removed caps for MATK, WDEF, MDEF, ACC and AVOID.
* Removed "AP excess" popup and "Admin/MWLB" action block, original credits to kevintjuh93.
* Removed "You've gained a level!" popup, original credits to PrinceReborn.
* Removed "Cannot enter MTS from this map." popup on maps that blocks transitions (such change channel, CS/MTS), rendering the buyback option now available for all maps.
* Removed "Cannot enter MTS from this map." popup on maps that blocks transitions (such change channel, CS/MTS).
* Removed a check for players wishing to create/join a party being novices under level 10.
* Set a new high cap for SPEED.
* Removed the AP assign block for novices.
* Removed a block that would show up when trying to apply an attack gem on equipments that aren't weapons.
---------------------------
---------------------------

74
pom.xml
View File

@@ -1,40 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cosmic-maplestory</groupId>
<artifactId>Cosmic</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Cosmic</name>
<description>Server emulator for Global MapleStory version 83</description>
<url>https://github.com/P0nk/Cosmic</url>
<inceptionYear>2021</inceptionYear>
<developers>
<developer>
<name>Ponk</name>
<email>ponkcode@gmail.com</email>
<url>https://github.com/P0nk</url>
<roles>
<role>maintainer</role>
<role>developer</role>
</roles>
<properties>
<discord>ponkcode</discord>
</properties>
</developer>
</developers>
<scm>
<connection>scm:git:https://github.com/P0nk/Cosmic.git</connection>
<developerConnection>scm:git:https://github.com/P0nk/Cosmic.git</developerConnection>
<url>https://github.com/P0nk/Cosmic</url>
</scm>
<issueManagement>
<system>GitHub Issues</system>
<url>https://github.com/P0nk/Cosmic/issues</url>
</issueManagement>
<ciManagement>
<system>GitHub Actions</system>
<url>https://github.com/P0nk/Cosmic/actions</url>
</ciManagement>
<properties>
<!-- Project -->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
<java.version>21</java.version>
<maven.compiler.source>${java.version}</maven.compiler.source>
<maven.compiler.target>${java.version}</maven.compiler.target>
<mainClass>net.server.Server</mainClass>
<!-- Maven plugins -->
<maven-surefire-plugin.version>3.0.0-M9</maven-surefire-plugin.version> <!-- For running unit tests -->
<maven-jar-plugin.version>3.3.0</maven-jar-plugin.version> <!-- Disabled. (for building thin jar) -->
<maven-assembly-plugin.version>3.5.0</maven-assembly-plugin.version> <!-- For packaging the executable fat jar -->
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version> <!-- For running unit tests -->
<maven-jar-plugin.version>3.4.1</maven-jar-plugin.version> <!-- Disabled. (for building thin jar) -->
<maven-assembly-plugin.version>3.7.1</maven-assembly-plugin.version> <!-- For packaging the executable fat jar -->
<!-- Dependencies -->
<slf4j-api.version>1.7.36</slf4j-api.version> <!-- Logging facade -->
<log4j.version>2.20.0</log4j.version> <!-- Slf4j implementation -->
<graalvm.version>22.3.1</graalvm.version> <!-- ScriptEngine implementation -->
<netty.version>4.1.89.Final</netty.version> <!-- Networking -->
<yamlbeans.version>1.15</yamlbeans.version> <!-- Config file -->
<slf4j-api.version>2.0.13</slf4j-api.version> <!-- Logging facade -->
<log4j.version>2.23.1</log4j.version> <!-- Slf4j implementation -->
<graalvm-js.version>23.0.4</graalvm-js.version>
<graalvm-js-scriptengine.version>24.0.1</graalvm-js-scriptengine.version> <!-- ScriptEngine implementation -->
<netty.version>4.1.109.Final</netty.version> <!-- Networking -->
<yamlbeans.version>1.17</yamlbeans.version> <!-- Config file -->
<jcip-annotations.version>1.0</jcip-annotations.version> <!-- Annotations for concurrency documentation -->
<HikariCP.version>5.0.1</HikariCP.version> <!-- Database connection pool -->
<mysql-connector-j.version>8.0.32</mysql-connector-j.version> <!-- MySQL JDBC driver -->
<jdbi-version>3.37.1</jdbi-version> <!-- Convenience wrapper around JDBC -->
<junit.version>5.9.2</junit.version> <!-- Unit test -->
<mockito.version>5.1.1</mockito.version> <!-- Unit test -->
<HikariCP.version>5.1.0</HikariCP.version> <!-- Database connection pool -->
<mysql-connector-j.version>8.4.0</mysql-connector-j.version> <!-- MySQL JDBC driver -->
<jdbi-version>3.45.1</jdbi-version> <!-- Convenience wrapper around JDBC -->
<junit.version>5.10.2</junit.version> <!-- Unit test -->
<mockito.version>5.11.0</mockito.version> <!-- Unit test -->
</properties>
<dependencies>
@@ -107,7 +139,7 @@
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<artifactId>log4j-slf4j2-impl</artifactId>
<version>${log4j.version}</version>
</dependency>
@@ -115,12 +147,12 @@
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js</artifactId>
<version>${graalvm.version}</version>
<version>${graalvm-js.version}</version>
</dependency>
<dependency>
<groupId>org.graalvm.js</groupId>
<artifactId>js-scriptengine</artifactId>
<version>${graalvm.version}</version>
<version>${graalvm-js-scriptengine.version}</version>
</dependency>
<!-- Testing -->

3
scripts/devtest.js Normal file
View File

@@ -0,0 +1,3 @@
function run(chr) {
chr.message("devtest.js")
}

View File

@@ -36,12 +36,6 @@ function stopEntry() {
}
function takeoff() {
const PacketCreator = Java.type('tools.PacketCreator');
//sound src: https://www.soundjay.com/transportation/metro-door-close-01.mp3
KC_docked.broadcastMessage(PacketCreator.playSound("subway/whistle"));
NLC_docked.broadcastMessage(PacketCreator.playSound("subway/whistle"));
em.setProperty("docked", "false");
KC_Waiting.warpEveryone(Subway_to_NLC.getId());
NLC_Waiting.warpEveryone(Subway_to_KC.getId());
@@ -52,10 +46,6 @@ function arrived() {
Subway_to_KC.warpEveryone(KC_docked.getId(), 0);
Subway_to_NLC.warpEveryone(NLC_docked.getId(), 0);
scheduleNew();
const PacketCreator = Java.type('tools.PacketCreator');
KC_docked.broadcastMessage(PacketCreator.playSound("subway/whistle"));
NLC_docked.broadcastMessage(PacketCreator.playSound("subway/whistle"));
}
function cancelSchedule() {}

View File

@@ -23,7 +23,12 @@ function action(mode, type, selection) {
}
if (!cm.isEventLeader()) {
cm.sendYesNo("I wish for your leader to talk to me. Alternatively, you may be wanting to quit. Are you going to abandon this campaign?");
// Player chose "No" or "End Chat"
if (mode <= 0) {
cm.dispose();
} else {
cm.sendYesNo("I wish for your leader to talk to me. Alternatively, you may be wanting to quit. Are you going to abandon this campaign?");
}
} else {
var eim = cm.getEventInstance();
if (eim == null) {

View File

@@ -24,7 +24,6 @@
var status;
var anthemSong = "Field/anthem/brazil"; // sound src: https://c7.rbxcdn.com/f91060652a6e9fbfbf92cb1418435448
var ambientSong = "Bgm04/Shinin'Harbor";
var feature_tree = [];
@@ -217,7 +216,6 @@ function writeFeatureTab_Serverpotentials() {
addFeature("Poison damage value visible for other players.");
addFeature("M. book announcer displays info based on demand.");
addFeature("Custom jail system.");
addFeature("Custom buyback system, uses mesos / NX, via MTS.");
addFeature("Custom fishing system having 'seasonal' catch times.");
addFeature("Actual fishing handling w/ F. Net - thanks Dragohe4rt!");
addFeature("Custom map leasing system.");
@@ -260,7 +258,7 @@ function writeFeatureTab_CustomNPCs() {
function writeFeatureTab_Localhostedits() {
addFeature("Removed the 'n' NPC dialog issue.");
addFeature("Removed caps for MATK, WMDEF, ACC and AVOID.");
addFeature("Removed MTS block, buyback available anywhere.");
addFeature("Removed MTS block.");
addFeature("Removed party blocks for novices under level 10.");
addFeature("Set a much more higher cap for SPEED.");
addFeature("Removed AP usage block for novices.");
@@ -308,8 +306,6 @@ function writeAllFeatures() {
}
function start() {
const PacketCreator = Java.type('tools.PacketCreator');
cm.getPlayer().sendPacket(PacketCreator.musicChange(anthemSong));
status = -1;
writeAllFeatures();
action(1, 0, 0);
@@ -369,4 +365,4 @@ function generateSelectionMenu(array) {
menu += "#L" + i + "#" + array[i] + "#l\r\n";
}
return menu;
}
}

View File

@@ -50,8 +50,14 @@ function end(mode, type, selection) {
status++;
}
// TODO: there are 10 different riffs; quest2288/0 through quest2288/9.
// One of the riffs should play randomly upon the death of Spirit of Rock, but there is currently no system in place to achieve that in a reasonable way.
// Spirit of Rock (4300013) spawns an invisible mob on death (Spirit of Rock's Soul, 4300017) which was likely used in some clever way in GMS.
// The map (103040430) has two scripts which could be useful: onFirstUserEnter=Depart_Boss_F_Enter and onUserEnter=Depart_BossEnter
// Currently, the best hypothesis is that one of the map scripts registers some form of "mob spawn" action/script that runs once the invisible mob spawns.
// The script would randomly pick one of the 10 riffs and then register it with all chrs on the map (to later be used by this quest 2293) and play it.
if (status == 0) {
qm.sendSimple("Here, I'll give you some samples. Please listen to them and choose one. Please listen carefully before making your choide.\r\n\
qm.sendSimple("Here, I'll give you some samples. Please listen to them and choose one. Please listen carefully before making your choice.\r\n\
\t#b#L1# Listen to song No. 1#l \r\n\
\t#L2# Listen to Song No. 2#l \r\n\
\t#L3# Listen to Song No. 3#l \r\n\
@@ -67,7 +73,7 @@ function end(mode, type, selection) {
qm.sendOk("Was it this?");
status = -1;
} else if (selection == 3) {
qm.playSound("quest2293/Die");
qm.playSound("quest2288/6");
qm.sendOk("You heard that?");
status = -1;
} else if (selection == 4) {
@@ -88,4 +94,4 @@ function end(mode, type, selection) {
} else if (status == 3) {
qm.dispose();
}
}
}

View File

@@ -24,8 +24,17 @@ package client;
import client.autoban.AutobanManager;
import client.creator.CharacterFactoryRecipe;
import client.inventory.*;
import client.inventory.Equip;
import client.inventory.Equip.StatUpgrade;
import client.inventory.Inventory;
import client.inventory.InventoryProof;
import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.ModifyInventory;
import client.inventory.Pet;
import client.inventory.PetDataFactory;
import client.inventory.WeaponType;
import client.inventory.manipulator.CashIdGenerator;
import client.inventory.manipulator.InventoryManipulator;
import client.keybind.KeyBinding;
@@ -40,7 +49,35 @@ import constants.id.ItemId;
import constants.id.MapId;
import constants.id.MobId;
import constants.inventory.ItemConstants;
import constants.skills.*;
import constants.skills.Aran;
import constants.skills.Beginner;
import constants.skills.Bishop;
import constants.skills.BlazeWizard;
import constants.skills.Bowmaster;
import constants.skills.Brawler;
import constants.skills.Buccaneer;
import constants.skills.Corsair;
import constants.skills.Crusader;
import constants.skills.DarkKnight;
import constants.skills.DawnWarrior;
import constants.skills.Evan;
import constants.skills.FPArchMage;
import constants.skills.Hermit;
import constants.skills.Hero;
import constants.skills.ILArchMage;
import constants.skills.Legend;
import constants.skills.Magician;
import constants.skills.Marauder;
import constants.skills.Marksman;
import constants.skills.NightLord;
import constants.skills.Noblesse;
import constants.skills.Paladin;
import constants.skills.Priest;
import constants.skills.Ranger;
import constants.skills.Shadower;
import constants.skills.Sniper;
import constants.skills.ThunderBreaker;
import constants.skills.Warrior;
import net.packet.Packet;
import net.server.PlayerBuffValueHolder;
import net.server.PlayerCoolDownValueHolder;
@@ -52,39 +89,98 @@ import net.server.guild.GuildCharacter;
import net.server.guild.GuildPackets;
import net.server.services.task.world.CharacterSaveService;
import net.server.services.type.WorldServices;
import net.server.world.*;
import net.server.world.Messenger;
import net.server.world.MessengerCharacter;
import net.server.world.Party;
import net.server.world.PartyCharacter;
import net.server.world.PartyOperation;
import net.server.world.World;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scripting.AbstractPlayerInteraction;
import scripting.event.EventInstanceManager;
import scripting.item.ItemScriptManager;
import server.*;
import server.CashShop;
import server.ExpLogger;
import server.ExpLogger.ExpLogRecord;
import server.ItemInformationProvider;
import server.ItemInformationProvider.ScriptedItem;
import server.Marriage;
import server.Shop;
import server.StatEffect;
import server.Storage;
import server.ThreadManager;
import server.TimerManager;
import server.Trade;
import server.events.Events;
import server.events.RescueGaga;
import server.events.gm.Fitness;
import server.events.gm.Ola;
import server.life.*;
import server.maps.*;
import server.life.MobSkill;
import server.life.MobSkillFactory;
import server.life.MobSkillId;
import server.life.MobSkillType;
import server.life.Monster;
import server.life.PlayerNPC;
import server.maps.AbstractAnimatedMapObject;
import server.maps.Door;
import server.maps.DoorObject;
import server.maps.Dragon;
import server.maps.FieldLimit;
import server.maps.HiredMerchant;
import server.maps.MapEffect;
import server.maps.MapItem;
import server.maps.MapManager;
import server.maps.MapObject;
import server.maps.MapObjectType;
import server.maps.MapleMap;
import server.maps.MiniGame;
import server.maps.MiniGame.MiniGameResult;
import server.maps.PlayerShop;
import server.maps.PlayerShopItem;
import server.maps.Portal;
import server.maps.SavedLocation;
import server.maps.SavedLocationType;
import server.maps.Summon;
import server.minigame.RockPaperScissor;
import server.partyquest.AriantColiseum;
import server.partyquest.MonsterCarnival;
import server.partyquest.MonsterCarnivalParty;
import server.partyquest.PartyQuest;
import server.quest.Quest;
import tools.*;
import tools.DatabaseConnection;
import tools.LongTool;
import tools.PacketCreator;
import tools.Pair;
import tools.Randomizer;
import tools.exceptions.NotEnabledException;
import tools.packets.WeddingPackets;
import java.awt.*;
import java.lang.ref.WeakReference;
import java.sql.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Stack;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -94,7 +190,9 @@ import java.util.concurrent.locks.ReentrantLock;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import static java.util.concurrent.TimeUnit.*;
import static java.util.concurrent.TimeUnit.DAYS;
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.SECONDS;
public class Character extends AbstractCharacterObject {
private static final Logger log = LoggerFactory.getLogger(Character.class);
@@ -128,7 +226,7 @@ public class Character extends AbstractCharacterObject {
private int expRate = 1, mesoRate = 1, dropRate = 1, expCoupon = 1, mesoCoupon = 1, dropCoupon = 1;
private int omokwins, omokties, omoklosses, matchcardwins, matchcardties, matchcardlosses;
private int owlSearch;
private long lastfametime, lastUsedCashItem, lastExpression = 0, lastHealed, lastBuyback = 0, lastDeathtime, jailExpiration = -1;
private long lastfametime, lastUsedCashItem, lastExpression = 0, lastHealed, lastDeathtime, jailExpiration = -1;
private transient int localstr, localdex, localluk, localint_, localmagic, localwatk;
private transient int equipmaxhp, equipmaxmp, equipstr, equipdex, equipluk, equipint_, equipmagic, equipwatk, localchairhp, localchairmp;
private int localchairrate;
@@ -6054,65 +6152,6 @@ public class Character extends AbstractCharacterObject {
}
}
private boolean canBuyback(int fee, boolean usingMesos) {
return (usingMesos ? this.getMeso() : cashshop.getCash(1)) >= fee;
}
private void applyBuybackFee(int fee, boolean usingMesos) {
if (usingMesos) {
this.gainMeso(-fee);
} else {
cashshop.gainCash(1, -fee);
}
}
private long getNextBuybackTime() {
return lastBuyback + MINUTES.toMillis(YamlConfig.config.server.BUYBACK_COOLDOWN_MINUTES);
}
private boolean isBuybackInvincible() {
return Server.getInstance().getCurrentTime() - lastBuyback < 4200;
}
private int getBuybackFee() {
float fee = YamlConfig.config.server.BUYBACK_FEE;
int grade = Math.min(Math.max(level, 30), 120) - 30;
fee += (grade * YamlConfig.config.server.BUYBACK_LEVEL_STACK_FEE);
if (YamlConfig.config.server.USE_BUYBACK_WITH_MESOS) {
fee *= YamlConfig.config.server.BUYBACK_MESO_MULTIPLIER;
}
return (int) Math.floor(fee);
}
public void showBuybackInfo() {
String s = "#eBUYBACK STATUS#n\r\n\r\nCurrent buyback fee: #b" + getBuybackFee() + " " + (YamlConfig.config.server.USE_BUYBACK_WITH_MESOS ? "mesos" : "NX") + "#k\r\n\r\n";
long timeNow = Server.getInstance().getCurrentTime();
boolean avail = true;
if (!isAlive()) {
long timeLapsed = timeNow - lastDeathtime;
long timeRemaining = MINUTES.toMillis(YamlConfig.config.server.BUYBACK_RETURN_MINUTES) - (timeLapsed + Math.max(0, getNextBuybackTime() - timeNow));
if (timeRemaining < 1) {
s += "Buyback #e#rUNAVAILABLE#k#n";
avail = false;
} else {
s += "Buyback countdown: #e#b" + getTimeRemaining(MINUTES.toMillis(YamlConfig.config.server.BUYBACK_RETURN_MINUTES) - timeLapsed) + "#k#n";
}
s += "\r\n";
}
if (timeNow < getNextBuybackTime() && avail) {
s += "Buyback available in #r" + getTimeRemaining(getNextBuybackTime() - timeNow) + "#k";
s += "\r\n";
} else {
s += "Buyback #bavailable#k";
}
this.showHint(s);
}
private static String getTimeRemaining(long timeLeft) {
int seconds = (int) Math.floor(timeLeft / SECONDS.toMillis(1)) % 60;
int minutes = (int) Math.floor(timeLeft / MINUTES.toMillis(1)) % 60;
@@ -6120,34 +6159,6 @@ public class Character extends AbstractCharacterObject {
return (minutes > 0 ? (String.format("%02d", minutes) + " minutes, ") : "") + String.format("%02d", seconds) + " seconds";
}
public boolean couldBuyback() { // Ronan's buyback system
long timeNow = Server.getInstance().getCurrentTime();
if (timeNow - lastDeathtime > MINUTES.toMillis(YamlConfig.config.server.BUYBACK_RETURN_MINUTES)) {
this.dropMessage(5, "The period of time to decide has expired, therefore you are unable to buyback.");
return false;
}
long nextBuybacktime = getNextBuybackTime();
if (timeNow < nextBuybacktime) {
long timeLeft = nextBuybacktime - timeNow;
this.dropMessage(5, "Next buyback available in " + getTimeRemaining(timeLeft) + ".");
return false;
}
boolean usingMesos = YamlConfig.config.server.USE_BUYBACK_WITH_MESOS;
int fee = getBuybackFee();
if (!canBuyback(fee, usingMesos)) {
this.dropMessage(5, "You don't have " + fee + " " + (usingMesos ? "mesos" : "NX") + " to buyback.");
return false;
}
lastBuyback = timeNow;
applyBuybackFee(fee, usingMesos);
return true;
}
public boolean isBuffFrom(BuffStat stat, Skill skill) {
effLock.lock();
chrLock.lock();
@@ -8911,11 +8922,7 @@ public class Character extends AbstractCharacterObject {
boolean playerDied = false;
if (hp <= 0) {
if (oldHp > hp) {
if (!isBuybackInvincible()) {
playerDied = true;
} else {
hp = 1;
}
playerDied = true;
}
}

View File

@@ -24,13 +24,180 @@
package client.command;
import client.Client;
import client.command.commands.gm0.*;
import client.command.commands.gm1.*;
import client.command.commands.gm2.*;
import client.command.commands.gm3.*;
import client.command.commands.gm4.*;
import client.command.commands.gm5.*;
import client.command.commands.gm6.*;
import client.command.commands.gm0.ChangeLanguageCommand;
import client.command.commands.gm0.DisposeCommand;
import client.command.commands.gm0.DropLimitCommand;
import client.command.commands.gm0.EnableAuthCommand;
import client.command.commands.gm0.EquipLvCommand;
import client.command.commands.gm0.GachaCommand;
import client.command.commands.gm0.GmCommand;
import client.command.commands.gm0.HelpCommand;
import client.command.commands.gm0.JoinEventCommand;
import client.command.commands.gm0.LeaveEventCommand;
import client.command.commands.gm0.MapOwnerClaimCommand;
import client.command.commands.gm0.OnlineCommand;
import client.command.commands.gm0.RanksCommand;
import client.command.commands.gm0.RatesCommand;
import client.command.commands.gm0.ReadPointsCommand;
import client.command.commands.gm0.ReportBugCommand;
import client.command.commands.gm0.ShowRatesCommand;
import client.command.commands.gm0.StaffCommand;
import client.command.commands.gm0.StatDexCommand;
import client.command.commands.gm0.StatIntCommand;
import client.command.commands.gm0.StatLukCommand;
import client.command.commands.gm0.StatStrCommand;
import client.command.commands.gm0.TimeCommand;
import client.command.commands.gm0.ToggleExpCommand;
import client.command.commands.gm0.UptimeCommand;
import client.command.commands.gm1.BossHpCommand;
import client.command.commands.gm1.BuffMeCommand;
import client.command.commands.gm1.GotoCommand;
import client.command.commands.gm1.MobHpCommand;
import client.command.commands.gm1.WhatDropsFromCommand;
import client.command.commands.gm1.WhoDropsCommand;
import client.command.commands.gm2.ApCommand;
import client.command.commands.gm2.BombCommand;
import client.command.commands.gm2.BuffCommand;
import client.command.commands.gm2.BuffMapCommand;
import client.command.commands.gm2.ClearDropsCommand;
import client.command.commands.gm2.ClearSavedLocationsCommand;
import client.command.commands.gm2.ClearSlotCommand;
import client.command.commands.gm2.DcCommand;
import client.command.commands.gm2.EmpowerMeCommand;
import client.command.commands.gm2.GachaListCommand;
import client.command.commands.gm2.GmShopCommand;
import client.command.commands.gm2.HealCommand;
import client.command.commands.gm2.HideCommand;
import client.command.commands.gm2.IdCommand;
import client.command.commands.gm2.ItemCommand;
import client.command.commands.gm2.ItemDropCommand;
import client.command.commands.gm2.JailCommand;
import client.command.commands.gm2.JobCommand;
import client.command.commands.gm2.LevelCommand;
import client.command.commands.gm2.LevelProCommand;
import client.command.commands.gm2.LootCommand;
import client.command.commands.gm2.MaxSkillCommand;
import client.command.commands.gm2.MaxStatCommand;
import client.command.commands.gm2.MobSkillCommand;
import client.command.commands.gm2.ReachCommand;
import client.command.commands.gm2.RechargeCommand;
import client.command.commands.gm2.ResetSkillCommand;
import client.command.commands.gm2.SearchCommand;
import client.command.commands.gm2.SetSlotCommand;
import client.command.commands.gm2.SetStatCommand;
import client.command.commands.gm2.SpCommand;
import client.command.commands.gm2.SummonCommand;
import client.command.commands.gm2.UnBugCommand;
import client.command.commands.gm2.UnHideCommand;
import client.command.commands.gm2.UnJailCommand;
import client.command.commands.gm2.WarpAreaCommand;
import client.command.commands.gm2.WarpCommand;
import client.command.commands.gm2.WarpMapCommand;
import client.command.commands.gm2.WhereaMiCommand;
import client.command.commands.gm3.BanCommand;
import client.command.commands.gm3.ChatCommand;
import client.command.commands.gm3.CheckDmgCommand;
import client.command.commands.gm3.ClosePortalCommand;
import client.command.commands.gm3.DebuffCommand;
import client.command.commands.gm3.EndEventCommand;
import client.command.commands.gm3.ExpedsCommand;
import client.command.commands.gm3.FaceCommand;
import client.command.commands.gm3.FameCommand;
import client.command.commands.gm3.FlyCommand;
import client.command.commands.gm3.GiveMesosCommand;
import client.command.commands.gm3.GiveNxCommand;
import client.command.commands.gm3.GiveRpCommand;
import client.command.commands.gm3.GiveVpCommand;
import client.command.commands.gm3.HairCommand;
import client.command.commands.gm3.HealMapCommand;
import client.command.commands.gm3.HealPersonCommand;
import client.command.commands.gm3.HpMpCommand;
import client.command.commands.gm3.HurtCommand;
import client.command.commands.gm3.IgnoreCommand;
import client.command.commands.gm3.IgnoredCommand;
import client.command.commands.gm3.InMapCommand;
import client.command.commands.gm3.KillAllCommand;
import client.command.commands.gm3.KillCommand;
import client.command.commands.gm3.KillMapCommand;
import client.command.commands.gm3.MaxEnergyCommand;
import client.command.commands.gm3.MaxHpMpCommand;
import client.command.commands.gm3.MonitorCommand;
import client.command.commands.gm3.MonitorsCommand;
import client.command.commands.gm3.MusicCommand;
import client.command.commands.gm3.MuteMapCommand;
import client.command.commands.gm3.NightCommand;
import client.command.commands.gm3.NoticeCommand;
import client.command.commands.gm3.NpcCommand;
import client.command.commands.gm3.OnlineTwoCommand;
import client.command.commands.gm3.OpenPortalCommand;
import client.command.commands.gm3.PeCommand;
import client.command.commands.gm3.PosCommand;
import client.command.commands.gm3.QuestCompleteCommand;
import client.command.commands.gm3.QuestResetCommand;
import client.command.commands.gm3.QuestStartCommand;
import client.command.commands.gm3.ReloadDropsCommand;
import client.command.commands.gm3.ReloadEventsCommand;
import client.command.commands.gm3.ReloadMapCommand;
import client.command.commands.gm3.ReloadPortalsCommand;
import client.command.commands.gm3.ReloadShopsCommand;
import client.command.commands.gm3.RipCommand;
import client.command.commands.gm3.SeedCommand;
import client.command.commands.gm3.SpawnCommand;
import client.command.commands.gm3.StartEventCommand;
import client.command.commands.gm3.StartMapEventCommand;
import client.command.commands.gm3.StopMapEventCommand;
import client.command.commands.gm3.TimerAllCommand;
import client.command.commands.gm3.TimerCommand;
import client.command.commands.gm3.TimerMapCommand;
import client.command.commands.gm3.ToggleCouponCommand;
import client.command.commands.gm3.UnBanCommand;
import client.command.commands.gm4.BossDropRateCommand;
import client.command.commands.gm4.CakeCommand;
import client.command.commands.gm4.DropRateCommand;
import client.command.commands.gm4.ExpRateCommand;
import client.command.commands.gm4.FishingRateCommand;
import client.command.commands.gm4.ForceVacCommand;
import client.command.commands.gm4.HorntailCommand;
import client.command.commands.gm4.ItemVacCommand;
import client.command.commands.gm4.MesoRateCommand;
import client.command.commands.gm4.PapCommand;
import client.command.commands.gm4.PianusCommand;
import client.command.commands.gm4.PinkbeanCommand;
import client.command.commands.gm4.PlayerNpcCommand;
import client.command.commands.gm4.PlayerNpcRemoveCommand;
import client.command.commands.gm4.PmobCommand;
import client.command.commands.gm4.PmobRemoveCommand;
import client.command.commands.gm4.PnpcCommand;
import client.command.commands.gm4.PnpcRemoveCommand;
import client.command.commands.gm4.ProItemCommand;
import client.command.commands.gm4.QuestRateCommand;
import client.command.commands.gm4.ServerMessageCommand;
import client.command.commands.gm4.SetEqStatCommand;
import client.command.commands.gm4.TravelRateCommand;
import client.command.commands.gm4.ZakumCommand;
import client.command.commands.gm5.DebugCommand;
import client.command.commands.gm5.IpListCommand;
import client.command.commands.gm5.SetCommand;
import client.command.commands.gm5.ShowMoveLifeCommand;
import client.command.commands.gm5.ShowPacketsCommand;
import client.command.commands.gm5.ShowSessionsCommand;
import client.command.commands.gm6.ClearQuestCacheCommand;
import client.command.commands.gm6.ClearQuestCommand;
import client.command.commands.gm6.DCAllCommand;
import client.command.commands.gm6.DevtestCommand;
import client.command.commands.gm6.EraseAllPNpcsCommand;
import client.command.commands.gm6.GetAccCommand;
import client.command.commands.gm6.MapPlayersCommand;
import client.command.commands.gm6.SaveAllCommand;
import client.command.commands.gm6.ServerAddChannelCommand;
import client.command.commands.gm6.ServerAddWorldCommand;
import client.command.commands.gm6.ServerRemoveChannelCommand;
import client.command.commands.gm6.ServerRemoveWorldCommand;
import client.command.commands.gm6.SetGmLevelCommand;
import client.command.commands.gm6.ShutdownCommand;
import client.command.commands.gm6.SpawnAllPNpcsCommand;
import client.command.commands.gm6.SupplyRateCouponCommand;
import client.command.commands.gm6.WarpWorldCommand;
import constants.id.MapId;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -177,7 +344,6 @@ public class CommandsExecutor {
addCommand("droplimit", DropLimitCommand.class);
addCommand("time", TimeCommand.class);
addCommand("credits", StaffCommand.class);
addCommand("buyback", BuyBackCommand.class);
addCommand("uptime", UptimeCommand.class);
addCommand("gacha", GachaCommand.class);
addCommand("dispose", DisposeCommand.class);
@@ -391,6 +557,7 @@ public class CommandsExecutor {
addCommand("addworld", 6, ServerAddWorldCommand.class);
addCommand("removechannel", 6, ServerRemoveChannelCommand.class);
addCommand("removeworld", 6, ServerRemoveWorldCommand.class);
addCommand("devtest", 6, DevtestCommand.class);
commandsNameDesc.add(levelCommandsCursor);
}

View File

@@ -1,48 +0,0 @@
/*
This file is part of the HeavenMS MapleStory Server, commands OdinMS-based
Copyleft (L) 2016 - 2019 RonanLana
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
@Author: Arthur L - Refactored command content into modules
*/
package client.command.commands.gm0;
import client.Client;
import client.command.Command;
import client.processor.action.BuybackProcessor;
public class BuyBackCommand extends Command {
{
setDescription("Revive yourself after a death.");
}
@Override
public void execute(Client c, String[] params) {
if (params.length < 1) {
c.getPlayer().yellowMessage("Syntax: @buyback <info|now>");
return;
}
if (params[0].contentEquals("now")) {
BuybackProcessor.processBuyback(c);
} else {
c.getPlayer().showBuybackInfo();
}
}
}

View File

@@ -0,0 +1,40 @@
package client.command.commands.gm6;
import client.Client;
import client.command.Command;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import scripting.AbstractScriptManager;
import javax.script.Invocable;
import javax.script.ScriptEngine;
import javax.script.ScriptException;
public class DevtestCommand extends Command {
{
setDescription("Runs devtest.js. Developer utility - test stuff without restarting the server.");
}
private static final Logger log = LoggerFactory.getLogger(DevtestCommand.class);
private static class DevtestScriptManager extends AbstractScriptManager {
@Override
public ScriptEngine getInvocableScriptEngine(String path) {
return super.getInvocableScriptEngine(path);
}
}
@Override
public void execute(Client client, String[] params) {
DevtestScriptManager scriptManager = new DevtestScriptManager();
ScriptEngine scriptEngine = scriptManager.getInvocableScriptEngine("devtest.js");
try {
Invocable invocable = (Invocable) scriptEngine;
invocable.invokeFunction("run", client.getPlayer());
} catch (ScriptException | NoSuchMethodException e) {
log.info("devtest.js run() threw an exception", e);
}
}
}

View File

@@ -47,19 +47,19 @@ public abstract class CharacterFactory {
return -1;
}
Character newchar = Character.getDefault(c);
newchar.setWorld(c.getWorld());
newchar.setSkinColor(SkinColor.getById(skin));
newchar.setGender(gender);
newchar.setName(name);
newchar.setHair(hair);
newchar.setFace(face);
Character newCharacter = Character.getDefault(c);
newCharacter.setWorld(c.getWorld());
newCharacter.setSkinColor(SkinColor.getById(skin));
newCharacter.setGender(gender);
newCharacter.setName(name);
newCharacter.setHair(hair);
newCharacter.setFace(face);
newchar.setLevel(recipe.getLevel());
newchar.setJob(recipe.getJob());
newchar.setMapId(recipe.getMap());
newCharacter.setLevel(recipe.getLevel());
newCharacter.setJob(recipe.getJob());
newCharacter.setMapId(recipe.getMap());
Inventory equipped = newchar.getInventory(InventoryType.EQUIPPED);
Inventory equipped = newCharacter.getInventory(InventoryType.EQUIPPED);
ItemInformationProvider ii = ItemInformationProvider.getInstance();
int top = recipe.getTop(), bottom = recipe.getBottom(), shoes = recipe.getShoes(), weapon = recipe.getWeapon();
@@ -88,12 +88,17 @@ public abstract class CharacterFactory {
equipped.addItemFromDB(eq_weapon.copy());
}
if (!newchar.insertNewChar(recipe)) {
if (!MakeCharInfoValidator.isNewCharacterValid(newCharacter)) {
log.warn("Owner from account {} tried to packet edit in character creation", c.getAccountName());
return -2;
}
c.sendPacket(PacketCreator.addNewCharEntry(newchar));
Server.getInstance().createCharacterEntry(newchar);
if (!newCharacter.insertNewChar(recipe)) {
return -2;
}
c.sendPacket(PacketCreator.addNewCharEntry(newCharacter));
Server.getInstance().createCharacterEntry(newCharacter);
Server.getInstance().broadcastGMMessage(c.getWorld(), PacketCreator.sendYellowTip("[New Char]: " + c.getAccountName() + " has created a new character with IGN " + name));
log.info("Account {} created chr with name {}", c.getAccountName(), name);

View File

@@ -0,0 +1,140 @@
package client.creator;
import client.Character;
import client.Job;
import client.inventory.InventoryType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import provider.Data;
import provider.DataTool;
import java.util.HashSet;
import java.util.Set;
public class MakeCharInfo {
private static final Logger log = LoggerFactory.getLogger(MakeCharInfo.class);
private static final String FACE_ID = "0";
private static final String HAIR_ID = "1";
private static final String HAIR_COLOR_ID = "2";
private static final String SKIN_ID = "3";
private static final String TOP_ID = "4";
private static final String BOTTOM_ID = "5";
private static final String SHOE_ID = "6";
private static final String WEAPON_ID = "7";
private final Set<Integer> charFaces = new HashSet<>();
private final Set<Integer> charHairs = new HashSet<>();
private final Set<Integer> charHairColors = new HashSet<>();
private final Set<Integer> charSkins = new HashSet<>();
private final Set<Integer> charTops = new HashSet<>();
private final Set<Integer> charBottoms = new HashSet<>();
private final Set<Integer> charShoes = new HashSet<>();
private final Set<Integer> charWeapons = new HashSet<>();
public MakeCharInfo(Data charInfoData) {
for (Data data : charInfoData.getChildren()) {
switch (data.getName()) {
case FACE_ID -> {
for (Data faceData : data) {
charFaces.add(DataTool.getInt(faceData));
}
}
case HAIR_ID -> {
for (Data hairData : data) {
charHairs.add(DataTool.getInt(hairData));
}
}
case HAIR_COLOR_ID -> {
for (Data hairColorData : data) {
charHairColors.add(DataTool.getInt(hairColorData));
}
}
case SKIN_ID -> {
for (Data skinData : data) {
charSkins.add(DataTool.getInt(skinData));
}
}
case TOP_ID -> {
for (Data topData : data) {
charTops.add(DataTool.getInt(topData));
}
}
case BOTTOM_ID -> {
for (Data bottomData : data) {
charBottoms.add(DataTool.getInt(bottomData));
}
}
case SHOE_ID -> {
for (Data shoeData : data) {
charShoes.add(DataTool.getInt(shoeData));
}
}
case WEAPON_ID -> {
for (Data weaponData : data) {
charWeapons.add(DataTool.getInt(weaponData));
}
}
default -> log.error("Unhandled node inside MakeCharInfo.img.xml: '" + data.getName() + "'");
}
}
}
public boolean verifyFaceId(int id) {
return this.charFaces.contains(id);
}
public boolean verifyHairId(int id) {
if (id % 10 != 0) {
return this.charHairs.contains(id - (id % 10));
}
return this.charHairs.contains(id);
}
public boolean verifyHairColorId(int id) {
return this.charHairColors.contains(id % 10);
}
public boolean verifySkinId(int id) {
return this.charSkins.contains(id);
}
public boolean verifyTopId(int id) {
return this.charTops.contains(id);
}
public boolean verifyBottomId(int id) {
return this.charBottoms.contains(id);
}
public boolean verifyShoeId(int id) {
return this.charShoes.contains(id);
}
public boolean verifyWeaponId(int id) {
return this.charWeapons.contains(id);
}
public boolean verifyCharacter(Character character) {
if (!verifyFaceId(character.getFace())) return false;
if (!verifyHairId(character.getHair())) return false;
if (!verifyHairColorId(character.getHair())) return false;
if (!verifySkinId(character.getSkinColor().getId())) return false;
// Here we only verify the equipment if the character that's being created is of type 'Beginner'
// This is because when the Maple Life A or Maple Life B items are used, the client does not send any data
// regarding what equipment the character should be wearing (as it's all handled server-side)
Job characterJob = character.getJob();
if (characterJob == Job.BEGINNER || characterJob == Job.NOBLESSE || characterJob == Job.LEGEND) {
if (!verifyTopId(character.getInventory(InventoryType.EQUIPPED).getItem((short) -5).getItemId()))
return false;
if (!verifyBottomId(character.getInventory(InventoryType.EQUIPPED).getItem((short) -6).getItemId()))
return false;
if (!verifyShoeId(character.getInventory(InventoryType.EQUIPPED).getItem((short) -7).getItemId()))
return false;
if (!verifyWeaponId(character.getInventory(InventoryType.EQUIPPED).getItem((short) -11).getItemId()))
return false;
}
return true;
}
}

View File

@@ -0,0 +1,41 @@
package client.creator;
import client.Character;
import provider.Data;
import provider.DataProviderFactory;
import provider.wz.WZFiles;
public class MakeCharInfoValidator {
private static final MakeCharInfo charFemale;
private static final MakeCharInfo charMale;
private static final MakeCharInfo orientCharFemale;
private static final MakeCharInfo orientCharMale;
private static final MakeCharInfo premiumCharFemale;
private static final MakeCharInfo premiumCharMale;
static {
Data data = DataProviderFactory.getDataProvider(WZFiles.ETC).getData("MakeCharInfo.img");
charFemale = new MakeCharInfo(data.getChildByPath("Info/CharFemale"));
charMale = new MakeCharInfo(data.getChildByPath("Info/CharMale"));
orientCharFemale = new MakeCharInfo(data.getChildByPath("OrientCharFemale"));
orientCharMale = new MakeCharInfo(data.getChildByPath("OrientCharMale"));
premiumCharFemale = new MakeCharInfo(data.getChildByPath("PremiumCharFemale"));
premiumCharMale = new MakeCharInfo(data.getChildByPath("PremiumCharMale"));
}
private static MakeCharInfo getMakeCharInfo(Character character) {
return switch (character.getJob()) {
case BEGINNER, WARRIOR, MAGICIAN, BOWMAN, THIEF, PIRATE -> character.isMale() ? charMale : charFemale;
case NOBLESSE -> character.isMale() ? premiumCharMale : premiumCharFemale;
case LEGEND -> character.isMale() ? orientCharMale : orientCharFemale;
default -> null;
};
}
public static boolean isNewCharacterValid(Character character) {
MakeCharInfo makeCharInfo = getMakeCharInfo(character);
if (makeCharInfo == null) return false;
return makeCharInfo.verifyCharacter(character);
}
}

View File

@@ -43,7 +43,6 @@ public class BeginnerCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BEGINNER, 1, MapId.MUSHROOM_TOWN, top, bottom, shoes, weapon));
return status;
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.BEGINNER, 1, MapId.MUSHROOM_TOWN, top, bottom, shoes, weapon));
}
}

View File

@@ -43,7 +43,6 @@ public class LegendCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.LEGEND, 1, MapId.ARAN_TUTORIAL_START, top, bottom, shoes, weapon));
return status;
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.LEGEND, 1, MapId.ARAN_TUTORIAL_START, top, bottom, shoes, weapon));
}
}

View File

@@ -43,7 +43,6 @@ public class NoblesseCreator extends CharacterFactory {
}
public static int createCharacter(Client c, String name, int face, int hair, int skin, int top, int bottom, int shoes, int weapon, int gender) {
int status = createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.NOBLESSE, 1, MapId.STARTING_MAP_NOBLESSE, top, bottom, shoes, weapon));
return status;
return createNewCharacter(c, name, face, hair, skin, gender, createRecipe(Job.NOBLESSE, 1, MapId.STARTING_MAP_NOBLESSE, top, bottom, shoes, weapon));
}
}

View File

@@ -1,83 +0,0 @@
/*
This file is part of the HeavenMS MapleStory Server
Copyleft (L) 2016 - 2019 RonanLana
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation version 3 as published by
the Free Software Foundation. You may not use, modify or distribute
this program under any other version of the GNU Affero General Public
License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package client.processor.action; // thanks Alex for pointing out some package structures containing broad modules
import client.Character;
import client.Client;
import server.maps.MapleMap;
import tools.PacketCreator;
/**
* @author RonanLana
*/
public class BuybackProcessor {
public static void processBuyback(Client c) {
Character chr = c.getPlayer();
boolean buyback;
c.lockClient();
try {
buyback = !chr.isAlive() && chr.couldBuyback();
} finally {
c.unlockClient();
}
if (buyback) {
String jobString;
switch (chr.getJobStyle()) {
case WARRIOR:
jobString = "warrior";
break;
case MAGICIAN:
jobString = "magician";
break;
case BOWMAN:
jobString = "bowman";
break;
case THIEF:
jobString = "thief";
break;
case BRAWLER:
case GUNSLINGER:
jobString = "pirate";
break;
default:
jobString = "beginner";
}
chr.healHpMp();
chr.purgeDebuffs();
chr.broadcastStance(chr.isFacingLeft() ? 5 : 4);
MapleMap map = chr.getMap();
map.broadcastMessage(PacketCreator.playSound("Buyback/" + jobString));
map.broadcastMessage(PacketCreator.earnTitleMessage(chr.getName() + " just bought back into the game!"));
chr.sendPacket(PacketCreator.showBuybackEffect());
map.broadcastMessage(chr, PacketCreator.showForeignBuybackEffect(chr.getId()), false);
}
}
}

View File

@@ -68,7 +68,6 @@ public class ServerConfig {
public boolean USE_MTS;
public boolean USE_CPQ;
public boolean USE_AUTOHIDE_GM;
public boolean USE_BUYBACK_SYSTEM;
public boolean USE_FIXED_RATIO_HPMP_UPDATE;
public boolean USE_FAMILY_SYSTEM;
public boolean USE_DUEY;
@@ -195,7 +194,6 @@ public class ServerConfig {
public boolean USE_PERFECT_SCROLLING;
public boolean USE_ENHANCED_CHSCROLL;
public boolean USE_ENHANCED_CRAFTING;
public boolean USE_ENHANCED_CLNSLATE;
public int SCROLL_CHANCE_ROLLS;
public int CHSCROLL_STAT_RATE;
public int CHSCROLL_STAT_RANGE;
@@ -296,14 +294,6 @@ public class ServerConfig {
public int WEDDING_GIFT_LIMIT;
public boolean WEDDING_BLESSER_SHOWFX;
//Buyback Configuration
public boolean USE_BUYBACK_WITH_MESOS;
public float BUYBACK_FEE;
public float BUYBACK_LEVEL_STACK_FEE;
public int BUYBACK_MESO_MULTIPLIER;
public int BUYBACK_RETURN_MINUTES;
public int BUYBACK_COOLDOWN_MINUTES;
// Login timeout by shavit
public long TIMEOUT_DURATION;

View File

@@ -95,46 +95,6 @@ public class ItemId {
public static final int BEGINNERS_GUIDE = 4161001;
public static final int LEGENDS_GUIDE = 4161048;
public static final int NOBLESSE_GUIDE = 4161047;
public static final int SWORD = 1302000; // Weapon
public static final int HAND_AXE = 1312004;
public static final int WOODEN_CLUB = 1322005;
public static final int BASIC_POLEARM = 1442079;
public static final int WHITE_UNDERSHIRT = 1040002; // Top
public static final int UNDERSHIRT = 1040006;
public static final int GREY_TSHIRT = 1040010;
public static final int WHITE_TUBETOP = 1041002;
public static final int YELLOW_TSHIRT = 1041006;
public static final int GREEN_TSHIRT = 1041010;
public static final int RED_STRIPED_TOP = 1041011;
public static final int SIMPLE_WARRIOR_TOP = 1042167;
public static final int BLUE_JEAN_SHORTS = 1060002; // Bottom
public static final int BROWN_COTTON_SHORTS = 1060006;
public static final int RED_MINISKIRT = 1061002;
public static final int INDIGO_MINISKIRT = 1061008;
public static final int SIMPLE_WARRIOR_PANTS = 1062115;
public static final int RED_RUBBER_BOOTS = 1072001;
public static final int LEATHER_SANDALS = 1072005;
public static final int YELLOW_RUBBER_BOOTS = 1072037;
public static final int BLUE_RUBBER_BOOTS = 1072038;
public static final int AVERAGE_MUSASHI_SHOES = 1072383;
public static final int BLACK_TOBEN = 30000; // Hair
public static final int ZETA = 30010;
public static final int BLACK_REBEL = 30020;
public static final int BLACK_BUZZ = 30030;
public static final int BLACK_SAMMY = 31000;
public static final int BLACK_EDGY = 31040;
public static final int BLACK_CONNIE = 31050;
public static final int MOTIVATED_LOOK_M = 20000; // Face
public static final int PERPLEXED_STARE = 20001;
public static final int LEISURE_LOOK_M = 20002;
public static final int MOTIVATED_LOOK_F = 21000;
public static final int FEARFUL_STARE_M = 21001;
public static final int LEISURE_LOOK_F = 21002;
public static final int FEARFUL_STARE_F = 21201;
public static final int PERPLEXED_STARE_HAZEL = 20401;
public static final int LEISURE_LOOK_HAZEL = 20402;
public static final int MOTIVATED_LOOK_AMETHYST = 21700;
public static final int MOTIVATED_LOOK_BLUE = 20100;
// Warrior
public static final int RED_HWARANG_SHIRT = 1040021;

View File

@@ -25,7 +25,6 @@ import client.Character;
import client.Client;
import client.inventory.Equip;
import client.inventory.Item;
import client.processor.action.BuybackProcessor;
import config.YamlConfig;
import net.AbstractPacketHandler;
import net.packet.InPacket;
@@ -45,136 +44,132 @@ import java.util.List;
public final class EnterMTSHandler extends AbstractPacketHandler {
@Override
public final void handlePacket(InPacket p, Client c) {
public void handlePacket(InPacket p, Client c) {
Character chr = c.getPlayer();
if (!chr.isAlive() && YamlConfig.config.server.USE_BUYBACK_SYSTEM) {
BuybackProcessor.processBuyback(c);
if (!YamlConfig.config.server.USE_MTS) {
c.sendPacket(PacketCreator.enableActions());
} else {
if (!YamlConfig.config.server.USE_MTS) {
c.sendPacket(PacketCreator.enableActions());
return;
}
if (chr.getEventInstance() != null) {
c.sendPacket(PacketCreator.serverNotice(5, "Entering Cash Shop or MTS are disabled when registered on an event."));
c.sendPacket(PacketCreator.enableActions());
return;
}
if (MiniDungeonInfo.isDungeonMap(chr.getMapId())) {
c.sendPacket(PacketCreator.serverNotice(5, "Changing channels or entering Cash Shop or MTS are disabled when inside a Mini-Dungeon."));
c.sendPacket(PacketCreator.enableActions());
return;
}
if (FieldLimit.CANNOTMIGRATE.check(chr.getMap().getFieldLimit())) {
chr.dropMessage(1, "You can't do it here in this map.");
c.sendPacket(PacketCreator.enableActions());
return;
}
if (!chr.isAlive()) {
c.sendPacket(PacketCreator.enableActions());
return;
}
if (chr.getLevel() < 10) {
c.sendPacket(PacketCreator.blockedMessage2(5));
c.sendPacket(PacketCreator.enableActions());
return;
}
chr.closePlayerInteractions();
chr.closePartySearchInteractions();
chr.unregisterChairBuff();
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(chr.getId(), chr.getAllBuffs());
Server.getInstance().getPlayerBuffStorage().addDiseasesToStorage(chr.getId(), chr.getAllDiseases());
chr.setAwayFromChannelWorld();
chr.notifyMapTransferToPartner(-1);
chr.removeIncomingInvites();
chr.cancelAllBuffs(true);
chr.cancelAllDebuffs();
chr.cancelBuffExpireTask();
chr.cancelDiseaseExpireTask();
chr.cancelSkillCooldownTask();
chr.cancelExpirationTask();
chr.forfeitExpirableQuests();
chr.cancelQuestExpirationTask();
chr.saveCharToDB();
c.getChannelServer().removePlayer(chr);
chr.getMap().removePlayer(c.getPlayer());
try {
c.sendPacket(PacketCreator.openCashShop(c, true));
} catch (Exception ex) {
ex.printStackTrace();
}
chr.getCashShop().open(true);// xD
c.enableCSActions();
c.sendPacket(PacketCreator.MTSWantedListingOver(0, 0));
c.sendPacket(PacketCreator.showMTSCash(c.getPlayer()));
List<MTSItemInfo> items = new ArrayList<>();
int pages = 0;
try (Connection con = DatabaseConnection.getConnection()) {
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = 1 AND transfer = 0 ORDER BY id DESC LIMIT 16, 16");
ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
if (rs.getInt("type") != 1) {
Item i = new Item(rs.getInt("itemid"), (short) 0, (short) rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo(i, rs.getInt("price") + 100 + (int) (rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setVicious((short) rs.getInt("vicious"));
equip.setFlag((short) rs.getInt("flag"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setItemLevel(rs.getByte("itemlevel"));
equip.setItemExp(rs.getInt("itemexp"));
equip.setRingId(rs.getInt("ringid"));
equip.setExpiration(rs.getLong("expiration"));
equip.setGiftFrom(rs.getString("giftFrom"));
items.add(new MTSItemInfo(equip, rs.getInt("price") + 100 + (int) (rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
}
try (PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items");
ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
c.sendPacket(PacketCreator.sendMTS(items, 1, 0, 0, pages));
c.sendPacket(PacketCreator.transferInventory(getTransfer(chr.getId())));
c.sendPacket(PacketCreator.notYetSoldInv(getNotYetSold(chr.getId())));
return;
}
if (chr.getEventInstance() != null) {
c.sendPacket(PacketCreator.serverNotice(5, "Entering Cash Shop or MTS are disabled when registered on an event."));
c.sendPacket(PacketCreator.enableActions());
return;
}
if (MiniDungeonInfo.isDungeonMap(chr.getMapId())) {
c.sendPacket(PacketCreator.serverNotice(5, "Changing channels or entering Cash Shop or MTS are disabled when inside a Mini-Dungeon."));
c.sendPacket(PacketCreator.enableActions());
return;
}
if (FieldLimit.CANNOTMIGRATE.check(chr.getMap().getFieldLimit())) {
chr.dropMessage(1, "You can't do it here in this map.");
c.sendPacket(PacketCreator.enableActions());
return;
}
if (!chr.isAlive()) {
c.sendPacket(PacketCreator.enableActions());
return;
}
if (chr.getLevel() < 10) {
c.sendPacket(PacketCreator.blockedMessage2(5));
c.sendPacket(PacketCreator.enableActions());
return;
}
chr.closePlayerInteractions();
chr.closePartySearchInteractions();
chr.unregisterChairBuff();
Server.getInstance().getPlayerBuffStorage().addBuffsToStorage(chr.getId(), chr.getAllBuffs());
Server.getInstance().getPlayerBuffStorage().addDiseasesToStorage(chr.getId(), chr.getAllDiseases());
chr.setAwayFromChannelWorld();
chr.notifyMapTransferToPartner(-1);
chr.removeIncomingInvites();
chr.cancelAllBuffs(true);
chr.cancelAllDebuffs();
chr.cancelBuffExpireTask();
chr.cancelDiseaseExpireTask();
chr.cancelSkillCooldownTask();
chr.cancelExpirationTask();
chr.forfeitExpirableQuests();
chr.cancelQuestExpirationTask();
chr.saveCharToDB();
c.getChannelServer().removePlayer(chr);
chr.getMap().removePlayer(c.getPlayer());
try {
c.sendPacket(PacketCreator.openCashShop(c, true));
} catch (Exception ex) {
ex.printStackTrace();
}
chr.getCashShop().open(true);// xD
c.enableCSActions();
c.sendPacket(PacketCreator.MTSWantedListingOver(0, 0));
c.sendPacket(PacketCreator.showMTSCash(c.getPlayer()));
List<MTSItemInfo> items = new ArrayList<>();
int pages = 0;
try (Connection con = DatabaseConnection.getConnection()) {
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM mts_items WHERE tab = 1 AND transfer = 0 ORDER BY id DESC LIMIT 16, 16");
ResultSet rs = ps.executeQuery()) {
while (rs.next()) {
if (rs.getInt("type") != 1) {
Item i = new Item(rs.getInt("itemid"), (short) 0, (short) rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo(i, rs.getInt("price") + 100 + (int) (rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
} else {
Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
equip.setOwner(rs.getString("owner"));
equip.setQuantity((short) 1);
equip.setAcc((short) rs.getInt("acc"));
equip.setAvoid((short) rs.getInt("avoid"));
equip.setDex((short) rs.getInt("dex"));
equip.setHands((short) rs.getInt("hands"));
equip.setHp((short) rs.getInt("hp"));
equip.setInt((short) rs.getInt("int"));
equip.setJump((short) rs.getInt("jump"));
equip.setVicious((short) rs.getInt("vicious"));
equip.setFlag((short) rs.getInt("flag"));
equip.setLuk((short) rs.getInt("luk"));
equip.setMatk((short) rs.getInt("matk"));
equip.setMdef((short) rs.getInt("mdef"));
equip.setMp((short) rs.getInt("mp"));
equip.setSpeed((short) rs.getInt("speed"));
equip.setStr((short) rs.getInt("str"));
equip.setWatk((short) rs.getInt("watk"));
equip.setWdef((short) rs.getInt("wdef"));
equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
equip.setLevel((byte) rs.getInt("level"));
equip.setItemLevel(rs.getByte("itemlevel"));
equip.setItemExp(rs.getInt("itemexp"));
equip.setRingId(rs.getInt("ringid"));
equip.setExpiration(rs.getLong("expiration"));
equip.setGiftFrom(rs.getString("giftFrom"));
items.add(new MTSItemInfo(equip, rs.getInt("price") + 100 + (int) (rs.getInt("price") * 0.1), rs.getInt("id"), rs.getInt("seller"), rs.getString("sellername"), rs.getString("sell_ends")));
}
}
}
try (PreparedStatement ps = con.prepareStatement("SELECT COUNT(*) FROM mts_items");
ResultSet rs = ps.executeQuery()) {
if (rs.next()) {
pages = (int) Math.ceil(rs.getInt(1) / 16);
}
}
} catch (SQLException e) {
e.printStackTrace();
}
c.sendPacket(PacketCreator.sendMTS(items, 1, 0, 0, pages));
c.sendPacket(PacketCreator.transferInventory(getTransfer(chr.getId())));
c.sendPacket(PacketCreator.notYetSoldInv(getNotYetSold(chr.getId())));
}
private List<MTSItemInfo> getNotYetSold(int cid) {
@@ -276,4 +271,4 @@ public final class EnterMTSHandler extends AbstractPacketHandler {
}
return items;
}
}
}

View File

@@ -25,8 +25,12 @@ import client.Character;
import client.Client;
import client.Skill;
import client.SkillFactory;
import client.inventory.*;
import client.inventory.Equip;
import client.inventory.Equip.ScrollResult;
import client.inventory.Inventory;
import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.ModifyInventory;
import client.inventory.manipulator.InventoryManipulator;
import constants.id.ItemId;
import constants.inventory.ItemConstants;
@@ -37,7 +41,6 @@ import tools.PacketCreator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @author Matze
@@ -50,8 +53,8 @@ public final class ScrollHandler extends AbstractPacketHandler {
if (c.tryacquireClient()) {
try {
p.readInt(); // whatever...
short slot = p.readShort();
short dst = p.readShort();
short scrollSlot = p.readShort();
short equipSlot = p.readShort();
byte ws = (byte) p.readShort();
boolean whiteScroll = false; // white scroll being used?
boolean legendarySpirit = false; // legendary spirit skill
@@ -61,24 +64,21 @@ public final class ScrollHandler extends AbstractPacketHandler {
ItemInformationProvider ii = ItemInformationProvider.getInstance();
Character chr = c.getPlayer();
Equip toScroll = (Equip) chr.getInventory(InventoryType.EQUIPPED).getItem(dst);
Equip toScroll = (Equip) chr.getInventory(InventoryType.EQUIPPED).getItem(equipSlot);
Skill LegendarySpirit = SkillFactory.getSkill(1003);
if (chr.getSkillLevel(LegendarySpirit) > 0 && dst >= 0) {
if (chr.getSkillLevel(LegendarySpirit) > 0 && equipSlot >= 0) {
legendarySpirit = true;
toScroll = (Equip) chr.getInventory(InventoryType.EQUIP).getItem(dst);
toScroll = (Equip) chr.getInventory(InventoryType.EQUIP).getItem(equipSlot);
}
byte oldLevel = toScroll.getLevel();
byte oldSlots = toScroll.getUpgradeSlots();
Inventory useInventory = chr.getInventory(InventoryType.USE);
Item scroll = useInventory.getItem(slot);
Item scroll = useInventory.getItem(scrollSlot);
Item wscroll = null;
if (ItemConstants.isCleanSlate(scroll.getItemId())) {
Map<String, Integer> eqStats = ii.getEquipStats(toScroll.getItemId()); // clean slate issue found thanks to Masterrulax
if (eqStats == null || eqStats.get("tuc") == 0) {
announceCannotScroll(c, legendarySpirit);
return;
}
if (ItemConstants.isCleanSlate(scroll.getItemId()) && !ii.canUseCleanSlate(toScroll)) {
announceCannotScroll(c, legendarySpirit);
return;
} else if (!ItemConstants.isModifierScroll(scroll.getItemId()) && toScroll.getUpgradeSlots() < 1) {
announceCannotScroll(c, legendarySpirit); // thanks onechord for noticing zero upgrade slots freezing Legendary Scroll UI
return;
@@ -103,11 +103,6 @@ public final class ScrollHandler extends AbstractPacketHandler {
}
}
if (ItemConstants.isCleanSlate(scroll.getItemId()) && !ii.canUseCleanSlate(toScroll)) {
announceCannotScroll(c, legendarySpirit);
return;
}
Equip scrolled = (Equip) ii.scrollEquipWithId(toScroll, scroll.getItemId(), whiteScroll, 0, chr.isGM());
ScrollResult scrollSuccess = Equip.ScrollResult.FAIL; // fail
if (scrolled == null) {
@@ -141,7 +136,7 @@ public final class ScrollHandler extends AbstractPacketHandler {
if (scrollSuccess == Equip.ScrollResult.CURSE) {
if (!ItemId.isWeddingRing(toScroll.getItemId())) {
mods.add(new ModifyInventory(3, toScroll));
if (dst < 0) {
if (equipSlot < 0) {
Inventory inv = chr.getInventory(InventoryType.EQUIPPED);
inv.lockInventory();
@@ -174,7 +169,7 @@ public final class ScrollHandler extends AbstractPacketHandler {
}
c.sendPacket(PacketCreator.modifyInventory(true, mods));
chr.getMap().broadcastMessage(PacketCreator.getScrollEffect(chr.getId(), scrollSuccess, legendarySpirit, whiteScroll));
if (dst < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) {
if (equipSlot < 0 && (scrollSuccess == Equip.ScrollResult.SUCCESS || scrollSuccess == Equip.ScrollResult.CURSE)) {
chr.equipChanged();
}
} finally {

View File

@@ -228,10 +228,10 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
return;
}
short flag = eq.getFlag();
flag |= ItemConstants.LOCK;
if (eq.getExpiration() > -1) {
if (eq.getExpiration() > -1 && (eq.getFlag() & ItemConstants.LOCK) != ItemConstants.LOCK) {
return; //No perma items pls
}
flag |= ItemConstants.LOCK;
eq.setFlag(flag);
long period = 0;
@@ -246,7 +246,8 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
}
if (period > 0) {
eq.setExpiration(currentServerTime() + DAYS.toMillis(period));
long expiration = eq.getExpiration() > -1 ? eq.getExpiration() : currentServerTime();
eq.setExpiration(expiration + DAYS.toMillis(period));
}
// double-remove found thanks to BHB

View File

@@ -25,43 +25,14 @@ import client.Client;
import client.creator.novice.BeginnerCreator;
import client.creator.novice.LegendCreator;
import client.creator.novice.NoblesseCreator;
import constants.id.ItemId;
import net.AbstractPacketHandler;
import net.packet.InPacket;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.PacketCreator;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public final class CreateCharHandler extends AbstractPacketHandler {
private static final Logger log = LoggerFactory.getLogger(CreateCharHandler.class);
private final static Set<Integer> IDs = new HashSet<>(Arrays.asList(
ItemId.SWORD, ItemId.HAND_AXE, ItemId.WOODEN_CLUB, ItemId.BASIC_POLEARM,// weapons
ItemId.WHITE_UNDERSHIRT, ItemId.UNDERSHIRT, ItemId.GREY_TSHIRT, ItemId.WHITE_TUBETOP, ItemId.YELLOW_TSHIRT,
ItemId.GREEN_TSHIRT, ItemId.RED_STRIPED_TOP, ItemId.SIMPLE_WARRIOR_TOP,// bottom
ItemId.BLUE_JEAN_SHORTS, ItemId.BROWN_COTTON_SHORTS, ItemId.RED_MINISKIRT, ItemId.INDIGO_MINISKIRT,
ItemId.SIMPLE_WARRIOR_PANTS, // top
ItemId.RED_RUBBER_BOOTS, ItemId.LEATHER_SANDALS, ItemId.YELLOW_RUBBER_BOOTS, ItemId.BLUE_RUBBER_BOOTS,
ItemId.AVERAGE_MUSASHI_SHOES,// shoes
ItemId.BLACK_TOBEN, ItemId.ZETA, ItemId.BLACK_REBEL, ItemId.BLACK_BUZZ, ItemId.BLACK_SAMMY,
ItemId.BLACK_EDGY, ItemId.BLACK_CONNIE,// hair
ItemId.MOTIVATED_LOOK_M, ItemId.PERPLEXED_STARE, ItemId.LEISURE_LOOK_M, ItemId.MOTIVATED_LOOK_F,
ItemId.FEARFUL_STARE_M, ItemId.LEISURE_LOOK_F, ItemId.FEARFUL_STARE_F, ItemId.PERPLEXED_STARE_HAZEL,
ItemId.LEISURE_LOOK_HAZEL, ItemId.MOTIVATED_LOOK_AMETHYST, ItemId.MOTIVATED_LOOK_BLUE //face
//#NeverTrustStevenCode
));
private static boolean isLegal(Integer toCompare) {
return IDs.contains(toCompare);
}
@Override
public final void handlePacket(InPacket p, Client c) {
public void handlePacket(InPacket p, Client c) {
String name = p.readString();
int job = p.readInt();
int face = p.readInt();
@@ -76,15 +47,6 @@ public final class CreateCharHandler extends AbstractPacketHandler {
int weapon = p.readInt();
int gender = p.readByte();
int[] items = new int[]{weapon, top, bottom, shoes, hair, face};
for (int item : items) {
if (!isLegal(item)) {
log.warn("Owner from account {} tried to packet edit in chr creation", c.getAccountName());
c.disconnect(true, false);
return;
}
}
int status;
switch (job) {
case 0: // Knights of Cygnus

View File

@@ -22,9 +22,16 @@
package server;
import client.Character;
import client.*;
import client.Client;
import client.Job;
import client.Skill;
import client.SkillFactory;
import client.autoban.AutobanFactory;
import client.inventory.*;
import client.inventory.Equip;
import client.inventory.Inventory;
import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.WeaponType;
import config.YamlConfig;
import constants.id.ItemId;
import constants.inventory.EquipSlot;
@@ -35,19 +42,36 @@ import constants.skills.NightWalker;
import net.server.Server;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import provider.*;
import provider.Data;
import provider.DataDirectoryEntry;
import provider.DataFileEntry;
import provider.DataProvider;
import provider.DataProviderFactory;
import provider.DataTool;
import provider.wz.WZFiles;
import server.MakerItemFactory.MakerItemCreateEntry;
import server.life.LifeFactory;
import server.life.MonsterInformationProvider;
import tools.*;
import tools.DatabaseConnection;
import tools.PacketCreator;
import tools.Pair;
import tools.Randomizer;
import tools.StringUtil;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
/**
* @author Matze
@@ -1025,9 +1049,16 @@ public class ItemInformationProvider {
Issue with clean slate found thanks to Masterrulax
Vicious added in the clean slate check thanks to Crypter (CrypterDEV)
*/
public boolean canUseCleanSlate(Equip nEquip) {
Map<String, Integer> eqstats = this.getEquipStats(nEquip.getItemId());
return YamlConfig.config.server.USE_ENHANCED_CLNSLATE || nEquip.getUpgradeSlots() < (byte) (eqstats.get("tuc") + nEquip.getVicious());
public boolean canUseCleanSlate(Equip equip) {
Map<String, Integer> eqStats = getEquipStats(equip.getItemId());
if (eqStats == null || eqStats.get("tuc") == 0 ) {
return false;
}
int totalUpgradeCount = eqStats.get("tuc");
int freeUpgradeCount = equip.getUpgradeSlots();
int viciousCount = equip.getVicious();
int appliedScrollCount = equip.getLevel();
return freeUpgradeCount + appliedScrollCount < totalUpgradeCount + viciousCount;
}
public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, int vegaItemId, boolean isGM) {

View File

@@ -190,6 +190,11 @@ public class MobSkill {
// TODO: avoid output argument banishPlayersOutput
public void applyEffect(Character player, Monster monster, boolean skill, List<Character> banishPlayersOutput) {
// See if the MobSkill is successful before doing anything
if (!makeChanceResult()) {
return;
}
Disease disease = null;
Map<MonsterStatus, Integer> stats = new EnumMap<>(MonsterStatus.class);
List<Integer> reflection = new ArrayList<>();
@@ -213,12 +218,12 @@ public class MobSkill {
case REVERSE_INPUT -> disease = Disease.CONFUSE;
case UNDEAD -> disease = Disease.ZOMBIFY;
case PHYSICAL_IMMUNE -> {
if (makeChanceResult() && !monster.isBuffed(MonsterStatus.MAGIC_IMMUNITY)) {
if (!monster.isBuffed(MonsterStatus.MAGIC_IMMUNITY)) {
stats.put(MonsterStatus.WEAPON_IMMUNITY, x);
}
}
case MAGIC_IMMUNE -> {
if (makeChanceResult() && !monster.isBuffed(MonsterStatus.WEAPON_IMMUNITY)) {
if (!monster.isBuffed(MonsterStatus.WEAPON_IMMUNITY)) {
stats.put(MonsterStatus.MAGIC_IMMUNITY, x);
}
}

View File

@@ -81,8 +81,9 @@ public class DatabaseConnection {
return true;
}
log.info("Initializing connection pool...");
final HikariConfig config = getConfig();
log.info("Initializing database connection pool. Connecting to:'{}' with user:'{}'", config.getJdbcUrl(),
config.getUsername());
Instant initStart = Instant.now();
try {
dataSource = new HikariDataSource(config);

View File

@@ -20,11 +20,29 @@
*/
package tools;
import client.BuddylistEntry;
import client.BuffStat;
import client.Character;
import client.*;
import client.Character.SkillEntry;
import client.inventory.*;
import client.Client;
import client.Disease;
import client.FamilyEntitlement;
import client.FamilyEntry;
import client.MonsterBook;
import client.Mount;
import client.QuestStatus;
import client.Ring;
import client.Skill;
import client.SkillMacro;
import client.Stat;
import client.inventory.Equip;
import client.inventory.Equip.ScrollResult;
import client.inventory.Inventory;
import client.inventory.InventoryType;
import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.ModifyInventory;
import client.inventory.Pet;
import client.keybind.KeyBinding;
import client.keybind.QuickslotBinding;
import client.newyear.NewYearCardRecord;
@@ -62,19 +80,45 @@ import net.server.world.World;
import server.CashShop.CashItem;
import server.CashShop.CashItemFactory;
import server.CashShop.SpecialCashItem;
import server.*;
import server.DueyPackage;
import server.ItemInformationProvider;
import server.MTSItemInfo;
import server.ShopItem;
import server.Trade;
import server.events.gm.Snowball;
import server.life.*;
import server.maps.*;
import server.life.MobSkill;
import server.life.MobSkillId;
import server.life.Monster;
import server.life.NPC;
import server.life.PlayerNPC;
import server.maps.AbstractMapObject;
import server.maps.Door;
import server.maps.DoorObject;
import server.maps.Dragon;
import server.maps.HiredMerchant;
import server.maps.MapItem;
import server.maps.MapleMap;
import server.maps.MiniGame;
import server.maps.MiniGame.MiniGameResult;
import server.maps.Mist;
import server.maps.PlayerShop;
import server.maps.PlayerShopItem;
import server.maps.Reactor;
import server.maps.Summon;
import server.movement.LifeMovementFragment;
import java.awt.*;
import java.net.InetAddress;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.*;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.TimeZone;
import java.util.stream.Collectors;
/**
@@ -6136,23 +6180,6 @@ public class PacketCreator {
return showSpecialEffect(15);
}
public static Packet showBuybackEffect() {
final OutPacket p = OutPacket.create(SendOpcode.SHOW_ITEM_GAIN_INCHAT);
p.writeByte(11);
p.writeInt(0);
return p;
}
public static Packet showForeignBuybackEffect(int cid) {
final OutPacket p = OutPacket.create(SendOpcode.SHOW_FOREIGN_EFFECT);
p.writeInt(cid);
p.writeByte(11);
p.writeInt(0);
return p;
}
/**
* 0 = Levelup 6 = Exp did not drop (Safety Charms) 7 = Enter portal sound
* 8 = Job change 9 = Quest complete 10 = Recovery 11 = Buff effect

View File

@@ -76,36 +76,4 @@
<sound name="8"/>
<sound name="9"/>
</imgdir>
<imgdir name="quest2293">
<sound name="Die"/>
</imgdir>
<imgdir name="subway">
<sound name="whistle"/>
</imgdir>
<imgdir name="anthem">
<sound name="brazil"/>
</imgdir>
<imgdir name="Buyback">
<sound name="beginner"/>
<sound name="magician"/>
<sound name="thief"/>
<sound name="bowman"/>
<string name="src" value="https://freesound.org/
www.freesfx.co.uk
Warrior: https://freesound.org/people/Sclolex/sounds/209546/download/209546__sclolex__warriordrums.wav
Magician: https://freesound.org/people/Timbre/sounds/221683/download/221683__timbre__another-magic-wand-spell-tinkle.flac
Bowman: https://freesound.org/people/StephenSaldanha/sounds/166515/download/166515__stephensaldanha__srs-cinematic-hit.wav
Thief: https://freesound.org/people/pcruzn/sounds/209579/download/209579__pcruzn__windy-transition.wav
Pirate: https://freesound.org/people/plamdi1/sounds/95062/download/95062__plamdi1__suspense-cue-2.aiff
Common: http://www.freesfx.co.uk/rx2/mp3s/6/18644_1464806042.mp3
"/>
<sound name="warrior"/>
<sound name="pirate"/>
</imgdir>
</imgdir>