Originally Posted By: GodSentDeath
Cleaned up (added {code} tags) by: acfrazier2
Difficulty: Medium 4/5
Originaly Posted By: Asrrin29
well this is the unpolished version I made before magnus cleaned it up, but it still works:
By Asrrin29
:::::::::::::::::: ::Server Side::::: ::::::::::::::::::
Go to modDatabase
Find
Sub SaveItem(ByVal ItemNum As Long)
Find
Call PutVar(FileName, "ITEM" & ItemNum, "Data3", Trim(Item(ItemNum).Data3)) in Sub
Add
Call PutVar(FileName, "ITEM" & ItemNum, "Data4", Trim(Item(ItemNum).Data4)) underneath
Find
Sub LoadItems()
Find
Item(i).Data3 = Val(GetVar(FileName, "ITEM" & i, "Data3")) in Sub
Add
Item(i).Data4 = Val(GetVar(FileName, "ITEM" & i, "Data4")) underneath
Go to modTypes
Find
Type ItemRec
Find
Data3 As Integer in Type
Add
Data4 As Integer underneath
Find
Sub ClearItem(ByVal index As Long)
Find
Item(index).Data3 = 0 in Sub
Add
Item(index).Data4 = 0 underneath
Go to modServerTCP
Find
Sub HandleData
Find
Save Item Packet
Find
Item(n).Data3 = Val(Parse(7)) in Packet
Add
Item(n).Data4 = Val(Parse(8)) underneath
Find
Sub SendUpdateItemToAll(ByVal ItemNum As Long)
Replace
packet = "UPDATEITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & END_CHAR
With
packet = "UPDATEITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & Item(ItemNum).Data4 & SEP_CHAR & END_CHAR
Find
Sub SendEditItemTo(ByVal index As Long, ByVal ItemNum As Long)
Replace
packet = "EDITITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & END_CHAR
With
packet = "EDITITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & Item(ItemNum).Data4 & SEP_CHAR & END_CHAR
Go to modGameLogic
Find
Function GetPlayerDamage
Replace
Call SetPlayerInvItemDur(index, WeaponSlot, GetPlayerInvItemDur(index, WeaponSlot) - 1)
With
'Check to see if Item is invulnrable, and if so, do not take away Durability. If Item(Player(index).Char(Player(index).CharNum).Inv (WeaponSlot).Num).Data4 = 0 Then Call SetPlayerInvItemDur(index, WeaponSlot, GetPlayerInvItemDur(index, WeaponSlot) - 1) End If
Find
Function GetPlayerProtection
Replace
Call SetPlayerInvItemDur(index, ArmorSlot, GetPlayerInvItemDur(index, ArmorSlot) - 1)
With
'Check to see if Armor is invulnrable, and if so, do not take away Durability. If Item(Player(index).Char(Player(index).CharNum).Inv (ArmorSlot).Num).Data4 = 0 Then Call SetPlayerInvItemDur(index, ArmorSlot, GetPlayerInvItemDur(index, ArmorSlot) - 1) End If
Replace
Call SetPlayerInvItemDur(index, HelmSlot, GetPlayerInvItemDur(index, HelmSlot) - 1)
With
'Check to see if Helm is invulnrable, and if so, do not take away Durability. If Item(Player(index).Char(Player(index).CharNum).Inv (HelmSlot).Num).Data4 = 0 Then Call SetPlayerInvItemDur(index, HelmSlot, GetPlayerInvItemDur(index, HelmSlot) - 1) End If
Done with server side :)
::::::::::::::::: ::Client Side::::: :::::::::::::::::
Go to modClientTCP
Find
Sub HandleData
Find
Update item packet
Find
Item(n).Data3 = 0 in Packet
Add
Item(n).Data4 = 0 underneath
Find
Edit item packet
Find
Item(n).Data3 = Val(Parse(7)) in packet
Add
Item(n).Data4 = Val(Parse(8)) underneath
Find
Sub SendSaveItem(ByVal ItemNum As Long)
Replace
Packet = "SAVEITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & END_CHAR
With
Packet = "SAVEITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(Item(ItemNum).Name) & SEP_CHAR & Item(ItemNum).Pic & SEP_CHAR & Item(ItemNum).Type & SEP_CHAR & Item(ItemNum).Data1 & SEP_CHAR & Item(ItemNum).Data2 & SEP_CHAR & Item(ItemNum).Data3 & SEP_CHAR & Item(ItemNum).Data4 & SEP_CHAR & END_CHAR
Go to modTypes
Find
Type ItemRec
Find
Data3 As Integer in Type
Add
Data4 As Interger underneath
Find
Sub ClearItem(ByVal index As Long)
Find
Item(index).Data3 = 0 in Sub
Add
Item(index).Data4 = 0 underneath
Go to modGameLogic
Find
Public Sub ItemEditorInit()
Find
frmItemEditor.scrlStrength.Value = Item(EditorIndex).Data2 in Public Sub
Add
frmItemEditor.chkDUR.Value = Item(EditorIndex).Data4 underneath
Find
Public Sub ItemEditorOk()
Replace
If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then Item(EditorIndex).Data1 = frmItemEditor.scrlDurability.Value Item(EditorIndex).Data2 = frmItemEditor.scrlStrength.Value Item(EditorIndex).Data3 = 0 End If
With
If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then Item(EditorIndex).Data1 = frmItemEditor.scrlDurability.Value Item(EditorIndex).Data2 = frmItemEditor.scrlStrength.Value Item(EditorIndex).Data3 = 0 Item(EditorIndex).Data4 = frmItemEditor.chkDUR.Value End If
Replace
If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then Item(EditorIndex).Data1 = frmItemEditor.scrlVitalMod.Value Item(EditorIndex).Data2 = 0 Item(EditorIndex).Data3 = 0 End If
With
If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then Item(EditorIndex).Data1 = frmItemEditor.scrlVitalMod.Value Item(EditorIndex).Data2 = 0 Item(EditorIndex).Data3 = 0 Item(EditorIndex).Data4 = 0 End If
Replace
If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then Item(EditorIndex).Data1 = frmItemEditor.scrlSpell.Value Item(EditorIndex).Data2 = 0 Item(EditorIndex).Data3 = 0 End If
With
If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then Item(EditorIndex).Data1 = frmItemEditor.scrlSpell.Value Item(EditorIndex).Data2 = 0 Item(EditorIndex).Data3 = 0 Item(EditorIndex).Data4 = 0 End If
Now open up frmItemEditor, and find fraEquipment, it should be located under Vitals Data and Spell Data
Make a CheckBox Labled chkDUR and have the caption set to "Invulnrable."
Save both projects and run, you should now have the option to make weapons, armor, and helms invulnrable, never losing durability. this can easily be changed with the checkbox located in frmItemEditor. :D
:::::::::::::::::: ::End Tutorial::::: ::::::::::::::::::
Phew took me a lot of typing to do that one... hope u like it folks...
|