V-ItemActions.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:18k
源码类别:
模拟服务器
开发平台:
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 Actions !
- ;////////////////////////////////////////////////////////////////////////////////////
- V_CItem_Clear Proc Uses Ecx
- Local MyStruct:DWord
- Mov MyStruct, Ecx
- Assume Ecx:Ptr ItemStruct
- Mov [Ecx].Item_Number, 0
- Mov [Ecx].Item_Type, 0FFH
- mov [ecx].Item_Index, 0FFh
- Mov [Ecx].Item_Level, 0
- Mov [Ecx].Item_Slot, 0
- Mov [Ecx].Item_Class, 0
- Mov [Ecx].Item_TwoHand, 0
- Mov [Ecx].Item_AttackSpeed, 0
- Mov [Ecx].Item_DamageMin, 0
- Mov [Ecx].Item_DamageMax, 0
- Mov [Ecx].Item_SuccesfulBlocking, 0
- Mov [Ecx].Item_Defense, 0
- Mov [Ecx].Item_MagicDefense, 0
- Mov [Ecx].Item_Durability, 0
- Mov [Ecx].Item_DurabilitySmall, 0
- Mov Dword ptr [Ecx].Item_SpecialNum, 0
- mov byte ptr [ecx].Item_SpecialNum + 5, 0
- Mov [Ecx].Item_LeaderShip, 0
- Mov [Ecx].Item_Value, 0
- Mov [Ecx].Item_PShopValue, -1
- Mov [Ecx].Item_Exist, 0
- Mov [Ecx].Item_Option1, 0
- Mov [Ecx].Item_Option2, 0
- Mov [Ecx].Item_Option3, 0
- Mov [Ecx].Item_NewOption, 0
- Mov [Ecx].Item_CurrentDurabilityState, 1.0 ;FPU
- Mov [Ecx].Item_QuestItem, 0
- Mov [Ecx].Item_SetOption, 0
- Mov [Ecx].Item_IsLoadPetItemInfo, 0
- Mov [Ecx].Item_PetItemLevel, 0
- Mov [Ecx].Item_PetItemExp, 0
- Mov [Ecx].Item_JewelOfHarmonyOption, 0
- Mov [Ecx].Item_Option380, 0
- Invoke V_ZeroBuff, Addr [Ecx].Item_Special, SizeOf ItemStruct.Item_Special
- Mov Ecx, MyStruct
- Invoke V_ZeroBuff, Addr [Ecx].Item_SpecialValue, SizeOf ItemStruct.Item_SpecialValue
- Mov Ecx, MyStruct
- Invoke V_ZeroBuff, Addr [Ecx].Item_Resistance, SizeOf ItemStruct.Item_Resistance
- Assume Ecx:Nothing
- Ret
- V_CItem_Clear EndP
- V_CItem_FillStruct Proc uses edx ItemType:Dword, ItemIndex:Dword, Option1:Dword, Option2:Dword, Option3:Dword, NewOption:Dword, SetOption:Dword, Option380:Dword
- local SetOptionValue:Dword
- local BonusRequirementStats:Dword
- local BonusForDmgs:Dword
- local UniversalFPUUsage:Real4
- local LoopCounter:Dword
- local pThisItem:Dword
- local MyStruct:Dword
- .Data
- BaseDurability_0 Real4 0.5
- BaseDurability_4 Real4 0.3
- BaseDurability_8 Real4 0.2
- .Code
- assume edx: ptr ItemStruct
- assume ecx:ptr ITEM_ATTRIBUTE_STRUCT ;From Item.txt
- ;----------------------------------------------
- ;Clean locals
- ;----------------------------------------------
- And LoopCounter, 0
- mov MyStruct, edx
- ;--------------------------------------------------------------
- ;Return pointer from pObjItemAttributes for determinated item
- ;--------------------------------------------------------------
- invoke V_CItem_RetnpStruct, ItemType, ItemIndex
- .If (eax == 0)
- xor eax, eax
- jmp @End
- .Endif
- mov pThisItem, eax
- mov edx, MyStruct
- ;----------------------------------------------
- ;Set ItemType & ItemIndex
- ;----------------------------------------------
- mov eax, ItemType
- mov ebx, ItemIndex
- mov [edx].Item_Type, Al
- mov [edx].Item_Index, Bl
- ;----------------------------------------------
- ;Set Real ItemID
- ;----------------------------------------------
- invoke V_CItem_GetRealItemID, ItemType, ItemIndex
- mov edx, MyStruct
- mov [edx].Item_Number, Ax
- ;----------------------------------------------
- ;Set New Option
- ;----------------------------------------------
- mov ecx, pThisItem
- .If ([ecx].UniversalVars.OptionFlag != 0)
- mov eax, NewOption
- mov [edx].Item_NewOption, Al
- .Else
- mov [edx].Item_NewOption, 0
- .Endif
- ;----------------------------------------------
- ;Set "SetOption"
- ;----------------------------------------------
- .If (SetOption == 1) || (SetOption == 2)
- mov eax, SetOption
- mov [edx].Item_SetOption, Al
- .Else
- mov [edx].Item_SetOption, 0
- .Endif
- ;----------------------------------------------
- ;Set "SetOption"
- ;----------------------------------------------
- .If (Option380 != 0)
- mov eax, Option380
- mov [edx].Item_Option380, Al
- .Else
- mov [edx].Item_Option380, 0
- .Endif
- ;----------------------------------------------
- ;Set Slot
- ;----------------------------------------------
- mov eax, [ecx].UniversalVars.ItemSlot
- mov [edx].Item_Slot, Al
- ;----------------------------------------------
- ;Set serial
- ;----------------------------------------------
- movsx eax, [ecx].UniversalVars.Serial
- mov [edx].Item_Serial, Al
- ;----------------------------------------------
- ;Set Item Size
- ;----------------------------------------------
- movsx eax, [ecx].UniversalVars.vWidth
- mov [edx].Item_Width, Al
- movsx eax, [ecx].UniversalVars.vHeight
- mov [edx].Item_Height, Al
- ;----------------------------------------------
- ;Set BuyMoney and SellMoney
- ;----------------------------------------------
- mov eax, [ecx].SpecialVars.BuyMoney
- mov [edx].Item_BuyMoney, eax
- mov eax, [ecx].SpecialVars.SellMoney
- mov [edx].Item_SellMoney, eax
- ;----------------------------------------------
- ;Set Item Level
- ;----------------------------------------------
- invoke V_CItem_GetItemLevel, ItemType, ItemIndex
- .If (eax == 0)
- xor eax, eax
- jmp @End
- .Endif
- mov edx, MyStruct
- mov [edx].Item_Level, Al
- ;----------------------------------------------
- ;Set Item BaseDurability
- ;----------------------------------------------
- invoke V_CItem_GetItemDurability, ItemType, ItemIndex
- .If (eax == 0)
- xor eax, eax
- jmp @End
- .Endif
- mov edx, MyStruct
- mov UniversalFPUUsage, eax
- fild UniversalFPUUsage
- fstp [edx].Item_BaseDurability
- ;----------------------------------------------
- ;Set Durability states
- ;----------------------------------------------
- fld [edx].Item_BaseDurability
- fmul BaseDurability_0
- fstp [edx].Item_DurabilityState
- fld [edx].Item_BaseDurability
- fmul BaseDurability_4
- fstp [edx].Item_DurabilityState + 4
- fld [edx].Item_BaseDurability
- fmul BaseDurability_8
- fstp [edx].Item_DurabilityState + 8
- ;----------------------------------------------
- ;Set Value
- ;----------------------------------------------
- mov ecx, pThisItem
- movsx eax, [ecx].SpecialVars.ItemValue
- mov [edx].Item_Value, eax
- ;----------------------------------------------
- ;Set Attack Speed
- ;----------------------------------------------
- movsx eax, [ecx].DamageVars.AttackSpeed
- mov [edx].Item_AttackSpeed, Al
- ;----------------------------------------------
- ;Set Two Hand
- ;----------------------------------------------
- movsx eax, [ecx].SpecialVars.TwoHand
- mov [edx].Item_TwoHand, Al
- ;----------------------------------------------
- ;Set SuccesFulBlocking & Defense
- ;----------------------------------------------
- movsx eax, [ecx].DefenseVars.SuccesfulBlocking
- movsx ebx, [ecx].DefenseVars.Defense
- mov [edx].Item_SuccesfulBlocking, Al
- mov [edx].Item_Defense, Bl
- ;-----------------------------------------------------------------------
- ;Set DamageMin, DamageMax & MagicPower.
- ;----------------------------------------------------------------------
- movsx eax, [ecx].DamageVars.DamageMin
- movsx ebx, [ecx].DamageVars.DamageMax
- mov [edx].Item_DamageMin, Ax
- mov [edx].Item_DamageMax, Bx
- mov eax, [ecx].DamageVars.MagicPower
- mov [edx].Item_MagicPower, Ax
- ;----------------------------------------------
- ;Set MagicDefense & WalkSpeed
- ;----------------------------------------------
- movsx eax, [ecx].DefenseVars.MagicDefense
- movsx ebx, [ecx].SpecialVars.WalkSpeed
- mov [edx].Item_MagicDefense, Al
- mov [edx].Item_WalkSpeed, Bl
- ;----------------------------------------------
- ;Set Additions in base of Options
- ;----------------------------------------------
- invoke V_CItem_SetBonusByOptions, ItemType, ItemIndex
- ;----------------------------------------------
- ;Set Class Requirement
- ;----------------------------------------------
- invoke MemCopy, Addr [ecx].ClassVars.ReqClass, Addr [edx].Item_ReqClass, SizeOf ItemStruct.Item_ReqClass
- ;----------------------------------------------
- ;Set Resistances calculation
- ;Calc: Resistance*Level
- ;----------------------------------------------
- mov ecx, pThisItem
- mov edx, MyStruct
- .Repeat
- lea eax, [ecx].DefenseVars.Resistance
- add eax, LoopCounter
- mov eax, [eax]
- and eax, 0FFh ;Avoid using byte mov (optimisation)
- movsx ebx, [edx].Item_Level
- imul eax, ebx
- lea ebx, [edx].Item_Resistance
- add ebx, LoopCounter
- mov [ebx], Al
- add LoopCounter, 1
- .Until (LoopCounter == SizeOf ItemStruct.Item_Resistance)
- ;----------------------------------------------
- ;Set Current durability states
- ;----------------------------------------------
- mov UniversalFPUUsage, 0
- fld [edx].Item_Durability
- fcomp UniversalFPUUsage
- fstsw Ax
- test ah, 40h
- je @NotZero
- mov [edx].Item_CurrentDurabilityState, 3F800000h ;1,0
- jmp @GoReqStats
- @NotZero:
- fld [edx].Item_Durability
- fcomp [edx].Item_DurabilityState
- fstsw Ax
- test ah, 1
- je @NextOne
- mov [edx].Item_CurrentDurabilityState, 3F000000h ;0,5
- jmp @GoReqStats
- @NextOne:
- fld [edx].Item_Durability
- fcomp [edx].Item_DurabilityState + 4
- fstsw Ax
- test ah, 1
- je @NextOne2
- mov [edx].Item_CurrentDurabilityState, 3E99999Ah ;0,3
- jmp @GoReqStats
- @NextOne2:
- fld [edx].Item_Durability
- fcomp [edx].Item_DurabilityState + 8
- fstsw Ax
- test ah, 1
- je @GoReqStats
- mov [edx].Item_CurrentDurabilityState, 3E4CCCCDh ;0,2
- @GoReqStats:
- ;-------------------------------------------------------
- ;Add requirements for stats like Strenght, Vit, etc
- ;Inside are some calculations in base of item options
- ;-------------------------------------------------------
- invoke V_CItem_SetRequiredStats, ItemType, ItemIndex
- ;------------------------------------------------------
- ;Set Required Level for some items
- ;------------------------------------------------------
- invoke V_CItem_SetReqLevel, ItemType, ItemIndex, NewOption
- ;------------------------------------------------------
- ;Set Skills if its the Option skill enabled
- ;------------------------------------------------------
- invoke V_CItem_SetSkillOpt, Option1
- add [edx].Item_SpecialNum, 1
- invoke V_CItem_SetOption2, ItemType, ItemIndex, Option2
- add [edx].Item_SpecialNum, 1
- invoke V_CItem_SetOption3, ItemType, ItemIndex, Option3
- add [edx].Item_SpecialNum, 1
- invoke V_CItem_SetBonusForRings, ItemType, ItemIndex
- invoke V_CItem_SetBonusForPendants, ItemType, ItemIndex
- mov edx, MyStruct
- mov ecx, pThisItem
- ;-------------------------------------------------------
- ;Set some options for wings !
- ;-------------------------------------------------------
- .If (ItemType == 12) && (ItemIndex >= 3) && (ItemIndex < 6) ; items Wings Spirit, Soul & Dragon
- jmp @4
- .ElseIf (ItemType == 13) && (ItemIndex == 30) ;Cape of Lord
- @4:
- movsx eax, [edx].Item_NewOption
- and eax, 1
- .If (eax != 0)
- movsx eax, [edx].Item_SpecialNum
- mov [[edx].Item_Special + eax], 100 ;Special[SpecialNum] (array) (SKILL = Unknown)
- add [edx].Item_SpecialNum, 1
- .Endif
- movsx eax, [edx].Item_NewOption
- and eax, 2
- .If (eax != 0)
- movsx eax, [edx].Item_SpecialNum
- mov [[edx].Item_Special + eax], 101 ;Special[SpecialNum] (array) (SKILL = Unknown)
- add [edx].Item_SpecialNum, 1
- .Endif
- movsx eax, [edx].Item_NewOption
- and eax, 4
- .If (eax != 0)
- movsx eax, [edx].Item_SpecialNum
- mov [[edx].Item_Special + eax], 102 ;Special[SpecialNum] (array) (SKILL = Unknown)
- add [edx].Item_SpecialNum, 1
- .Endif
- movsx eax, [edx].Item_NewOption
- and eax, 8
- .If (eax != 0)
- movsx eax, [edx].Item_SpecialNum
- mov [[edx].Item_Special + eax], 105 ;Special[SpecialNum] (array) (SKILL = Unknown)
- add [edx].Item_SpecialNum, 1
- .Endif
- .Endif
- ;-------------------------------------------------------
- ;Set some options for Fenrir !
- ;-------------------------------------------------------
- .If (ItemType == 13) && (ItemIndex == 37) ;Horn of Fenrir
- movsx eax, [edx].Item_NewOption
- and eax, 1
- .If (eax != 0)
- movsx eax, [edx].Item_SpecialNum
- mov [[edx].Item_Special + eax], 106 ;Special[SpecialNum] (array) (SKILL = Unknown)
- add [edx].Item_SpecialNum, 1
- .Endif
- movsx eax, [edx].Item_NewOption
- and eax, 2
- .If (eax != 0)
- movsx eax, [edx].Item_SpecialNum
- mov [[edx].Item_Special + eax], 107 ;Special[SpecialNum] (array) (SKILL = Unknown)
- add [edx].Item_SpecialNum, 1
- .Endif
- .Endif
- ;-------------------------------------------------------
- ;Set special attribute !
- ;-------------------------------------------------------
- mov edx, MyStruct
- mov eax, SetOption
- and eax, 0FFh
- sar eax, 2
- and eax, 3
- .If (Eax != 0)
- mov SetOptionValue, eax
- mov ecx, pThisItem
- movsx eax, [ecx].SpecialVars.SetAttribute
- .If (eax != 0)
- add eax, 195 ;0C3h
- movsx ebx, [edx].Item_SpecialNum
- mov [[edx].Item_Special + ebx], Al ;Special[SpecialNum] (array) (SKILL = Unknown)
- mov eax, SetOptionValue
- imul eax, eax, 5
- mov [edx].Item_SetAddStat, Al
- add [edx].Item_SpecialNum, 1
- .Endif
- .Endif
- ;-------------------------------------------------------
- ;Set Damage Min & Defense into their origins
- ;-------------------------------------------------------
- movsx eax, [edx].Item_DamageMin
- mov [edx].Item_DamageMinOrigin, Ax
- movsx eax, [edx].Item_Defense
- mov [edx].Item_DefenseOrigin, Ax
- ;-------------------------------------------------------
- ;Last calculation for DamageMin
- ;Calc: (CurrentDurabilityState * DamageMin) - DamageMin
- ;-------------------------------------------------------
- movsx eax, [edx].Item_DamageMin
- mov UniversalFPUUsage, eax
- fild UniversalFPUUsage
- fmul [edx].Item_CurrentDurabilityState
- fistp UniversalFPUUsage
- mov eax, UniversalFPUUsage
- sub [edx].Item_DamageMin, Ax
- ;-------------------------------------------------------
- ;Last calculation for DamageMax
- ;Calc: (CurrentDurabilityState * DamageMax) - DamageMax
- ;-------------------------------------------------------
- movsx eax, [edx].Item_DamageMax
- mov UniversalFPUUsage, eax
- fild UniversalFPUUsage
- fmul [edx].Item_CurrentDurabilityState
- fistp UniversalFPUUsage
- mov eax, UniversalFPUUsage
- sub [edx].Item_DamageMax, Ax
- ;-------------------------------------------------------
- ;Last calculation for Defense
- ;Calc: (CurrentDurabilityState * Defense) - Defense
- ;-------------------------------------------------------
- movsx eax, [edx].Item_Defense
- mov UniversalFPUUsage, eax
- fild UniversalFPUUsage
- fmul [edx].Item_CurrentDurabilityState
- fistp UniversalFPUUsage
- mov eax, UniversalFPUUsage
- sub [edx].Item_Defense, Al
- ;-------------------------------------------------------------
- ;Last calculation for SuccesfulBlocking
- ;Calc: (CurrentDurabilityState * SuccesBlock) - SuccesBlock
- ;-------------------------------------------------------------
- movsx eax, [edx].Item_SuccesfulBlocking
- mov UniversalFPUUsage, eax
- fild UniversalFPUUsage
- fmul [edx].Item_CurrentDurabilityState
- fistp UniversalFPUUsage
- mov eax, UniversalFPUUsage
- sub [edx].Item_SuccesfulBlocking, Al
- mov eax, 1
- @End:
- assume edx:NOTHING
- assume ecx:NOTHING
- Ret
- V_CItem_FillStruct Endp
- V_CItem_RetnpStruct Proc ItemType:Dword, ItemIndex:Dword
- assume ecx:ptr ITEM_ATTRIBUTE_STRUCT
- lea ecx, pObjItemAttributes
- xor ebx, ebx
- .Repeat
- mov eax, ItemType
- .If (Al == [ecx].ItemType)
- mov edx, ItemIndex
- .If (Dl == [ecx].ItemIndex)
- lea eax, [ecx] ;Pointer to struct of the belong item
- jmp @End
- .Endif
- .Endif
- add ebx, 1
- add ecx, SizeOf ITEM_ATTRIBUTE_STRUCT
- .Until (ebx == TotalItemsLoaded)
- xor eax, eax
- @End:
- assume ecx:nothing
- ret
- V_CItem_RetnpStruct Endp
- V_CItem_GetRealItemID Proc ItemType:Dword, ItemIndex:Dword
- mov eax, ItemType
- shl eax, 9 ;Do not change this calculation if not, Client wont detect your item ID
- add eax, ItemIndex
- ret
- V_CItem_GetRealItemID Endp
- V_CItem_GetSize Proc ItemType:Dword, ItemIndex:Dword
- assume ecx:ptr ITEM_ATTRIBUTE_STRUCT
- invoke V_CItem_RetnpStruct, ItemType, ItemIndex
- .If (eax == 0)
- mov eax, -1
- jmp @End
- .Endif
- movsx eax, [ecx].UniversalVars.vWidth
- movsx edx, [ecx].UniversalVars.vHeight
- @End:
- Ret
- V_CItem_GetSize EndP
- V_CItem_IsItemValid Proc ItemType:Dword, ItemIndex:Dword
- invoke V_CItem_RetnpStruct, ItemType, ItemIndex ;Just a wrapper
- Ret
- V_CItem_IsItemValid EndP
- V_CItem_GetItemLevel Proc ItemType:Dword, ItemIndex:Dword
- assume ecx:ptr ITEM_ATTRIBUTE_STRUCT
- invoke V_CItem_RetnpStruct, ItemType, ItemIndex
- .If (eax == 0)
- xor eax, eax
- jmp @End
- .Endif
- mov ecx, eax
- movsx eax, [ecx].SpecialVars.Level
- @End:
- assume ecx:nothing
- Ret
- V_CItem_GetItemLevel Endp
- V_CItem_GetItemDurability Proc ItemType:Dword, ItemIndex:Dword
- assume ecx:ptr ITEM_ATTRIBUTE_STRUCT
- invoke V_CItem_RetnpStruct, ItemType, ItemIndex
- .If (eax == 0)
- xor eax, eax
- jmp @End
- .Endif
- mov ecx, eax
- movsx eax, [ecx].DefenseVars.Durability
- @End:
- assume ecx:nothing
- Ret
- V_CItem_GetItemDurability Endp