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

[Trigger] Indexing non-array variables

Status
Not open for further replies.
Level 19
Joined
Oct 7, 2014
Messages
2,209
Can anyone please help me fix this trigger? It makes an error Attempt to index a non-array variable
Line 703, 706, 715

  • First
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chaosflare
    • Actions
      • Set tmppoint[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
      • Set tmppoint3[(Player number of (Owner of (Triggering unit)))] = (Position of (Target unit of ability being cast))
      • -------- Edit the following values to change the damage which is dealt --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Chaosflare for (Triggering unit)) Equal to 1
        • Then - Actions
          • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 55.00 damage of attack type Spells and damage type Normal
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Chaosflare for (Triggering unit)) Equal to 2
            • Then - Actions
              • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 65.00 damage of attack type Spells and damage type Normal
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Chaosflare for (Triggering unit)) Equal to 3
                • Then - Actions
                  • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing 80.00 damage of attack type Spells and damage type Normal
                • Else - Actions
      • Special Effect - Create a special effect at tmppoint[(Player number of (Owner of (Triggering unit)))] using Abilities\Spells\Other\Volcano\VolcanoDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • For each (Integer A) from 1 to ((Integer((Distance between tmppoint[(Player number of (Owner of (Triggering unit)))] and tmppoint3[(Player number of (Owner of (Triggering unit)))]))) / 100), do (Actions)
        • Loop - Actions
          • Set tmppoint2[(Player number of (Owner of (Triggering unit)))] = (tmppoint[(Player number of (Owner of (Triggering unit)))] offset by (x[(Player number of (Owner of (Triggering unit)))] + 100.00) towards (Angle from tmppoint[(Player number of (Owner of (Triggering unit)))] to tmppoint3[(Player number of (Owner of (Triggeri
          • Unit - Create 1 firedummy2 for (Owner of (Triggering unit)) at tmppoint2[(Player number of (Owner of (Triggering unit)))] facing tmppoint3[(Player number of (Owner of (Triggering unit)))]
          • Custom script: call RemoveLocation(udg_tmppoint2[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
          • Set x[(Player number of (Owner of (Triggering unit)))] = (x[(Player number of (Owner of (Triggering unit)))] + 100.00)
          • Unit - Add a 0.20 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 firedummy for (Owner of (Triggering unit)) at tmppoint3[(Player number of (Owner of (Triggering unit)))] facing tmppoint3[(Player number of (Owner of (Triggering unit)))]
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Shadow Strike to (Last created unit)
      • Unit - Set level of Shadow Strike for (Last created unit) to (Level of Hex (Team Killer) for (Triggering unit))
      • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike (Target unit of ability being cast)
      • Set x[(Player number of (Owner of (Triggering unit)))] = 0.00
      • Custom script: call RemoveLocation(udg_tmppoint[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
      • Custom script: call RemoveLocation(udg_tmppoint3[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])
 
Level 20
Joined
Jul 14, 2011
Messages
877
JASS:
Custom script: call RemoveLocation(udg_tmppoint2[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])

This maybe? Is tmppoint2 and array.


EDIT: nvm, my bad

Also replace GetOwningPlayer(GetTriggerUnit()) with GetTriggerPlayer() and put the functions you use more than once in a variable first.
 
Level 4
Joined
Feb 28, 2014
Messages
70
your trigger is unnecesarry long, create a Interger variable "TempPlayerNumber" then:

  • Custom script: set udg_TempPlayerNumber = GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))
and finally, use it with the rest of your actions. It's less confusing when reading and you won't have this kind of problem, it seems that you have a syntax error using custom script but I don't know how your trigger exactly is. It would be easier if you take a screenshoot and paste it here becuase sometimes we write a trigger with a little but very significant difference.

JASS:
Custom script: call RemoveLocation(udg_tmppoint2[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))])

This maybe? Is tmppoint2 and array.


EDIT: nvm, my bad

Also replace GetOwningPlayer(GetTriggerUnit()) with GetTriggerPlayer() and put the functions you use more than once in a variable first.

Since when Triggering Player works with Unit events? o_O
 
Since when Triggering Player works with Unit events? o_O

Unit starts the effect of an ability is not a unit event. It is a player unit event. That means that both triggering player / triggering unit are set and can be used. A lot of other events are player unit events.

Also anything used twice or more should be stored into a variable and the variable should be used.

You tell us the error is on line 703 / 706 / 715. But how are we supposed to know what lines of code match up to those numbers ? You should post the individual lines so we know which ones are the problem.
 
Level 4
Joined
Feb 28, 2014
Messages
70
Unit starts the effect of an ability is not a unit event. It is a player unit event. That means that both triggering player / triggering unit are set and can be used. A lot of other events are player unit events.

Also anything used twice or more should be stored into a variable and the variable should be used.

You tell us the error is on line 703 / 706 / 715. But how are we supposed to know what lines of code match up to those numbers ? You should post the individual lines so we know which ones are the problem.

Oh I didn't know that, also, I didn't tell anything about the error... I'm not the Original Poster if you didn't notice...

Also, WE has a bug since a long time ago, it shows that the error is in X line but it's false, it's usually 1 line with syntax error/grammar error that 'shits' all the funtion and then it causes errors in mony other lines. So I suppose that OP's triggger error is for a bad written custom script and he didn't notice (This also has happened to me, when you put a wrong Cap or a wrong letter into the index in a custom script, it shows that error. It also happens when you have 2 variables with almost the same name and you just mistype the variable)
 
Oh I didn't know that, also, I didn't tell anything about the error... I'm not the Original Poster if you didn't notice...

Also, WE has a bug since a long time ago, it shows that the error is in X line but it's false, it's usually 1 line with syntax error/grammar error that 'shits' all the funtion and then it causes errors in mony other lines. So I suppose that OP's triggger error is for a bad written custom script and he didn't notice (This also has happened to me, when you put a wrong Cap or a wrong letter into the index in a custom script, it shows that error. It also happens when you have 2 variables with almost the same name and you just mistype the variable)

Oops sorry about that I meant to include an @OP for that message.
 
Level 19
Joined
Oct 7, 2014
Messages
2,209
Oops sorry its the line 13, 16, 23 the last three variables I set.
 

Attachments

  • Untitled.png
    Untitled.png
    48.6 KB · Views: 157
Level 4
Joined
Feb 28, 2014
Messages
70
the problem must be with a custom script, maybe you wrote something different in your trigger than the one you posted in this thread, post an image of you trigger

Or do what I posted, set the Index in a variable and use that variable instead of using (Player number of (Owner of (Triggering unit))) too many times.
 
Level 19
Joined
Oct 7, 2014
Messages
2,209
These are the errors

  • Set tmppoint2[(Player number of (Owner of (Triggering unit)))] = (tmppoint[(Player number of (Owner of (Triggering unit)))] offset by (x[(Player number of (Owner of (Triggering unit)))] + 100.00) towards (Angle from tmppoint[(Player number of (Owner of (Triggering unit)))] to tmppoint3[(Player number of (Owner of (Triggeri
  • Set x[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))] + 100.00 )
  • Set tmppoint3[GetConvertedPlayerId(GetOwningPlayer(GetTriggerUnit()))]))
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Don't use tmppoint1/2/3[], just use temppoints[]. There is no need for multiple variables when you array them all. Also, do not store the location in the player index, just use 0, 1, 2, etc. The trigger is instant anyways.
Arrays should only be used when dynamic lookup is required. A non-array variable is generally faster to access than an array due to the parsing of the index.
 
use an integer variable for 'Player number of (Owner of (Triggering unit))' at the beginning of the trigger, atm it's very bad to even read the trigger, I see that you converted it to custom script. Maybe you erased something in there (like brackets) coz atm in GUI I cant seem to see anything coz in GUI you cant press OK if the variables are not set (except empty strings)...

the spell itself doesnt need that integer (indexed) anyway as the spell has no waits involved, use loops also in your iff condition so that it will be multi level...
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
That compile error happens simply because tmppoint2 is not an array variable (line 712)
Dunno about the other two lines.

Blizzard attached a "nice" compile error reports to the trigger editor. It's very understandable. Try to read every single reported error and you should be able to understand what's your mistake.
Attempt to index a non-array variable
Is it pretty clear?

Anyway, why on earth this page is stretched? :(
 
Level 4
Joined
Feb 28, 2014
Messages
70
  • First
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chaosflare
    • Actions
      • Set TempInt = (Player number of (Owner of (Triggering unit)))
      • Set tmppoint[TempInt] = (Position of (Triggering unit))
      • Set tmppoint3[TempInt] = (Position of (Target unit of ability being cast))
      • Set AbilityLvL = (Level of (Ability being cast))
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing ((2.5*(Abilitylvl*Abilitylvl))+(50+(2.5*Abilitylvl)) damage of attack type Spells and damage type Normal
      • Special Effect - Create a special effect at tmppoint[TempInt] using Abilities\Spells\Other\Volcano\VolcanoDeath.mdl
      • Special Effect - Destroy (Last created special effect)
      • ---------------------------
      • --- Do not use Integer A ---
      • ---------------------------
      • Set TempReal = (Distance between tmppoint[TempInt] and tmppoint3[TempInt] / 100)
      • For each (Integer Index) from 1 to ((Integer(TempReal), do (Actions)
        • Loop - Actions
          • Set tmppoint2[TempInt] = (tmppoint[TempInt] offset by (x[TempInt] + 100.00) towards (Angle from tmppoint[TempInt] to tmppoint3[TempInt]
          • Unit - Create 1 firedummy2 for (Owner of (Triggering unit)) at tmppoint2[TempInt] facing tmppoint3[TempInt]
          • Custom script: call RemoveLocation(udg_tmppoint2[udg_TempInt])
          • Set x[TempInt] = (x[TempInt] + 100.00)
          • Unit - Add a 0.20 second Generic expiration timer to (Last created unit)
      • Unit - Create 1 firedummy for (Owner of (Triggering unit)) at tmppoint3[TempInt] facing tmppoint3[TempInt]
      • Unit - Add a 3.00 second Generic expiration timer to (Last created unit)
      • Unit - Add Shadow Strike to (Last created unit)
      • Unit - Set level of Shadow Strike for (Last created unit) to (Level of Hex (Team Killer) for (Triggering unit))
      • Unit - Order (Last created unit) to Night Elf Warden - Shadow Strike (Target unit of ability being cast)
      • Set x[TempInt] = 0.00
      • Custom script: call RemoveLocation(udg_tmppoint[udg_TempInt])
      • Custom script: call RemoveLocation(udg_tmppoint3[udg_TempInt])
This is more Human-Readable
You shouldn't get problems with this.

Also, use formulas instead of if/then/else, if lvl 1, else if level 2, else if level 3.. ZZZZ.....
You could easily do 5/2x²+5/2x+50 which is f(1) = 55, f(2) = 65, f(3) = 80
 
Status
Not open for further replies.
Top