# Random spells?

#### Marcus 小羊

Level 2
Hello guys, I'm still a totally noob when it comes to trigger editor.

May i ask if it's possible to gives hero random abilities every time they die?

Q, W, E, R 4 keys for 4 different abilities that will randomly be given to newly respawn heroes.

Well in my mind i got an idea about saving each abilities to variables

Example,
Q_Spell[1] = Thunder clap
Q_Spell[2] = Chain lightning
.
.
.
Q_SpellMax = 23(maximum number of Q Spell)
And so on..... there goes the same for others 3, W_Spell, E_spell, blablabla

Then will randomly gives every hero that respawned one random for each of the 4 keys QWER, but here's the problem, i don't know how to do it correctly, i assume we are needed to remove abilities from heroes once they died right?

Can somebody show me an example please...

I hope you guys can understand, because im bad at english

#### Marcus 小羊

Level 2
Nevermind, i kinda found a way to do it already

#### Pyrogasm

Level 25
The simplest solution is to save the given spells of each hero in an array when you give them. Either something like:

Q_Spell_Player[1] = <q spell for player 1>
W_Spell_Player[1] = <w spell for player 1>
E_Spell_Player[1] = <e spell for player 1>
R_Spell_Player[1] = <r spell for player 1>
---
Q_Spell_Player[2] = <q spell for player 2>
W_Spell_Player[2] = <w spell for player 2>
E_Spell_Player[2] = <e spell for player 2>
R_Spell_Player[2] = <r spell for player 2>

Or this (a 2-D array):
PlayerSpells[1*4 + 1] = <q spell for player 1>
PlayerSpells[1*4 + 2] = <w spell for player 1>
PlayerSpells[1*4 + 3] = <e spell for player 1>
PlayerSpells[1*4 + 4] = <r spell for player 1>
---
PlayerSpells[2*4 + 1] = <q spell for player 2>
PlayerSpells[2*4 + 2] = <w spell for player 2>
PlayerSpells[2*4 + 3] = <e spell for player 2>
PlayerSpells[2*4 + 4] = <r spell for player 2>

Replies
5
Views
598
Replies
10
Views
564
Replies
3
Views
429
Replies
14
Views
416
Replies
10
Views
1K