|
楼主 |
发表于 2009-11-4 11:05
|
显示全部楼层
Sub fffff()
Dim h, m, i, n, h1, e, k, q As Double
'定义相关变量为Double型
Dim p
Dim a(1 To 5) As Double
Dim b(1 To 4) As Double
Dim c3, c1, c2 As String
Dim tt1 As Date
'---------------------------------------------
'以下为提取工作表1中两个人物的相关数据至数组A(i)和B(i)中去
For i = 1 To 5
a(i) = Worksheets(1).Cells(i + 7, 2).Value
Next i
For i = 1 To 4
b(i) = Worksheets(1).Cells(i + 7, 7).Value
Next i
'--------------------------------------------
e = Worksheets(1).Cells(12, 7).Value
'将怪的经验赋值给e
n = 3
'赋值n=3
If a(2) = 0 Then
Call Module1.see11
End If
'进行判定,A(2)是人物的血值, 如果人物!
Do While a(2) > 0 And b(2) > 0
'进行循环(当人物和怪的血大于0,也就是说没有挂掉
h = a(3)
'人物攻击力赋给h
m = b(3)
'怪物攻击力赋值m
k = Worksheets(3).Cells(10, 5).Value
'将工作表3的武器攻击力赋给k
Worksheets(3).Cells(13, 5) = "=rand()"
'工作表3中E13单元格填入Rand()函数随机值
q = Worksheets(3).Cells(13, 5)
'然后将上述得到的随机值赋给q
If mode = True Then
b(2) = b(2) - b(2)
c3 = "你开启是GM模式,怪物被秒杀了"
Worksheets(1).Cells(4, 3).Value = c3
GoTo ess
End If
If h + k > b(4) Then
'人物攻击力加上武器的攻击力大于怪物的防御就
h1 = h - b(4) + k + Int(q * h * 0.1)
'人攻-怪防+武器攻+取整(随机值(0~1)*人攻*0.1)
If Int(q * 100) > Worksheets(3).Cells(9, 5) Then
'---------
'取整(随机值*100)(0~100)大于工作表3 F9 就
'普通攻击一下
b(2) = b(2) - h1
'怪物的血值就减少一个h1数
c1 = h1
'c1等于刚才计算出的刀值
c2 = Worksheets(1).Cells(7, 6).Value
'c2等于怪物的名字
c3 = "[你]对[" & c2 & "]造成了" & c1 & "点伤害"
'c3将刚才上述的整理出一段话
Worksheets(1).Cells(4, 3).Value = c3
'C4进行赋值c3进行显示
Worksheets(1).Shapes("WordArt 16").TextEffect.Text = h1
Worksheets(1).Shapes("WordArt 16").Visible = True
For ds = 1 To 360
Worksheets(1).Shapes("WordArt 16").IncrementRotation 1
Next
DoEvents
Worksheets(1).Shapes("WordArt 16").Visible = False
If b(2) < 1 Then
'假如怪的血值少于1即,怪挂了
GoTo ess
'转到ess执行
End If
Else
'假设Int(q*100)<=F9就猛攻一下
b(2) = b(2) - h1 * Worksheets(3).Cells(9, 6).Value
'怪血=怪血-攻击数
c1 = h1 * Worksheets(3).Cells(9, 6).Value
'c1=h1*F6(工作表3)
c2 = Worksheets(1).Cells(7, 6).Value
c3 = "[你]对[" & c2 & "]造成了" & c1 & "点伤害(致命一击!!!)"
Worksheets(1).Cells(4, 3).Value = c3
'赋值显示刚才攻击的结果
If b(2) < 1 Then
'经过刚才的攻击的,怪死了就转向
GoTo ess
End If
End If
Else
'人攻加武器攻<=怪防
h1 = 0
'攻击值为0,即砍不动怪怪
b(2) = b(2) - 0
c1 = h1
c2 = Worksheets(1).Cells(7, 6).Value
c3 = "[你]对[" & c2 & "]造成了" & c1 & "点伤害"
Worksheets(1).Cells(4, 3).Value = c3
'说明砍不动的结果
End If
'------------------------------------
For i = 1 To 5
Worksheets(1).Cells(i + 7, 2).Value = a(i)
Next i
'两个赋值
For i = 1 To 4
Worksheets(1).Cells(i + 7, 7).Value = b(i)
Next i
'两个赋值
Application.Wait (Now() + TimeValue("00:00:01"))
'程序执行等待1秒.
k = Worksheets(3).Cells(11, 5).Value
'人物防具防御数赋给k
If m > a(4) + k Then
'怪物的攻击值大于人物自防+防具防
h1 = m - a(4) - k
'攻击力点数等于怪攻-人防-防具防
a(2) = a(2) - h1
'人物血值=人物血值-攻击力点数
If a(2) < 1 Then
'假如人挂掉了就执行 bss
GoTo bss
End If
Else
'假如怪攻击力小于或等于人防+防具防
'攻击数为0
h1 = 0
a(2) = a(2) - 0
End If
c1 = h1
c2 = Worksheets(1).Cells(7, 6).Value
c3 = "[" & c2 & "]对[你]造成了" & c1 & "点伤害"
Worksheets(1).Cells(4, 3).Value = c3
'进行刚才的显示
For i = 1 To 5
Worksheets(1).Cells(i + 7, 2).Value = a(i)
Next i
For i = 1 To 4
Worksheets(1).Cells(i + 7, 7).Value = b(i)
Next i
'更新上述值
Application.Wait (Now() + TimeValue("00:00:01"))
'程序执行等待一秒的动作
Loop
'结束的循环的条件为:只要有一个血值<=0即为结束战斗
'ess为怪物死了执行的操作
ess:
Worksheets(1).Cells(9, 7).Value = 0
'怪物挂掉,血值为零
Worksheets(1).Cells(9, 2).Value = Worksheets(3).Cells(3, 2).Value
'为下一轮作准备,从后台读取当前的血值
Worksheets(1).Cells(14, 2).Value = Worksheets(1).Cells(14, 2).Value + Int(Worksheets(1).Cells(13, 7).Value * (1 + Worksheets(3).Cells(12, 5).Value))
Worksheets(1).Cells(12, 2).Value = Worksheets(1).Cells(12, 2).Value + Int(e * (1 + Worksheets(3).Cells(12, 6).Value))
'计算怪物死掉后的经验
Worksheets(1).Cells(4, 3).Value = "你赢了!"
'回写战斗结果
e = Worksheets(1).Cells(12, 2).Value
'将战斗结束后的经验赋给e
For i = 10 To 108
If e > Worksheets(3).Cells(i, 2).Value And Worksheets(3).Cells(i, 1).Value = Worksheets(1).Cells(8, 2).Value Then
Worksheets(1).Cells(4, 3).Value = "你升级了!"
Worksheets(1).Cells(8, 2).Value = Worksheets(1).Cells(8, 2).Value + 1
Worksheets(1).Cells(10, 2).Value = Worksheets(1).Cells(10, 2).Value + 3
Worksheets(1).Cells(11, 2).Value = Worksheets(1).Cells(11, 2).Value + 3
Worksheets(1).Cells(9, 2).Value = Worksheets(3).Cells(3, 2).Value + 30
Call Module2.logon
'显示升级奖励
End If
Next i
If Worksheets(2).Cells(1, 1).Value = 7 And Worksheets(3).Cells(1, 4).Value <> 1 Then
MsgBox ("你击败了BOSS大强王,请领取特殊奖励!")
Worksheets(3).Cells(1, 4).Value = 1
For i = 1 To 10
Call Module2.logon
Next i
MsgBox ("作弊密码第一个字母提示:时间的原点")
End If
If Worksheets(2).Cells(1, 1).Value = 14 And Worksheets(3).Cells(1, 5).Value <> 1 Then
MsgBox ("你击败了BOSS小强大将,他为了向您臣服,愿意献出其属性,你可以吸收其属性了!")
Worksheets(3).Cells(1, 5).Value = 1
Worksheets(1).Cells(9, 2).Value = Worksheets(1).Cells(9, 2).Value + 8000
Worksheets(1).Cells(10, 2).Value = Worksheets(1).Cells(10, 2).Value + 305
Worksheets(1).Cells(11, 2).Value = Worksheets(1).Cells(11, 2).Value + 236
MsgBox ("作弊密码第二个字母提示:ASEA")
End If
If Worksheets(2).Cells(1, 1).Value = 15 And Worksheets(3).Cells(1, 6).Value <> 1 Then
MsgBox ("你击败了BOSS天神小强,属性大幅度提升")
Worksheets(3).Cells(1, 6).Value = 1
Worksheets(1).Cells(9, 2).Value = Worksheets(1).Cells(9, 2).Value + 10000
Worksheets(1).Cells(10, 2).Value = Worksheets(1).Cells(10, 2).Value + 1000
Worksheets(1).Cells(11, 2).Value = Worksheets(1).Cells(11, 2).Value + 800
End If
If Worksheets(2).Cells(1, 1).Value = 16 And Worksheets(3).Cells(1, 7).Value <> 1 Then
MsgBox ("你击败了BOSS天神中强,恭喜你!")
Worksheets(3).Cells(1, 7).Value = 1
MsgBox ("作弊密码第三个字母提示:我为什么总是第一")
End If
If Worksheets(2).Cells(1, 1).Value = 17 And Worksheets(3).Cells(1, 8).Value <> 1 Then
MsgBox ("你击败了BOSS小强天将-赤,得到饰品[小强的触角]()")
Worksheets(3).Cells(1, 8).Value = 1
Worksheets(1).Cells(18, 2).Value = "[小强的触角]"
Worksheets(3).Cells(12, 5).Value = 0.8
Worksheets(3).Cells(12, 6).Value = 0.8
MsgBox ("你装备了 [小强的触角],获得金钱及经验提高80%")
End If
If Worksheets(2).Cells(1, 1).Value = 18 And Worksheets(3).Cells(1, 9).Value <> 1 Then
MsgBox ("你击败了BOSS小强天将-青,得到[曾哥的背心]")
Worksheets(3).Cells(1, 9).Value = 1
Worksheets(1).Cells(17, 2).Value = "[曾哥的背心]"
Worksheets(1).Cells(11, 3).Value = "+4000000"
Worksheets(3).Cells(11, 5).Value = 4000000
MsgBox ("你装备了 [曾哥的背心],防御+4000000")
End If
If Worksheets(2).Cells(1, 1).Value = 19 And Worksheets(3).Cells(1, 10).Value <> 1 Then
MsgBox ("你击败了BOSS小强天将-白,得到[曾哥的吉他]")
Worksheets(3).Cells(1, 10).Value = 1
Worksheets(1).Cells(16, 2).Value = "[曾哥的吉他]"
Worksheets(1).Cells(10, 3).Value = "+5000000"
Worksheets(3).Cells(10, 5).Value = 5000000
Worksheets(3).Cells(9, 5).Value = 55
Worksheets(3).Cells(9, 6).Value = 5
MsgBox ("你装备了 [曾哥的吉他],攻击+5000000,55%的几率5倍暴击!")
End If
If Worksheets(2).Cells(1, 1).Value = 20 And Worksheets(3).Cells(1, 11).Value <> 1 Then
MsgBox ("你击败了最终BOSS小强之神,恭喜你!")
MsgBox ("隐藏BOSS开启!!!")
Worksheets(3).Cells(1, 11).Value = 1
Worksheets(3).Cells(9, 1).Value = 1
MsgBox ("作弊密码第四个字母提示:你错了!")
End If
If Worksheets(2).Cells(1, 1).Value = 21 Then
MsgBox ("你击败了隐藏BOSS[一丁],谢谢您的参与!")
MsgBox ("作弊密码:tbwx-攻击+120万 gmm-金钱+999999999 hy-游戏重置")
End If
For i = 1 To 5
Worksheets(3).Cells(i + 1, 2).Value = Worksheets(1).Cells(i + 7, 2).Value
Next i
Worksheets(3).Cells(7, 2).Value = Worksheets(1).Cells(14, 2).Value
Call Module1.see11
'重新开始赋
Exit Sub
'以下为人物死掉了执行的操作
bss:
Worksheets(1).Cells(9, 2).Value = 1
'血值设为1,方便下一轮操作
Worksheets(1).Cells(4, 3).Value = "你输了"
'进行输的显示
p = MsgBox("你是否相信春哥???", vbYesNo, "注意")
If p = 6 Then
MsgBox ("虽然你输了,但是没关系!信春哥!满血满魔!原地复活!!!")
Call Module1.see11
Else
p = MsgBox("你是否相信曾哥???", vbYesNo, "注意")
If p = 6 Then
MsgBox ("曾哥保佑你!!")
Call Module1.see11
Else
MsgBox ("春哥&曾哥: 凡人,你这是自寻死路!")
Worksheets(1).Cells(14, 2).Value = 0
'将0赋给人物的金钱显示数
Worksheets(3).Cells(7, 2).Value = Worksheets(1).Cells(14, 2).Value
'将人物金钱显示数回写后台人物金钱数
MsgBox ("全部金钱被春哥曾哥抢走!!!")
j = Worksheets(2).Cells(1, 1).Value
'工作表2,A1的值赋给j
For i = 1 To 5
Worksheets(1).Cells(7 + i, 7).Value = Worksheets(2).Cells(i, j).Value
'将怪的参数读取出来
Next i
End If
End If
If Worksheets(1).Cells(14, 2).Value > 0 Then
Worksheets(1).Cells(14, 2).Value = Worksheets(1).Cells(14, 2).Value - Int(Worksheets(1).Cells(14, 2).Value * 0.5)
Worksheets(3).Cells(7, 2).Value = Worksheets(1).Cells(14, 2).Value
MsgBox ("一半金钱被怪物抢走!!!")
'输了,扣除一半的金钱,并对金钱客回写到后观中
End If
Exit Sub
End Sub |
|