forked from Asnxthaony/Roco-Kingdom-World-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNRCAutoTest.lua
More file actions
291 lines (244 loc) · 9.69 KB
/
Copy pathNRCAutoTest.lua
File metadata and controls
291 lines (244 loc) · 9.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
local LoginModuleEvent = require("NewRoco.Modules.System.LoginModule.LoginModuleEvent")
local JsonUtils = require("Common.JsonUtils")
NRCAutoTestModule = {}
function NRCAutoTestModule.AvatarMergeTestStart(count)
local localPlayer = NRCModuleManager:DoCmd(PlayerModuleCmd.GET_LOCAL_PLAYER)
UE4.UNRCStatics.ExecConsoleCommand("AvatarSystemCmd TestAvatar Start " .. count, localPlayer:GetUEController())
end
function NRCAutoTestModule.AvatarMergeTestPause()
local localPlayer = NRCModuleManager:DoCmd(PlayerModuleCmd.GET_LOCAL_PLAYER)
UE4.UNRCStatics.ExecConsoleCommand("AvatarSystemCmd TestAvatar pause ", localPlayer:GetUEController())
end
function NRCAutoTestModule.AvatarMergeTestResume()
local localPlayer = NRCModuleManager:DoCmd(PlayerModuleCmd.GET_LOCAL_PLAYER)
UE4.UNRCStatics.ExecConsoleCommand("AvatarSystemCmd TestAvatar resume ", localPlayer:GetUEController())
end
function NRCAutoTestModule.GetMemoryPoolCacheSize()
local MemoryPoolCache = UE4.UNRCStatics.GetMemoryPoolCacheSize()
Log.DebugFormat("MemoryPoolCacheSize = %dMB", MemoryPoolCache)
return MemoryPoolCache
end
function NRCAutoTestModule.DumpLuaObjectInfos()
local mcw = require("Debug.MemoryCheckWrapper")
mcw:DumpCurrMemorySnapshotWithGC()
_G.SnapshotNum = _G.SnapshotNum + 1
collectgarbage("collect")
end
function NRCAutoTestModule.StartMoveRecord()
local playerModule = NRCModuleManager:GetModule("PlayerModule")
playerModule.movementRecorder:StartRecord()
end
function NRCAutoTestModule.StopMoveRecord()
local playerModule = NRCModuleManager:GetModule("PlayerModule")
playerModule.movementRecorder:StopRecord()
end
function NRCAutoTestModule.StartMainPlayerAutoMove()
local debugModule = NRCModuleManager:GetModule("DebugModule")
debugModule:StartMainPlayerAutoMove()
end
function NRCAutoTestModule.EnterTextInLogin(Text)
NRCEventCenter:DispatchEvent(LoginModuleEvent.AutoTestEnterText, Text)
end
function NRCAutoTestModule.SetEnableTeleport()
GlobalConfig.EnableDeahTeleport = not GlobalConfig.EnableDeahTeleport
Log.Debug("EnableDeathTeleport=", GlobalConfig.EnableDeahTeleport)
end
function NRCAutoTestModule.ChangeTime(value)
local time = value or 0
NRCModuleManager:DoCmd(EnvSystemModuleCmd.GMChangeGameTime, time)
end
function NRCAutoTestModule.ChangeTimeScale(value)
local scale = value or 0
NRCModuleManager:DoCmd(EnvSystemModuleCmd.ChangeTimeScale, scale)
end
function NRCAutoTestModule.GetPlayerUin()
return _G.DataModelMgr.PlayerDataModel:GetPlayerUin()
end
function initModuleEnv(envTable, inModuleDotPath)
envTable.__module_define__ = true
envTable.__module_writable__ = true
envTable.__module_path__ = inModuleDotPath
envTable.__sub_module_pure_names__ = {}
envTable.__all_fields__ = {}
function envTable.Ref(prop)
envTable.__all_fields__[prop] = prop
end
local modObjMT = {
__index = {},
__newindex = {}
}
return setmetatable(envTable, modObjMT)
end
function error_handler(err)
local extMsg = ""
extMsg = "[Error]" .. tostring(extMsg)
if err then
extMsg = extMsg .. "\n" .. tostring(err)
end
extMsg = extMsg .. "\n" .. debug.traceback()
UE4.UNRCPlatformGameInstance.GetInstance():ReportLuaErrorMsg(extMsg)
return extMsg
end
function NRCAutoTestModule.DoString(chunkStr)
local func, err = load(chunkStr, "ChunkDoString", "bt")
local _bOK, _rt = xpcall(func, error_handler)
if not _bOK then
Log.Error("[NRCEnv][NRCEditorEntrance]ChunkDoString xpcall error!!!!!!! " .. (_rt or ""))
return
end
return _rt
end
function NRCAutoTestModule.StartAutoPlayBattleRecords(recordsFileName)
BattleAutoTest:StartAutoPlayBattleRecords(recordsFileName)
end
function NRCAutoTestModule.StartAutoBattle()
BattleAutoTest:StartAutoBattle()
end
function NRCAutoTestModule.GetIsInAutoBattle()
if BattleAutoTest.IsAutoBattle then
return "1"
else
return "0"
end
end
function NRCAutoTestModule.GetIsInBattle()
if BattleAutoTest.IsStartBattle then
return "1"
else
return "0"
end
end
function NRCAutoTestModule.GetAutoBattleLogFilePath()
return BattleAutoTest.LogFilePath
end
function NRCAutoTestModule.GetBattleFailNumber()
return tostring(BattleAutoTest.failNumber)
end
function NRCAutoTestModule.BreakAutoBattle()
BattleAutoTest:AddFailNumber()
Log.Warning("自动化战斗测试中, error 日志数目超出限制")
end
function NRCAutoTestModule.ServerUnlockNPC(npc_refresh_cfg_id)
local req = ProtoMessage:newZoneGmUnlockWorldMapStaticNpcReq()
req.npc_refresh_cfg_id = npc_refresh_cfg_id
_G.ZoneServer:SendWithHandler(ProtoCMD.ZoneSvrGmCmd.ZONE_GM_UNLOCK_WORLD_MAP_STATIC_NPC_REQ, req, nil, function()
end)
end
function NRCAutoTestModule.EnterBigWorldLocalMode()
NRCModeManager:ActiveMode("LocalMode")
if _G.GlobalConfig.MemoryAutoTest then
UE4.UKismetSystemLibrary.ExecuteConsoleCommand(nil, "n.CustomGameModePath /Game/Game/NRC/GameMode/AutoTest/DefaultGM.DefaultGM_C")
_G.LevelHelper:OpenLevel("/Game/ArtRes/Level/Game/BigWorld/L_Bigworld_01_Release/L_Bigworld_01_Release")
else
_G.NRCModeManager:DoCmd(SceneModuleCmd.EnterMap, 103)
end
_G.NRCModeManager:DoCmd(EnvSystemModuleCmd.ChangeTimeScale, 1)
end
function NRCAutoTestModule.EnterNothingWorldLocalMode()
NRCModeManager:ActiveMode("LocalMode")
_G.LevelHelper:OpenLevel("/Game/ArtRes/Level/Game/BigWorld/L_Bigworld_01_Release/NothingWorldDGM")
_G.NRCModeManager:DoCmd(EnvSystemModuleCmd.ChangeTimeScale, 1)
end
function NRCAutoTestModule.GetPerformanceTestOver()
local RSPTable = require("Common.LocalServer.LocalBattleRSPTable")
return RSPTable.AutoTestOver
end
function NRCAutoTestModule.MoveToLocation(targetPos)
local localPlayer = NRCModuleManager:DoCmd(PlayerModuleCmd.GET_LOCAL_PLAYER)
local playerPos = localPlayer:GetActorLocation()
local currentLocation = SceneUtils.GetPosInNearLand(playerPos) or playerPos
currentLocation = SceneUtils.ConvertAbsoluteToRelative(currentLocation)
targetPos = SceneUtils.ConvertAbsoluteToRelative(targetPos)
UE4.UNRCNavLibrary.MoveToLocationForce(localPlayer.viewObj, localPlayer:GetUEController(), currentLocation, targetPos, -1, true, true)
end
function NRCAutoTestModule.SpawnNPC(num)
local localPlayer = NRCModuleManager:DoCmd(PlayerModuleCmd.GET_LOCAL_PLAYER)
localPlayer.NPCPressureComponent:SpawnNPC(num)
end
function NRCAutoTestModule.SpawnPet(num)
local localPlayer = NRCModuleManager:DoCmd(PlayerModuleCmd.GET_LOCAL_PLAYER)
localPlayer.NPCPressureComponent:SpawnPet(num)
end
function NRCAutoTestModule.PreLoadNPCTable()
DataConfigManager:GetTable(119)
DataConfigManager:GetTable(107)
DataConfigManager:GetTable(142)
DataConfigManager:GetTable(140)
DataConfigManager:GetTable(209)
DataConfigManager:GetTable(126)
DataConfigManager:GetTable(174)
end
function NRCAutoTestModule.StartUpdateLocalProtocol()
local tab = require("NewRoco.Modules.System.Debug.Tabs.DebugTabBattle")
tab:UpdateLocalProtocol()
end
function NRCAutoTestModule.StartSkillPerformAutoBattle()
local tab = require("NewRoco.Modules.System.Debug.Tabs.DebugTabBattle")
tab:AutoPerformBattle()
end
function NRCAutoTestModule.AutomationStartSkillPerformAutoBattle_FxPerfTool()
local LoginModule = NRCModuleManager:GetModule("LoginModule")
local LoginEnum = require("NewRoco.Modes.LoginMode.LoginEnum")
if not LoginModule then
return false
end
local Panel = LoginModule:GetPanel(LoginEnum.PanelNames.NRCLoginPanel)
if not Panel then
return false
end
local defaultServerList = JsonUtils.LoadDefaultServerList({})
if defaultServerList then
for index, server in ipairs(defaultServerList) do
if 18 == server.id then
Panel.data:SetServer(server)
break
end
end
end
NRCAutoTestModule.StartSkillPerformAutoBattle()
return true
end
function NRCAutoTestModule.GetIsUpdateLocalProtocolFinished()
return ProtoRecorder.IsFinished
end
function NRCAutoTestModule.GetIsSkillPerformAutoBattleStarted()
local SkillPerformAutoBattle = require("Common.LocalServer.SkillPerformAutoBattle")
return SkillPerformAutoBattle.isStarted
end
function NRCAutoTestModule.GetIsSkillPerformAutoBattleFinished()
local SkillPerformAutoBattle = require("Common.LocalServer.SkillPerformAutoBattle")
return SkillPerformAutoBattle.isFinished
end
function NRCAutoTestModule.GetSequenceConf()
local Raw = _G.DataConfigManager:GetTable(DataConfigManager.ConfigTableId.SEQUENCE_CONF):GetAllDatas()
return JsonUtils.EncodeTable(Raw)
end
function NRCAutoTestModule.IsSequencePlaying()
return _G.NRCModuleManager:DoCmd(_G.CinematicModuleCmd.IsPlaying)
end
function NRCAutoTestModule.LoginToMagicAcademy()
UE4.UKismetSystemLibrary.ExecuteConsoleCommand(nil, "WorldTileTool.LoadLevelPath /Game/ArtRes/Level/Game/MagicAcademy/Release/MA_Release")
end
function NRCAutoTestModule.ProfileLayerActorDensity(StreamingLayer)
return UE4.UNRCStatics.ProfileLayerActorDensity(StreamingLayer)
end
function NRCAutoTestModule.LocalEnterBigWorld()
NRCModeManager:ActiveMode("LocalMode")
_G.LevelHelper:OpenLevel("/Game/ArtRes/Level/Game/BigWorld/L_Bigworld_01_Release/L_Bigworld_01_Release")
_G.NRCModeManager:DoCmd(EnvSystemModuleCmd.ChangeTimeScale, 1)
end
function NRCAutoTestModule.LocalEnterMagicAcademy()
NRCModeManager:ActiveMode("LocalMode")
_G.LevelHelper:OpenLevel("/Game/ArtRes/Level/Game/MagicAcademy/Release/MA_Release")
_G.NRCModeManager:DoCmd(EnvSystemModuleCmd.ChangeTimeScale, 1)
end
function NRCAutoTestModule.PureSceneTeleport(X, Y, Z)
UE4.UKismetSystemLibrary.ExecuteConsoleCommand(nil, "WorldTileTool.FreezeAllLevels 0")
local ValueX = tostring(X)
local ValueY = tostring(Y)
local ValueZ = tostring(Z)
local TeleportCommand = "NRCTransport " .. ValueX .. " " .. ValueY .. " " .. ValueZ
Log.Warning(TeleportCommand)
UE4.UKismetSystemLibrary.ExecuteConsoleCommand(nil, TeleportCommand)
end
return NRCAutoTestModule