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

[EO] Spells Require Equipment


RyokuHasu
 Share

Recommended Posts

This was a simple request over in Q&A. I worked on it and decided to share it.

This can easily be modded to work in different ways if you wish.

**BOTH client and server**

in modTypes

In Private Type SpellRec

add at the bottom
```
WepReq As Long
```
**Server side**

In modCombat

in Public Sub BufferSpell

Bellow
```
' Make sure player has the spell
    If Not HasSpell(index, spellnum) Then Exit Sub
```
add

```
    If Spell(spellnum).WepReq <> 0 Then
        If Item(Spell(spellnum).WepReq).Type = ITEM_TYPE_WEAPON Then
            If Not Spell(spellnum).WepReq = Player(index).Equipment(1) Then
                PlayerMsg index, "You dont have the right Equipment! (" + Trim$(Item(Spell(spellnum).WepReq).Name) + ")", BrightRed
                Exit Sub
            End If
        End If
    End If
```
**Client Side**

On frmEditor_Spells

add a label and a scroll bar as shown

![](http://www.mediafire.com/convkey/7388/gati49ijw5pa6sd5g.jpg)

name the scroll bar "scrlWepReq"

name the label "lblWepReq"

2x click on the scroll bar and add

```
If scrlWepReq.Value > 0 Then
    lblWepReq.Caption = "Weapon: " + Item(scrlWepReq.Value).Name
Else
    lblWepReq.Caption = "Weapon: None"
End If

Spell(EditorIndex).WepReq = scrlWepReq.Value

```
then anywhere in the same form code add
```
Private Sub Form_Load()
    scrlWepReq.Max = MAX_ITEMS
End Sub
```
In modGameEditors

in Public Sub SpellEditorInit()

under
```
.scrlStun.Value = Spell(EditorIndex).StunDuration
```
add
```
.scrlWepReq.Value = Spell(EditorIndex).WepReq
```
**DONE**
Link to comment
Share on other sites

  • 1 month later...
Im trying to make a shield requirement as well. I added the same things except adding ShieldReq instead of WepReq. I compiled on client and all was good. I compiled on server, and it showed me this error "Compile error: Method or data member not found"

over

>!     ' Make sure player has the spell
    If Not HasSpell(index, spellnum) Then Exit Sub
        If Spell(spellnum).WepReq <> 0 Then
        If Item(Spell(spellnum).WepReq).Type = ITEM_TYPE_WEAPON Then
            If Not Spell(spellnum).WepReq = Player(index).Equipment(1) Then
                PlayerMsg index, "You dont have the right Equipment! (" + Trim$(Item(Spell(spellnum).WepReq).Name) + ")", BrightRed
                Exit Sub
            End If
        End If
    End If

        If Spell(spellnum).**ShieldReq** <> 0 Then
        If Item(Spell(spellnum).ShieldReq).Type = ITEM_TYPE_SHIELD Then
            If Not Spell(spellnum).ShieldReq = Player(index).Equipment(1) Then
                PlayerMsg index, "You dont have the right Equipment! (" + Trim$(Item(Spell(spellnum).ShieldReq).Name) + ")", BrightRed
                Exit Sub
            End If
        End If
    End If

    ' see if cooldown has finished

What am i doing wrong?
Link to comment
Share on other sites

  • 3 months later...
  • 1 month later...
> triple_X a tutorial for 2 handed weapons already exist, although ill admit im not exactly 100% sure of what you mean. check out the advanced weapons tutorial if you just want a 2 handed weapons tutorial.

I have advenced weapons in my engine. I need change it so that players can use spell when they have equip one-hand weapon or two-hand weapon or shield.
Link to comment
Share on other sites

oh I get it now im not sure why a 2 handed weapon doesnt already work if you have added the tutorial but to make it do sheilds are required just read the tutorial and replace where it says Item_type_weapon replace it with ITEM_TYPE_SHIELD and change wherever it says wepreq with ShieldReq
Link to comment
Share on other sites

  • 1 month later...
Okay….does this only work for Weapons? <.< i tried it with a custom Equipmentslot "Classitem" i can compile wihtout error, it works almost...if someone equips the needed item, he still can cast the spell, it says that he has not the right equipment. even if he has it equiped.
Link to comment
Share on other sites

you need to edit this part```
If Spell(spellnum).WepReq <> 0 Then

If Item(Spell(spellnum).WepReq).Type = ITEM_TYPE_WEAPON Then

If Not Spell(spellnum).WepReq = Player(index).Equipment(1) Then

PlayerMsg index, "You dont have the right Equipment! (" + Trim$(Item(Spell(spellnum).WepReq).Name) + ")", BrightRed

Exit Sub

End If

End If

End If
```i dont know what type of item your using but lets say you wanna make your shield be required to cast a spell first your would need to change the

```
if item(spell(spellnum).wepreq).type = item_type_shield then
```next you would need to go to the next line of code and change```
if notspell(spellnum).wepreq = player(index).equipment(4) then
```<– see what i changed? the 1 got changed to a 4 because in modconstants under item constants the shield is number 4\. so just go to mod constants and find what item type your planning on using and use the number next to it. hope that helps.
Link to comment
Share on other sites

Thanks oǝɹo you was abit wrong with your answer but got me on the Right Track. The Number is not the Number the item have in Modconstants, rather it is the itemslot it is attached to.

means: i have 12 equipslots for a player, the item the spell(can or cant't) cast is boudn to has the number 9, but is equiped in the 12\. equipmentslot.

Anyway, much thanks you help me out.
Link to comment
Share on other sites

  • 3 months later...
Sorry to bump but since TripleX didn't post his solution to the problem, I was wondering if anyone knew of a way to require a specific item type. For example, these abilities can only be used with a 1h sword (but all 1h swords work), 1h wand (but all 1h wands work), etc.

Thanks ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

> Sorry to bump but since TripleX didn't post his solution to the problem, I was wondering if anyone knew of a way to require a specific item type. For example, these abilities can only be used with a 1h sword (but all 1h swords work), 1h wand (but all 1h wands work), etc.
>
> Thanks ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

It would be rather easy. Add the rec in SpellRec, add the cmb or whatever to the Spell Editor and make sure it saves, then put in cast spell a check to see if they have a weapon/shield etc
Link to comment
Share on other sites

  • 3 weeks later...

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...