游戏开发论坛

 找回密码
 立即注册
搜索
12
返回列表 发新帖
楼主: 唐僧

[原创] 【VBA】RPG网游经验模型搭建和验算

[复制链接]

2

主题

46

帖子

267

积分

中级会员

Rank: 3Rank: 3

积分
267
QQ
发表于 2016-7-7 14:27:15 | 显示全部楼层
Private Sub UserForm_Initialize()
Dim d                '定义字典转换数组用        '
Dim i%
'-------------获取武将所有数据---------------
arr = Sheet3.[a1].Resize(Sheet3.[a1].End(xlDown).Row, Sheet3.[a1].End(xlToRight).Column)
Set d = CreateObject("scripting.dictionary")
For i = 2 To UBound(arr, 1)
    d(arr(i, 2)) = ""
Next i
brr = d.keys
'-------------选择武将库初始化---------------
M1.List = brr
M2.List = brr
M3.List = brr
M4.List = brr
M5.List = brr
M6.List = brr
Y1.List = brr
Y2.List = brr
Y3.List = brr
Y4.List = brr
Y5.List = brr
Y6.List = brr
End Sub
Private Sub get_hero(ByRef newhero As hero)

'-----------------------------------------武将属性数据-------------------------------------------
    '武将攻击状态
    newhero.hero_act = False
    newhero.hero_dead = False
    '武将ID
    newhero.hero_id = arr(newhero.hero_pos + 1, 1)
    '武将名称
    newhero.hero_name = arr(newhero.hero_pos + 1, 2)
    '武将名称
    newhero.hero_indro = arr(newhero.hero_pos + 1, 3)
    '攻击成长
    newhero.hero_atk_up = arr(newhero.hero_pos + 1, 4)
     '防御成长
    newhero.hero_def_up = arr(newhero.hero_pos + 1, 5)
    '血量成长
    newhero.hero_hp_up = arr(newhero.hero_pos + 1, 6)
    '初始攻击
    newhero.hero_ini_atk = arr(newhero.hero_pos + 1, 7)
    '初始防御
    newhero.hero_ini_def = arr(newhero.hero_pos + 1, 8)
    '初始血量
    newhero.hero_ini_hp = arr(newhero.hero_pos + 1, 9)
    '武将类型
    newhero.hero_type = arr(newhero.hero_pos + 1, 10)
    '怒气上限
    newhero.hero_power_limit = arr(newhero.hero_pos + 1, 11)
    '技能ID
    newhero.hero_skill = arr(newhero.hero_pos + 1, 12)
'-----------------------------------------武将属性数据-------------------------------------------

'-----------------------------------------武将类型数据-------------------------------------------
Dim e    '字典e武将类型数据
Dim j%
'-----------------------------------------武将类型数据-------------------------------------------
crr = Sheet4.[a1].Resize(Sheet4.[a1].End(xlDown).Row, Sheet4.[a1].End(xlToRight).Column)
Set e = CreateObject("scripting.dictionary")
For j = 2 To UBound(crr, 1)
    e(crr(j, 1)) = ""
Next j
drr = e.keys
'根据类型获取等级提升值
newhero.hero_atk_lv = crr(Application.WorksheetFunction.Match(newhero.hero_type, drr, 0) + 1, 2)
newhero.hero_def_lv = crr(Application.WorksheetFunction.Match(newhero.hero_type, drr, 0) + 1, 3)
newhero.hero_hp_lv = crr(Application.WorksheetFunction.Match(newhero.hero_type, drr, 0) + 1, 4)
'-----------------------------------------武将类型数据-------------------------------------------
End Sub
Private Sub set_hero(ByRef newlist As ComboBox)
Dim hero_select As hero
Dim hero_newlv As Object
Dim battle_atk As Object
Dim battle_def As Object
Dim battle_hp As Object
'-----------------------------------------NEWLIST------------------------------------------------
Select Case control
'>>>>>>>>>>>>>>>>>>我方阵营<<<<<<<<<<<<<<<<<<
    Case 1
        Set hero_select = Hero_M1
        Set battle_atk = m1_atk
        Set battle_def = m1_def
        Set battle_hp = m1_hp
        Set hero_newlv = m1_lv
    Case 2
        Set hero_select = Hero_M2
        Set battle_atk = m2_atk
        Set battle_def = m2_def
        Set battle_hp = m2_hp
        Set hero_newlv = m2_lv
    Case 3
        Set hero_select = Hero_M3
        Set battle_atk = m3_atk
        Set battle_def = m3_def
        Set battle_hp = m3_hp
        Set hero_newlv = m3_lv
    Case 4
        Set hero_select = Hero_M4
        Set battle_atk = m4_atk
        Set battle_def = m4_def
        Set battle_hp = m4_hp
        Set hero_newlv = m4_lv
    Case 5
        Set hero_select = Hero_M5
        Set battle_atk = m5_atk
        Set battle_def = m5_def
        Set battle_hp = m5_hp
        Set hero_newlv = m5_lv
    Case 6
        Set hero_select = Hero_M6
        Set battle_atk = m6_atk
        Set battle_def = m6_def
        Set battle_hp = m6_hp
        Set hero_newlv = m6_lv
'>>>>>>>>>>>>>>>>>>敌方阵营<<<<<<<<<<<<<<<<<<
    Case 7
        Set hero_select = Hero_Y1
        Set battle_atk = y1_atk
        Set battle_def = y1_def
        Set battle_hp = y1_hp
        Set hero_newlv = y1_lv
    Case 8
        Set hero_select = Hero_Y2
        Set battle_atk = y2_atk
        Set battle_def = y2_def
        Set battle_hp = y2_hp
        Set hero_newlv = y2_lv
    Case 9
        Set hero_select = Hero_Y3
        Set battle_atk = y3_atk
        Set battle_def = y3_def
        Set battle_hp = y3_hp
        Set hero_newlv = y3_lv
    Case 10
        Set hero_select = Hero_Y4
        Set battle_atk = y4_atk
        Set battle_def = y4_def
        Set battle_hp = y4_hp
        Set hero_newlv = y4_lv
    Case 11
        Set hero_select = Hero_Y5
        Set battle_atk = y5_atk
        Set battle_def = y5_def
        Set battle_hp = y5_hp
        Set hero_newlv = y5_lv
    Case 12
        Set hero_select = Hero_Y6
        Set battle_atk = y6_atk
        Set battle_def = y6_def
        Set battle_hp = y6_hp
        Set hero_newlv = y6_lv
End Select

'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>武将数据位置<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
If newlist.Value <> "" Then
'-------------------------------------根据武将选择获取数据--------------------------------------
    hero_select.hero_name = newlist.Value
    hero_select.hero_pos = Application.WorksheetFunction.Match(newlist.Value, brr, 0)
    get_hero hero_select      '<====调用get_hero====>
    hero_indro.text = hero_select.hero_indro
'-----------------------------------------------------------------------------------------------

    '武将等级
    With hero_select
'=========================武将等级========================
        If hero_newlv.Value <> "" Then
            .hero_lv = hero_newlv.Value
        Else
            .hero_lv = 1
        End If
'=========================================================
'----------------------------------------武将攻防血---------------------------------------------
On Error GoTo err

        .hero_atk = .hero_ini_atk + .hero_atk_lv * (.hero_lv - 1) * .hero_atk_up
        .hero_def = .hero_ini_def + .hero_def_lv * (.hero_lv - 1) * .hero_def_up
        .hero_hp = .hero_ini_hp + .hero_hp_lv * (.hero_lv - 1) * .hero_hp_up
        '=================prop================
            battle_atk.Caption = .hero_atk
            battle_def.Caption = .hero_def
            battle_hp.Caption = .hero_hp
    End With
'-----------------------------------------------------------------------------------------------
Else
    MsgBox "请选择武将后再设定等级参数!"
End If
err: MsgBox "请填写正确的武将数据!"
End Sub


1

主题

147

帖子

583

积分

高级会员

Rank: 4

积分
583
发表于 2016-7-7 14:29:58 | 显示全部楼层
唐僧 发表于 2016-7-7 13:49
这位朋友估计是没看excel,模型就是如此,且都已做公式关联,配置即可实现想要的节奏
...

。。还没明白我的意思吗?你的表里没有配对的时间体验公式,而且是需要分阶段调整K值和B,而且你涉及这么多行为干嘛?都是经验总表做好之后再去分配经验的

6

主题

22

帖子

174

积分

注册会员

Rank: 2

积分
174
 楼主| 发表于 2016-7-8 12:53:11 | 显示全部楼层
lathur 发表于 2016-7-7 14:29
。。还没明白我的意思吗?你的表里没有配对的时间体验公式,而且是需要分阶段调整K值和B,而且你涉及这么 ...

这位朋友,不如发个模型出来,让大家参考参考,比较直观

6

主题

22

帖子

174

积分

注册会员

Rank: 2

积分
174
 楼主| 发表于 2016-7-8 13:15:09 | 显示全部楼层
半不癫 发表于 2016-7-7 14:27
Private Sub UserForm_Initialize()
Dim d                '定义字典转换数组用        '
Dim i%

厉害,
这部分代码像是选择武将获取数据属性,属性是通过初始和等级成长算出来的
没有excel,有些地方还不太确定,
话说获取武将属性后,是不是要做战斗模拟?

2

主题

46

帖子

267

积分

中级会员

Rank: 3Rank: 3

积分
267
QQ
发表于 2016-7-8 13:52:54 | 显示全部楼层
唐僧 发表于 2016-7-8 13:15
厉害,
这部分代码像是选择武将获取数据属性,属性是通过初始和等级成长算出来的
没有excel,有些地方还 ...

这只是一部分,我是做了一个USERFORM,可以选择武将对战模拟,文字战报。数据源在EXCEL里,USERFORM选择玩家行为。比如武将是什么,多少级有没有装备,可以扩展至多系统,因为我是用类写的,扩展的话不会去改原来的代码只需要做加法。

6

主题

22

帖子

174

积分

注册会员

Rank: 2

积分
174
 楼主| 发表于 2016-7-8 15:00:52 | 显示全部楼层
半不癫 发表于 2016-7-8 13:52
这只是一部分,我是做了一个USERFORM,可以选择武将对战模拟,文字战报。数据源在EXCEL里,USERFORM选择 ...

厉害,方便的话,分享一下excel

0

主题

3

帖子

8

积分

新手上路

Rank: 1

积分
8
发表于 2016-7-18 09:58:17 | 显示全部楼层
楼主好人
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-6-27 00:19

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表