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

[Trigger] Custom Scripts

Status
Not open for further replies.
Level 29
Joined
Jul 29, 2007
Messages
5,174
I wonderd if people who know some custom scrips can post what ever they know (with descriptions on when/how/what to use it) here, because a huge number of things that can't be done with pure GUI, can be done with GUI + custom scrips.

There are probably pretty much endless list, but please try to post as much as you can, especialy more common/usefull ones.

(If people will really post a lot of custom scrips I suggest making this a sticky)

Thanks in advance


LIST

Removeing Locations
  • Custom script: call RemoveLocation(udg_Point)
  • -------- Normal point --------
  • Custom script: call RemoveLocation(udg_Point[X])
  • -------- Point with harrays --------
This custom script will remove a point variable called Point / Point[X] (X being 0-Unlimited number)
You will need to use this to remove leaks, whenever you set a new point it will make a new point and not move the old point.


Removing Unit Groups
  • Custom script: set bj_wantDestroyGroup = true
  • -------- Put this in [B]before[/B] you pick a group and it will remove the group leaks --------
  • Custom script: DestroyGroup(someGroup)
  • -------- Destroys someGroup --------
Put this in before you pick a group and it will remove the group leaks


Removing a Trigger
  • Custom script: call DestroyTrigger(gg_trg_Trigger)
  • -------- Change "Trigger" into your own trigger's name --------
  • Custom script: call DestroyTrigger(GetTriggeringTrigger())
  • -------- Put this into your trigger so after you finished using it, it will delete itself --------
Removes a trigger from the game (usefull if you don't need the trigger anymore - less lag).


Getting a location's Z and setting it to another variable
  • Custom script: GetLocationZ(someLocation)
  • Custom script: set udg_Real = GetLocationZ(udg_someLocation)
1. Returns the Z height (terrain height, walkable doodads included) of someLocation.
2. Setting Real to be worth the Z (height) of someLocation.


Single Player Check
  • Custom script: bj_isSinglePlayer
True if the game is in single player mode <NOT if there is only one player playing!>, False otherwise.


Destroy Player Groups
  • Custom script: DestroyForce(someForce)
Destroys someForce <Player Group in GUI>


Getting Local Player
  • Custom script: GetLocalPlayer()
Returns the player at the computer the script is running for. Useful in if-statements to do player-local effects and such.


Exit a Loop
  • Custom script: exitwhen val
Immediately exits the loop when val = true. (For use inside For Each Integer A)


If - then
  • Custom script: if val then
A JASS if-statement, good for use with GetLocalPlayer(), bj_isSinglePlayer, etc.


end If
  • Custom script: endif
The end of a JASS if-statement


Explode on death
  • Custom script: SetUnitExploded(someUnit,val)
If val=true, when the unit dies it will explode (remove the model instead of playing its death animation, and play the unit's Art - Special like when a catapult hits it). If val=false, it will turn off this effect if the unit was previously set to explode.



[NOTICE] The custom script commands (such as RemoveLocation, DestroyTrigger) MUST be typed like they are here with big letters on each word (Case Sensitive).
For example:
RemoveLocation works.
removelocation won't work.



Any mistakes ? Correct me :)
(Hope more will come from YOU)
 
Last edited:
Level 7
Joined
Dec 17, 2005
Messages
337
I know a few, to remove triggers.

(Sorry, I don't know how to post things like triggers like you guys did :()

call DestroyTrigger(GetTriggeringTrigger())
Destroys the current trigger, preventing any move use of it.

call DestroyTrigger(gg_trg_*Triggername*)
Replace the *Triggername* with the trigger you want to remove.

These are basicly the only ones I know :/. Hope it helps.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
"Custom Script" = JASS. WAY too many to list.

Ones you may ever need (haven't read previous posts, may have repetition. There are also reams more useful ones, these are just ones that come to mind):

  • GetLocationZ(someLocation)
    Returns the Z height (terrain height, walkable doodads included) of someLocation.
  • bj_wantDestroyGroup
    When you set this variable to true, the next group used in a Unit Group - Pick Every Unit in <Group> and do <Actions> will be automatically destroyed after iteration
  • DestroyGroup(someGroup)
    Destroys someGroup
  • RemoveLocation(someLoc)
    Removes someLoc
  • DestroyTrigger(someTrg)
    Destroys someTrg
  • bj_isSinglePlayer
    True if the game is in single player mode <NOT if there is only one player playing!>, False otherwise.
  • DestroyForce(someForce)
    Destroys someForce <Player Group in GUI>
  • GetLocalPlayer()
    Returns the player at the computer the script is running for. Useful in if-statements to do player-local effects and such.
  • DisplayTextToPlayer(player,xoffset,yoffset,text)
    Displays text to player, with xoffset and yoffset from the default text position. Useful to send text to a variable player.
  • DisplayTimedTextToPlayer(player,xoffset,yoffset,time,text)
    Like DisplayTextToPlayer, but with a time setting before fading.
  • exitwhen val
    Immediately exits the loop when val = true. (For use inside For Each Integer A)
  • if val then
    A JASS if-statement, good for use with GetLocalPlayer(), bj_isSinglePlayer, etc.
  • endif
    The end of a JASS if-statement
  • loop
    Starts a JASS loop, useful if you want to have special kinds of exits other than a for-loop. (exitwhen is used in these statements)
  • endloop
    Ends a JASS loop
  • SetUnitExploded(someUnit,val)
    If val=true, when the unit dies it will explode (remove the model instead of playing its death animation, and play the unit's Art - Special like when a catapult hits it). If val=false, it will turn off this effect if the unit was previously set to explode.

Note: things followed by brackets are functions, others are variables.

To set a variable to a function value, set <variable> = <function>(<paramaters of function>)

To set a variable to a non-function value, set <variable> = <value>

To call a function, call <function>(<parameters>)

To read a variable, use the name <variable>

To read an array variable, use the name, followed by square brackets containing the number (which can be variable or a function) <variable>[<index>]

To set an array variable, use the name, followed by square brackets containing the index set <variable>[<index>] = <value>
 
Last edited:
Level 40
Joined
Dec 14, 2005
Messages
10,532
1. Returns the Z height (terrain height, walkable doodads included) of someLocation.
2. Setting Real to be worth the Z (height) of someLocation.
The first call is unneeded and would cause a syntax error (you forgot 'call' at the front) anyways.

By the way, I would put endif in the same category as endif.

Also, mention that "else" is, well, else...

[jass=eg]if val then
//blah
else
//blah2
endif

//the following also works, if you don't need else that is
if val then
//blah
endif[/code]
 
Status
Not open for further replies.
Top