V-MobItemMngActions.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:7k
源码类别:
模拟服务器
开发平台:
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...
- ;-----------------------------------------------------------------------------------
- .const
- .data?
- .data
- .code
- V_MonsterItemMng_Init Proc
- local LoopCounter:Dword
- lea ecx, pObjMobItemMng.pItemsPerLevel
- xor edx, edx
- ;-------------------------------------
- ;Initialise the mob manager array
- ;------------------------------------
- .Repeat ;Infinit loop
- mov eax, TotalItemsLoaded
- imul eax, eax, SizeOf ItemStruct
- push ecx
- push edx
- fastalloc eax, 2 ;Allocate Total items loaded (item.txt) * ItemStruct
- pop edx
- pop ecx
- .if (eax == 0)
- ;Put Error here
- .Endif
- mov [ecx + edx * 4], eax ;Save Pointer
- push ecx
- push edx
- invoke V_VectorCreator, eax, Offset V_CItem_Clear, SizeOf ItemStruct, TotalItemsLoaded
- pop edx
- pop ecx ;Struct
- add edx, 1
- .Until (edx == MAX_MONSTER_LEVEL)
- ;----------------------------
- ;Give items to monsters
- ;----------------------------
- xor edx, edx
- assume eax:ptr MONSTER_ATTRIBUTE
- .Repeat
- push edx
- invoke V_Monster_MatchIndex, edx
- .If (eax != 0)
- pObj edx, SizeOf MONSTER_ATTRIBUTE, pObjMonsterAttr
- .If [eax].Level >= 0 && [eax].Level < MAX_MONSTER_LEVEL
- invoke V_MonsterItemMng_GiveItem, [eax].Level, [eax].MinItemLevel, [eax].MaxItemLevel
- .endif
- .Endif
- pop edx
- add edx, 1
- .Until (edx == MonsterCounter)
- RGB 24, 116, 205 ;Light blue
- Mov Edx, Eax
- Invoke vprint, $CTA0("MobItemMng_Init:] Monster inventory initialised "), Edx, 0
- Ret
- V_MonsterItemMng_Init EndP
- V_MonsterItemMng_GiveItem Proc MobLevel:Dword, MinItemLevel:Dword, MaxLevelItem:Dword
- local ItemType:Dword
- local ItemIndex:Dword
- local Counter:Dword
- local ItemAdded:Dword
- local pItemCounter:Dword
- ;-------------------------------------
- ;Clean locals
- ;-------------------------------------
- And ItemType, 0
- And ItemIndex, 0
- And Counter, 0
- ;-------------------------------------
- ;Get pointer to counter for item lvl
- ;-------------------------------------
- lea eax, pObjMobItemMng.ItemsTotalPerLevl
- mov edx, MobLevel
- imul edx, edx, 2 ;MobLevel * Word
- add eax, edx
- mov pItemCounter, eax
- ;-------------------------------------
- ;Initialise random num generator
- ;------------------------------------
- rdtsc
- Invoke MRandomInit, Eax ;Initialize random number generator
- xor ecx, ecx
- ;-------------------------------------
- ;Get random item
- ;-------------------------------------
- .While (ecx != -1)
- Invoke MIRandom, 0, MAX_ITEM_TYPES ;Generate a random item type
- mov ItemType, eax
- Invoke MIRandom, 0, MAX_ITEM_INDEX ;Generate a random item index
- mov ItemIndex, eax
- Invoke V_CItem_GetItemLevel, ItemIndex, ItemType ;Take item level for that exclusive item
- .If (eax == 0)
- ; RGB 255, 64, 64 ;Red Collor
- ; Mov Edx, Eax
- ; Invoke vprint, $CTA0("MobItemMng_SetItem:] CANT FIND ITEM LEVEL FOR ITEM TYPE [%d] ITEM INDEX [%d] "), Edx, 2, ItemType, ItemIndex
- .Continue
- .Endif
- .If (eax >= MinItemLevel) && (eax < MaxLevelItem)
- invoke V_MonsterItemMng_IsBlockedItem, ItemType, ItemIndex ;Check if the item is blocked
- .If (eax != 0) ;Item not blocked
- invoke V_MonsterItemMng_AddItem, pItemCounter, MobLevel, ItemType, ItemIndex ;, ItemOp1, ItemOp2, ItemOp3 (unused)
- mov eax, pItemCounter
- add byte ptr [eax], 1 ;Add 1 to total items for this mob level
- mov edx, TotalItemsLoaded
- .If ([eax] >= edx)
- .Break
- .Endif
- .Endif
- .Endif
- add Counter, 1
- mov eax, Counter
- .If (eax >= TotalItemsLoaded)
- .Break
- .Endif
- .Endw
- Ret
- V_MonsterItemMng_GiveItem EndP
- V_MonsterItemMng_AddItem Proc pItemPerLvlCounter:Dword, MonsterLevel:Dword, ItemType:Dword, ItemIndex:Dword
- mov eax, pItemPerLvlCounter
- mov edx, [eax]
- imul edx, edx, SizeOf ItemStruct
- mov ecx, MonsterLevel
- lea ebx, pObjMobItemMng.pItemsPerLevel
- mov eax, [ebx + ecx * 4] ;MonsterLevel*DWORD+pItemsPerLevel = Pointer to item space for this monster level
- lea eax, [eax]
- add edx, eax ;Pointer to item space + Item Counter (Array method)
- invoke V_CItem_FillStruct, ItemType, ItemIndex, 0, 0, 0, 0, 0, 0 ;Fill Item Space with the information from Item.txt
- Ret
- V_MonsterItemMng_AddItem EndP
- V_MonsterItemMng_IsBlockedItem Proc ItemType:Dword, ItemIndex:Dword
- local TotalItems:Dword
- local LoopCounter:Dword
- local ItemReaded:Dword
- assume eax:ptr MONSTER_ITEM_MANAGER_FILE
- And LoopCounter, 0
- And ItemReaded, 0
- And TotalItems, 0
- mov eax, pObjMobItemMngFile
- xor ecx, ecx
- .Repeat
- .Repeat
- mov edx, ItemType
- .If (Dl == [eax].ItemType)
- mov ebx, ItemIndex
- .If (Bl == [eax].ItemIndex)
- jmp @IsEvent
- .Endif
- .Endif
- .If (ItemReaded == 0)
- movsx edx, [eax].ItemCounter
- mov TotalItems, edx
- .Endif
- add ItemReaded, 1
- mov ecx, ItemReaded
- add eax, 2 ;ItemType & ItemIndex
- .Until (ecx == TotalItems)
- mov edx, ItemReaded
- mov ItemReaded, 0
- add LoopCounter, edx
- mov edx, LoopCounter
- add eax, TOTAL_EVENTS_SUPPORTED + SizeOf MONSTER_ITEM_MANAGER_FILE.ItemCounter
- .Until (edx == TotalItemsMobMng)
- mov eax, 1 ;Item dont founded
- jmp @End
- @IsEvent:
- mov edx, ItemReaded
- shl edx, 1 ;*2 (ItemType & ItemIndex)
- .If ([eax].DevilSquare == 0) && ([eax].BloodCastle == 0) && ([eax].ChaosCastle == 0)
- xor eax, eax
- jmp @End
- .Endif
- mov eax, 2 ;Item blocked but only for events
- @End:
- assume eax:NOTHING
- Ret
- V_MonsterItemMng_IsBlockedItem EndP