• 🏆 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!
deathdoorway
Reaction score
15

Profile posts Latest activity Postings Experience Albums Resources About

  • Why don't you add link to your spell factory in your signature? people can easier to see your spell factory if you put the link to you signature
    To give you a quick general idea of how the trigger handle works, because now I'm out of time, you create the trigger handle, attach conditions, actions, and register events to it.

    I haven't even included registering events, because that's a little more complex, but the basic outline is that when any of the registered events occur, war3 executes all of the conditions/boolexprs attached to the trigger-handle, then if they all return true, war3 then proceeds to execute all of the actions attached to the trigger handle. What can be confusing about the registration of events, is that Blizzard could only provide ones that they believed you'd want, and nothing more, therefore, you can be tremendously limited in what you can actually code for, although the events for spells opens up a huge number of options, which kept me satisfied for a while.
    What we've done, is create a variable of type trigger, named it 't', set what it will reference equal to the handle that will be created/returned from the function 'CreateTrigger()'. Next, we use a method that is specific to trigger handles, which attaches an action to the given handle. Here, we use the 't' variable to refer to the specific trigger/handle that we want the action to be attached to.

    A second parameter that is interesting is the 'codefunc' parameter. This uses an actual function, in our example that function is DoThis().

    The next method called for the handle is the TriggerAddCondition() function, which again, uses something similar to the 'codefunc', although it is actually a 'boolexpr', or boolean expression.

    I don't have time to go into boolean expressions, but they are a crucial piece in using trigger-handles.
    function OnlyIfThisIsTrue takes nothing returns boolean
    return true
    endfunction

    function DoThis takes nothing returns nothing
    endfunction

    function CreatingTriggers_InitTrig takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerAddAction(t, function DoThis)
    call TriggerAddCondition(t, Condition(function OnlyIfThisIsTrue))
    endfunction

    There is alot to be explained in these 3 functions, and the trigger still won't have an effect, because there is no event attached to our trigger handle.
    What the 'trigger' variable actual is is an integer that references data. But, you don't need to worry about that.

    What you need to understand, is that the trigger variable does not act as the trigger. The trigger variable is more like an arrow, or what most people refer to, a pointer. It references the trigger, but it is not the trigger handle.

    All handles work in this way, they can only be referenced by variables, but they are NOT the actual handle.

    On that note, handles that are leaked are handles that have not been destroyed. Due to some strange setup by Blizzard, even if you call the destroy function on a handle, there is a reference table that keeps track internally of how many variables are pointing to the handle. If there is still a variable pointing to a handle, the handle/data won't be removed properly by war3s' internal system, resulting in a memory leak.
    Last time I posted, I was easing into an explanation of creating a triggered effect in JASS.

    We know that the function with _InitTrig attached to its name is the function that is ultimately called by war3's main startup script.

    From here, we create a specific handle called a 'trigger'. The way this is done, is simply create a variable of variable-type 'trigger', give it a name, and set its value equal to the 'CreateTrigger()' function, which returns a trigger handle. Now, as you begin to understand how programming works, you could guess that there is no such thing as a 'trigger'. that 'trigger' is just a made-up symbol to help make an idea tangible.
    Leave the requests and enter the contest, you might just win. Ima entering as well. I know the theme is a little weird but it can be cool.
    i was on your site awhile ago, and it had a way to protect your map. Do you think you go send me those steps again? thanks
    [I think 'hfoo' is the rawcode for footman]

    In the example, instead of using a player variable like the function says it takes, I used a function, Player(). This simple function converts an integer parameter into a player variable. The function itself returns the player variable, so I can use it in the CreateUnit() function as the 'player' variable-type parameter.

    On a sidenote, if you feel like I'm moving too slowly and the explainations are too drawn out, just ask questions and I'll fill you in on any info you might need at the moment.
    Quite a bit happening in that single line of code...

    Anyway, the unit handle is probably the biggest handle-type in war3 (cept the effect handle, which is just huge because its a whole animation)

    There are a sh*tload of methods that use the unit parameter, and because the unit handle is actually the units that run around on the screen, players have made many many many functions that use the unit variable as a parameter.

    For the most part, with handles, their methods either return or change the data already contained in them, for our unit, this could be the owner of the unit, the position of the unit the direction the unit is facing, and I don't believe there is a method for changing the unit-type. There might be others but those are the main ones.

    Lastly, the 'CreateUnit' function returns 'unit', which means a variable can be set to the function, and the variable will refer to the unit create in that original line whenever you use the variable.
    If you don't know how to find the rawcode of the unit-type, simply open the object editor, and press Cntrl+D, (I think), if you still can't find it just PM me.

    The next 3 parameters are reals, the first one represents the x-coordinate of where the unit will be placed, the second represents the y-coordinate, and the last represents the degrees that the unit will be facing on creation.
    You don't really need to know the difference between BJ's and natives, you'll pick up on it when you start writing scripts.

    The 'CreateUnit' function actually physically creates a unit in the 3D world, and it returns a unit, which a 'unit' variable-type can refer to.

    The parameters it needs to create the unit are...

    player id - The 'player' is the type of variable, and 'id' is just what the variable would be named in the function if you could see what it does. With natives, the variable names are just clues to what the variable does. Here, it is the owner of the unit
    (Btw, you can find functions online by searching the 'jass vault' on google)

    integer unitid - Now, this part is interesting, because this is how you tell the computer what unit-type you want created. The unitid is the rawcode of the unit-type, which you can find in the object editor (which can be frustrating, but it is necessary).
    (Btw, the 'unit' variable-type is a handle)

    function Example takes nothing returns nothing
    local unit u = CreateUnit(Player(0),'hfoo',10000,10000,270)
    endfunction

    There are a few things I should explain first.

    This is the syntax for the 'CreateUnit' function...


    ----------
    CreateUnit takes player id, integer unitid, real x, real y, real face returns unit
    ----------
    The 'CreateUnit' function is what is called a 'native' function, meaning that Blizzard created it, it can't be replaced by another user-created function (in rare cases they can be), and (generally) they are the most efficient functions. The last part usually pertains to using BJ's vs. using natives (BJ's are functions that do exactly the same thing as natives, except they call the natives, wasting a function call)
    Eh, its not as fun as it used to be. The newer online games like Gears, Halo, and fps types are just insane, and the main reason I played war3 was because you could play online with other players.

    I can post some more info about handles...

    Handles are large pieces of data treated like objects. A handle can have alot of different methods and data attached to them. One of the main obstacles of JASS was that one could not edit handles, you can edit the values and use their methods to make them do things, but you could not add your own methods and pieces of data that the handle would use. That was why vJASS came into existence, I'll explain that further later on, but for now we aren't up to vJASS quite yet.

    The most important aspect of handles that many many many people seem to never understand is that the variables that you would use with a handle, are NOT the actual handle. For instance...
    Dear deathdoorway,
    if you think i'm just sitting back without any things to do, you are completely wrong.
    I don't know your problem, but you seriously have one if you think "I've seen this somewhere else before" is somekind of insult.
    I closed the Spell Factory since we hadn't the time to work on such things anymore.
    Just to tie the things up, and to make it clear:
    I'm wishing you only the best for your factory, just as i said before.
    Why should i be mad about you?
    I'm thankful that so many new Spell Factorys take place.
    Reputation (--1):
    (Post) [highlight](-1)[/highlight] You are not allowed to discuss map de-protection anywhere on the site.
    In the '_InitTrig', we define the events, conditions, and actions that will be attached to the trigger handle. (when you get better at vJASS and JASS, you'll find you can do more with the '_InitTrig' than you expected)

    Now, this is where a healthy understanding of handles is necessary.

    I need to take a break, in my next series of posts, I'll explain further about handles, and then specifically the trigger handle
    With that knowledge, we will work into what handles are, right now, specificially, I'll give you some info on the trigger handle.

    In GUI, traditionally, triggers have events, conditions, and actions. The events cause it the actions to execute only if the conditions are met. Again, the event causes the trigger to react. If the conditions return true, then the actions contained in the trigger will be executed.

    The trigger handle itself is the exact same thing, and events, conditions, and actions are all defined within that first '_InitTrig' function.

    NOTE - The name of the '_InitTrig' function may be changed, but the function's name MUST ALWAYS be the name of the trigger in the trigger editor (the name that highlights blue when you select it, next to the white page-type picture) with '_InitTrig' attached to it. To make things easy, when you change the name of the text that you select (which highlights blue), it also changes the name of the '_InitTrig' function.
    There is a main script that warcraft uses to initialize all the triggers. This is common in many systems, and is often referred to as the main function. NOTE - You cannot manually edit the main script (although vJASS allows the capability, somewhat, it is mostly unnecessary, so don't worry about it).

    When you create a new trigger via the trigger editor, the main function adds in the function that has '_InitTrig' attached to its list of functions that it needs to call.

    Within that function with '_InitTrig', is the code normally used to setup a GUI triggered effect.
    Okay, we left off with triggered effects using JASS, firstly, you need to know what happens when you create a trigger in the first place (here, I am referring to using the trigger editor to create a new trigger)

    When you do that, it will come up in GUI format, which you can convert (and will from now on) to JASS. You will get some garble that doesn't seem to make any sense in a few different functions.

    The most important function is the one with '_InitTrig' at the end of the function name
    Ah, terrific :D

    I feel I should let you know, I'm slowly dropping warcraft, for the sake of learning I'll occasionally send you messages of what I know about mapping, but they may be scarce and far apart
  • Loading…
  • Loading…
  • Loading…
  • Loading…
  • Loading…
  • Loading…
Top