You must be logged in to post messages.
Please login or register

Scenario Design
Moderated by Yeebaagooon, nottud

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: y triggers redesigned
posted 29 December 2019 03:58 PM EDT (US)   

y Triggers


Overview


The idea of search triggers is it enables you to find any newly created units in the game and perform actions based on what it currently is. For example you might want an SPCMeteor to cast whenever a building is destroyed or to create a unit at every bolt strike. Unlike most triggers this will find all units created - even unsearchable ones which change in area would not normally work on!

Changes from previous version


This new version resolves a lot of the issues and complaints from the previous version:
  • It is now much simpler to use - there is now nothing to set up! No more highest unit name, buffer sizing, or rebooting nonsense!
  • It now runs much faster no longer using an internal buffer and not deploying units.
  • Unit types are now calculated on the fly rather than stored. This reduces bugs where the unit gets changed outside of the trigger control.
  • I have restructured some of the triggers to accept variables to make working with players a bit easier and unlock more opportunities

    Getting started


    Below is a simple example which makes a lighting storm summon anubites:

    Insert a trigger with run immediately, looped, and active checked and put on highest priority. Insert the following effects:
  • yaaStart Search
  • yCondition - is protounit (Select lighting scorch)
  • yChange Unit Type (Select anubite)
  • yCondition zEnd
  • yaaEnd Search
    Run the scenario and cast a lighting storm and enjoy your new army!

    Play around with the effects and you will quickly learn lots of neat tricks you can do!

    Variables


    To make it easier to work with players the system supports variables. An example of something you want to do might be to deploy units the same player as the owner of the unit. To do this use the trigger effect:
  • ySet variable from unit owner
    This will ask you to input a variable name such as p. In a later trigger effect where you input a player, you can put the variable name you entered instead. E.g. you can grant a player a god power based on the player of the unit. Note that if you are using yArmy Deploy for comps online the player is actually making a string and needs entering in the form "+VariableName+" instead.

    Delegating search handling


    One of the annoyances with the original ySearch was you had to perform all handling all inside a single trigger. This got difficult to work with very quickly with a lot of effects to handle. I have now added to support delegate the handling to other triggers. To use the effect:
  • yDelegate
    Enter a unique name for a delegate handler. I normally put the trigger name doing the handling. Note that spaces in the name is not permitted.

    Next to make a trigger perform the handling, insert a trigger and make it inactive. For the first effect insert the effect:
  • yDelegate Handler
    Enter the same unique name you entered earlier to handle.

    IMPORTANT: When adding a trigger handler, it will not work unless the search trigger is a more "recent trigger" and cause a trigger lock. To resolve make a copy of the search trigger and delete the original (This will make the search trigger more recent). The copy can then be named to be the same as the original. This is a limitation in the game language I cannot resolve.

    Database searching


    This allows found units to be stored and then freely searched separately to the y triggers. This can be used to allow re-searching previously found units. To add units to a database use the effect:
  • yAdd to yDatabase
    This will store the unit for searching later (There is a non y version allowing existing units to be added also). You can then search the units freely with a similar structure to search triggers using instead the following structure:
  • yaaStart Database Search
  • Your conditionals and effects
  • yaaEnd Database Search
    Units that no longer exist (Dead and corpse gone) are automatically pruned out the database for efficiency. You can also remove units found during a search so they will not be found in future searches with the effect:
  • yRemove from yDatabase (During search)
    This removes the currently found unit from the database. The database name should match what is currently being found.

    Troubleshooting


    If you encounter a trigger locks check the following things:
  • A search start must have the corresponding search end
  • Every condition needs a corresponding end
  • When you set up a delegate the search trigger calling the delegate needs to be more "recent". Use the copy trick described above to resolve this.

    Download


    http://aom.heavengames.com/downloads/showfile.php?fileid=11471

    [This message has been edited by nottud (edited 12-29-2019 @ 04:53 PM).]

  • Replies:
    posted 16 January 2020 05:32 PM EDT (US)     1 / 1  
    Great stuff!

    Age of Mythology Heaven » Forums » Scenario Design » y triggers redesigned
    Top
    You must be logged in to post messages.
    Please login or register
    Hop to:    
    Age of Mythology Heaven | HeavenGames