公共函数.bas
资源名称:vbmcrisrc.rar [点击查看]
上传用户:pcw2004
上传日期:2022-02-02
资源大小:743k
文件大小:4k
源码类别:
DirextX编程
开发平台:
Visual Basic
- Attribute VB_Name = "公共函数"
- Option Explicit
- '/////// 怪物动作初始化
- Public Sub InitMonAct(MonID As Long)
- Mon(MonID).Face = Rnd * 7
- If Mon(MonID).DBInfo.Race_种族 = 101 Then
- Mon(MonID).Act = Stand_怪站立
- Mon(MonID).Pic = 0
- Mon(MonID).PicSpeed = 0
- Else
- Mon(MonID).Act = Stand_怪站立
- Mon(MonID).Pic = 0
- Mon(MonID).PicSpeed = 0
- End If
- End Sub
- Public Sub InitMon()
- Dim i As Long
- Randomize
- MonCount = 1
- ReDim Mon(MonCount)
- For i = 1 To MonCount
- Mon(i).Id = i
- Mon(i).X = Rnd * Map.Width
- Mon(i).Y = Rnd * Map.Height
- Mon(i).DBInfo = MonDB(GetMonDBNum("祖玛雕像"))
- ' Mon(i).DBInfo = MonDB(Rnd * (MonDBCount - 1) + 1)
- Mon(i).DBInfo.HP = 1000
- Mon(i).MaxHP = Mon(i).DBInfo.HP
- Mon(i).HP = Mon(i).MaxHP
- InitMonAct i
- Map.Map4(Mon(i).X, Mon(i).Y) = Map.Map4(Mon(i).X, Mon(i).Y) + 1
- Next
- End Sub
- Public Sub ItemsXY(mItemName() As String, mItemCount, XX As Long, YY As Long)
- Dim i As Integer, j As Integer, C As Integer
- Dim Work As Boolean, N As Integer
- Dim mICount As Integer
- Work = True
- N = 0
- Do
- N = N + 1
- If N > Map.Width Or N > Map.Height Then Exit Do
- For j = YY + N To YY - N Step -1
- For i = XX - N To XX + N Step 1
- If i >= 0 And i <= Map.Width And j >= 0 And j <= Map.Height Then
- mICount = mICount + 1
- MapItemCount = MapItemCount + 1
- ReDim Preserve MapItem(MapItemCount)
- MapItem(MapItemCount).Id = MapItemCount
- MapItem(MapItemCount).mItem = ItemDB(GetItemNum(mItemName(mICount)))
- MapItem(MapItemCount).X = i
- MapItem(MapItemCount).Y = j
- MapItem(MapItemCount).mTime = GetTickCount
- If mICount = mItemCount Then Exit Do
- End If
- Next
- Next
- DoEvents
- Loop
- End Sub
- Public Sub AddMon(MonName As String, X As Integer, Y As Integer, Optional mCount As Integer = 1, Optional Pos As Integer = 0)
- Dim i As Integer
- If mCount < 1 Then Exit Sub
- For i = 1 To mCount
- MonCount = MonCount + 1
- ReDim Preserve Mon(MonCount)
- Mon(MonCount).Id = MonCount
- If Rnd * 1 < 0.5 Then
- Mon(MonCount).X = X + Rnd * Pos
- Else
- Mon(MonCount).X = X - Rnd * Pos
- End If
- If Rnd * 1 < 0.5 Then
- Mon(MonCount).Y = Y + Rnd * Pos
- Else
- Mon(MonCount).Y = Y - Rnd * Pos
- End If
- If Mon(MonCount).X < 0 Then Mon(MonCount).X = 0
- If Mon(MonCount).X > Map.Width Then Mon(MonCount).X = Map.Width
- If Mon(MonCount).Y < 0 Then Mon(MonCount).Y = 0
- If Mon(MonCount).Y > Map.Height Then Mon(MonCount).Y = Map.Height
- Mon(MonCount).DBInfo = MonDB(GetMonDBNum(MonName))
- Mon(MonCount).MaxHP = Mon(MonCount).DBInfo.HP
- Mon(MonCount).HP = Mon(MonCount).MaxHP
- InitMonAct MonCount
- Mon(MonCount).Dead = False
- Map.Map4(Mon(MonCount).X, Mon(MonCount).Y) = Map.Map4(Mon(MonCount).X, Mon(MonCount).Y) + 1
- Next
- End Sub
- Public Sub ActMonGen()
- Dim i As Integer, mID As Long, mMonCount As Long, j As Long
- FrmMain.Caption = MonGenCount
- If MonGenCount = 0 Then Exit Sub
- For i = 1 To MonGenCount
- If GetTickCount / 1000 / 60 - MonGen(i).LTime > MonGen(i).mTime Then
- MonGen(i).LTime = GetTickCount / 1000 / 60
- mID = GetMonDBNum(MonGen(i).MonName)
- If mID > 0 Then
- AddMon MonGen(i).MonName, MonGen(i).X, MonGen(i).Y, MonGen(i).mCount, MonGen(i).Pos
- End If
- End If
- Next
- End Sub