Well this is my first tutorial and im changing somethings in the 2handed tutorial so. here it is
Copy and paste 1/5
Understanding 2/5
Untested but 99.9% im sure it will work
*i used the 2handed version by Sync and changed somethings around*
Lets begin.
-=Server side=-
Go into Modtypes and find.
Code:
Type ItemRec
Add This
Code:
Ranged As Byte
Below
Code:
Data3 Integer
Now go into ModDatabase and Find.
Code:
Sub SaveItem(ByVal ItemNum As Long)
Then add
Code:
Call PutVar(FileName, "ITEM" & ItemNum, "Ranged", Trim(Item(ItemNum).Ranged))
Below
Code:
Call PutVar(FileName, "ITEM" & ItemNum, "Data3", Trim(Item(ItemNum).Data3))
Now find
Code:
Sub Loaditems()
Add in
Code:
Item(i).Ranged = Val(GetVar(FileName, "ITEM" & i, "Ranged"))
Below
Code:
Item(i).Data3 = Val(GetVar(FileName, "ITEM" & i, "Data3"))
Server side is almost done now.
Go into Modhandledata find
Code:
If LCase(Parse(0)) = "useitem" Then
And find
Code:
Case ITEM_TYPE_WEAPON
Change it to this
Code:
Case ITEM_TYPE_WEAPON
If InvNum <> GetPlayerWeaponSlot(Index) Then
If Item(GetPlayerInvItemNum(Index, InvNum)).Ranged < 1 Then
If Int(GetPlayerSTR(Index)) < n Then
Call PlayerMsg(Index, "Your strength is to low to hold this weapon! Required SPEED (" & n * 2 & ")", BrightRed)
Exit Sub
End If
Call SetPlayerWeaponSlot(Index, InvNum)
Else
If GetPlayerShieldSlot(Index) = 0 Then
Call SetPlayerWeaponSlot(Index, InvNum)
Call SetPlayerShieldSlot(Index, InvNum)
Else
Call PlayerMsg(Index, "You have a sheild on!!", BrightRed)
End If
End If
Else
Call SetPlayerWeaponSlot(Index, 0)
End If
Call SendWornEquipment(Index)
Just under the Case_item_Weapon
You have Case_item_shield make it look like this
Code:
Case ITEM_TYPE_SHIELD
If GetPlayerShieldSlot(Index) > 0 Then
If GetPlayerWeaponSlot(Index) = GetPlayerShieldSlot(Index) Then
Call PlayerMsg(Index, "You have a Ranged weapon equipped! Please unequip it before using your shield!", BrightRed)
Exit Sub
Else
Call PlayerMsg(Index, "You already have a shield equipped! Please unequip it before using your shield!", BrightRed)
End If
Else
If InvNum <> GetPlayerShieldSlot(Index) Then
Call SetPlayerShieldSlot(Index, InvNum)
Else
Call SetPlayerShieldSlot(Index, 0)
End If
Call SendWornEquipment(Index)
End If
Now find
Code:
If LCase(Parse(0)) = "saveitem" Then
Add in
Code:
Item(n).Ranged = Val(Parse(8))
So now it looks like this
Code:
' Update the item
Item(n).Name = Parse(2)
Item(n).Pic = Val(Parse(3))
Item(n).Type = Val(Parse(4))
Item(n).Data1 = Val(Parse(5))
Item(n).Data2 = Val(Parse(6))
Item(n).Data3 = Val(Parse(7))
Item(n).Ranged = Val(Parse(8)) <----- added in
Go into ModGameLogic find
Code:
Sub PlayerMapDropItem(ByVal Index As Long, ByVal InvNum As Long, ByVal Ammount As Long)
Find
Code:
Case ITEM_TYPE_WEAPON
make it look like
Code:
Case ITEM_TYPE_WEAPON
If Item(GetPlayerInvItemNum(Index, InvNum)).TwoHanded < 1 Then
If InvNum = GetPlayerWeaponSlot(Index) Then
Call SetPlayerWeaponSlot(Index, 0)
Call SendWornEquipment(Index)
End If
MapItem(GetPlayerMap(Index), i).Dur = GetPlayerInvItemDur(Index, InvNum)
Else
If InvNum = GetPlayerWeaponSlot(Index) And InvNum = GetPlayerShieldSlot(Index) Then
Call SetPlayerWeaponSlot(Index, 0)
Call SetPlayerShieldSlot(Index, 0)
Call SendWornEquipment(Index)
End If
MapItem(GetPlayerMap(Index), i).Dur = GetPlayerInvItemDur(Index, InvNum)
End If
Now go into modServerTCP Find
Code:
Sub SendUpdateItemToAll(ByVal ItemNum As Long)
Make the packet look like this =)
Code:
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).Ranged & SEP_CHAR & END_CHAR
Right so close to the bottom now Find.
Code:
Sub SendEditItemTo(ByVal Index As Long, ByVal ItemNum As Long)
make the packet like this
Code:
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).Ranged & SEP_CHAR & END_CHAR
Done -=server side completed Congratulations=-
Right the client now
-=Client side=-
Find modtypes and look for
Code:
Type ItemRec
right under DATA 3 As integer
Add
Code:
Ranged As Byte
Now go to modClientTCP Find:
Code:
Public Sub SendSaveItem(ByVal ItemNum As Long)
Make the packet look like this
Code:
Packet = "SAVEITEM" & SEP_CHAR & ItemNum & SEP_CHAR & Trim(.Name) & SEP_CHAR & .Pic & SEP_CHAR & .Type & SEP_CHAR & .Data1 & SEP_CHAR & .Data2 & SEP_CHAR & .Data3 & SEP_CHAR & .Ranged & SEP_CHAR & END_CHAR
Now add
You now have to add a checkbox in the equipment frame, in the items editor. Call it chkRanged and your set.
Now, go into modGameLogic and find:
Code:
Public Sub ItemEditorOk()
At the bottom of:
Code:
If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_POTIONADDHP) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_POTIONSUBSP) Then
and
Code:
If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
add
Code:
Item(EditorIndex).Ranged = 0
So should look sorta like this.
Code:
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).Ranged = 0
End If
Code:
If (frmItemEditor.cmbType.ListIndex = ITEM_TYPE_SPELL) Then
Item(EditorIndex).Data1 = frmItemEditor.scrlSpell.Value
Item(EditorIndex).Data2 = 0
Item(EditorIndex).Data3 = 0
Item(EditorIndex).Ranged = 0
End If
now at the bottom of
Code:
If (frmItemEditor.cmbType.ListIndex >= ITEM_TYPE_WEAPON) And (frmItemEditor.cmbType.ListIndex <= ITEM_TYPE_SHIELD) Then
after
Code:
Item(EditorIndex).Data3 = 0
add
Code:
Item(EditorIndex).Ranged = frmItemEditor.chkRanged.Value
Ok, now go into modHandleData and find:
Code:
If (LCase(Parse(0)) = "updateitem") Then
Add below the update item section this:
Item(n).Ranged = 0
Now find:
Code:
If (LCase(Parse(0)) = "edititem") Then
And below:
Code:
Item(n).Data3 = Val(Parse(7))
ADD:
Code:
Item(n).Ranged = Val(Parse(8))
Well that's done and i hope it works =)
Message me if it doesn't and ill help fix it
MSN:
[email protected]