Commit 6e14dda8 authored by Benjamin Elsdon's avatar Benjamin Elsdon
Browse files
parents 5cea728e 2d2013df
...@@ -27,7 +27,7 @@ A WIP server emulator for Genshin Impact 2.3-2.6 ...@@ -27,7 +27,7 @@ A WIP server emulator for Genshin Impact 2.3-2.6
### Connecting with the client ### Connecting with the client
½. Create an account using command below ½. Create an account using command below
1. Run a proxy daemon: 1. Run a proxy daemon: (choose either one)
- mitmdump: `mitmdump -s proxy.py --ssl-insecure` - mitmdump: `mitmdump -s proxy.py --ssl-insecure`
- Fiddler Classic: Run Fiddler Classic, turn on `Decrypt https traffic` in setting and change the default port there (Tools -> Options -> Connections) to anything other than `8888`, and load [this script](https://github.lunatic.moe/fiddlerscript). - Fiddler Classic: Run Fiddler Classic, turn on `Decrypt https traffic` in setting and change the default port there (Tools -> Options -> Connections) to anything other than `8888`, and load [this script](https://github.lunatic.moe/fiddlerscript).
- [Hosts file](https://github.com/Melledy/Grasscutter/wiki/Running#traffic-route-map) - [Hosts file](https://github.com/Melledy/Grasscutter/wiki/Running#traffic-route-map)
...@@ -38,7 +38,8 @@ A WIP server emulator for Genshin Impact 2.3-2.6 ...@@ -38,7 +38,8 @@ A WIP server emulator for Genshin Impact 2.3-2.6
* or you can use `run.cmd` to start Server & Proxy daemon with one click * or you can use `run.cmd` to start Server & Proxy daemon with one click
### Grasscutter server console commands # Grasscutter commands
### Server console commands
`account create [username] {playerid}` - Creates an account with the specified username and the in-game uid for that account. The playerid parameter is optional and will be auto generated if not set. `account create [username] {playerid}` - Creates an account with the specified username and the in-game uid for that account. The playerid parameter is optional and will be auto generated if not set.
...@@ -49,10 +50,14 @@ There is a dummy user named "Server" in every player's friends list that you can ...@@ -49,10 +50,14 @@ There is a dummy user named "Server" in every player's friends list that you can
`!give [item id] [amount]` `!give [item id] [amount]`
`!givechar [avatar id] [level]`
`!drop [item id] [amount]` `!drop [item id] [amount]`
`!killall` `!killall`
`!setworldlevel [level]` - Relog to see effects properly
`!godmode` - Prevents you from taking damage `!godmode` - Prevents you from taking damage
`!resetconst` - Resets the constellation level on your current active character, will need to relog after using the command to see any changes. `!resetconst` - Resets the constellation level on your current active character, will need to relog after using the command to see any changes.
...@@ -61,7 +66,7 @@ There is a dummy user named "Server" in every player's friends list that you can ...@@ -61,7 +66,7 @@ There is a dummy user named "Server" in every player's friends list that you can
`!clearartifacts` - Deletes all unequipped and unlocked level 0 artifacts, **including yellow rarity ones** from your inventory `!clearartifacts` - Deletes all unequipped and unlocked level 0 artifacts, **including yellow rarity ones** from your inventory
### Quick Troubleshooting # Quick Troubleshooting
* If compiling wasnt successful, please check your JDK installation (must be JDK 8 and validated JDK's bin PATH variable) * If compiling wasnt successful, please check your JDK installation (must be JDK 8 and validated JDK's bin PATH variable)
* My client doesn't connect, doesn't login, 4206, etc... - Mostly your proxy daemon setup is the issue, if using Fiddler make sure it running on another port except 8888 * My client doesn't connect, doesn't login, 4206, etc... - Mostly your proxy daemon setup is the issue, if using Fiddler make sure it running on another port except 8888
* Startup sequence: Mongodb > Grasscutter > Proxy daemon (mitmdump, fiddler, etc.) > Client * Startup sequence: Mongodb > Grasscutter > Proxy daemon (mitmdump, fiddler, etc.) > Client
......
...@@ -3,6 +3,8 @@ package emu.grasscutter.commands; ...@@ -3,6 +3,8 @@ package emu.grasscutter.commands;
import emu.grasscutter.Grasscutter; import emu.grasscutter.Grasscutter;
import emu.grasscutter.data.GenshinData; import emu.grasscutter.data.GenshinData;
import emu.grasscutter.data.def.ItemData; import emu.grasscutter.data.def.ItemData;
import emu.grasscutter.data.def.AvatarData;
import emu.grasscutter.data.def.AvatarSkillDepotData;
import emu.grasscutter.data.def.MonsterData; import emu.grasscutter.data.def.MonsterData;
import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.GenshinPlayer;
import emu.grasscutter.game.World; import emu.grasscutter.game.World;
...@@ -15,6 +17,7 @@ import emu.grasscutter.game.inventory.Inventory; ...@@ -15,6 +17,7 @@ import emu.grasscutter.game.inventory.Inventory;
import emu.grasscutter.game.inventory.ItemType; import emu.grasscutter.game.inventory.ItemType;
import emu.grasscutter.game.props.ActionReason; import emu.grasscutter.game.props.ActionReason;
import emu.grasscutter.game.props.FightProperty; import emu.grasscutter.game.props.FightProperty;
import emu.grasscutter.game.props.PlayerProperty;
import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify; import emu.grasscutter.server.packet.send.PacketEntityFightPropUpdateNotify;
import emu.grasscutter.server.packet.send.PacketItemAddHintNotify; import emu.grasscutter.server.packet.send.PacketItemAddHintNotify;
import emu.grasscutter.utils.Position; import emu.grasscutter.utils.Position;
...@@ -176,6 +179,133 @@ public final class PlayerCommands { ...@@ -176,6 +179,133 @@ public final class PlayerCommands {
} }
} }
} }
@Command(label = "givechar", aliases = { "givec" }, usage = "Usage: givechar <playerId> <avatarId> [level]")
public static class GiveCharCommand implements CommandHandler {
@Override public void execute(GenshinPlayer player, List<String> args) {
int target, avatarID, level = 1, ascension = 1;
if(args.size() < 2) {
CommandHandler.sendMessage(null, "Usage: givechar <player> <avatarId> [level]");
return;
}
switch(args.size()) {
default:
CommandHandler.sendMessage(null, "Usage: givechar <player> <avatarId> [level]");
return;
case 1:
try {
avatarID = Integer.parseInt(args.get(0));
target = player.getAccount().getPlayerId();
} catch (NumberFormatException ignored) {
// TODO: Parse from avatar name using GM Handbook.
CommandHandler.sendMessage(player, "Invalid avatar id.");
return;
}
break;
case 2:
try {
target = Integer.parseInt(args.get(0));
if(Grasscutter.getGameServer().getPlayerById(target) == null) {
target = player.getId(); level = Integer.parseInt(args.get(1));
avatarID = Integer.parseInt(args.get(0));
} else {
avatarID = Integer.parseInt(args.get(1));
}
} catch (NumberFormatException ignored) {
// TODO: Parse from avatar name using GM Handbook.
CommandHandler.sendMessage(player, "Invalid avatar or player ID.");
return;
}
break;
case 3:
try {
target = Integer.parseInt(args.get(0));
if(Grasscutter.getGameServer().getPlayerById(target) == null) {
CommandHandler.sendMessage(player, "Invalid player ID."); return;
}
avatarID = Integer.parseInt(args.get(1));
level = Integer.parseInt(args.get(2));
} catch (NumberFormatException ignored) {
// TODO: Parse from avatar name using GM Handbook.
CommandHandler.sendMessage(player, "Invalid avatar or player ID.");
return;
}
break;
}
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerById(target);
if(targetPlayer == null) {
CommandHandler.sendMessage(null, "Player not found."); return;
}
AvatarData avatarData = GenshinData.getAvatarDataMap().get(avatarID);
if(avatarData == null) {
CommandHandler.sendMessage(null, "Invalid avatar id."); return;
}
// Calculate ascension level.
if (level <= 40) {
ascension = (int)Math.ceil(level / 20);
} else if (level > 20) {
ascension = (int)Math.ceil(level / 10) - 3;
}
GenshinAvatar avatar = new GenshinAvatar(avatarID);
avatar.setLevel(level);
avatar.setPromoteLevel(ascension);
// This will handle stats and talents
avatar.recalcStats();
targetPlayer.addAvatar(avatar);
}
@Override
public void execute(List<String> args) {
if(args.size() < 2) {
CommandHandler.sendMessage(null, "Usage: givechar <player> <itemId|itemName> [amount]");
return;
}
try {
int target = Integer.parseInt(args.get(0));
int avatarID = Integer.parseInt(args.get(1));
int level = 1; if(args.size() > 2) level = Integer.parseInt(args.get(2));
int ascension = 1;
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerById(target);
if(targetPlayer == null) {
CommandHandler.sendMessage(null, "Player not found."); return;
}
AvatarData avatarData = GenshinData.getAvatarDataMap().get(avatarID);
if(avatarData == null) {
CommandHandler.sendMessage(null, "Invalid avatar id."); return;
}
// Calculate ascension level.
if (level <= 40) {
ascension = (int)Math.ceil(level / 20);
} else if (level > 20) {
ascension = (int)Math.ceil(level / 10) - 3;
}
GenshinAvatar avatar = new GenshinAvatar(avatarID);
avatar.setLevel(level);
avatar.setPromoteLevel(ascension);
// This will handle stats and talents
avatar.recalcStats();
targetPlayer.addAvatar(avatar);
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(null, "Invalid item or player ID.");
}
}
}
@Command(label = "spawn", execution = Command.Execution.PLAYER, @Command(label = "spawn", execution = Command.Execution.PLAYER,
usage = "spawn <entityId|entityName> [level] [amount]", description = "Spawns an entity near you", permission = "server.spawn") usage = "spawn <entityId|entityName> [level] [amount]", description = "Spawns an entity near you", permission = "server.spawn")
...@@ -304,6 +434,29 @@ public final class PlayerCommands { ...@@ -304,6 +434,29 @@ public final class PlayerCommands {
} }
} }
} }
@Command(label = "setworldlevel", aliases = {"setworldlvl"},
usage = "Usage: setworldlevel <level>", execution = Command.Execution.PLAYER)
public static class SetWorldLevelCommand implements CommandHandler {
@Override
public void execute(GenshinPlayer player, List<String> args) {
if(args.size() < 1) {
CommandHandler.sendMessage(null, "Usage: setworldlevel <level>"); return;
}
try {
int level = Integer.parseInt(args.get(0));
// Set in both world and player props
player.getWorld().setWorldLevel(level);
player.setProperty(PlayerProperty.PROP_PLAYER_WORLD_LEVEL, level);
player.dropMessage("World level set to " + level + ".");
} catch (NumberFormatException ignored) {
CommandHandler.sendMessage(null, "Invalid world level.");
}
}
}
@Command(label = "clearartifacts", aliases = {"clearart"}, @Command(label = "clearartifacts", aliases = {"clearart"},
usage = "clearartifacts", execution = Command.Execution.PLAYER, permission = "player.clearartifacts", usage = "clearartifacts", execution = Command.Execution.PLAYER, permission = "player.clearartifacts",
......
...@@ -510,6 +510,21 @@ public class GenshinAvatar { ...@@ -510,6 +510,21 @@ public class GenshinAvatar {
} }
} }
// Add proud skills and unlock them if needed
AvatarSkillDepotData skillDepot = GenshinData.getAvatarSkillDepotDataMap().get(this.getSkillDepotId());
this.getProudSkillList().clear();
for (InherentProudSkillOpens openData : skillDepot.getInherentProudSkillOpens()) {
if (openData.getProudSkillGroupId() == 0) {
continue;
}
if (openData.getNeedAvatarPromoteLevel() <= this.getPromoteLevel()) {
int proudSkillId = (openData.getProudSkillGroupId() * 100) + 1;
if (GenshinData.getProudSkillDataMap().containsKey(proudSkillId)) {
this.getProudSkillList().add(proudSkillId);
}
}
}
// Proud skills // Proud skills
for (int proudSkillId : this.getProudSkillList()) { for (int proudSkillId : this.getProudSkillList()) {
ProudSkillData proudSkillData = GenshinData.getProudSkillDataMap().get(proudSkillId); ProudSkillData proudSkillData = GenshinData.getProudSkillDataMap().get(proudSkillId);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment