초기커밋
This commit is contained in:
195
GameServer/Contents/Npc/NpcCheat.cs
Normal file
195
GameServer/Contents/Npc/NpcCheat.cs
Normal file
@@ -0,0 +1,195 @@
|
||||
|
||||
using ServerCommon;
|
||||
using ServerCore; using ServerBase;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
|
||||
using OWNER_GUID = System.String;
|
||||
|
||||
|
||||
namespace GameServer;
|
||||
|
||||
|
||||
//npcattributechangeall [<5B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>Ӽ<EFBFBD><D3BC><EFBFBD>] ["Beacon"] [<5B><><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD>]
|
||||
[ChatCommandAttribute("npcattributechangeall", typeof(ChatCommandNpcAttributeChangeAll), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandNpcAttributeChangeAll : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
Log.getLogger().info($"Call npcattributechangeall !!! - {player.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (args.Length < 3)
|
||||
{
|
||||
err_msg = $"Not enough argument !!! : argCount:{args.Length} == 3 - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
if (false == int.TryParse(args[0], out var to_change_all_value))
|
||||
{
|
||||
Log.getLogger().error($"to_change_all_value param parsing Error arg 1 : {args[0]}");
|
||||
return;
|
||||
}
|
||||
if (0 >= to_change_all_value)
|
||||
{
|
||||
Log.getLogger().error($"Invalid to change Attribute All value of arg 1 !!! : 0 < toChangeValue:{to_change_all_value} - {player.toBasicString()}");
|
||||
return;
|
||||
}
|
||||
|
||||
var npc_type_string = args[1];
|
||||
if (true == npc_type_string.isNullOrWhiteSpace())
|
||||
{
|
||||
err_msg = $"arg 2 (NpcTypeString of EntityType) is empty !!! - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var param = args[2];
|
||||
if (true == param.isNullOrWhiteSpace())
|
||||
{
|
||||
err_msg = $"arg 3 is empty !!! - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var owner_entity_type = OwnerEntityType.None;
|
||||
OWNER_GUID owner_guid = string.Empty;
|
||||
AbilityAction? found_ability_action_nullable;
|
||||
|
||||
var converted_type = EnumHelper.convertEnumTypeAndValueStringToEnum(npc_type_string, EntityType.None);
|
||||
|
||||
if ( EntityType.UgcNpc == converted_type
|
||||
|| EntityType.Beacon == converted_type )
|
||||
{
|
||||
var ugc_npc_nickname = param;
|
||||
|
||||
var player_action = player.getEntityAction<PlayerAction>();
|
||||
ArgumentNullException.ThrowIfNull(player_action, $"player_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var found_ugc_npc = player_action.findUgcNpcByNickname(ugc_npc_nickname);
|
||||
if(null == found_ugc_npc)
|
||||
{
|
||||
err_msg = $"Not found UgcNpc !!! : UgcNpcNickName:{ugc_npc_nickname} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
found_ability_action_nullable = found_ugc_npc.getEntityAction<AbilityAction>();
|
||||
ArgumentNullException.ThrowIfNull(found_ability_action_nullable, $"found_ability_action_nullable is null !!! : {found_ugc_npc.toBasicString()} - {player.toBasicString()}");
|
||||
|
||||
owner_guid = found_ugc_npc.getUgcNpcMetaGuid();
|
||||
owner_entity_type = OwnerEntityType.UgcNpc;
|
||||
}
|
||||
else
|
||||
{
|
||||
err_msg = $"Invalid arg 3 (NpcTypeString of EntityType) !!! : NpcTypeString:{converted_type} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
found_ability_action_nullable.forceSetAbilityAll(to_change_all_value);
|
||||
|
||||
var ntf_msg = new ClientToGameMessage.Types.GS2C_NTF_ATTRIBUTE_UPDATE();
|
||||
ntf_msg.OwnerEntityType = owner_entity_type;
|
||||
ntf_msg.OwnerGuid = owner_guid;
|
||||
ntf_msg.AttributeInfo = found_ability_action_nullable.toAbilityInfo();
|
||||
|
||||
ClientToGame clientToGame = new ClientToGame();
|
||||
clientToGame.Message = new ClientToGameMessage();
|
||||
clientToGame.Message.NtfAttributeUpdate = ntf_msg;
|
||||
GameServerApp.getServerLogic().onSendPacket(player, clientToGame);
|
||||
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
//npcattributechangeall ["Beacon"] [<5B><><EFBFBD><EFBFBD><EFBFBD>г<EFBFBD><D0B3><EFBFBD>]
|
||||
[ChatCommandAttribute("npcattributeresetall", typeof(ChatCommandNpcAttributeResetAll), AuthAdminLevelType.Developer, AuthAdminLevelType.GmNormal, AuthAdminLevelType.GmSuper)]
|
||||
internal class ChatCommandNpcAttributeResetAll : ChatCommandBase
|
||||
{
|
||||
public override async Task invoke(Player player, string token, string[] args)
|
||||
{
|
||||
Log.getLogger().info($"Call npcattributeresetall !!! - {player.toBasicString()}");
|
||||
|
||||
var result = new Result();
|
||||
var err_msg = string.Empty;
|
||||
|
||||
if (args.Length < 2)
|
||||
{
|
||||
err_msg = $"Not enough argument !!! : argCount:{args.Length} == 2 - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var npc_type_string = args[0];
|
||||
if (true == npc_type_string.isNullOrWhiteSpace())
|
||||
{
|
||||
err_msg = $"arg 1 (NpcTypeString of EntityType) is empty !!! - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var param = args[1];
|
||||
if (true == param.isNullOrWhiteSpace())
|
||||
{
|
||||
err_msg = $"arg 2 is empty !!! - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
var owner_entity_type = OwnerEntityType.None;
|
||||
OWNER_GUID owner_guid = string.Empty;
|
||||
AbilityAction? found_ability_action_nullable;
|
||||
|
||||
var converted_type = EnumHelper.convertEnumTypeAndValueStringToEnum(npc_type_string, EntityType.None);
|
||||
|
||||
if ( EntityType.UgcNpc == converted_type
|
||||
|| EntityType.Beacon == converted_type)
|
||||
{
|
||||
var ugc_npc_nickname = param;
|
||||
|
||||
var player_action = player.getEntityAction<PlayerAction>();
|
||||
ArgumentNullException.ThrowIfNull(player_action, $"player_action is null !!! - {player.toBasicString()}");
|
||||
|
||||
var found_ugc_npc = player_action.findUgcNpcByNickname(ugc_npc_nickname);
|
||||
if (null == found_ugc_npc)
|
||||
{
|
||||
err_msg = $"Not found UgcNpc !!! : UgcNpcNickName:{ugc_npc_nickname} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
found_ability_action_nullable = found_ugc_npc.getEntityAction<AbilityAction>();
|
||||
ArgumentNullException.ThrowIfNull(found_ability_action_nullable, $"found_ability_action_nullable is null !!! : {found_ugc_npc.toBasicString()} - {player.toBasicString()}");
|
||||
|
||||
owner_guid = found_ugc_npc.getUgcNpcMetaGuid();
|
||||
owner_entity_type = OwnerEntityType.UgcNpc;
|
||||
}
|
||||
else
|
||||
{
|
||||
err_msg = $"Invalid arg 1 (NpcTypeString of EntityType) !!! : NpcTypeString:{converted_type} - {player.toBasicString()}";
|
||||
Log.getLogger().error(err_msg);
|
||||
return;
|
||||
}
|
||||
|
||||
result = await found_ability_action_nullable.forceResetAll();
|
||||
if (result.isFail())
|
||||
{
|
||||
Log.getLogger().error($"Invalid to forceResetAll() !!! : {result.toBasicString()} - {player.toBasicString()}");
|
||||
return;
|
||||
}
|
||||
|
||||
var ntf_msg = new ClientToGameMessage.Types.GS2C_NTF_ATTRIBUTE_UPDATE();
|
||||
ntf_msg.OwnerEntityType = owner_entity_type;
|
||||
ntf_msg.OwnerGuid = owner_guid;
|
||||
ntf_msg.AttributeInfo = found_ability_action_nullable.toAbilityInfo();
|
||||
|
||||
ClientToGame clientToGame = new ClientToGame();
|
||||
clientToGame.Message = new ClientToGameMessage();
|
||||
clientToGame.Message.NtfAttributeUpdate = ntf_msg;
|
||||
GameServerApp.getServerLogic().onSendPacket(player, clientToGame);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user