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

Scenario Design
Moderated by Yeebaagooon, nottud

Hop to:    
loginhomeregisterhelprules
Bottom
Topic Subject: NEW Trigger Pack: Target Protounit Query Triggers
« Previous Page  1 2  Next Page »
posted 02 December 2009 00:08 AM EDT (US)   
TARGET PROTOUNIT QUERY TRIGGERS
HailToTheOboe

DOWNLOAD HERE

This is a pack of triggers, similar to nottud's ySearch triggers, that let you find protounits in an area without selecting object parameters, and target them with any effect/conditions you want. Sort of a "Build Your Own Unit Query," if you will.

The idea is to perform multiple actions on protounits under various conditions without making a specific query trigger for every combination of conditions and effects.

Think of it as being very similar to a ySearch, but it uses knowledge base unit queries instead of an exhaustive search through all units. Here are the main differences between v TPQ and ySearch.
1) Faster and more reliable
2) No hassle with "max unit name", rebooting, and the buffer size.
3) Cannot find all units - things like projectiles or SFX will not be found. ySearch on the other hand, can find anything.
4) Does not find the unit "name" just the unit ID, which limits (slightly) the possibilities for effects.

Here is an example of how you may use it.
v Target Protounit Query Start
v Conditional Percent Damaged
v Invoke God Power
v Kill
v Condition zEnd
v Target Protounit Query End

This would find the protounits in the area, and if they are damaged a certain amount it will invoke a GP at the location and kill the unit.
This means you do not need to request a "invoke GP and kill percent damaged protounits in area."
Each individual condition and effect is very easy to code on request, if the non v TPQ version already exists. Additionally, many yTrigger effects can be used directly, and those that can't would only need very small modifications.
In order to code new v TPQ effects, here are things to keep in mind:
1) The unit is already selected by trUnitSelectByID
2) The unit ID is stored in the variable "UnitID"
3) The player of the unit is stored in the variable "pid" and the context is already set.
4) The location of the object can be found with kbUnitGetPosition(UnitID)
5) The protounit can be found with kbGetUnitBaseTypeID(UnitID)

Another feature has been added to some of the Conditions and Effects, this is the "QV?" parameter. When this parameter is set to ON, enter the input as a quest var name, and if it is set to OFF, enter the input as a number. This prevents the need for typing trQuestVarGet("QV1") or making separate triggers for QVs and numbers.

TL - means trigger loader required (downloadable here http://aom.heavengames.com/downloads/showfile.php?fileid=7609)
SP - means Single Player only.


Effects List:

  • v 1 Target Protounit Query Start

    This is the first effect to put in.
    This effect defines which protounits you are looking for, where, and what basic conditions apply.
    After this effect, place all of the conditions and effects you want to target the protounits with, and at the very end of the trigger put "v 2 Target Protounit Query End"

    Parameters:
    Center Unit: A unit located at the centre of the circular area you want to search (optional)
    Radius: The radius of the circular area you want to search. If you enter -1, the query will search the entire map.
    Player: The player to whom the targeted protounits belong. Enter 99 to search for all players.
    Protounit: The type of protounit that will be found. Leaving this parameter blank will search for all units.
    Action: The Action ID of the targeted units. For example 9, for idle, or 29 for "Thrown" See the attached list of action IDs. Leaving it at -1 will accept any action.
    Unit State: 2 for alive, 4 for dead, 255 for any. Be careful when searching dead units, because long dead units will still be found, but their location will be interpreted as (-1,-1,-1), or the bottom corner. There is a condition available ("Condition Ignore invalid unit") to ignore these.

  • v 1 Target Protounit Query Start (Center Army)
    Same as above with an army instead of a centre unit. Army of just one unit, please.

  • v Secondary Target Protounit Query Start
    This effect has all the same parameters except for center unit. This starts a second query, where the centre location is a protounit found by the main query. This lets you target units in area of protounits in area. Make sure you end with a Secondary Target Protounit Query End.

  • v Secondary Target Protounit Query End
    Closes the secondary search, and goes back to the primary search

  • v Condition Else
    This is used as part of a multi-stage condition, where the following effects will target units that did not satisfy the previous condition. It is most easily demonstrated by example. You do not need a Condition zEnd to match the Else, just to match the regular conditions.

    v Condition Percent Damaged
    v Kill
    v Condition Else
    v Change Unit Type
    v Condition zEnd

    If the unit is damaged enough, it kills it. If not, it changes it to another unit.

    It can also be used to invert a condition.

    v Condition Unit Type
    v Condition Else
    v Change Unit Type
    v Condition zEnd

    Any unit that is NOT the specified unit type, gets changed.


  • v Condition OR
    Place this after each Condition that you want to be grouped. For the effect to fire, one condition OR another must be true, not necessarily both. You can use groups of more than 2 conditions, and choose the minimum number that must be satisfied (for example if 2 out of 3 conditions are true, fire the effect).

    The last OR in the group should be a v Condition OR last. You only need a Condition zEnd for the OR last, not for the rest of the conditions.

    v Condition Percent Damaged
    v Condition OR
    v Condition Distance to Unit
    v Condition OR last
    v Change Unit Type
    v Condition zEnd


  • v Condition Diplomacy of Unit
    Select a player, and it will check the unit's diplomacy towards that player.

  • v Condition Diplomacy towards Unit
    Select a player, and it will check that players diplomacy towards the unit.

  • v Condition Distance to Unit

  • v Condition Distance to Army

  • v Condition Ignore invalid unit
    This checks if the unit is "invalid". The condition is true only when the unit is NOT valid. An invalid unit is a unit that does not exist, or has been dead for a very long time. This condition is only necessary when using Unit States of 4 (dead) or 255 (any) in the query.

  • v Condition Percent Complete

  • v Condition Percent Damaged

  • v Condition Unit Action
    Checks if a unit is performing specific action. See attached list of action IDs. Example, 9 for idle, 11 for move.

  • v Condition Unit Current HP

  • v Condition Units in Area

  • v Condition Unit Height

  • v Army Deploy to Unit
    new function for "overlap." Deploys as flying unit, grounds it, and changes type.

  • v Camera Cut to Unit

  • v Garrison

  • v Flare Minimap on Unit

  • v Move to Random Location

  • v Move Random Direction TL

  • v Move away from unit TL
    Moves the units found in the search away from the selected unit.

  • v Move away from army TL

  • v Move unit away from protounit TL
    Inverse of the above, moves the select unit away from protounits found in the search. Only works well for small numbers of protounits.

  • v Move army away from protounit TL

  • v QV Count Units
    QV counts upwards, once per unit. NOTE: It starts at its current value, not zero. Initialize it to zero before the query if you want it to start at zero.

  • v Teleport to Unit SP
    Teleports to the location of the unit + (X,Y,Z)

  • v Unit Stance

  • v Unit Work

  • v Kill

  • v Invoke God Power

  • v UI Select Unit

  • v Conditional zEnd
    Closes a condition.

  • v 2 Target Protounit Query End
    Closes the search.

    Thanks to invent00r, Mythic_Freak, nottud, angryzor, pftq, and perpetual_n00b. Whether they knew it or not, they were all a great help, even if it was just me looking at their code.

    The download contains the trigger pack (typetest_TargetProtounit.xml) which goes in your trigger or trigger2 folder.
    Also contains a scenario demo, which you should watch and look at the triggers, and a text file that outlines the important triggers in that demo.

    DOWNLOAD HERE

    Feel free to ask questions about them now, I'll try to answer, and also feel free to request additional effects/conditions will fit. If they're easy I'll do them.

    ************************
    Updated February 9

    Modified:
    v 1 TPQ Start
    v 1 TPQ Start (Centre army)
    v Condition Unit Type

    to allow using unit type IDs, as well as protounit type. If you have the trigger loader activated, you can type in constant names like cUnitTypeUlfsark for the unit type of an Ulfsark, or cUnitTypeAbstractArcher, or cUnitTypeLogicalTypeIdleCivilian etc. See the trigger loader or protox for more info on these lists. You can also use the number, if you happen to know the number.

    Added:
    v Army Add Unit
    v Condition Unit Selected (Thanks lostrozzacavalli, although I modded it)
    v Condition Random Unit (Thanks perpetual n00b though I modded this too)
    v Change Type, v Convert, and a number of others which I had left out previously because they are identical to yEffects. I put them in to try to avoid confusion.


    ************************
    Update June 23
    Lots of bugs fixed. Including many effects which broke if you tried to use QVs. Secondary Query is fixed after being broken in a previous update. A couple other small issues fixed.
    New trigger subset: Array search.
    These are older triggers of mine modified to work in compliance with v triggers. These use QV arrays made by invent00r in the trigger loader.
    You store units in this array, and later you can find them by searching through the array. All the v conditions and effects should be usable during an array search. If any are not, let me know.

    [This message has been edited by HailToTheOboe (edited 06-23-2010 @ 11:21 PM).]

  • Replies:
    posted 02 December 2009 02:26 AM EDT (US)     1 / 42  
    I reviewed. Great work, HailToTheOboe!



    ~Guard of Olympus ~
    _______________________________________
    Jag ser mot solen och tankarna de för mig hem till AomH SD igen
    Learn how to create a website from scratch!
    _______________________________________
    Dark Times|My work (4.6)|Teaser #2
    posted 02 December 2009 02:28 AM EDT (US)     2 / 42  
    This must have been so hard to code!

    castwcrt rip 2010-2010
    posted 02 December 2009 04:11 PM EDT (US)     3 / 42  
    Urgh? It says file not found for me! The link seems to be broken because I found it in ythe file list. Weird....

    The boy with the mad imagination
    Prepare for the ultimate duel!
    Learn to use all my triggers and what you can do with them. Visit here.
    Find out and download the transform trigger here.
    Play some minigames I have created outside AOM including some 3D games here.
    posted 02 December 2009 04:36 PM EDT (US)     4 / 42  
    I have been looking forward to this. Thank you very much for both creating and publishing this.

    Very nice and detailed explanation too.
    posted 02 December 2009 06:48 PM EDT (US)     5 / 42  
    Sorry nottud, my bad. The link is fixed now.
    I reviewed. Great work, HailToTheOboe!
    Already? Thanks!
    This must have been so hard to code!
    Most of it was quite straightforward, but there were a handful of niggly tricky bits.

    There are a few vEffects in there that don't exactly exist as regular effects, but they would be handy. I'm thinking of "Move away from unit" which can be used as a sort of poor man's AG (although AG is better), and the new "overlap" function for Army Deploy to Unit.

    Also, to fellow trigger coders, take a look at what I did for several of those effects to let you choose whether the input is a number or a QV, I encourage you to include that in new triggers you make, to reduce the need for duplicating triggers with a QV version.

    If anyone has any questions about using them, or any easy requests of effects to add in, go ahead and ask.
    posted 02 December 2009 07:50 PM EDT (US)     6 / 42  
    Explain move away from unit. It sounds like something i might need.
    posted 02 December 2009 08:05 PM EDT (US)     7 / 42  
    It makes a unit run away from another unit. You give it the distance to run, but the trigger finds the best direction. It's like antigravity, but it doesn't work well for multiple units, and it doesn't calculate the running distance. But it is simpler and works for some simple situations.

    In the demo scenario, the last section with the ulf and the priests - I used v Move Away from Unit to keep the priests running away from the ulf whenever he got close, so the poor guy could never get more than one or two hits in.

    If you're up there God, thanks for the title fix

    [This message has been edited by HailToTheOboe (edited 12-02-2009 @ 08:09 PM).]

    posted 02 December 2009 09:20 PM EDT (US)     8 / 42  
    I cant help but think that my PC effects, with the protounit queries and such, were a contributing factor to your inspiration to make this. Basically, this is what I have been trying to do for a while with my effects, and it takes it to a level where I can manipulate it as anyway I want. Thanks hail, I dont know if I will use these yet, but its really great what you have done here.

    Only complaint==This, well, it makes all my pc effects basically not needed.

    Tired of unorigional, boring campaigns? Try out DEMO|Legacy - The Uprising|DEMO
    Completely New Gameplay. Random Map Type Replayability. Delve into Nomadican|FEATURES|DOWNLOAD|
    Want to know how to use triggers and/or create amazing factors in your scenarios? You need Combination Effects|FEATURES|DOWNLOAD|
    Automaton Metals Textures, New Custom Triggers
    Upcoming Projects: Legacy - The Uprising, Destiny
    6/12/1997, a day that will live in infamy.
    posted 02 December 2009 09:34 PM EDT (US)     9 / 42  
    The idea behind this trigger pack is not a new one, it has surfaced a lot of times before, I just finally got around to doing it.

    angryzor did something similar with his FAOC triggers. Invent00r was considering doing this when he released his proactive triggers, but didn't. When Nottud released his ySearch triggers, I thought that it would be handy to use that setup with queries as well, but I didn't get around to it, because I figured there weren't that many combinations of effects you'd want to use, and they weren't that hard to code into a self-contained trigger anyway.

    Eventually though, after writing (seemingly) hundreds of minute variations on the same query trigger it was time to bite the bullet, and git 'er done.
    This, well, it makes all my pc effects basically not needed.
    Yep. It also means you won't need to ask for more
    posted 02 December 2009 09:35 PM EDT (US)     10 / 42  
    whats the difference between these and the ysearch triggers? I mean, I have never used them, so what I have heard makes it sound like these are the same basically.

    What would be the differences then in the way these find units and the effects you perform?

    Tired of unorigional, boring campaigns? Try out DEMO|Legacy - The Uprising|DEMO
    Completely New Gameplay. Random Map Type Replayability. Delve into Nomadican|FEATURES|DOWNLOAD|
    Want to know how to use triggers and/or create amazing factors in your scenarios? You need Combination Effects|FEATURES|DOWNLOAD|
    Automaton Metals Textures, New Custom Triggers
    Upcoming Projects: Legacy - The Uprising, Destiny
    6/12/1997, a day that will live in infamy.
    posted 02 December 2009 09:47 PM EDT (US)     11 / 42  
    The difference is the search method for finding the unit.
    These triggers do a unit query, and the yTriggers do an exhaustive search.

    Let's say you're looking for a pencil.
    Using a ySearch to find your pencil would be like starting in your front yard and scanning every square centimetre of lawn, then working your way into the house and searching the entire floor, then the couch, under the cushions, behind the TV, the big chair, the little chair, the ceiling, the wall, behind the photo albums, up the chimney, until it eventually finds the pencil.

    A unit query is like starting at your desk and looking for pencils where you would expect a pencil to be.

    Basically, it is faster and more efficient (less laggy). It also skips the hurdle of having to input the Max unit name, and dealing with the buffer and rebooting built into ySearch.

    Granted, ySearch is not as bad as I made it sound. You give it a starting point for the search, so it is not endless, but still not as quick as a query.

    The flip side is that ySearch can find absolutely any type of unit, but unit queries cannot find projectiles or SFX and some others.

    If you're looking for a minotaur, use a unit query. If you're looking for a Ball of Fire Impact, use a ySearch.

    [This message has been edited by HailToTheOboe (edited 12-02-2009 @ 09:54 PM).]

    posted 03 December 2009 04:11 PM EDT (US)     12 / 42  
    A funny desctiption of a search thigny. Search is a sort of bad name for my triggers really in temrs of how it actuyally works (Its a better name when descripbing what it does to new untis on the map ). Its more like a queue set of triggers. New units created get added to the end of a queue and then the tirggers check each unit in the queue and execute relevant effects on them depending what the thing is.

    The boy with the mad imagination
    Prepare for the ultimate duel!
    Learn to use all my triggers and what you can do with them. Visit here.
    Find out and download the transform trigger here.
    Play some minigames I have created outside AOM including some 3D games here.
    posted 03 December 2009 11:47 PM EDT (US)     13 / 42  
    I guess that's another point. Queries can find units no matter when they were created.

    The way the ySearch triggers work makes it so it only finds units created since the previous execution of the ySearch (and if I'm not mistaken, he did this in order to keep the lag at a minimum).
    Since most of the units that you NEED ySearch for are temporary, that is rarely an issue, and you can use the search database thing to save a unit and find it again later.
    posted 05 December 2009 09:16 AM EDT (US)     14 / 42  
    Another feature has been added to some of the Conditions and Effects, this is the "QV?" parameter. When this parameter is set to ON, enter the input as a quest var name, and if it is set to OFF, enter the input as a number. This prevents the need for typing trQuestVarGet("QV1") or making separate triggers for QVs and numbers.
    It is a good feature but you left the varType as "long" so you can't type directly the name of the QV, only typing it in a "string" parameter and then copying it with ctrl+c and ctrl+v. I guess why we don't put "string" everywhere instead of "long" or "float"... isn't the same thing but you can put variables?

    Utilities || Map Tool 3.1 Inventory Triggers MP Triggers Comic AoM
    RandomMaps || Mad Supremacy Escape Your Mates Escape
    Scenarios || Bomberman Minigames Y 2.0 Convert & Fight
    Games || Bullet Demo Ball Bouncer 3D
    WRP_Beater: "Meglio una gallina oggi che un uovo domani."
    My name has been misspelled 132 times (Last: BSU_DoLhades Best: Lostrozzabercrombie In a row: 5)
    posted 05 December 2009 01:39 PM EDT (US)     15 / 42  
    Really? I thought I made them all string. I'll double check, may have missed something.

    edit: You're right, I did miss it on a good handful. I'll update. Thanks.

    [This message has been edited by HailToTheOboe (edited 12-05-2009 @ 01:42 PM).]

    posted 05 December 2009 01:44 PM EDT (US)     16 / 42  
    No problem Hail, you helped me tons of times. Take a look on MPs, I posted a trigger that should work but doesn't...

    Utilities || Map Tool 3.1 Inventory Triggers MP Triggers Comic AoM
    RandomMaps || Mad Supremacy Escape Your Mates Escape
    Scenarios || Bomberman Minigames Y 2.0 Convert & Fight
    Games || Bullet Demo Ball Bouncer 3D
    WRP_Beater: "Meglio una gallina oggi che un uovo domani."
    My name has been misspelled 132 times (Last: BSU_DoLhades Best: Lostrozzabercrombie In a row: 5)
    posted 05 December 2009 01:45 PM EDT (US)     17 / 42  
    Haha, I was trying to avoid that so I tested each one carefully, but I didn't try them out with both QVs and numbers (only did that once, the first time).

    It's updated, so you can either redownload, or just go into the file and find-and-replace all "long" with "string".
    posted 05 December 2009 01:46 PM EDT (US)     18 / 42  
    Queries will work with arrows correct?
    posted 05 December 2009 01:56 PM EDT (US)     19 / 42  
    posted 05 December 2009 02:00 PM EDT (US)     20 / 42  
    Looks good, you earned yourself a place in the TRT download list! :P

    If we knew what it was we were doing, it would not be called research, would it? - Einstein, A.
    Master XS - AoM Code Reference - Trigger Loader - Trigger Requests - Chess

    Wow, I never thought that I would actually know something before nottud did... it's actually not all that satisfying ~ Steak
    posted 05 December 2009 02:14 PM EDT (US)     21 / 42  
    Woohoo! Thanks.

    BTw GOO I answered your question in the dl comments. I don't have a v Change Unit Type, because it would be indentical to yChange Unit Type. There are quite a few yEffects that can be used with these triggers just fine.

    The bottom line for compatibility is this:

    If the only requirement is that the unit gets selected, it is compatible with both v and y.

    If the effect needs to determine the unit's location or action, it is not compatible with v and y.

    If you look at the code, you'll see that mine use kbUnitGetPosition(UnitID) for the location, but nottud's use kbGetBlockPosition(""+1*trQuestVarGet(%qv%)).
    So if you look at the y trigger and it has that line in it, a new effect is needed to work with the v triggers. I tried to get the important ones, but I may have missed some.
    posted 01 February 2010 01:30 PM EDT (US)     22 / 42  
    Hello HTTO this is a bit late however i wanted to ask you is it possible to use two triggers working the same time? For example one that searches for huskarl for unit heading v2End and a separate trigger for kastor soundfilename v2End?? I tried but i got a trigger block, uhh! So if so can i only search one trigger at a time or can i do more also with the vchangeunitype , vconditionalelse can i select more units to exclude? Get back to me here or msn dude, cheers!

    |MEMORY|
    posted 01 February 2010 01:36 PM EDT (US)     23 / 42  
    You can.

    Try it with something simpler
    posted 01 February 2010 01:41 PM EDT (US)     24 / 42  
    posted 01 February 2010 03:17 PM EDT (US)     25 / 42  
    Awesome.

    ______________________________________ Yeebaagooon ______________________________________
    ____________________ AoMH Seraph ____________________
    "You can't trust yeebaagooon to lead a rebelion, He would send everyone to steal mirrors so he could bask in his own brilliance." - Out Reach
    "Yeebaagooon had never seen a more handsome man in all his life. He couldn't control himself, He needed to act. Gripping the mirror in his strong arms he kissed the figure before him..." - Out Reach
    AoMH: Unfinished Scenarios|Singleplayer: Codename Ripto|Multiplayer: Minigames Z|CSC 7
    Ex Seraphs Dictator, Spore Heaven Seraph
    « Previous Page  1 2  Next Page »
    Age of Mythology Heaven » Forums » Scenario Design » NEW Trigger Pack: Target Protounit Query Triggers
    Top
    You must be logged in to post messages.
    Please login or register
    Hop to:    
    Age of Mythology Heaven | HeavenGames