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

Modding and Scripting
Moderated by Yeebaagooon, TAG, nottud

Hop to:    
Welcome! You are not logged in. Please Login or Register.1 reply
Age of Mythology Heaven » Forums » Modding and Scripting » [XML] Custom Trigger - AOM:EE
Topic Subject:[XML] Custom Trigger - AOM:EE
posted 26 July 2018 09:31 PM EDT (US)

Video explaining the goal and what I've wrote so far.

I'm new to AOM:EE XML

I've asked on the steam forums, but nobody has actually helped, they're just listed functions from mythicfreak which doesn't help when they don't explain how everyone co-exists lol.

The goal:
Use trCountUnitsInArea on an army (in my case the army will only ever be 1 unit) to find out if there are any enemy units in a set radius around the army. trCountUnitsInArea("%SrcArmy%",%Player%,"%UnitType%",trQuestVarGet("%Dist%")) %Op% trQuestVarGet("%Count%")

The reason I cannot use a single unit is because the unit in this army will die and a new unit will be created and added to the army (See video for the scenario and everything).

Thank you.
posted 30 July 2018 12:13 PM EDT (US)     1 / 1       
[SOLVED] -- 7-30-18 by Loggy
   <Condition name="Count Units in Area Around Army">
<Param name="SrcArmy" dispName="$$22348$$Army" VarType="group">default</Param>
<Param name="Player" dispName="$$22301$$Player" VarType="player">1</Param>
<Param name="Dist" dispName="QV Radius" VarType="string">healingradius</Param>
<Param name="Count" dispName="QV Count" VarType="string">healingcount</Param>
<Command>static int constUnitTypeUnit = -1;</Command>
<Command>if (constUnitTypeUnit == -1) {</Command>
<Command>constUnitTypeUnit = 500;</Command>
<Command>while (kbGetUnitTypeName(constUnitTypeUnit) != "Unit") { constUnitTypeUnit++; }</Command>
<Command>int results = 0;</Command>
<Command>int oldcontext = xsGetContextPlayer();</Command>
<Command>int query = kbUnitQueryCreate("SomeTriggerQuery");</Command>
<Command>vector armypos = kbUnitGetPosition(trGetSelectedUnitID(0));</Command>
<Command>if (i == %Player% || kbIsPlayerAlly(i))</Command>
<Command>kbUnitQuerySetPlayerID(query, i);</Command>
<Command>kbUnitQuerySetPosition(query, armypos);</Command>
<Command>kbUnitQuerySetMaximumDistance(query, trQuestVarGet("%Dist%"));</Command>
<Command>kbUnitQuerySetState(query, cUnitStateAlive);</Command>
<Command>kbUnitQuerySetUnitType(query, constUnitTypeUnit);</Command>
<Command>results = results + kbUnitQueryExecute(query);</Command>
<Command>if (results > trQuestVarGet("%Count%"))</Command>
<Command>bool out = (trQuestVarGet("%Count%") == results);</Command>

So thank you to Loggy for working with me and showing/teaching me a lot about AOM:EE and its querky code. You're especially patient.

Thank you as well to nottud on reddit and Azerath on Steam.

How the trigger works:
Unlike Count Units in Area, this triggers "player" selector is needed for the army so whatever player owns the army, put that player in the player selector.

This trigger then looks in a radius around that army and returns true if there are no units in the area.

You can modify the trigger how you want, but this was created for my specific use case for my upcoming scenario.

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

Hop to:    

Age of Mythology Heaven | HeavenGames