数值策划的自我修养(一):任务流程的修改
因为项目要缩短前期主线任务流程,所以我需要对前六张地图的任务进行删减,也需要对任务奖励等相关数值内容进行修改。这篇博文是根据我们项目实际情况,对整个工作过程的梳理(以下内容均已消掉项目真实信息)。
处理front_id与next_id
任务流程的进行是通过程序读取该任务的next_id和front_id参数控制的。所以,首先在任务配置表里将我们不需要的任务行进行置灰,然后利用任务表的next_id和front_id跳过被置灰的任务,即可实现缩减任务流程的效果。代码如下
Sub nextId()
Dim i As Integer
i = 5
For i = 5 To 255
//判断当前任务是不是被置灰的任务 ,如果是则继续执行
If Cells(i, 1).Interior.Color = Cells(2, 1).Interior.Color Then
Dim n As Integer
//被置灰的任务最多连续出现50个
For n = 1 To 50
//从当前任务向下检索,直到找到下一个为被置灰的任务
If Cells(i + n, 1).Interior.Color = Cells(2, 1).Interior.Color Then
//找到当前未被置灰任务的下一个未置灰任务,这个任务的ID就是当前任务的next_id
Cells(i, 3) = "[" & Cells(i + n, 1) & "]"
//找到一个就立刻跳出当前循环,进入下一个任务netx_id的查找
Exit For
End If
Next n
End If
Next i
End Sub
front_id与next_id的作用正好相反,代表当前任务的上一个任务。所以我们只需要将查找next_id的思路倒过来,向上查找上一个未置灰任务的id,就是我们当前任务的front_id
Sub frontid()
Dim i As Integer
For i = 5 To 255
//判断当前任务是不是被置灰的任务 ,如果是则继续执行
If Cells(i, 1).Interior.Color = Cells(2, 1).Interior.Color Then
Dim n As Integer
//被置灰的任务最多连续出现50个
For n = 1 To 50
//从当前任务向上检索,直到找到上一个为被置灰的任务
If Cells(i - n, 1).Interior.Color = Cells(2, 1).Interior.Color Then
//找到当前未被置灰任务的上一个未置灰任务,这个任务的ID就是当前任务的front_id
Cells(i, 4) = Cells(i - n, 1)
//退出当前循环
Exit For
End If
Next n
End If
Next i
End Sub
执行后效果如图所示(数组项特殊处理)
处理任务奖励
被跳过的任务都有相应的任务奖励(经验、金币,道具等),我们需要把被跳过的任务奖励转移到未被跳过的任务中。简单起见,我们将被跳过的任务奖励累加到之后第一个出现的未被跳过任务中并把单元格置红方便我们检验
Sub rewardadd()
//定义变量接收经验与金币奖励,因为数值较大所以采用Long类型
Dim i As Integer, sumexp As Long, sumgold As Long
sumexp = 0
sumgold = 0
//开始检索
For i = 2 To 255
//如果是被置灰(跳过)的任务
If Cells(i, 9).Interior.Color = Cells(3, 9).Interior.Color Then
//将其奖励累加起来
sumexp = sumexp + Cells(i, 9)
sumgold = sumgold + Cells(i, 11)
//若果是未被置灰的任务,且其上一个任务是被置灰的任务
ElseIf Cells(i, 9).Interior.Color = Cells(2, 9).Interior.Color And Cells(i - 1, 9).Interior.Color = Cells(3, 9).Interior.Color Then
//将之前累加奖励与自身奖励再进行累加,作为自己的任务奖励
Cells(i, 9) = Cells(i, 9) + sumexp
Cells(i, 9).Interior.ColorIndex = 3
Cells(i, 11) = Cells(i, 11) + sumgold
Cells(i, 11).Interior.ColorIndex = 3
//重置累加奖励,继续检索
sumexp = 0
sumgold = 0
End If
Next i
End Sub
等一下,发现问题所在了吗?
如果我们把前面跳过的任务经验奖励,放到下一个没跳过的任务中,会有什么问题?会造成我们的流程中玩家获得不到足够的经验来升级!例如,我们跳过了任务2-4,而第5个任务要求玩家达到N级才能完成任务,这个时候玩家却需要完成任务5才能获得之前的经验补偿!
所以,我们应该倒过来,把后面跳过的任务经验转移至前面没有跳过的任务中,代码如下,
Sub rewardadd()
Dim i As Integer, sumexp As Long, sumgold As Long
sumexp = 0
sumgold = 0
//从后向前检索
For i = 251 To 2 Step -1
If Cells(i, 9).Interior.Color = Cells(3, 9).Interior.Color Then
sumexp = sumexp + Cells(i, 9)
sumgold = sumgold + Cells(i, 11)
//如果该任务没有被跳过且他的下一个任务是被跳过的,就将经验累加至该任务上
ElseIf Cells(i, 9).Interior.Color = Cells(2, 9).Interior.Color And Cells(i + 1, 9).Interior.Color = Cells(3, 9).Interior.Color Then
Cells(i, 9) = Cells(i, 9) + sumexp
Cells(i, 9).Interior.ColorIndex = 3
Cells(i, 11) = Cells(i, 11) + sumgold
Cells(i, 11).Interior.ColorIndex = 3
sumexp = 0
sumgold = 0
End If
Next i
End Sub
统计修改效果
每个任务都有不同的任务类型(杀怪、对话,位面,采集),我们利用代码统计修改前与修改后不同类型的任务数量,写进表格中进行对比
Sub tasksum()
Dim i As Integer, monster As Integer, dialog As Integer, space As Integer, take As Integer, name As String, r As Integer
r = 2
//检索统计表中的地图名
For i = 3 To 8
name = Cells(i, 8)
//检索地图名的相应任务类型,检索到一个,对应类型数量+1
Do While Cells(r, 1) <> ""
If Cells(r, 1) = name Then
If Cells(r, 3) = "杀怪" Then
monster = monster + 1
ElseIf Cells(r, 3) = "对话" Then
dialog = dialog + 1
ElseIf Cells(r, 3) = "完成位面" Then
space = space + 1
ElseIf Cells(r, 3) = "采集" Then
take = take + 1
End If
r = r + 1
Else
r = r + 1
End If
Loop
//将数量写入对应类型
Cells(i, 9) = monster
Cells(i, 10) = dialog
Cells(i, 11) = space
Cells(i, 12) = take
//重置数据,进行下一张地图的检索
monster = 0
dialog = 0
space = 0
take = 0
r = 2
Next i
End Sub
运行后效果如下