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

Creating a spells actionbar with keybindings and icons


tom22
 Share

Recommended Posts

Hi there,

I want to create an actionbar with keybindings and icons to activate spells instead of the current spell list which is really uncomfortable to play with.

Has such thing been done before? How should I do this? Any suggestions or tips?

Currently I'm not even sure where to start so any help is appreciated. I can do some VB6.
Link to comment
Share on other sites

i did it for my tiny project, and its probalby oing to be added in Aura: The Beginning to :)
i aslo added casting time for spells, reload time and even interrupt skills for PVP.

anyhow the basic idea to create such a system (basic is just casting thats all) is to create icons of your spells and add this code to the button

```
Sub picSpell01_Click()

SpellMemorized = 1
    If Player(MyIndex).Spell(lstSpells.ListIndex + 1) > 0 Then
        If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
            If Player(MyIndex).Moving = 0 Then
                Call SendData("cast" & SEP_CHAR & SpellMemorized & END_CHAR)
                Player(MyIndex).Attacking = 1
                Player(MyIndex).AttackTimer = GetTickCount
                Player(MyIndex).CastedSpell = YES
            Else
                Call AddText("Cannot cast while walking!", BRIGHTRED)
            End If
        End If
    Else
        Call AddText("No spell here.", BRIGHTRED)
    End If

```
its just a mix of the original code for casting & learning spells.

BUT: you have to be sure that your spell that the icon needs to CAST is on the RIGHT place in the listbox!

well, thats the basic stuff, i added way more features already (oh and click on the lisbox, visible = false the ppl don't need to c that box)
i also know that this code can be made way easier, but i thought this code would might be the best to udnerstand :)

i hope i helped you out, if there are any other questions feel free to ask me ^^

Peace out, Tyr
Link to comment
Share on other sites

Thanks.

Looks like it's going to be a hard thing to do and thus I'll add it to the end of my ToDo.

Still trying to figure out how to smoothly convert 3d models to 2d sprites. Problem is that I'm seeing a black border (or whatever colour, depends on what background colour the character sprite has) around the character. Which is no problem for pixely sprites, but when you have those very detailed ones converted from 3d models, it's very ugly.

Anyhow thats a different topic so I'll start another thread in the graphics section. :)

Thanks!
Link to comment
Share on other sites

@Tyr:

> i did it for my tiny project, and its probalby oing to be added in Aura: The Beginning to :)
> i aslo added casting time for spells, reload time and even interrupt skills for PVP.
>
> anyhow the basic idea to create such a system (basic is just casting thats all) is to create icons of your spells and add this code to the button
>
> ```
> Sub picSpell01_Click()
>
> SpellMemorized = 1
>     If Player(MyIndex).Spell(lstSpells.ListIndex + 1) > 0 Then
>         If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
>             If Player(MyIndex).Moving = 0 Then
>                 Call SendData("cast" & SEP_CHAR & SpellMemorized & END_CHAR)
>                 Player(MyIndex).Attacking = 1
>                 Player(MyIndex).AttackTimer = GetTickCount
>                 Player(MyIndex).CastedSpell = YES
>             Else
>                 Call AddText("Cannot cast while walking!", BRIGHTRED)
>             End If
>         End If
>     Else
>         Call AddText("No spell here.", BRIGHTRED)
>     End If
>
> ```
> its just a mix of the original code for casting & learning spells.
>
> BUT: you have to be sure that your spell that the icon needs to CAST is on the RIGHT place in the listbox!
>
> well, thats the basic stuff, i added way more features already (oh and click on the lisbox, visible = false the ppl don't need to c that box)
> i also know that this code can be made way easier, but i thought this code would might be the best to udnerstand :)
>
> i hope i helped you out, if there are any other questions feel free to ask me ^^
>
> Peace out, Tyr

i think i'm going to give this a shot too, if you don't mind that is  :P
Link to comment
Share on other sites

hey, dont no if this is a necro or not, but i am trying to apply this to my game.  This only casts the spell that i have selected in the spells list box, like i have the second one sellected, and it casts it, and then i have the third spell selected, and it does the third spell.  Also i have 6 spell buttons, and they all do the same spell.  Sorry i couldnt find any help on this.

Thanks
Link to comment
Share on other sites

lol dude ^^

first of all, its not a necro 3/11 and 11/11 so whatever, just check the date.
secondly when i post a code on the forums its not meant just to copy and paste you will have to UNDERSTAND the code.

the code i gave you actually worked for spell 1 (of course) ok gimme a second… i'll make the code easier for you all, and also way more efficient (as i only posted the code for spell 1 i will now post the code for every single spell you desire)

Put this at the end of modgame logic:

```
Sub CastSpell(ByVal SpellNum As Integer, ByVal Mana As Integer)
If GetPlayerMP(MyIndex) >= Mana Then 'check for MP

If Player(MyIndex).Moving = 0 Then
        If GetTickCount > Player(MyIndex).AttackTimer + 1000 Then
            If Player(MyIndex).Moving = 0 Then
                Call SendData("cast" & SEP_CHAR & SpellNum & END_CHAR)
                Player(MyIndex).Attacking = 1
                Player(MyIndex).AttackTimer = GetTickCount
                Player(MyIndex).CastedSpell = YES
                SpellCasted = 0
            Else
                Call AddText("Cannot cast while walking!", YELLOW)
            End If
        End If
Else
    Call AddText("Cannot cast while Moving", YELLOW)
End If
Else
    Call AddText("Not enough mana!", YELLOW)
    End If
End Sub
```
well now add to each spell button this code:

   ```
Call CastSpell(SPELLNUMER, MANA)
```
with spellnumber the number of the spell listed in the casting dialog and mana of course the amount of mana needed to cast the spell (this may not be needed as this is also checked at the server side, i only did this because with my reloading system you would cast and then it would say not enough mana etc… whatever)

so, again wait an example:

you have a spell button that needs to cast fireball, and the code under it is for example Call CastSpell(1 ,5)

THEN YOU HAVE TO BE SURE THAT THE SPELL IS IN THE FIRST PLACE! if not everything would go wrong...

Note: with this system it will also "disable" that persons can buy scrolls and lean spells taht way because they can learn them in a random way! (instead when you make your own item type and code it all like i did, but thats not the point) this means that players will have to learn spells when they have a good magic req ok?

mhh, i might consider making a tut about this =/

ok, i hope i helped you all out now. Took me some time to make this post

Good luck, Tyr
Link to comment
Share on other sites

yea, thanks i did not under stand at first, i thought that went in my button sub lol, i am trying it out now.

Thanks

[EDIT]
ok when i compile the client, i get a Variable not defined on

Spellcasted = 0

i will try some other things to get it to work, any ideas?
Link to comment
Share on other sites

@Warconn:

> yea, thanks i did not under stand at first, i thought that went in my button sub lol, i am trying it out now.
>
> Thanks
>
> [EDIT]
> ok when i compile the client, i get a Variable not defined on
>
> Spellcasted = 0
>
> i will try some other things to get it to work, any ideas?

well ya i forgot to add that, as i guess everyone knew what to do when a variable isn't defenice, you have to declare it oO
go to modGlobals and add to the bottom

```
'Visual Spell Declarations
Public SpellCasted As Integer
```
but probably you won't need that var as its probably for the reloading system… anyhow that should work eve nif you didn't need the variable.
Link to comment
Share on other sites

```
HotKey(1 to 12) as byte

```
```
Select Case KeyCode
  Case vbKeyF1
    If Spell(HotKey(1)) > 0 then
        CastSpell HotKey(1)
    end if
  Case vbKeyF2
    If Spell(HotKey(2)) > 0 then
        CastSpell HotKey(2)
    end if
etc. etc.

```
```
If ControlDown = true then
  Select Case KeyCode
    Case vbKeyF1
      AddText "Hotkey 1 spell set", Red?
      HotKey(1) = lstSpells.listindex + 1
etc. etc..

```
Or just steal my spell book system :3
Link to comment
Share on other sites

@apf42589:

> tried it… didnt work.. i suck.. i quit... lmfao... nah i dont quit... but.. anyways... hopefully it works out for all of you, i'm not really going into changing the interface as of right now in my game...
>
>     APF

actually that post didn't made really sense, if you are not changing the the interface… whatever it s not a code you copy paste in 5 secs oO
Link to comment
Share on other sites

@Warconn:

> yea, i had some difficulty when i just tryed to copy and paste the code, but i took some time, and i have some skill with source, and i read the code to try and understand it better, thats how i learned vb6, reading other peoples codes ;)

and thats how it should be done :)
Link to comment
Share on other sites

@Robin:

> ```
> HotKey(1 to 12) as byte
>
> ```
> ```
> Select Case KeyCode
>   Case vbKeyF1
>     If Spell(HotKey(1)) > 0 then
>         CastSpell HotKey(1)
>     end if
>   Case vbKeyF2
>     If Spell(HotKey(2)) > 0 then
>         CastSpell HotKey(2)
>     end if
> etc. etc.
>
> ```
> ```
> If ControlDown = true then
>   Select Case KeyCode
>     Case vbKeyF1
>       AddText "Hotkey 1 spell set", Red?
>       HotKey(1) = lstSpells.listindex + 1
> etc. etc..
>
> ```
> Or just steal my spell book system :3

so this will allow the user to set the spells to a hotkey, can they choose which one they want in a certain hotkey, or is it just by the spells list.

Also, which spellbook system are you talking about, i have searched and searched for it, but i have found nothing.

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