Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

(EO) Advanced Weapon types - DELETE PLEASE


tslusny
 Share

Recommended Posts

So in this tutorial you will make possible to have this weapon types:

* [2 Handed](http://www.touchofdeathforums.com/smf2/index.php/topic,80386) - by Sigridunset
* Dagger
* Normal weapon

2 Handed - If u have daggers or normal weapon and shield equipped, it will unequip them and equip 2 handed weapon. [Made by Sigridunset](http://www.touchofdeathforums.com/smf2/index.php/topic,80386).

Dagger - If u have weapon and shield equipped, it will first unequip weapon, and if u equip another dagger, it will equip on shield slot ( so you can have 2 weapons equipped, and yes stats stack, so if first dagger have bonus 5 dmg and second dagger have bonus 10 dmg, bonus will be 15 dmg). And u can have equipped shield with dagger.

Normal weapon - Like dagger but u cant have equipped this item on shield slot, so u can have equiped this weapon and shield, but not this weapon and this weapon.

Some parts of this tutorial is by Sigridunset.

Thx to Sigridunset for [2h system](http://www.touchofdeathforums.com/smf2/index.php/topic,80386).

CLIENT SIDE

Go to frmEditor_Item and make 2 checkboxes in fraEquipment

First

Name: chkTwoh

Caption: Two Handed

Add into it

```
' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

If chkTwoh.Value = 0 Then

Item(EditorIndex).isTwoHanded = False

Else

Item(EditorIndex).isTwoHanded = True

Item(EditorIndex).isDagger = False

chkDagger.Value = 0

End If

' Error handler

Exit Sub

errorhandler:

HandleError "chkTwoh", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub
```

Second

Name: chkDagger

Caption: Dagger

Add into it

```
If Options.Debug = 1 Then On Error GoTo errorhandler

If chkDagger.Value = 0 Then

Item(EditorIndex).isDagger = False

Else

Item(EditorIndex).isDagger = True

Item(EditorIndex).isTwoHanded = False

chkTwoh.Value = 0

End If

' Error handler

Exit Sub

errorhandler:

HandleError "chkTwoh", "frmEditor_Item", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub
```

Now add at bottom of Private Type ItemRec

```
isTwoHanded As Boolean

isDagger As Boolean
```

Now go to Public Sub ItemEditorInit()

Here find

```
frmEditor_Item.scrlSpeed.Value = .Speed
```

Add under it

```
If Item(EditorIndex).isTwoHanded Then

frmEditor_Item.chkTwoh.Value = 1

Else

frmEditor_Item.chkTwoh.Value = 0

End If

If Item(EditorIndex).isDagger Then

frmEditor_Item.chkDagger.Value = 1

Else

frmEditor_Item.chkDagger.Value = 0

End If
```

SERVER SIDE

At bottom of Private Type ItemRec add

```
isTwoHanded As Boolean

isDagger As Boolean
```

At top of Public Sub UseItem add

```
Dim b As Long, j As Long

For j = 1 To MAX_INV

Next

b = FindOpenInvSlot(index, j)
```

Now find

```
Case ITEM_TYPE_WEAPON
```

Under

```
' access requirement
```

Put

```
If Item(itemnum).isTwoHanded = True Then

If GetPlayerEquipment(index, Shield) > 0 Then

If GetPlayerEquipment(index, Weapon) > 0 Then

If b < 1 Then

Call PlayerMsg(index, "You have no room in your inventory.", BrightRed)

Exit Sub

End If

End If

End If

End If
```

Still in ITEM_TYPE_WEAPON in Sub UseItem in ModPlayer

Above this:

```
PlayerMsg Index, "You equip " & CheckGrammar(Item(itemnum).Name), BrightGreen
```

Remove this:

```
SetPlayerEquipment Index, itemnum, Weapon
```
Delete this

```
If GetPlayerEquipment(Index, Weapon) > 0 Then

tempItem = GetPlayerEquipment(Index, Weapon)

End If
```

And replace this

```
If tempItem > 0 Then

GiveInvItem Index, tempItem, 0 ' give back the stored item

tempItem = 0

End If
```

With this

```
If Item(ItemNum).isDagger Then

If GetPlayerEquipment(index, Shield) > 0 Then

If GetPlayerEquipment(index, Weapon) > 0 Then

If Item(GetPlayerEquipment(index, Weapon)).isDagger Then

GiveInvItem index, GetPlayerEquipment(index, Shield), 0

SetPlayerEquipment index, ItemNum, Shield

Else

GiveInvItem index, GetPlayerEquipment(index, Weapon), 0

SetPlayerEquipment index, ItemNum, Weapon

End If

Else

SetPlayerEquipment index, ItemNum, Weapon

End If

Else

If GetPlayerEquipment(index, Weapon) > 0 Then

If Item(GetPlayerEquipment(index, Weapon)).isDagger Then

GiveInvItem index, GetPlayerEquipment(index, Shield), 0

SetPlayerEquipment index, ItemNum, Shield

Else

GiveInvItem index, GetPlayerEquipment(index, Weapon), 0

SetPlayerEquipment index, ItemNum, Weapon

End If

Else

SetPlayerEquipment index, ItemNum, Weapon

End If

End If

ElseIf Item(ItemNum).isTwoHanded Then

If GetPlayerEquipment(index, Shield) > 0 Then

If GetPlayerEquipment(index, Weapon) > 0 Then

GiveInvItem index, GetPlayerEquipment(index, Weapon), 0

GiveInvItem index, GetPlayerEquipment(index, Shield), 0

SetPlayerEquipment index, 0, Shield

SetPlayerEquipment index, ItemNum, Weapon

Else

GiveInvItem index, GetPlayerEquipment(index, Shield), 0

SetPlayerEquipment index, 0, Shield

SetPlayerEquipment index, ItemNum, Weapon

End If

Else

If GetPlayerEquipment(index, Weapon) > 0 Then

GiveInvItem index, GetPlayerEquipment(index, Weapon), 0

SetPlayerEquipment index, ItemNum, Weapon

Else

SetPlayerEquipment index, ItemNum, Weapon

End If

End If

Else

If GetPlayerEquipment(index, Shield) > 0 Then

If GetPlayerEquipment(index, Weapon) > 0 Then

GiveInvItem index, GetPlayerEquipment(index, Weapon), 0

SetPlayerEquipment index, ItemNum, Weapon

Else

SetPlayerEquipment index, ItemNum, Weapon

End If

Else

If GetPlayerEquipment(index, Weapon) > 0 Then

GiveInvItem index, GetPlayerEquipment(index, Weapon), 0

SetPlayerEquipment index, ItemNum, Weapon

Else

SetPlayerEquipment index, ItemNum, Weapon

End If

End If

End If

```

Now find

```
Case ITEM_TYPE_SHIELD
```

In this case replace this:

```
If tempItem > 0 Then

GiveInvItem index, tempItem, 0 ' give back the stored item

tempItem = 0

End If
```

With this:

```
If GetPlayerEquipment(Index, Weapon) > 0 Then

If Item(GetPlayerEquipment(Index, Weapon)).isTwoHanded Then

GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0

SetPlayerEquipment Index, 0, Weapon

Else

If tempItem > 0 Then

GiveInvItem Index, tempItem, 0 ' give back the stored item

tempItem = 0

End If

End If

End If
```

And now you will have working 3 types of weapons in game. :cheesy:

Report any Bugs found.

_________________________________________________________________________

But i need help with paperdolling. I tried to make this - if dagger is equipped on shield slot, it will change DaggerEq boolean to true ( and i added DaggerEq as Boolean to ItemRec) and on client side i tried to add scrollbar similar do Paperdoll scrollbar, but it will give atribute Item(EditorIndex).DaggerPaperdoll and i tried to add DaggerPaperdoll as Long attribute to ItemRec

And i tried to add check:

```
If Item(GetPlayerEquipment(Index, PaperdollOrder(I)))).DaggerEq = True Then

Call BltPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(I))).DaggerPaperdoll, Anim, SpriteTop)

Else

Call BltPaperdoll(x, y, Item(GetPlayerEquipment(Index, PaperdollOrder(I))).Paperdoll, Anim, SpriteTop)
```

But it dont worked
Link to comment
Share on other sites

@Sigridunset:

> Why did you combine your dagger tutorial with my Two handed tutorial?…

I think the idea was that certain parts of it would make it incompatible with your tutorial. (For example, now clicking the dagger checkbox removes the two-handed checkbox.) I have added a link to your topic in the tutorial, although I could remove your tutorial from the tutorial completely if you wish.
Link to comment
Share on other sites

can you make it so if the item is in the shield slot than it uses to shield paperdoll layer to render? im not sure how to go about it  but that  semms like the easiest way to make the  item show up. ill try n figure it out  and  ill post it here if i do.
Link to comment
Share on other sites

@Soul:

> I think the idea was that certain parts of it would make it incompatible with your tutorial. (For example, now clicking the dagger checkbox removes the two-handed checkbox.) I have added a link to your topic in the tutorial, although I could remove your tutorial from the tutorial completely if you wish.

Yeah that would be great! I felt repeating it was unnecessary. As long as it mentions that it requires the two handed addition it should be fine. Thank you :)
Link to comment
Share on other sites

@Sigridunset:

> Yeah that would be great! I felt repeating it was unnecessary. As long as it mentions that it requires the two handed addition it should be fine. Thank you :)

Yes it necessary becouse if i dont include it in it i will must add if u added Sigirdunsets tutorial remove that, replace it with that and soo many replacement will be made so it was necessary to copy your tutorial.
Link to comment
Share on other sites

@or3o:

> can you make it so if the item is in the shield slot than it uses to shield paperdoll layer to render? im not sure how to go about it  but that  semms like the easiest way to make the  item show up. ill try n figure it out  and  ill post it here if i do.

I tried to make that i have scrollbar for another paperdoll in equipment window and i maked check if .isdagger then it will show that paperdoll. Its irrevelant for now in what paperdoll layer it render. Its easy to do in what paperdoll layer it render but i cant figure this problem.
Link to comment
Share on other sites

  • 3 weeks later...
I have a problem that when I equip sword then he dublicates it and one sword is equiped and one in inventory from that who i tryed to equip… and when I equip dagger he equips in both off hand and main hand solts.....
Link to comment
Share on other sites

Weird, i had this problem too but only when i started making on this code and i fixed it with couple of IFs, so that weird it still occur

EDIT:
Do you deleted this?
```
If GetPlayerEquipment(Index, Weapon) > 0 Then
                    tempItem = GetPlayerEquipment(Index, Weapon)
                End If
```Do you replaced this?
             ```
If tempItem > 0 Then
                  GiveInvItem Index, tempItem, 0 ' give back the stored item
                    tempItem = 0
                End If
```Becouse you MUST replace it becouse it stores that weapon and after equip another it will give you back

Aboves are in Case ITEM_TYPE_WEAPON
Link to comment
Share on other sites

I'v done it all, maybe I have made a mistake and added if checks afther code somewhere .. :D
But here is both weapon and shield type… dunno why showing u shield cuz there is no problem only with weapon xD

>! ```
Case ITEM_TYPE_WEAPON
>!                 ' stat requirements
                For i = 1 To Stats.Stat_Count - 1
                    If GetPlayerRawStat(Index, i) < Item(itemnum).Stat_Req(i) Then
                        PlayerMsg Index, "You do not meet the stat requirements to equip this item.", BrightRed
                        Exit Sub
                    End If
                Next

                ' level requirement
                If GetPlayerLevel(Index) < Item(itemnum).LevelReq Then
                    PlayerMsg Index, "You do not meet the level requirement to equip this item.", BrightRed
                    Exit Sub
                End If

                If Item(itemnum).isTwoHanded = True Then
                    If GetPlayerEquipment(Index, Shield) > 0 Then
                        If GetPlayerEquipment(Index, Weapon) > 0 Then
                            If b < 1 Then
                                Call PlayerMsg(Index, "You have no room in your inventory.", BrightRed)
                                Exit Sub
                            End If
                        End If
                    End If
                End If

                ' class requirement
                If Item(itemnum).ClassReq > 0 Then
                    If Not GetPlayerClass(Index) = Item(itemnum).ClassReq Then
                        PlayerMsg Index, "You do not meet the class requirement to equip this item.", BrightRed
                        Exit Sub
                    End If
                End If

                ' access requirement
                If Not GetPlayerAccess(Index) >= Item(itemnum).AccessReq Then
                    PlayerMsg Index, "You do not meet the access requirement to equip this item.", BrightRed
                    Exit Sub
                End If
>!                 SetPlayerEquipment Index, itemnum, Weapon
                PlayerMsg Index, "You equip " & CheckGrammar(Item(itemnum).Name), BrightGreen
                TakeInvItem Index, itemnum, 1

                If Item(itemnum).isDagger Then
                    If GetPlayerEquipment(Index, Shield) > 0 Then
                        If GetPlayerEquipment(Index, Weapon) > 0 Then
                            If Item(GetPlayerEquipment(Index, Weapon)).isDagger Then
                                GiveInvItem Index, GetPlayerEquipment(Index, Shield), 0
                                SetPlayerEquipment Index, itemnum, Shield
                            Else
                                GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                                SetPlayerEquipment Index, itemnum, Weapon
                            End If
                        Else
                            SetPlayerEquipment Index, itemnum, Weapon
                        End If
                    Else
                        If GetPlayerEquipment(Index, Weapon) > 0 Then
                            If Item(GetPlayerEquipment(Index, Weapon)).isDagger Then
                                GiveInvItem Index, GetPlayerEquipment(Index, Shield), 0
                                SetPlayerEquipment Index, itemnum, Shield
                            Else
                                GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                                SetPlayerEquipment Index, itemnum, Weapon
                            End If
                        Else
                            SetPlayerEquipment Index, itemnum, Weapon
                        End If
                    End If
                ElseIf Item(itemnum).isTwoHanded Then
                    If GetPlayerEquipment(Index, Shield) > 0 Then
                        If GetPlayerEquipment(Index, Weapon) > 0 Then
                            GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                            GiveInvItem Index, GetPlayerEquipment(Index, Shield), 0
                            SetPlayerEquipment Index, 0, Shield
                            SetPlayerEquipment Index, itemnum, Weapon
                        Else
                            GiveInvItem Index, GetPlayerEquipment(Index, Shield), 0
                            SetPlayerEquipment Index, 0, Shield
                            SetPlayerEquipment Index, itemnum, Weapon
                        End If
                    Else
                        If GetPlayerEquipment(Index, Weapon) > 0 Then
                            GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                            SetPlayerEquipment Index, itemnum, Weapon
                        Else
                            SetPlayerEquipment Index, itemnum, Weapon
                        End If
                    End If
                Else
                    If GetPlayerEquipment(Index, Shield) > 0 Then
                        If GetPlayerEquipment(Index, Weapon) > 0 Then
                            GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                            SetPlayerEquipment Index, itemnum, Weapon
                        Else
                            SetPlayerEquipment Index, itemnum, Weapon
                        End If
                    Else
                        If GetPlayerEquipment(Index, Weapon) > 0 Then
                            GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                            SetPlayerEquipment Index, itemnum, Weapon
                        Else
                            SetPlayerEquipment Index, itemnum, Weapon
                        End If
                    End If
                End If
>!                 Call SendWornEquipment(Index)
                Call SendMapEquipment(Index)

                ' send vitals
                Call SendVital(Index, Vitals.HP)
                Call SendVital(Index, Vitals.MP)
                ' send vitals to party if in one
                If TempPlayer(Index).inParty > 0 Then SendPartyVitals TempPlayer(Index).inParty, Index

                ' send the sound
                SendPlayerSound Index, GetPlayerX(Index), GetPlayerY(Index), SoundEntity.seItem, itemnum
>! ```

>! ```
Case ITEM_TYPE_SHIELD

                ' stat requirements
                For i = 1 To Stats.Stat_Count - 1
                    If GetPlayerRawStat(Index, i) < Item(itemnum).Stat_Req(i) Then
                        PlayerMsg Index, "You do not meet the stat requirements to equip this item.", BrightRed
                        Exit Sub
                    End If
                Next

                ' level requirement
                If GetPlayerLevel(Index) < Item(itemnum).LevelReq Then
                    PlayerMsg Index, "You do not meet the level requirement to equip this item.", BrightRed
                    Exit Sub
                End If

                ' class requirement
                If Item(itemnum).ClassReq > 0 Then
                    If Not GetPlayerClass(Index) = Item(itemnum).ClassReq Then
                        PlayerMsg Index, "You do not meet the class requirement to equip this item.", BrightRed
                        Exit Sub
                    End If
                End If

                ' access requirement
                If Not GetPlayerAccess(Index) >= Item(itemnum).AccessReq Then
                    PlayerMsg Index, "You do not meet the access requirement to equip this item.", BrightRed
                    Exit Sub
                End If
>!                 If GetPlayerEquipment(Index, Shield) > 0 Then
                    tempItem = GetPlayerEquipment(Index, Shield)
                End If
>!                 SetPlayerEquipment Index, itemnum, Shield
                PlayerMsg Index, "You equip " & CheckGrammar(Item(itemnum).Name), BrightGreen
                TakeInvItem Index, itemnum, 1

                If GetPlayerEquipment(Index, Weapon) > 0 Then
                    If Item(GetPlayerEquipment(Index, Weapon)).isTwoHanded Then
                        GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                        SetPlayerEquipment Index, 0, Weapon
                    End If
                End If
>!                 If tempItem > 0 Then
                    GiveInvItem Index, tempItem, 0 ' give back the stored item
                    tempItem = 0
                End If

                ' send vitals
                Call SendVital(Index, Vitals.HP)
                Call SendVital(Index, Vitals.MP)
                ' send vitals to party if in one
                If TempPlayer(Index).inParty > 0 Then SendPartyVitals TempPlayer(Index).inParty, Index
>!                 Call SendWornEquipment(Index)
                Call SendMapEquipment(Index)

                ' send the sound
                SendPlayerSound Index, GetPlayerX(Index), GetPlayerY(Index), SoundEntity.seItem, itemnum
>! ```
Link to comment
Share on other sites

Above this:
PlayerMsg Index, "You equip " & CheckGrammar(Item(itemnum).Name), BrightGreen

Remove this:
SetPlayerEquipment Index, itemnum, Weapon

And in shield case replace this:

If GetPlayerEquipment(Index, Weapon) > 0 Then
                    If Item(GetPlayerEquipment(Index, Weapon)).isTwoHanded Then
                        GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                        SetPlayerEquipment Index, 0, Weapon
                    End If
                End If

                If tempItem > 0 Then
                    GiveInvItem Index, tempItem, 0 ' give back the stored item
                    tempItem = 0
                End If

With this:

If GetPlayerEquipment(Index, Weapon) > 0 Then
                    If Item(GetPlayerEquipment(Index, Weapon)).isTwoHanded Then
                        GiveInvItem Index, GetPlayerEquipment(Index, Weapon), 0
                        SetPlayerEquipment Index, 0, Weapon
    Else
                        If tempItem > 0 Then
                            GiveInvItem Index, tempItem, 0 ' give back the stored item
                            tempItem = 0
                        End If
                    End If
                End If 

I thin thiw will fix all i must add it to tutorial
Link to comment
Share on other sites

  • 1 month later...
  • 2 weeks later...
@chamster:

> I found an bug? When a dagger is equipped into the shield slot, and you log out, and you log back in the dagger is gone, cannot be found in inventory either…

Before I add this code, was this ever fixed?
Link to comment
Share on other sites

  • 4 weeks later...
> Im gonna try to fix it and release a working tutorial today, the way i have it planned might make it a little longer of a tutorial but at least it will be done right.

If you can then thank you. I would really like that code. ![;)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/wink.png)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...