Monday, April 16, 2012

Declaring a User Defined Global 'trigger'

Is there anyone that can tell me what the purpose of having a trigger type in the GUI user defined global variables? Is it possible to set them up instead of the usual set gg_trg_blahblah = CreateTrigger( ) that usually occurs with converting a GUI trigger to custom text. I looked around in these forums and I can't seem to find anything about it. Thanks!!!|||I have never had cause to declare a global trigger myself, and I cannot imagine any scenario which would require their use. As for your question, if you're using JASS you could replace 'set gg_trg_TriggerName = CreateTrigger( )' with 'set YourGlobalTriggerName = CreateTrigger( )' as long as you replaced all other references in the trigger script to it, but I don't see why you would wish to.|||Thanks a bunch for your reply, but I now have a newer question to pose :) I have become aware of somthing that it seems like a couple of maps out there are currently using. From what I have gathered, these maps completely skip the standard:


Code:
function InitTrig_doesStuff takes nothing returns nothing
set gg_trg_doesStuff = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_doesStuff, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_doesStuff, Condition( function Trig_doesStuff_Conditions ) )
call TriggerAddAction( gg_trg_doesStuff, function Trig_doesStuff_Actions )
endfunction

and instead they have all of the code like they usually would as tho they were 'declared' (which is what it seemed like to me) and then at the end, these functions were executed with something like this:


Code:
function InitTrig_init takes nothing returns nothing
set udg_Trigger01 = CreateTrigger()
set udg_Trigger02 = CreateTrigger()
.
.
.
set udg_TriggerXX = CreateTrigger()
call ExecuteFunc("main")
endfunction

Is anyone at all familiar with this?|||The function 'main' is a part of every map's script. It is automatically called at map initialization. I don't know why you'd want to execute it again. As for that method of creating triggers... sure, you can, but why would you want to?|||I guess the question would be to you is, why did Elimination Tournament, Battleships Pro, and a bunch of other maps do it that way? I really want to know what the allure is for doing it that way.|||Are you asking why would you want to use a trigger variable?

There are plenty of reasons you might want to use a trigger variable - particularly if you make them into an array - since you could easily run a random trigger by setting the array index with a random number generator or set the array index to a value when players are voting using a dialog menu. Or if you have a sequence of triggers you use every time the map is reset in-game, it could be more efficient to run the triggers via a loop.

It's not clear to me, based on what you presented, why map-makers would apply the system you showed above, other than perhaps they didn't actually write the code that way, but rather the code was re-written by an optimizer or another 3rd-party tool for some specific reason - or they were reconstructed that way from the program that was used to break their security - since all of the maps you mentioned seem likely to have been originally protected by the author.

In any case, rather than worrying about why someone else (or their 3rd party tool) wrote their code a certain way, why not concern yourself with just writing what works for yourself?|||Ok, so are you aware of a 3rd party tool, such as vex or something like that that would create global triggers when the map was optimzed?

I'm not sure if you've ever done any triggering or not, but the more events that go into the map the more things start to get 'laggy' because of the quantity of events that can can occur. Let me just go further to say that certain events such as
Code:
call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_SPELL_CAST )

can be interrupted such that the spell isn't technically casted even tho the trigger does x, y, z (becuase the event was begins casting a spell). Where as something like this:
Code:
call TriggerRegisterAnyUnitEventBJ( gg_trg_Untitled_Trigger_001, EVENT_PLAYER_UNIT_SPELL_EFFECT )

can actually lag if you have even the most basic of triggers. I've tried this on many different types of triggers, dummy casters, simple special effects, etc etc etc, and what I keep finding is a little lag (or in the case of many triggered spells, a LOT of lag).

I'll go one further, I have tested different abilities that were taken from some very popular maps which PROVED to me that this declaring of a global trigger thing was somehow preventing the lag. Now, I didn't do this to steal their work and put my name on it. No one would believe me if I released a DotA 6.67 with my name on it or even a Legion TD 1.43. I'm not looking to rip someone else's work off. What I am looking for is a simple answer. Is there a utility that takes your GUI/Jass(converted GUI) triggers and puts them into this format? Did the authors all use WinMPQ and go through line by line writing this and upload it back into the w3x file? Did they just write all the triggers in the header? Did they do something else?

I don't believe this is too much to ask for. Thank you for your time |||Quote:






View Post

Ok, so are you aware of a 3rd party tool, such as vex or something like that that would create global triggers when the map was optimzed?




I think there's some options in Vex's optimizer that will rewrite code. Do I know if it is these particular triggers? No. But you know who would know... Vex. You could interface with him directly - or even some of the other people who contributed to Vex's optimizer over at WC3C. I would suggest you try asking about the specifics of his tools on a site where he participates.


Quote:






View Post

I'm not sure if you've ever done any triggering or not, but the more events that go into the map the more things start to get 'laggy' because of the quantity of events that can can occur.




Really? The ~20 tutorials on triggering I've written on this site and the two handfuls of maps I have listed on this site weren't a clue? I know I'm old and mostly forgotten, but seriously, you probably shouldn't make the assumption that anyone (even the most basic poster) on this part of the forum hasn't done any triggering.

With regards to the content of your comment, I'm not sure I completely agree - or rather what you are saying may be true, but maybe not for the reason you think. I'm fairly certain that it is NOT the number of events that's the problem, since I have made multiple maps where the number of events increases with each unit that enters the map and they experience no lag from it whatsoever.

That said, a simple way to reduce function calls is just to limit the number of units that could feasible call the function - either by reducing the number of events or reducing the number of generic events. For example, rather than using the generic "begins casting" (on a side note, that event is generally not something anyone should be using, unless you have a lot of channeling abilities or something) you could just link specific events to specific units (Unit X starts the effect of an ability). Unless all units in your map can cast every triggered spell, there's not much reason to use generic events to trigger them, when a specific event would be more effective.


Quote:






View Post

Is there a utility that takes your GUI/Jass(converted GUI) triggers and puts them into this format?




Do you think JASS as converted GUI is somehow different than GUI? You do know that when your map compiles (i.e. you hit the save button), it compiles/converts your GUI triggers into JASS, right? The GUI is only there as a construct to help you write the language of JASS for the compiler - they aren't separate forms of code.


Quote:






View Post

Did the authors all use WinMPQ and go through line by line writing this and upload it back into the w3x file? Did they just write all the triggers in the header? Did they do something else?




Doubtful. No author in their right mind wastes that kind of time. Why don't you just try looking around in Vex's optimizer in the optional (tweaks) features - I bet you'll find what you are looking for there.

No comments:

Post a Comment