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

3 script errors

Status
Not open for further replies.
Level 2
Joined
Mar 6, 2010
Messages
26
Hello huys.
I am new to jass and custom script and stuff. i found out I needed it for a trigger. But I only get Script error with the trigger. Can anyone tell me what I did wrong?
There are my errors:
Expected 'endif'
Expected a variable name
Expected a name
  • Quest 5 Summoning Stone
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Arghar
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) is in (Units in Pit of Corruption <gen>)) Equal to True
        • Then - Actions
          • Custom script: local location Ability_Target_Point
          • Custom script: set Ability_Target_Point = GetSpellTargetLoc()
          • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Items\VampiricPotion\VampPotionCaster.mdl
          • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Undead\UnholyAura\UnholyAura.mdl
          • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
          • Player Group - Pick every player in (All players) and do (Camera - Shake the camera for (Picked player) with magnitude 3.00)
          • Game - Display to (All players) the text: Arghar: Who dares t...
          • Wait 5.00 seconds
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Destroy (Last created special effect)
          • Special Effect - Destroy (Last created special effect)
          • Custom script: call CreateNUnitsAtLoc( 1, 'n00C', Player(10), Ability_Target_Point, 300.00 )
        • Else - Actions
          • Do nothing
Edit: could it be possible to move this thread to the Trigger and Script forum? I didnt see that
 
Level 8
Joined
Aug 21, 2009
Messages
333
rockthar,

a few things:
  1. Check the spelling of your variable name in the custom scripts. They are spelled correctly in here, but they might not be in your map.
  2. The three instances of:
    • Special Effect - Destroy (Last created special effect)
    is only deleting the LAST special effect created 3 times! not the last three once.
  3. Clean up your leaks! use these after you create the units:
    • Custom script: call RemoveLocation(Ability_Target_Point)
    • Custom script: set Ability_Target_Point = null

EDIT:
Edit: could it be possible to move this thread to the Trigger and Script forum? I didnt see that
Yes, this does belong in that forum. A moderator will probably move it shortly :p
 
Level 2
Joined
Mar 6, 2010
Messages
26
Well I just got more errors now.
new errors:
Expected a name AND Expected a variable name
:S

I changed it to this
  • Quest 5 Summoning Stone
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Summon Arghar
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Casting unit) is in (Units in Pit of Corruption <gen>)) Equal to True
        • Then - Actions
          • Custom script: local location Ability_Target_Point
          • Custom script: set Ability_Target_Point = GetSpellTargetLoc()
          • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Items\VampiricPotion\VampPotionCaster.mdl
          • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Undead\UnholyAura\UnholyAura.mdl
          • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Undead\DarkRitual\DarkRitualTarget.mdl
          • Player Group - Pick every player in (All players) and do (Camera - Shake the camera for (Picked player) with magnitude 3.00)
          • Game - Display to (All players) the text: Arghar: Who dares t...
          • Wait 5.00 seconds
          • Custom script: call CreateNUnitsAtLoc( 1, 'n00C', Player(10), Ability_Target_Point, 300.00 )
          • Custom script: call RemoveLocation(Ability_Target_Point)
          • Custom script: set Ability_Target_Point = null
        • Else - Actions
          • Do nothing
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
You cannot set up a local after you've done an action, that means.

  • Custom script: local location Ability_Target_Point
Must be the FIRST action of the entire trigger.
Do this and the errors will magically disappear (unless I missed something else, but this makes a lot of sense: 1 error for creating a variable when you're not supposed to create one, the other errors for using a variable that doesn't exist).

Edit: also, remove the "Do Nothing".

Edit 2: only create 1 thread, seriously. No need in creating a million of threads (meaning 2) because you won't get any more help, you'll only get yourself in trouble.
 
Level 2
Joined
Mar 6, 2010
Messages
26
Thank you so much both of you!
Problem is solved :) i love when something gets solved and I learn something new, thank you very much!

Edit: yes I know, I tried to create a new one and deleting this one. sorry for that I am new to this stuff :(
 
Level 8
Joined
Aug 21, 2009
Messages
333
You cannot set up a local after you've done an action, that means.

  • Custom script: local location Ability_Target_Point
Must be the FIRST action of the entire trigger.
Do this and the errors will magically disappear (unless I missed something else, but this makes a lot of sense: 1 error for creating a variable when you're not supposed to create one, the other errors for using a variable that doesn't exist).

Edit: also, remove the "Do Nothing".

Edit 2: only create 1 thread, seriously. No need in creating a million of threads (meaning 2) because you won't get any more help, you'll only get yourself in trouble.

lol, yes. ap0calypse is right, of course.... An easy remedy for this is to take the condition in your if statement and move it up to the trigger's condition. This way you can get rid of the if statement and the "Do Nothing" will be gone and the creation of the local variable will also be the first thing that happens in the Actions; problem solved!

EDIT: glad we could help :)

EDIT 2: And you still need to clean up your leaks from your special effects. You still need to destroy them, but you will need local variables to do it. Ask if you need more guidance :)
 
Level 2
Joined
Mar 6, 2010
Messages
26
EDIT 2: And you still need to clean up your leaks from your special effects. You still need to destroy them, but you will need local variables to do it. Ask if you need more guidance :)

Hmm, not really sure how to remove them yet.. any tips? I did create global variables for them, But I would LOVE to have some guidance on how to remove them with local :p for both training and leaks sake.
+ rep ofc :)
 
Level 8
Joined
Aug 21, 2009
Messages
333
Hmm, not really sure how to remove them yet.. any tips? I did create global variables for them, But I would LOVE to have some guidance on how to remove them with local :p for both training and leaks sake.

Sure thing. The JASS name for a Special Effect is "effect"; so...
  • Custom script: local effect e1
  • Custom script: local effect e2
  • Custom script: local effect e3
  • Custom script: local location Ability_Target_Point = GetSpellTargetLoc()
  • Custom script: set e1 = AddSpecialEffect("Abilities\\Spells\\Items\\VampiricPotion\\VampPotionCaster.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
  • Custom script: set e1 = AddSpecialEffect("Abilities\\Spells\\Undead\\UnholyAura\\UnholyAura.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
  • Custom script: set e1 = AddSpecialEffect("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
  • Player Group - Pick every player in (All players) and do (Camera - Shake the camera for (Picked player) with magnitude 3.00)
  • Game - Display to (All players) the text: Arghar: Who dares t...
  • Wait 5.00 seconds
  • Custom script: call CreateNUnitsAtLoc( 1, 'n00C', Player(10), Ability_Target_Point, 300.00 )
  • Custom script: call RemoveLocation(Ability_Target_Point)
  • Custom script: set Ability_Target_Point = null
  • Custom script: call DestroyEffect(e1)
  • Custom script: call DestroyEffect(e2)
  • Custom script: call DestroyEffect(e3)
  • Custom script: set e1 = null
  • Custom script: set e2 = null
  • Custom script: set e3 = null
lol, there is so much custom script that this might as well be in JASS.
for learning purposes, you may want to try copying your trigger and converting the copy to JASS just to see what it looks like.
(in the trigger window, go to Edit -> Convert to Custom Text)
 
Level 2
Joined
Mar 6, 2010
Messages
26
Thank you so much!
I noticed the "convert to Custom text" thingy and it helps me so much :)
+rep for giving me a basic guidance about custom scripting and JASS!

Edit: isnt it effectBJ?
 
Level 8
Joined
Aug 21, 2009
Messages
333
Thank you so much!
I noticed the "convert to Custom text" thingy and it helps me so much :)
+rep for giving me a basic guidance about custom scripting and JASS!

Edit: isnt it effectBJ?

no, don't use effectBJ.
There are two different libraries of JASS: BJ and natives.
A majority of GUI code converts into BJ JASS which tends to be slower and less efficient. Any experienced JASSer will tell you to avoid it.

Here is a comprehensive JASS API: jass manual
I hope you find this as useful as I have :)
 
Level 8
Joined
Aug 21, 2009
Messages
333
I see. So if I "convert to Custom Script" and see soemthing with BJ on it, I just remove the "BJ"?

lol, no not in most cases. Usually, the BJ JASS is easier to interface with; ie. it will use Points instead of x and y reals. A lot of times, I just leave the BJ there to save me some headaches, but if you are trying to make your code efficient, then use the API I linked you to to find the name and arguments of the equivalent native JASS function :)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
lol, no not in most cases. Usually, the BJ JASS is easier to interface with; ie. it will use Points instead of x and y reals. A lot of times, I just leave the BJ there to save me some headaches, but if you are trying to make your code efficient, then use the API I linked you to to find the name and arguments of the equivalent native JASS function :)
Not exactly true.
Most BJ's just switched their arguments.

An example:
PauseUnitBJ(pause, whichUnit) is the same as PauseUnit(whichUnit, pause).
As you can see: they just switched "pause" and "whichUnit", absolutely pointless :/

And there are others, where Blizzard decided to be a total dick and don't change anything at all

An example:
GetLoadedUnitBJ() is exactly the same as GetLoadedUnit().
GroupTargetOrderBJ(whichGroup, order, targetWidget) is exactly the same as GroupTargetOrder(whichGroup, order, targetWidget)


The bottom line is: if you want an easy method of knowing whether you can easily convert a BJ to a native, then use JNGP (if you're new to JASS).
Eventually, when your JASS gets better, you don't even know the BJ functions anymore :D
 
Level 2
Joined
Mar 6, 2010
Messages
26
3 errors. Expected ')'
hmm, I copied your the three triggers from you and gave it a try.

  • Actions
    • Custom script: local location Ability_Target_Point
    • Custom script: local effect e1
    • Custom script: local effect e2
    • Custom script: local effect e3
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • ((Casting unit) is in (Units in Pit of Corruption <gen>)) Equal to True
      • Then - Actions
        • Item - Remove (Item carried by (Casting unit) of type Summoning Stone)
        • Custom script: set Ability_Target_Point = GetSpellTargetLoc()
        • Custom script: set e1 = AddSpecialEffect("Abilities\\Spells\\Items\\VampiricPotion\\VampPotionCaster.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
        • Custom script: set e2 = AddSpecialEffect("Abilities\\Spells\\Undead\\UnholyAura\\UnholyAura.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
        • Custom script: set e3 = AddSpecialEffect("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
        • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Items\VampiricPotion\VampPotionCaster.mdl
        • Player Group - Pick every player in (All players) and do (Camera - Shake the camera for (Picked player) with magnitude 3.00)
        • Game - Display to (All players) the text: Arghar: Who dares t...
        • Wait 8.00 seconds
        • Player Group - Pick every player in (All players) and do (Camera - Stop swaying/shaking the camera for (Picked player))
        • Custom script: call CreateNUnitsAtLoc( 1, 'n00C', Player(10), Ability_Target_Point, 300.00 )
        • Custom script: call RemoveLocation(Ability_Target_Point)
        • Custom script: call DestroyEffect(e1)
        • Custom script: call DestroyEffect(e2)
        • Custom script: call DestroyEffect(e3)
        • Custom script: set Ability_Target_Point = null
        • Custom script: set e1 = null
        • Custom script: set e2 = null
        • Custom script: set e3 = null
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
@ rockthar at this stage, wouldn't it be easier to actually convert it to JASS? I mean, 90% of the trigger is already JASS :D

And yes:
  • Custom script: set e1 = AddSpecialEffect("Abilities\\Spells\\Items\\VampiricPotion\\VampPotionCaster.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
  • Custom script: set e2 = AddSpecialEffect("Abilities\\Spells\\Undead\\UnholyAura\\UnholyAura.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
  • Custom script: set e3 = AddSpecialEffect("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point)))
In all these 3 scripts, remove the last ')'

Baintastic said:
lol, ap0calypse... always sandbagging me with the details :p
But details are really important :mad:
 
Level 2
Joined
Mar 6, 2010
Messages
26
Ah :)
Oh, and if it wouldnt be too much to bother about; could it be possible to make the trigger only happen IF the Ability_Target_Point where INSIDE a region? I mean you have to cast the spell inside a selected region.
Regards
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
In JASS it would be:

JASS:
local real xmax = GetRectMaxX(region)
local real xmin = GetRectMinX(region)
local real ymax = GetRectMaxY(region)
local real ymin = GetRectMinY(region)
local real x = GetUnitX(unit)
local real y = GetUnitY(unit)

if xmin <= x and x <= xmax and ymin <= y and y <= ymax then
    // Do actions
endif

Might seem like a lot of variables, but that's also how GUI does it (it just looks easier in GUI).
Actually, GUI uses a longer method (you probably know this already, whatever).

  • Set TempLoc = location of unit
  • if then else I don't have the editor
    • Conditions
      • ((Playable map area) contains TempLoc Equal to True
    • Actions
  • Custom script: call RemoveLocation(udg_TempLoc)
 
Level 8
Joined
Aug 21, 2009
Messages
333
  • Actions
    • Custom script: local effect e1
    • Custom script: local effect e2
    • Custom script: local effect e3
    • Custom script: local location Ability_Target_Point = GetSpellTargetLoc()
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Pit of Corruption <gen> contains Ability_Target_Point) Equal to True
      • Then - Actions
        • Item - Remove (Item carried by (Casting unit) of type Summoning Stone)
        • Custom script: set e1 = AddSpecialEffect("Abilities\\Spells\\Items\\VampiricPotion\\VampPotionCaster.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point))
        • Custom script: set e2 = AddSpecialEffect("Abilities\\Spells\\Undead\\UnholyAura\\UnholyAura.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point))
        • Custom script: set e3 = AddSpecialEffect("Abilities\\Spells\\Undead\\DarkRitual\\DarkRitualTarget.mdl", GetLocationX(Ability_Target_Point), GetLocationY(Ability_Target_Point))
        • Special Effect - Create a special effect at (Target point of ability being cast) using Abilities\Spells\Items\VampiricPotion\VampPotionCaster.mdl
        • Player Group - Pick every player in (All players) and do (Camera - Shake the camera for (Picked player) with magnitude 3.00)
        • Game - Display to (All players) the text: Arghar: Who dares t...
        • Wait 8.00 seconds
        • Player Group - Pick every player in (All players) and do (Camera - Stop swaying/shaking the camera for (Picked player))
        • Custom script: call CreateNUnitsAtLoc( 1, 'n00C', Player(10), Ability_Target_Point, 300.00 )
        • Custom script: call RemoveLocation(Ability_Target_Point)
        • Custom script: call DestroyEffect(e1)
        • Custom script: call DestroyEffect(e2)
        • Custom script: call DestroyEffect(e3)
        • Custom script: set Ability_Target_Point = null
        • Custom script: set e1 = null
        • Custom script: set e2 = null
        • Custom script: set e3 = null
 
Level 2
Joined
Mar 6, 2010
Messages
26
Thanks both of you. But i think you misunderstood Ap0calypse. the unit does not have to stand in the region. but the spell must be cast in the region (it must be pointed in the region). or maybe I misunderstood? :S

I figured i could just do
  • Set point = (Target point of ability being cast)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (PitOfCorruption <gen> contains point) Equal to True
I dont understand how you Baintastic did the:
  • (Pit of Corruption <gen> contains Ability_Target_Point) Equal to True
I couldnt find the variable called Ability_Target_Point.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Thanks both of you. But i think you misunderstood Ap0calypse. the unit does not have to stand in the region. but the spell must be cast in the region (it must be pointed in the region). or maybe I misunderstood? :S

I figured i could just do
  • Set point = (Target point of ability being cast)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (PitOfCorruption <gen> contains point) Equal to True
I dont understand how you Baintastic did the:
  • (Pit of Corruption <gen> contains Ability_Target_Point) Equal to True
I couldnt find the variable called Ability_Target_Point.
I'm sorry: I did indeed misunderstand your question.
You gave a correct answer yourself though :D

(And Baintastic created a local variable with that name. Of course you cannot use those in GUI unless you cheat a little, but his intention was correct).
 
Level 8
Joined
Aug 21, 2009
Messages
333
I'm sorry: I did indeed misunderstand your question.
You gave a correct answer yourself though :D

(And Baintastic created a local variable with that name. Of course you cannot use those in GUI unless you cheat a little, but his intention was correct).

lol, oops, you are right. I was trying to use the local variable that we were already using for the rest of the triggers :) it would work correctly if it was all in JASS ;)
 
Status
Not open for further replies.
Top