角色升级模拟VBA(转给想学VBA的数值新人,带附件)
发表于2016-07-03
笔者最近抽空写了一个简单的RPG游戏的升级经验模型。主要包含主线任务、日常任务,其他经验产出渠道可自行补充,这里只分享一个模型思路,抛砖引玉,欢迎大家讨论。
excel中还包含一个升级模拟工具,该工具主要作用是,当频繁调整升级经验时(项目早期),能快速的看到各个经验卡点的变化(主线任务经验不足,需要做日常任务、刷副本等)的情况。实际上如果模型搭建合理,这个验算工具基本没什么卵用。
excel中的数值笔者已做过特殊处理,仅供测试模型用,不建议直接使用:)。
欢迎有兴趣的朋友一起讨论
QQ:1437900504 唐僧
Q群:564663199
以下是相关的VBA代码:
复制代码
excel中还包含一个升级模拟工具,该工具主要作用是,当频繁调整升级经验时(项目早期),能快速的看到各个经验卡点的变化(主线任务经验不足,需要做日常任务、刷副本等)的情况。实际上如果模型搭建合理,这个验算工具基本没什么卵用。
excel中的数值笔者已做过特殊处理,仅供测试模型用,不建议直接使用:)。
欢迎有兴趣的朋友一起讨论
QQ:1437900504 唐僧
Q群:564663199
以下是相关的VBA代码:
- Private Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
- Sub 升级行为模拟器2()
- '模拟器只规划玩家行为,统计经验在表格中。
- '定义变量----------------------------------------------
- action_type = 0 '确定行为类型
- task_zhuxian = "主线"
- task_richang = "日常"
- task_richang_huan_max = 20 '日常任务最大环数
- task_richang_huan_finished = 0
- guaji = "挂机"
- guaji_time_max = 60 * 8 '每日挂机时间
- guaji_time = 0
-
- '初始化数据-------------------------------------------------------------------------------
-
- sheetname = "升级模拟器2.0"
- playerlv = 1 '玩家初始等级
- playerlv_max = 150 '设定玩家等级上限
- action_row = 18 '开始写入行为相关内容的行-------------------
-
- action_column = "L"
- '清空行为区域-------------------------------------------------------------------------------
-
- rangevalue = "L" & action_row & ":L10000" '清空行为区域的范围
- Sheets(sheetname).Select
- Range(rangevalue).Select
- Selection.ClearContents
- '开始循环======================================================================================================================
- For action_row = 18 To 4000
-
- Cells(action_row, 1).Select
- Debug.Print action_row
-
- playerlv = Sheets(sheetname).Cells(action_row, "B") '获取上一次行为后玩家等级
- playerlv_lastture = Sheets(sheetname).Cells(action_row - 1, "B")
- '主线任务-----------------------------------------------------------------------------
- If playerlv = 1 Then
-
- action_type = task_zhuxian
- Sheets(sheetname).Cells(action_row, action_column).Value = action_type & "Lv." & playerlv '写入行为类型
- Debug.Print action_type & "Lv." & playerlv
- GoTo nextfor '跳下一循环
-
- ElseIf playerlv > playerlv_lastture Then '判断是否升级了,如果升级则做主线,并退出当前循环------------------------------------
-
- action_type = task_zhuxian
- Sheets(sheetname).Cells(action_row, action_column).Value = action_type & "Lv." & playerlv '写入行为类型
-
- Debug.Print action_type & "Lv." & playerlv
- GoTo nextfor '跳下一循环
-
- End If
-
-
-
- '日常任务--------------------------------------------------------------------------
-
- If task_richang_huan_finished < task_richang_huan_max Then '如果日常任务还有剩余,则做日常任务,直到升级或做完。
- action_type = task_richang
- task_richang_huan_finished = task_richang_huan_finished + 1
- Sheets(sheetname).Cells(action_row, action_column).Value = action_type & "(" & task_richang_huan_finished & "/" & task_richang_huan_max & ")" '写入行为类型
-
-
- Debug.Print action_type & "(" & task_richang_huan_finished & "/" & task_richang_huan_max & ")"
- GoTo nextfor '跳下一循环
-
- End If
- 'Debug.Print "日常任务已全部完成!!!";
- '挂机--------------------------------------------------------------------------------
- guijia:
-
- If guaji_time < guaji_time_max Then '如果挂机可已做,则做,直到升级或做完
- action_type = guaji
- guaji_time = guaji_time + 60
- Sheets(sheetname).Cells(action_row, action_column).Value = action_type & "(小时:" & guaji_time / 60 & "/" & guaji_time_max / 60 & ")" '写入行为类型
-
-
- Debug.Print action_type & "(" & guaji_time / 60 & "/" & guaji_time_max / 60 & ")"
- GoTo nextfor '跳下一循环
- End If
- 'Debug.Print "挂机已全部完成!!!";
-
-
- '离线&重置次数--------------------------------------------------------------------------------
- lixian:
-
- action_type = lixian
-
- lixian_time = 60 * 24 - guaji_time
- Sheets(sheetname).Cells(action_row, action_column).Value = action_type & "(小时:" & lixian_time / 60 & ")" '写入行为类型
-
- '重置次数和时间
- task_richang_huan_finished = 0
- task_bangpai_huan_finished = 0
- juqingfuben_finished = 0
- 'shouweinvshen_finished = 0
- shouweinvshen_saodang_finished = 0
- 'tongtianta_finished = 0
- tongtianta_saodang_finished = 0
- danaotiangong_finished = 0
- zuduifuben_finished = 0
- yabiao_finished = 0
- shuilufahui_finished = 0
- guaji_time = 0
- '等级最大时---------------------------------------------------------------------------------
-
- If playerlv = playerlv_max Then
- Exit For
- End If
- nextfor: '跳下一循环---------------------------------------------------------------------------
- Next
-
- Sheets("模拟2数据分析").EnableCalculation = True '开启分析表的自动运算
-
- End Sub
附件下载地址:
http://bbs.gameres.com/forum.php?mod=attachment&aid=MzQyNTA5fDIyZmE1ZTNmfDE0Njc4NzExNDB8MTk0MTQ1fDY2ODM2Mg%3D%3D