载入数据库.bas
资源名称:vbmcrisrc.rar [点击查看]
上传用户:pcw2004
上传日期:2022-02-02
资源大小:743k
文件大小:11k
源码类别:
DirextX编程
开发平台:
Visual Basic
- Attribute VB_Name = "载入数据库"
- Option Explicit
- '/////载入刷怪数据
- Public Sub LoadMonGen()
- Dim i As Integer, SS As String
- Dim AA() As String
- Open App.Path & "DataMonGen.txt" For Input As #1
- Do While Not EOF(1)
- Line Input #1, SS
- For i = 9 To 2 Step -1
- SS = Replace(SS, String(i, " "), " ")
- Next i
- If Left(SS, 1) <> ";" Then
- AA = Split(SS, " ")
- If UBound(AA) >= 5 Then
- If GetMonDBNum(AA(0)) > 0 Then
- MonGenCount = MonGenCount + 1
- ReDim Preserve MonGen(MonGenCount)
- MonGen(MonGenCount).MonName = AA(0)
- MonGen(MonGenCount).X = AA(1)
- MonGen(MonGenCount).Y = AA(2)
- MonGen(MonGenCount).mCount = AA(3)
- MonGen(MonGenCount).Pos = AA(4)
- MonGen(MonGenCount).mTime = AA(5)
- End If
- End If
- End If
- DoEvents
- Loop
- Close #1
- End Sub
- '////////// 载入等级HP数据
- Public Sub LoadLevelHP()
- Dim i As Integer
- For i = 1 To 255
- LevelHP(i) = ReadINIFile("HP", Str(i), App.Path & "DataHP.txt")
- Next
- End Sub
- '///////// 载入注册玩家信息
- Public Sub loadRegPlayerInfo()
- Dim i As Integer, j As Integer
- Open App.Path & "SavePlayerPlayerlist.txt" For Input As #1
- Input #1, RegPlayerCount
- ReDim RegPlayer(RegPlayerCount)
- If RegPlayerCount > 0 Then
- For i = 1 To RegPlayerCount
- Input #1, RegPlayer(i).Id
- Input #1, RegPlayer(i).SelNum
- Input #1, RegPlayer(i).SavePlayerCount
- ReDim RegPlayer(i).mPlayer(RegPlayer(i).SavePlayerCount)
- If RegPlayer(i).SavePlayerCount > 0 Then
- For j = 1 To RegPlayer(i).SavePlayerCount
- Input #1, RegPlayer(i).mPlayer(RegPlayer(i).SavePlayerCount).PlayerName
- Input #1, RegPlayer(i).mPlayer(RegPlayer(i).SavePlayerCount).Level
- Input #1, RegPlayer(i).mPlayer(RegPlayer(i).SavePlayerCount).Job
- Input #1, RegPlayer(i).mPlayer(RegPlayer(i).SavePlayerCount).Sex
- Next
- End If
- Next
- End If
- Close #1
- End Sub
- '//////// 载入注册玩家信息
- Public Sub LoadPlayer(PlayerNum As Integer, PlayerName As String)
- Dim i As Integer, SS As String
- Open App.Path & "SavePlayerSave" & PlayerName & ".DB" For Input As #1
- Input #1, Player(PlayerNum).Name_名字
- Input #1, Player(PlayerNum).Level
- Input #1, Player(PlayerNum).Exp_经验值
- Input #1, Player(PlayerNum).Job_职业
- Input #1, Player(PlayerNum).Sex_性别
- Input #1, SaveHero.Gold_金币
- Input #1, Player(PlayerNum).Face
- Input #1, Player(PlayerNum).X
- Input #1, Player(PlayerNum).Y
- Input #1, Player(PlayerNum).HP
- Input #1, Player(PlayerNum).MaxHP
- Input #1, Player(PlayerNum).MP
- Input #1, Player(PlayerNum).MaxMP
- Input #1, Player(PlayerNum).Clothing.State
- Input #1, SS
- Player(PlayerNum).Clothing.Item = GetItem(SS)
- Input #1, Player(PlayerNum).Weapon.State
- Input #1, SS
- Player(PlayerNum).Weapon.Item = GetItem(SS)
- Input #1, Player(PlayerNum).HeadPiece.State
- Input #1, SS
- Player(PlayerNum).HeadPiece.Item = GetItem(SS)
- Input #1, Player(PlayerNum).Necklace.State
- Input #1, SS
- Player(PlayerNum).Necklace.Item = GetItem(SS)
- Input #1, Player(PlayerNum).BraceletLeft.State
- Input #1, SS
- Player(PlayerNum).BraceletLeft.Item = GetItem(SS)
- Input #1, Player(PlayerNum).BraceletRight.State
- Input #1, SS
- Player(PlayerNum).BraceletRight.Item = GetItem(SS)
- Input #1, Player(PlayerNum).FingerRingLeft.State
- Input #1, SS
- Player(PlayerNum).FingerRingLeft.Item = GetItem(SS)
- Input #1, Player(PlayerNum).FingerRingRight.State
- Input #1, SS
- Player(PlayerNum).FingerRingRight.Item = GetItem(SS)
- '//////// 载入玩家包裹信息
- For i = 0 To 39
- Input #1, Player(PlayerNum).Bag(i).State
- Input #1, SS
- Player(PlayerNum).Bag(i).Item = GetItem(SS)
- Next
- Close #1
- End Sub
- '//////// 保存玩家信息
- Public Sub SavePlayerInfo()
- Dim i As Integer
- Open App.Path & "SavePlayerSave" & SaveHero.Name_名字 & ".DB" For Output As #1
- Write #1, SaveHero.Name_名字
- Write #1, SaveHero.Level
- Write #1, SaveHero.Exp_经验值
- Write #1, SaveHero.Job_职业
- Write #1, SaveHero.Sex_性别
- Write #1, SaveHero.Gold_金币
- Write #1, SaveHero.Face
- Write #1, SaveHero.X
- Write #1, SaveHero.Y
- Write #1, SaveHero.HP
- Write #1, SaveHero.MaxHP
- Write #1, SaveHero.MP
- Write #1, SaveHero.MaxMP
- Write #1, SaveHero.Clothing.State
- Write #1, ItemStr(SaveHero.Clothing.Item)
- Write #1, SaveHero.Weapon.State
- Write #1, ItemStr(SaveHero.Weapon.Item)
- Write #1, SaveHero.HeadPiece.State
- Write #1, ItemStr(SaveHero.HeadPiece.Item)
- Write #1, SaveHero.Necklace.State
- Write #1, ItemStr(SaveHero.Necklace.Item)
- Write #1, SaveHero.BraceletLeft.State
- Write #1, ItemStr(SaveHero.BraceletLeft.Item)
- Write #1, SaveHero.BraceletRight.State
- Write #1, ItemStr(SaveHero.BraceletRight.Item)
- Write #1, SaveHero.FingerRingLeft.State
- Write #1, ItemStr(SaveHero.FingerRingLeft.Item)
- Write #1, SaveHero.FingerRingRight.State
- Write #1, ItemStr(SaveHero.FingerRingRight.Item)
- '////////// 保存包裹信息
- For i = 0 To 39
- Write #1, SaveHero.Bag(i).State
- Write #1, ItemStr(SaveHero.Bag(i).Item)
- Next
- Close #1
- End Sub
- '/////////// 载入各等级所需经验
- Public Sub LoadLevelExpData()
- Dim i As Integer
- For i = 1 To 255
- LevelExp(i) = ReadINIFile("Exp", Str(i), App.Path & "DataExp.txt")
- Next
- End Sub
- '/////////// 载入NPC脚本
- Public Sub LoadNPCInfo()
- Dim SS As Variant, Num As Integer
- Dim nn As String, mStr As String
- Dim i As Integer, j As Integer
- Open App.Path & "DataNpcs.txt" For Input As #1
- Line Input #1, nn
- NpcCount = nn
- ReDim NPCInfo(NpcCount)
- For i = 1 To nn
- Line Input #1, mStr
- For j = 9 To 2 Step -1
- mStr = Replace(mStr, String(j, " "), " ")
- Next j
- SS = Split(mStr, " ")
- NPCInfo(i).Name_名称 = SS(0)
- NPCInfo(i).X = SS(1)
- NPCInfo(i).Y = SS(2)
- NPCInfo(i).Pic = 17
- NPCInfo(i).Image = SS(3)
- NPCInfo(i).ScriptFileName = SS(4)
- Map.Map5(NPCInfo(i).X, NPCInfo(i).Y) = Map.Map5(NPCInfo(i).X, NPCInfo(i).Y) + 1
- Next
- Close #1
- For i = 1 To nn
- LoadScriptFile i, App.Path & "NpcScript" & NPCInfo(i).ScriptFileName & ".txt"
- Next
- End Sub
- Public Sub LoadMonDBData()
- Dim i As Integer
- Open App.Path & "DBMon.DB" For Input As #1
- Input #1, MonDBCount
- ReDim MonDB(MonDBCount)
- For i = 1 To MonDBCount
- Input #1, MonDB(i).Name_名称
- Input #1, MonDB(i).Race_种族
- Input #1, MonDB(i).RaceImage_种族图像
- Input #1, MonDB(i).Appr_形象代码
- Input #1, MonDB(i).Level_等级
- Input #1, MonDB(i).UnDead_不死系
- Input #1, MonDB(i).CoolEye_视觉范围
- Input #1, MonDB(i).Exp_经验值
- Input #1, MonDB(i).HP
- Input #1, MonDB(i).MP
- Input #1, MonDB(i).AC
- Input #1, MonDB(i).MAC
- Input #1, MonDB(i).DC_攻击力
- Input #1, MonDB(i).DCMax_最大攻击力
- Input #1, MonDB(i).MC_魔法力
- Input #1, MonDB(i).SC_道术力
- Input #1, MonDB(i).Speed_速度
- Input #1, MonDB(i).Hit_命中率
- Input #1, MonDB(i).WalkSpeed_行走速度
- Input #1, MonDB(i).WalkStep_行走步伐
- Input #1, MonDB(i).WalkWait_行走等待
- Input #1, MonDB(i).AttactSpeed_攻击速度
- Next
- Close #1
- End Sub
- '/////// 载入魔法数据
- Public Sub LoadMagicDBData()
- Dim i As Integer
- Open App.Path & "DBMagic.DB" For Input As #1
- Input #1, MagicDBCount
- ReDim MagicDB(MagicDBCount)
- If MagicDBCount > 0 Then
- For i = 1 To MagicDBCount
- Input #1, MagicDB(i).MagID_序号
- Input #1, MagicDB(i).MagName_名称
- Input #1, MagicDB(i).EffectType_动作效果
- Input #1, MagicDB(i).Effect_魔法效果
- Input #1, MagicDB(i).Spell_魔法消耗
- Input #1, MagicDB(i).Power_基本威力
- Input #1, MagicDB(i).MaxPower_最大威力
- Input #1, MagicDB(i).DefSpell_升级魔法
- Input #1, MagicDB(i).DefPower_升级威力
- Input #1, MagicDB(i).DefMaxPower_升最大威力
- Input #1, MagicDB(i).Job_职业
- Input #1, MagicDB(i).NeedL1_1级等级
- Input #1, MagicDB(i).L1Train_1级经验
- Input #1, MagicDB(i).NeedL2_2级等级
- Input #1, MagicDB(i).L2Train_2级经验
- Input #1, MagicDB(i).NeedL3_3级等级
- Input #1, MagicDB(i).L3Train_3级经验
- Input #1, MagicDB(i).Delay_技能延时
- Next
- End If
- Close #1
- End Sub
- '/////// 载入物品数据
- Public Sub LoadItemDBData()
- Dim i As Integer
- Open App.Path & "DBStdItem.DB" For Input As #1
- Input #1, ItemDBCount
- ReDim ItemDB(ItemDBCount)
- If ItemDBCount > 0 Then
- For i = 1 To ItemDBCount
- Input #1, ItemDB(i).Idx
- Input #1, ItemDB(i).Name
- Input #1, ItemDB(i).StdMode
- Input #1, ItemDB(i).Shape
- Input #1, ItemDB(i).Weight
- Input #1, ItemDB(i).Anicount
- Input #1, ItemDB(i).Source
- Input #1, ItemDB(i).Reserved
- Input #1, ItemDB(i).Looks
- Input #1, ItemDB(i).DuraMax
- Input #1, ItemDB(i).AC
- Input #1, ItemDB(i).Ac2
- Input #1, ItemDB(i).MAC
- Input #1, ItemDB(i).Mac2
- Input #1, ItemDB(i).DC
- Input #1, ItemDB(i).Dc2
- Input #1, ItemDB(i).MC
- Input #1, ItemDB(i).Mc2
- Input #1, ItemDB(i).SC
- Input #1, ItemDB(i).Sc2
- Input #1, ItemDB(i).Need
- Input #1, ItemDB(i).NeedLevel
- Input #1, ItemDB(i).Price
- Next
- End If
- Close #1
- End Sub
- Public Function GetMonDBNum(MonName As String) As Integer
- Dim i As Integer
- For i = 1 To MonDBCount
- If MonName = MonDB(i).Name_名称 Then
- GetMonDBNum = i
- Exit For
- End If
- Next
- End Function