• 🏆 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!

[Trigger] Get unit's abilities

Status
Not open for further replies.
Level 4
Joined
Sep 6, 2012
Messages
88
Hi everyone !

Can someone help me with this problem ? I want to store a unit's abilities in a variable array. I can do it manually by setting each of array member to a specific ability (Assuming that ability is one of the unit's abilities). It would look like this

  • Set Temp_Ability[0] = Acid Bomb
However, doing it this way is so time-consuming since there are so many units available in my map. That's why I would like to ask if there is any dynamic method so that I would be able to detect which unit the player is using and store its abilities in the variables ? The current unit-in-use detection is not important here, please just focus on how to store a unit's abilities in variables, please :).

Thank you very much !
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
Hi

You could do something along the lines of:
1. Detect when a unit owned by a player casts a spell
2. Search that player's existing list of spells to see if it's already registered
3. If not, register it as a new element in the array list.

As for detecting it when the unit is made, you'd need a preset list.

What exactly are you trying to make? Perhaps we can find another workaround that doesn't require an array of abilities.
 
Level 4
Joined
Sep 6, 2012
Messages
88
Thanks for replying !

I don't really understand how to perform stuff you stated, but here's my situation so you can understand what I really mean better:

-I'm trying to create a system where players pick a hero of their choice (like most TD or DotA-like games). However, these heroes start with no ability.

-I don't allow these heroes to gain skill points by leveling, instead they gain abilities by completing certain quests. That's why I need to store each hero's abilities in variables so later I can add them to that specific hero as a reward for players.

-So, I'd like to know when a player pick a hero, is it possible for me to get and store that hero's abilities somewhere so I could add them one-by-one throughout the game flow later ?

I hope this is clear enough for you to understand. Thanks for your help !
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I see.

A simple way would be:
heroType[ ] = array unit type
spellA[ ] = array ability
spellB[ ] = array ability
etc to
spellD[ ] = array ability
  • Actions:
    • ----- Hero 1 -----
    • Set heroType[1] = Blademaster
    • Set spellA[1] = Wind Walk
    • Set spellB[1] = Mirror Image
    • ----- Hero 2 -----
    • Set heroType[2] = Paladin
    • Set spellA[2] = Holy Light
    • Set spellB[2] = Divine Shield
    • Set spellC[2] = Devotion Aura
    • ----- End of list -----
    • Set totalHeroes = 2
And so on. You'll need to setup each hero type this way.

When a player chooses a hero:
  • Events:
    • Player chooses a hero
  • Actions:
    • For each integer A from 1 to totalHeroes do (actions)
      • Loop - Actions
        • If (unit type of picked hero) equal to heroType[Integer A]
        • Then
          • Player - Disable spellA[Integer A] for (Triggering player)
          • Player - Disable spellB[Integer A] for (Triggering player)
          • Player - Disable spellC[Integer A] for (Triggering player)
Later on for the quest, we detect which hero type is finishing the quest (once again using the for loop as in this trigger, although we could just save the index in the player's variable..), and we just run:
  • Player - Enable spellA[hero index] for (Triggering player)
  • Player - Enable spellB[hero index] for (Triggering player)
  • Player - Enable spellC[hero index] for (Triggering player)
I hope that's a bit more clear :)

PS: Don't double post
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I see.

A simple way would be:
heroType[ ] = array unit type
spellA[ ] = array ability
spellB[ ] = array ability
etc to
spellD[ ] = array ability
  • Actions:
    • ----- Hero 1 -----
    • Set heroType[1] = Blademaster
    • Set spellA[1] = Wind Walk
    • Set spellB[1] = Mirror Image
    • ----- Hero 2 -----
    • Set heroType[2] = Paladin
    • Set spellA[2] = Holy Light
    • Set spellB[2] = Divine Shield
    • Set spellC[2] = Devotion Aura
    • ----- End of list -----
    • Set totalHeroes = 2
And so on. You'll need to setup each hero type this way.

When a player chooses a hero:
  • Events:
    • Player chooses a hero
  • Actions:
    • For each integer A from 1 to totalHeroes do (actions)
      • Loop - Actions
        • If (unit type of picked hero) equal to heroType[Integer A]
        • Then
          • Player - Disable spellA[Integer A] for (Triggering player)
          • Player - Disable spellB[Integer A] for (Triggering player)
          • Player - Disable spellC[Integer A] for (Triggering player)
Later on for the quest, we detect which hero type is finishing the quest (once again using the for loop as in this trigger, although we could just save the index in the player's variable..), and we just run:
  • Player - Enable spellA[hero index] for (Triggering player)
  • Player - Enable spellB[hero index] for (Triggering player)
  • Player - Enable spellC[hero index] for (Triggering player)
I hope that's a bit more clear :)

PS: Don't double post

I want to store a unit's abilities in a variable array. I can do it manually by setting each of array member to a specific ability

However, doing it this way is so time-consuming since there are so many units available in my map

Derp.
 
Status
Not open for further replies.
Top