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
SP - means Single Player only.
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.
Same as above with an army instead of a centre unit. Army of just one unit, please.
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.
Closes the secondary search, and goes back to the primary search
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.
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
Select a player, and it will check the unit's diplomacy towards that player.
Select a player, and it will check that players diplomacy towards the 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.
Checks if a unit is performing specific action. See attached list of action IDs. Example, 9 for idle, 11 for move.
new function for "overlap." Deploys as flying unit, grounds it, and changes type.
Moves the units found in the search away from the selected unit.
Inverse of the above, moves the select unit away from protounits found in the search. Only works well for small numbers of protounits.
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.
Teleports to the location of the unit + (X,Y,Z)
Closes a condition.
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.
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.
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.
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.
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.
| HailToTheOboe's Work |
| Let Heaven and Nature Sing (5.0) | Spinning Wheel (5.0) | Screenshots | Prime |
| Calendar Competition 2009 | Screenshot Tournament I | Screenshot Tournament III |
| Farewell. City of the Sea | We're on a Mission From God | Going for a Drive |
| Trigger pack:Target Protounit Query (5.0) | Rocmaninov | AOM World Cup |
[This message has been edited by HailToTheOboe (edited 06-23-2010 @ 11:21 PM).]