• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Random spells?

Status
Not open for further replies.
Level 2
Joined
Aug 29, 2019
Messages
15
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
 
Level 39
Joined
Feb 27, 2007
Messages
4,992
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>
 
Status
Not open for further replies.
Top