V-ItemLoad.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:28k
源码类别:
模拟服务器
开发平台:
Asm
- ;EasyCodeName=Module1,1
- ;-----------------------------------------------------------------------------------
- ; VeMU
- ; Its a package that allows the user to set his own server of the game
- ; "MuOnline", this is not an emulator since i am not "emulating"
- ; what the actual games does, i am "creating" a method for set a Server
- ; of this Game.
- ;
- ; Copyright (C) 2010 Felipe Ya馿z
- ;
- ; This program is free software: you can redistribute it and/or modify
- ; it under the terms of the GNU General Public License as published by
- ; the Free Software Foundation, either version 3 of the License, or
- ; (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public License for more details.
- ;
- ; You should have received a copy of the GNU General Public License
- ; along with this program. If not, see http://www.gnu.org/licenses/.
- ;-----------------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------------
- ; -----------------
- ; Coded /
- ; By /
- ; -={FeN$x)=-
- ; / Felipe Y.
- ; /
- ; -----------------
- ; Programming Lang: ASM
- ; Country: Chile
- ; My respect for all those who lost their lifes
- ; In the earthquake of my country...
- ; Let god take their spirits home...
- ;-----------------------------------------------------------------------------------
- ;////////////////////////////////////////////////////////////////////////////////////
- ; VeMU Project
- ; Item Load !
- ;////////////////////////////////////////////////////////////////////////////////////
- .Const
- .Data?
- .Data
- szItemScript DB ".DataGamePlayItemsItem.txt", 0
- .Code
- V_CItem_LoadItemScript Proc
- local NextTypePlease:Dword
- local pItemObjSpace:Dword
- local LoopCounter:Dword
- local ItemType:Dword
- local ItemIndex:Dword
- local pBufferSpace:Dword
- local FilePosition:Dword
- local BytesReaded:Dword
- local StructFile:WIN32_FILE_ATTRIBUTE_DATA
- .const
- qSWORD equ 0
- qSTAFFS equ 5
- SHIELDS equ 6
- HELMS equ 7
- PANTS equ 9
- GLOVES equ 10
- BOOTS equ 11
- ACCESORIES equ 12
- MISCELLANEOUS1 equ 13
- MISCELLANEOUS2 equ 14
- SCROLLS equ 15
- RepTimesForItemUniversalVars equ 7 ;Variables loadeds: ItemSlot, vWidht, vHeight, Serial, SkillType,OptionFlag,DropFlag
- RepTimesForDamageVars equ 4 ;Variable loadeds: DamageMin DamageMax AttackSpeed MagicPower
- RepTimesForRequirementsVars equ 6 ;Variable loadeds: LvlReq StrReq AgiReq EneReq VitReq CMDReq
- RepTimesForClassVars equ 6 ;Variable loadeds: DW/SM DK/BK ELF/ME MG DL SUM
- .code
- assume eax:ptr ITEM_ATTRIBUTE_STRUCT
- mov LoopCounter, 0
- mov FilePosition, 0
- mov NextTypePlease, 1
- lea eax, pObjItemAttributes
- xor ecx, ecx
- ;-------------------------------
- ;Clean some Attribute Values
- ;-------------------------------
- .Repeat
- mov [eax].SpecialVars.Level, 0FFh ;-1
- mov [eax].SpecialVars.RepairMoney, 0
- mov [eax].SpecialVars.AllRepairMoney, 0
- add ecx, 1
- .until (ecx == MAX_ITEMS)
- ;-------------------------------
- ;Load file into memory
- ;-------------------------------
- lea edx, StructFile
- GetFileLength addr szItemScript, edx
- mov eax, StructFile.nFileSizeLow
- fastalloc eax, 1 ;alloc space for file
- mov pBufferSpace, eax
- lea ecx, BytesReaded
- ReadThisFile Addr szItemScript, pBufferSpace, ecx ;read of file and handles the close
- mov ecx, StructFile.nFileSizeLow
- add eax, ecx
- mov dword ptr [eax], 0 ;Append to 00 byte in the end of file for prevent bugs
- xor ecx, ecx
- ;-------------------------------
- ;INITIALISE LOOP
- ;SAVE ITEM TYPE AND INDEX
- ;-------------------------------
- .While (ecx != -1) ;Infinite loop
- pObj TotalItemsLoaded, SizeOf ITEM_ATTRIBUTE_STRUCT, pObjItemAttributes ;New calculation avoiding WZ bug of not using all the space struct
- mov pItemObjSpace, eax
- .If (NextTypePlease == 1)
- invoke GetToken, pBufferSpace, ecx, NULL ;Get Item Type
- .If (edx == 1)
- xor eax, eax
- .Break
- .Endif
- mov ItemType, eax
- .Endif
- invoke GetToken, pBufferSpace, ecx, NULL ;Get Item Index
- .If (edx == 1)
- xor eax, eax
- .Break
- .Endif
- mov ItemIndex, eax
- .If (ItemType >= 0) || (ebx < MAX_ITEMS)
- mov eax, pItemObjSpace
- mov ebx, ItemType
- mov edx, ItemIndex
- mov [eax].ItemType, bl
- mov [eax].ItemIndex, dl
- .Else
- .Continue
- .Endif
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = FOR ALL KIND OF ITEM TYPES =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;---------------------------------------------------
- ;LOAD NAME OF ITEM FOR ALL KIND OF ITEMS
- ;----------------------------------------------------
- push eax
- invoke GetString, pBufferSpace, ecx ;Item Name
- mov FilePosition, ecx
- pop eax
- push eax
- invoke lstrcat, addr [eax].ItemName, addr StringToken
- pop eax
- mov ecx, FilePosition
- ;---------------------------------------------------
- ;LOAD UNIVERSAL VARIABLES FOR ALL KIND OF ITEMS
- ;----------------------------------------------------
- lea eax, [eax].UniversalVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- .if (LoopCounter == 0) || (LoopCounter == 4)
- mov [eax + ebx], edx
- add ebx, 4
- .else
- mov byte ptr [eax + ebx], dl
- add ebx, 1
- .endif
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == RepTimesForItemUniversalVars)
- mov LoopCounter, 0
- mov eax, pItemObjSpace
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = ONLY FOR WEAPONS =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- .If (ItemType >= qSWORD) && (ItemType < qSTAFFS) ;IF ITEM TYPE IS ACCORDING TO ANY WEAPON...
- ;--------------------------------------------------------
- ;LOAD SPECIAL VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.Level, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SetAttribute, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.BuyMoney, edx
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SellMoney, edx
- ;--------------------------------------------------------
- ;LOAD DAMAGE VARIABLES !
- ;--------------------------------------------------------
- lea eax, [eax].DamageVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- .if (LoopCounter == 3) ;MagicPower
- mov [eax + ebx], edx
- add ebx, 4
- .else ;DamageMin, DamageMax, AttackSpeed
- mov byte ptr [eax + ebx], dl
- add ebx, 1
- .endif
- mov ecx, FilePosition
- add LoopCounter, 1
- .Until (LoopCounter == RepTimesForDamageVars)
- mov LoopCounter, 0
- ;--------------------------------------------------------
- ;LOAD DEFENSE VARIABLES
- ;--------------------------------------------------------
- mov eax, pItemObjSpace
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.Durability, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.MagicDurability, dl
- ;--------------------------------------------------------
- ;LOAD REQUIREMENTS VARIABLES
- ;--------------------------------------------------------
- lea eax, [eax].ReqVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- .if (LoopCounter == 5) ;CmdReq
- mov [eax + ebx], edx
- add ebx, 4
- .else ;LvlReq StrReq AgiReq EneReq VitReq CMDReq
- mov Word ptr [eax + ebx], dx
- add ebx, 2
- .endif
- mov ecx, FilePosition
- add LoopCounter, 1
- .Until (LoopCounter == RepTimesForRequirementsVars)
- mov LoopCounter, 0
- ;--------------------------------------------------------
- ;LOAD CLASS VARIABLES
- ;--------------------------------------------------------
- mov eax, pItemObjSpace
- lea eax, [eax].ClassVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- mov Byte ptr [eax + ebx], dl ;DW/SM DK/BK ELF/ME MG DL SUM
- add ebx, 1
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == RepTimesForClassVars)
- mov LoopCounter, 0
- mov eax, pItemObjSpace
- .If ([eax].UniversalVars.vWidth >= 2)
- mov [eax].SpecialVars.TwoHand, 1
- .Endif
- movsx edx, [eax].DefenseVars.MagicDurability
- add [eax].DefenseVars.Durability, dl
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = ONLY FOR ARMORS =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- .ElseIf (ItemType >= HELMS) && (ItemType <= BOOTS)
- ;--------------------------------------------------------
- ;LOAD SPECIAL VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.Level, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SetAttribute, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.BuyMoney, edx
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SellMoney, edx
- ;--------------------------------------------------------
- ;LOAD DEFENSE VARIABLES FOR ALL KIND OF ARMORS
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.Defense, dl
- ;--------------------------------------------------------
- ;LOAD DEFENSE SPECIFIC VARIABLES FOR SHIELDS
- ;--------------------------------------------------------
- .If (ItemType == SHIELDS)
- invoke GetToken, pBufferSpace, ecx, NULL
- .If (ecx == 1)
- xor eax, eax
- .Break
- .Endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.SuccesfulBlocking, dl
- ;-----------------------------------------------------------
- ;LOAD DEFENSE SPECIFIC VARIABLES FOR HELMS, ARMORS & PANTS
- ;-----------------------------------------------------------
- .Elseif (ItemType >= HELMS) && (ItemType <= PANTS)
- invoke GetToken, pBufferSpace, ecx, NULL
- .If (ecx == 1)
- xor eax, eax
- .Break
- .Endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.MagicDefense, dl
- ;--------------------------------------------------------
- ;LOAD DEFENSE SPECIFIC VARIABLES FOR GLOVES
- ;--------------------------------------------------------
- .Elseif (ItemType == GLOVES)
- invoke GetToken, pBufferSpace, ecx, NULL
- .If (ecx == 1)
- xor eax, eax
- .Break
- .Endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DamageVars.AttackSpeed, dl
- ;--------------------------------------------------------
- ;LOAD DEFENSE SPECIFIC VARIABLES FOR BOOTS
- ;--------------------------------------------------------
- .ElseIf (ItemType == BOOTS)
- invoke GetToken, pBufferSpace, ecx, NULL
- .If (ecx == 1)
- xor eax, eax
- .Break
- .Endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.WalkSpeed, dl
- .Else
- .Endif
- ;--------------------------------------------------------
- ;LOAD LAST DEFENSE VARIABLE FOR ALL KIND OF ARMORS
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.Durability, dl
- ;--------------------------------------------------------
- ;LOAD REQUIREMENTS VARIABLES
- ;--------------------------------------------------------
- lea eax, [eax].ReqVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- .if (LoopCounter == 5) ;CmdReq
- mov [eax + ebx], edx
- add ebx, 4
- .else ;LvlReq StrReq AgiReq EneReq VitReq CMDReq
- mov Word ptr [eax + ebx], dx
- add ebx, 2
- .endif
- mov ecx, FilePosition
- add LoopCounter, 1
- .Until (LoopCounter == RepTimesForRequirementsVars)
- mov LoopCounter, 0
- ;--------------------------------------------------------
- ;LOAD CLASS VARIABLES
- ;--------------------------------------------------------
- mov eax, pItemObjSpace
- lea eax, [eax].ClassVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- mov Byte ptr [eax + ebx], dl ;DW/SM DK/BK ELF/ME MG DL SUM
- add ebx, 1
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == RepTimesForClassVars)
- mov LoopCounter, 0
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = ONLY FOR ACCESORIES =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- .ElseIf (ItemType == ACCESORIES)
- ;--------------------------------------------------------
- ;LOAD SPECIAL VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.Level, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.BuyMoney, edx
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SellMoney, edx
- ;--------------------------------------------------------
- ;LOAD DEFENSE VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.Defense, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.Durability, dl
- ;--------------------------------------------------------
- ;LOAD REQUIREMENTS VARIABLES
- ;--------------------------------------------------------
- lea eax, [eax].ReqVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- .if (LoopCounter == 5) ;CmdReq
- mov [eax + ebx], edx
- add ebx, 4
- .else ;LvlReq StrReq AgiReq EneReq VitReq CMDReq
- mov Word ptr [eax + ebx], dx
- add ebx, 2
- .endif
- mov ecx, FilePosition
- add LoopCounter, 1
- .Until (LoopCounter == RepTimesForRequirementsVars)
- mov LoopCounter, 0
- ;--------------------------------------------------------
- ;LOAD CLASS VARIABLES
- ;--------------------------------------------------------
- mov eax, pItemObjSpace
- lea eax, [eax].ClassVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- mov Byte ptr [eax + ebx], dl ;DW/SM DK/BK ELF/ME MG DL SUM
- add ebx, 1
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == RepTimesForClassVars)
- mov LoopCounter, 0
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = ONLY FOR MISCELLANEOUS1 =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- .ElseIf (ItemType == MISCELLANEOUS1)
- ;--------------------------------------------------------
- ;LOAD SPECIAL VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.Level, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SetAttribute, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.BuyMoney, edx
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SellMoney, edx
- ;--------------------------------------------------------
- ;LOAD DEFENSE VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].DefenseVars.Defense, dl
- ;--------------------------------------------------------
- ;LOAD DEFENSE VARIABLES SPECIFIC: RESISTANCE !
- ;--------------------------------------------------------
- lea eax, [eax].DamageVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- mov byte ptr [eax + ebx], dl ;Resistance[0] to Resistance[7]
- add ebx, 1
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == SizeOf ITEM_ATTRIBUTE_STRUCT.DefenseVars.Resistance)
- mov LoopCounter, 0
- ;--------------------------------------------------------
- ;LOAD CLASS VARIABLES
- ;--------------------------------------------------------
- mov eax, pItemObjSpace
- lea eax, [eax].ClassVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- mov Byte ptr [eax + ebx], dl ;DW/SM DK/BK ELF/ME MG DL SUM
- add ebx, 1
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == RepTimesForClassVars)
- mov LoopCounter, 0
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = ONLY FOR MISCELLANEOUS2 =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- .ElseIf (ItemType == MISCELLANEOUS2)
- ;--------------------------------------------------------
- ;LOAD SPECIAL VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.Level, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.ItemValue, Dx
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.BuyMoney, edx
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SellMoney, edx
- ;--------------------------------------------------------
- ;LOAD CLASS VARIABLES
- ;--------------------------------------------------------
- mov eax, pItemObjSpace
- lea eax, [eax].ClassVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- mov Byte ptr [eax + ebx], dl ;DW/SM DK/BK ELF/ME MG DL SUM
- add ebx, 1
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == RepTimesForClassVars)
- mov LoopCounter, 0
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = ONLY FOR SCROLLS =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- .ElseIf (ItemType == SCROLLS)
- ;--------------------------------------------------------
- ;LOAD SPECIAL VARIABLES !
- ;--------------------------------------------------------
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.Level, dl
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.BuyMoney, edx
- invoke GetToken, pBufferSpace, ecx, NULL
- .if (edx == 1)
- xor eax, eax
- .break
- .endif
- mov edx, eax ;Avoid bugs
- mov eax, pItemObjSpace
- mov [eax].SpecialVars.SellMoney, edx
- ;--------------------------------------------------------
- ;LOAD REQUIREMENTS VARIABLES
- ;--------------------------------------------------------
- lea eax, [eax].ReqVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- .if (LoopCounter == 5) ;CmdReq
- mov [eax + ebx], edx
- add ebx, 4
- .else ;LvlReq StrReq AgiReq EneReq VitReq CMDReq
- mov Word ptr [eax + ebx], dx
- add ebx, 2
- .endif
- mov ecx, FilePosition
- add LoopCounter, 1
- .Until (LoopCounter == RepTimesForRequirementsVars)
- mov LoopCounter, 0
- ;--------------------------------------------------------
- ;LOAD CLASS VARIABLES
- ;--------------------------------------------------------
- mov eax, pItemObjSpace
- lea eax, [eax].ClassVars
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- .if (ecx == 1)
- xor eax, eax
- .break
- .endif
- mov Byte ptr [eax + ebx], dl ;DW/SM DK/BK ELF/ME MG DL SUM
- add ebx, 1
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == RepTimesForClassVars)
- mov LoopCounter, 0
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- ;
- ; = END OF LOOP =
- ;
- ;////////////////////////////////////////////////////////////////////////////////////////////////////
- .Else
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("CItemLoad:] ITEM TYPE: [%d] IS INVALID, PLEASE MODIFY SOURCE CODE"), Edx, 1, ItemType
- mov ecx, FilePosition
- .Continue
- .Endif
- add TotalItemsLoaded, 1
- .If (TotalItemsLoaded > MAX_ITEMS * SizeOf ITEM_ATTRIBUTE_STRUCT)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("CItemLoad:] ERROR YOU CANT LOAD MORE THAN : [%d] ITEMS"), Edx, 1, MAX_ITEMS * SizeOf ITEM_ATTRIBUTE_STRUCT
- .Break
- .Endif
- mov FilePosition, ecx
- invoke GetString, pBufferSpace, ecx ;Try to search for "end" string
- push ecx
- invoke szCmp, $CTA0("end"), Addr StringToken ;If end string
- pop ecx
- .If (eax != 0) ;Founded
- push ecx
- invoke GetToken, pBufferSpace, ecx, NULL ;Lets check if its really the end of file
- pop ecx
- .if (edx == 1)
- mov eax, 1
- .Break
- .endif
- mov NextTypePlease, 1 ; Lets read the next type
- .Continue
- .Endif
- mov ecx, FilePosition
- mov NextTypePlease, 0 ;Keep in the same item type
- .Endw
- .If (eax == 0)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("CItemLoad:] UNKNOWN ERROR, LAST ITEM LOADED : [%d]"), Edx, 1, TotalItemsLoaded
- .Else
- RGB 24, 116, 205 ;Light blue
- Mov Edx, Eax
- Invoke vprint, $CTA0("CItemLoad:] Operation Successful total items loaded : [%d]"), Edx, 1, TotalItemsLoaded
- .Endif
- FastDeAlloc pBufferSpace, NULL, 0 ;Free the heap when we dont use it anymore
- assume eax:nothing
- Ret
- V_CItem_LoadItemScript EndP