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

Triggers Indigestion

Status
Not open for further replies.
Level 17
Joined
Oct 10, 2011
Messages
462
I post a thread here because I have a problem about triggers in my map
The Last Blade.

I have 113 198 lines of codes when I see all the triggers compiled with the jass new gen pack and 925 triggers.

Now when I create a trigger with Gui or Jass the new trigger is just not working at all, I tried with a lot of event and just a simple action like a message.

I can't create anymore triggers in my map!!

Firstly I had to remove every triggers with the event "Map Initialization" because the game don't used them.

I want to know if there is a limit with that, (I think, dota as more heroes so maybe there is a solution) I'm optimizing my triggers with vjass and scopes, I want to know if I can fix the problem with that.

Thanks for your answers
 
If you are having issues with the syntax checker, then you may want to update PJASS:
http://www.hiveworkshop.com/forums/warcraft-editing-tools-277/pjass-updates-258738/

On really large codes, it might stop running prematurely. If you aren't having issues with the syntax checker, then ignore this.

Otherwise, you might be running into the op limit early in your code. Make sure that your variable arrays don't have really large initial sizes.

Optimizations will help, but just changing the code to vJASS won't help unless you understand how to use the language. If your new triggers aren't working, then it means that you're hitting the op limit early on around the event registry stage. So you'll have to reduce the bottleneck over there.
 
Level 17
Joined
Oct 10, 2011
Messages
462
thanks for your answer
Ok what is PJass? Is there more native functions

I use only 5 variable arrays
1 is a unit
2 are unit types
2 are locations

I want to create unit pool for hero to replace my unit type variable but the trigger isn't executed

to clarify :
when I create a new trigger with an event a condition and an action, the syntax checker control it then the map just agree with my code and when I play the map the trigger don't run, when I copy paste the trigger on an other map it works ??!

How to reduce the event bottleneck? What is it?
 
Level 12
Joined
May 22, 2015
Messages
1,051
Every trigger you create has an initialisation function that gets run while the map is loading. If you don't modify it, it basically creates a blank trigger and then adds events, conditions, and actions to it. I imagine with that many triggers that it is hitting some limit and just stops running the initialisation functions after a while. This might also be why the "map initialisation" event isn't doing anything, since that would add more operations to the initial map load.

I think if you condense some triggers and clean up the code, you could add more, but I would have to see how it's working. I don't even know if my idea is the actual problem or not. Have you tried deleting other triggers (just for now) to see if the ones you added work?

In my map, for triggers that will only do anything after some other event happens, I have a trigger that creates all the triggers for after that event and I only check when the event occurs to run that trigger. This is more just to make my code cleaner and less pointlessly slow. You could adopt a similar strategy to help condense other triggers. It could get ugly, though, so make sure you know what you're doing with that.

How big are your arrays? I made 4 or 5 arrays of size 1000 and it broke my map lol.
 
Level 25
Joined
Jul 10, 2006
Messages
3,315
I encountered a similar problem while working on my TD, and discovered that if I added any new events my triggers would all fail.

As others have explained in this post this is due to events being declared at map initialization and your map init code going over the op limit.

I fixed mine by removing events from as many triggers as possible.
- Instead of having an event for every triggered spell, use only one trigger with an event, and in this trigger you check which spell is being cast and then run the corresponding trigger.
- Do the same for other common events, like damage or attack.
 

TKF

TKF

Level 19
Joined
Nov 29, 2006
Messages
1,266
To many triggers and events are not good because of the limit of the wc3 engine. You cannot just spam triggers in the world editor infinitely. Try to keep below 500-600 triggers if you can.

I have slightly over 600 in cruiser command, and I see sometimes some triggers not firing at all or slight delay in trigger actions. The AI is the last thing I added in my map which consist of 60+ triggers and its those AI systems which pause out sometimes in my map, which is not so critical systems.


The best way is to delete unnecesary triggers and combine triggers, such as player commands for example which you really only need 1 trigger for all commands in the map, using substring event and using conditions to check the command. Simply combine triggers which has same events and reduce the number of actions.
 
You just can use the scope keyword to declare a scope:

JASS:
scope MyScope initializer Init // run the Init function

    private function MyTriggerFunc takes nothing returns boolean
        // some trigger code
        return false
    endfunction

    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        // add some event
        call TriggerAddCondition(t, Condition(function MyTriggerFunc))
    endfunction
endscope
 
You guys are suffering from a thing I'd call "event polution".

In other words: using the same event way too often to run multiple triggers.


In general, there is very little reason to have any event more than once in your map.
You can easily make one event fire multiple triggers via the "Run - trigger" action.

The only reason why any event should be doubled is for 'specific unit'-exclusive events, like damage taken. But for this, we usually have libraries that will do the job for you.
 
Status
Not open for further replies.
Top