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

Scenario Design
Moderated by Yeebaagooon, TAG

Hop to:    
Welcome! You are not logged in. Please Login or Register.42 replies
Age of Mythology Heaven » Forums » Scenario Design » NEW Trigger Pack: Target Protounit Query Triggers
Bottom
Topic Subject:NEW Trigger Pack: Target Protounit Query Triggers
« Previous Page  1 2  Next Page »
HailToTheOboe
Bitten by a radioactive ostrich
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).]

  • AuthorReplies:
    HailToTheOboe
    Bitten by a radioactive ostrich
    posted 09 February 2010 09:14 PM EDT (US)     26 / 42       
    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.

    check DL section for new version.
    Elrich
    Hero
    posted 12 March 2010 01:48 PM EDT (US)     27 / 42       
    I will study these as I am getting back into trigger development (for once I will try not to re-invent the wheel)

    I have just one request:

    When you explain the difference between Nottud's Y and your V triggers, you mentioned a trigger searching the house, chimney and all. Can you write one of those triggers for me? oh and what is the protounit or TL constant for 'tv remote'?


    In all your science of the mind, seeking blind through flesh and bone
    Find the blood inside this stone
    Well, I know I've never shown what I feel, I've always known
    I plan my vengeance on my own - and I was always alone
    HailToTheOboe
    Bitten by a radioactive ostrich
    posted 12 March 2010 11:24 PM EDT (US)     28 / 42       
    Hm couldn't tell you for sure, TV remote was never implemented in vanilla. We have to get up and change channels manually, and even that is assuming we get decent reception on more than one or two channels.

    Glad you're interested. I released these mainly as a tool to reduce the load on trigger scripters. It feels like a big share of new requests can be settled with a link to this thread

    You're welcome to expand and further develop, if any further possibilities come to mind.
    andrewv42
    Mortal
    posted 13 March 2010 05:00 AM EDT (US)     29 / 42       
    wow this looks great! downloading now!

    Hello, my name CHEEZ BIX:
  • Download the beta version of my map, Hero Wars: Godpowers Unleashed!
  • lostrozzacavalli
    Mortal
    posted 13 March 2010 06:36 AM EDT (US)     30 / 42       
    if anyone is intrested, I just converted TPQ to RM codes, in the way me and nottud and some others use:

    //TPQ_Start
    code("for(Qid=0;>1) {} for(UnitID=0;>1) {} for(maxPlayer=0;>1) {}");
    code("for(minPlayer=0;>1) {} for(TempORVar=0;>1) {}");
    code("for(oldPlayer=0;>1) {} for(finalORResult=0;>1) {}");
    code("oldPlayer=xsGetContextPlayer(); minPlayer=0; maxPlayer="+cNumberNonGaiaPlayers+";");
    code("for(pid=minPlayer;<=maxPlayer){");
    code("xsSetContextPlayer(pid);");
    code("kbLookAtAllUnitsOnMap();");
    code("Qid=kbUnitQueryCreate(\"tp_query_convarea_1\");"); //Create
    code("kbUnitQuerySetPlayerID(Qid,pid);"); //Player
    code("kbUnitQuerySetUnitType(Qid,kbGetProtoUnitID(\"Unit\"));"); //Type
    code("kbUnitQuerySetState(Qid,2);"); //State
    //code("kbUnitQuerySetActionType(Qid,9);"); //ActionID
    //code("trUnitSelectClear();");
    //code("trUnitSelect(\"\");");
    //code("if(trUnitAlive()==false){break;}");
    //code("kbUnitQuerySetPosition(Qid, kbGetBlockPosition(\"\"));"); //Object Position
    //code("kbUnitQuerySetMaximumDistance(Qid,5);"); //Distance
    code("kbUnitQuerySetAscendingSort(Qid, true);"); //???
    code("for(j=kbUnitQueryExecute(Qid)-1;>-1){");
    code("UnitID=kbUnitQueryGetResult(Qid,j);");
    code("type=kbGetUnitBaseTypeID(UnitID);");
    code("trUnitSelectClear(); trUnitSelectByID(UnitID);");
    //code("if(UnitID==kbGetBlockID(\"\")){continue;}");
    //TPQ_Main_Code

    //TPQ_End
    code("}}");
    code("xsSetContextPlayer(oldPlayer);");


    I don't want any credit, it's just to let people avoid to do it every time

    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)

    [This message has been edited by lostrozzacavalli (edited 03-15-2010 @ 05:25 AM).]

    Milkman Matty
    Mortal
    (id: Khan And Steak)
    posted 05 April 2010 08:48 AM EDT (US)     31 / 42       
    Just wondering, can you use these to find out if a unit is effected by Spy? ~ Khan

    <||=================================||>
    Proud Member of Forgotten Empires
    96Reviews KaS Dota2 Halo 5 Reach
    { "Work until your idols become your rivals" }
    ༼ つ ◕_◕ ༽つ trGetUnitScenarioName(); ༼ つ ◕_◕ ༽つ
    HailToTheOboe
    Bitten by a radioactive ostrich
    posted 05 April 2010 12:12 PM EDT (US)     32 / 42       
    nottud
    Mortal
    posted 05 April 2010 12:39 PM EDT (US)     33 / 42       
    You could check to see if a spy eye is at/very close to the location of the unit in question. This could be achieved by the use of database and search triggers.

    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.
    generaljet
    Mortal
    posted 08 April 2010 04:40 PM EDT (US)     34 / 42       
    It HURTS MY HEAD but.. thanks i guess..
    Kai Hirogashi
    Mortal
    posted 07 May 2010 11:05 PM EDT (US)     35 / 42       
    Hey HailToTheOboe, i have a problem with one effect:

    V Condition unit current hp! I know you said it caused issue for you but the new one isn't working also. I tried to input the Query you showed me earlier today on msn however this effect breaks the triggers. Please get back to me as soon as possible, thanks.

    Kai

    |MEMORY|
    HailToTheOboe
    Bitten by a radioactive ostrich
    posted 08 May 2010 03:07 PM EDT (US)     36 / 42       
    Sorry, I think there was a miscommunication about the new one - if you wanted to use a QV you had to type trQuestVarGet("QV"), as I did in the example scen, not just the QV name, but I accidentally left an extra parameter there to confuse things.

    Apparently I let a number of dumb mistakes slip through testing.

    lostrozzacavalla came up with one hell of a clever little fix

    <Effect name ="v Condition Unit Current HP">
    <Param name = "Operator" dispName = "Operator" varType = "operator">==</Param>
    <Param name = "HP" dispName = "Hitpoints" varType = "string">0</Param>
    <Param name = "qv" dispName="QV HP?" varType="bool">false</Param>
    <Command>for(result=0;>1) {} for(%HP%=0;>1) {}</Command>
    <Command>if(%qv%) {result = trQuestVarGet("%HP%");</Command>
    <Command>} else {</Command>
    <Command>result = %HP%;}</Command>
    <Command>if(kbUnitGetCurrentHitpoints(UnitID) %Operator% result) {</Command>
    </Effect>


    There's going to be an update for this trigger pack while I apply his clever fix to a number of other triggers to make sure they all work as originally intended.

    For those interested in scripting, the original problem was that when you typed in a QV name instead of a number, the line

    result = %HP%;

    would cause trigger lock even though it doesn't get used, because you are trying to put a word into an integer variable.
    lostrozzacavalli's fix was to disguise the parameter as a new integer variable
    for(%HP%=0;>1) {}
    so there is a variable named after the value of the parameter so that
    result = %HP% will be a number even if %HP% was originally a string. cool, eh?

    [This message has been edited by HailToTheOboe (edited 05-08-2010 @ 03:17 PM).]

    HailToTheOboe
    Bitten by a radioactive ostrich
    posted 23 June 2010 11:24 PM EDT (US)     37 / 42       
    necroed because of update. There was some stuff pretty wrong, so I fixed it and added some new stuff as well. If anything goes wrong with it let me know.
    ************************
    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.
    Download again here
    invent00r
    Mortal
    posted 24 June 2010 07:00 AM EDT (US)     38 / 42       
    Looks good.. I had a different idea on how to implement this - commenting out the selecting unit part by adding /**/ at the end, and whenever a query was placed down it would open up a comment.

    This would work for simple effects. Oh And also, I don't really trust my code on the QV Arrays - be aware. .
    -invent00r

    My Work: 1 2 3 4 5 6 7 8 9 10

    WIP: Master XS Battle Micro AI
    Paused: AI (%4.247)
    Os segredos são de quem os souber guardar.
    fight_to_plight
    Mortal
    posted 04 July 2010 04:04 PM EDT (US)     39 / 42       
    Does this require the trigger loader?

    Meh
    HailToTheOboe
    Bitten by a radioactive ostrich
    posted 04 July 2010 04:13 PM EDT (US)     40 / 42       
    The ones that have TL in the name will require the trigger loader, but in general most of them do not.

    But since you're on vanilla, you need the trigger loader for QVs so you should definitely be using it all the time anyway.
    There may be a few unmarked ones that have QVs in them, but most don't.

    [This message has been edited by HailToTheOboe (edited 07-04-2010 @ 04:14 PM).]

    fight_to_plight
    Mortal
    posted 04 July 2010 04:18 PM EDT (US)     41 / 42       
    Well as far as i knew, the QV's won't work on multiplayer maps, along with most of the triggers that require the loader. Im not entirely sure though.

    Meh
    HailToTheOboe
    Bitten by a radioactive ostrich
    posted 04 July 2010 04:22 PM EDT (US)     42 / 42       
    « Previous Page  1 2  Next Page »
    You must be logged in to post messages.
    Please login or register

    Hop to:    

    Age of Mythology Heaven | HeavenGames