• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

efficiency of gui triggered spell

Status
Not open for further replies.
Level 4
Joined
Feb 22, 2012
Messages
74
This is just a question about theory really, because one of these options is clearly much easier to work with.

My map has several heroes who each have about 6 spells, and all of the spells are triggered. I have thought about doing triggered spells in 2 different ways:

Method 1
For each ability, have a trigger beginning like this:
  • Events
  • A unit starts the effect of an ability
  • Conditions
  • Ability being cast is equal to X
  • Actions
Method 2
For each hero, have a trigger beginning like this
  • Events
  • A unit starts the effect of an ability
  • Conditions
  • Unit type of triggering unit is equal to CLASS
  • Actions
  • If ability being cast is equal to X, then
  • else
  • If ability being cast is equal to Y, then
  • else
  • If ability being cast is equal to Z, then
  • else
So method 1 is easier to work with for me, it has the advantage of smaller triggers but there are many per hero.

Method 2 has the advantage of being 1 spell trigger per hero, but each trigger is very large.

I am wondering if either method has any difference performance wise. To give you an idea of the scope, my map will have about 6 hero classes; each hero has 5 spells that are only 1-level, a single spell that has 5 levels, and a passive ability that has 5 levels.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You could use this system:

  • Untitled Trigger 061
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set hash = (Last created hashtable)
      • -------- ---------------------------------------- --------
      • Set trig = Untitled Trigger 062 <gen>
      • Set ab = Divine Shield
      • Custom script: call SaveTriggerHandle(udg_hash, udg_ab, 0, udg_trig)
      • -------- ---------------------------------------- --------
      • Set trig = Untitled Trigger 063 <gen>
      • Set ab = Holy Light
      • Custom script: call SaveTriggerHandle(udg_hash, udg_ab, 0, udg_trig)
      • -------- ---------------------------------------- --------
  • Untitled Trigger 064
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Custom script: call TriggerExecute(LoadTriggerHandle(udg_hash, GetSpellAbilityId(), 0))
  • Untitled Trigger 062
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: shield
  • Untitled Trigger 063
    • Events
    • Conditions
    • Actions
      • Game - Display to Player Group - Player 1 (Red) the text: holy
 
Level 5
Joined
Sep 19, 2006
Messages
152
Maker,

2 questions:

1. Is your method more efficient, or just "prettier"?
2. What if a unit casts an ability for which there is no hashtable function?
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Maker,

2 questions:

1. Is your method more efficient, or just "prettier"?
2. What if a unit casts an ability for which there is no hashtable function?

1. More efficient
2. Nothing happens. Trying to execute null trigger won't cause problems

The system Magtheridon posted is even better than the one I posted, use it.
 
Level 5
Joined
Sep 19, 2006
Messages
152
What does the "0" in the following function represent?

JASS:
call TriggerExecute (LoadTriggerHandle (udg_hash, GetSpellAbilityId (), 0))
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
What does the "0" in the following function represent?

JASS:
call TriggerExecute (LoadTriggerHandle (udg_hash, GetSpellAbilityId (), 0))

just a key, in this case non important what number u write to second key, can be any number but must be same, its like the 2nd array index, so if u use 1000 then when u save the ability id's everywhere must be saved to GetSpellAbilityId (), 1000

hashtable like 2d array

so udg_Variable[x][y]
in this case u store like this
udg_Variable[GetSpellAbilityId ()][0]

just to hashtable u can use any integer type like index/key not like in variable case, so this is why needed a second key, because hashtable is like a double indexed array
 
Status
Not open for further replies.
Top