Some trigger effects work, but others do not

Hey! Super long text ahead. TL;DR: in a trigger, some effects won’t fire, but others will

I need some help with triggers. It seems some effects won’t launch. For more context, here all all the files related to the scenario
This is the scenario
lepanto.aoe2scenario (566.5 KB)
Change the aoe2scenario extension to age3scn

These are the AI files. These go into steamapps\common\AoE3DE\Game\AI\Lepanto or your AoE3DE installation folder
LepantoGreek.aoe2scenario (3.1 KB)
LepantoOttoman.aoe2scenario (4.2 KB)
Change the aoe2scenario extension to xs

And the homecity files. These go into steamapps\common\AoE3DE\Game\Campaign, or your AoE3DE installation folder
homecitygreekslepanto.aoe2scenario (34.7 KB)
homecityottomanslepanto.aoe2scenario (91.1 KB)
homecityspanishlepanto.aoe2scenario (75.3 KB)
Change the aoe2.scenario extension to xml extension

Now, the thing is, in the AttackingOttomansLoop Trigger Group, in the MoveGalleyArmyToLand Trigger, the Army Move Effects don’t work, but the other Effects DO fire, so I’m at lost. Any clue what it may be?

Thanks!

Did army move ever worked ? If you want to see a work around, check the first campaign scenario. Where they made the ottoman units move in batches.

Just checked. It uses Army move near unit, while I use Army move to Area

Also, the same effect DOES work on other triggers.

What’s the trigger name ? Remember that the game still converts triggers to XS

The not working is MoveGalleyArmyToLand
The working ones are called OttomanWave1, OttomanWave2, OttomanWave3 and OttomanWave4

If you are looking the scenario (THANKS!), in the same AttackingOttomansLoop group, there’s a trigger which deploys the army, called CreateWarShipNavalArmy1. AFAI have tested, this works. I use the mercator cheat, and both Xebecs and Privateers are deployed to docks

What trigger pack do you user ? Can you send me?

Isnt this what they are supposed to do?

What i noticed is, that the units that landed, dont move forward.

After some more playtesting

  1. that was actually what needed to happen when ships landed. I hadn’t actually detected they didn’t move forward; in the few playthroughs I made, they did.
  2. Found out my issue. The army that didn’t move was a naval army. It turns I was telling them to move to another place every ten secons; so obvoiusly, they didn’t arrive where I wanted them to be
    My trigger pack is one I did, precisely for this scenario. Check it out
<?xml version="1.0"?>
<trigger version="2">
<!-- 
THESE FUNCTIONS WON'T WORK IN AOE3. I haven't tested them in AoE3 DE, but I don't care
kbUnitQuerySetArmyID(long queryID, int armyID)   	kbArmyGetID(string name) -->
<!--These triggers wouldn't have been possible without the help of Dr. Maxy and AlistairJah. A shout out to ageekhere, Mandos and Penelope Candelaria who helped me to start my trigger journey-->
<Conditions>
      <Condition name="Army UnitType Count Compare">
            <Param name="SrcArmy" dispName="$$22348$$Army" VarType="group">default</Param>
            <Param name="Player" dispName="Player of Army" VarType="player">1</Param>
            <Param name="TargetUnitType" dispName="Target UnitType" varType="unittype">All</Param>
            <Param name="Op" dispName="$$22297$$Operator" VarType="operator">==</Param>
            <Param name="Count" dispName="$$22321$$Number" VarType="long">1</Param>
            <Command>trUnitSelectClear();</Command>
            <Command>for (all=0; &lt;=100000){ if (kbGetUnitTypeName(all)=="%TargetUnitType%") break;}</Command>
            <Command>for(counter=-1;&lt;0){}</Command>
            <Command>for(un=-2;&lt;-1){}</Command>
            <Command>trArmySelect("%SrcArmy%");</Command>
            <Command>for(a=trGetNumberSelectedUnitIDs();>=999999){break;}</Command>
            <Command>if (a != 0){ xsSetContextPlayer(%Player%);</Command><!--if we have selected units--> <!-- &excl;= means !=-->      
            <Command>for (i=0;&lt;a){</Command><!--for every unit we have selected-->
            <Command>un=trGetSelectedUnitID(i);</Command><!--ID of selected unit-->
            <Command>if(kbUnitIsType(un,all)){</Command><!--if our unit is of unitType-->
            <Command>counter=counter+1;</Command><!--the counter rises by one-->
            <Command>}</Command><!--end if(kbUnitIsType(un,all)-->
            <Command>}</Command><!--end for(i=0;<=a)-->
            <Command>}</Command><!--end if (a!=0)-->
            <Expression>counter %Op% %Count%</Expression>
            <Command>trUnitSelectClear();</Command>
<!-- <Command>un=trGetSelectedUnitID(0);
      trChatSend(2,"unitID="+un);
      for(player=0;&lt;10){
            if (trUnitIsOwnedBy(player)){
                  trChatSend(2,"player="+player);
                  break;
                  }
      }
       	xsSetContextPlayer(player);
             if(kbUnitIsType(un,all)){counter=1;}</Command> -->




      <!--this functions must be protected with life and limb  	kbUnitQuerySetArmyID(long queryID, int armyID)   	kbArmyGetID(string name)-->
      </Condition>
<Condition name="XS Condition Multiple">
<Param name="C1" dispName="$$20102$$Command" VarType="stringid"></Param>
<Param name="C2" dispName="$$20102$$Command" VarType="stringid"></Param>
<Param name="C3" dispName="$$20102$$Command" VarType="stringid"></Param>
<Param name="C4" dispName="$$20102$$Command" VarType="stringid"></Param>
<Param name="C5" dispName="$$20102$$Command" VarType="stringid"></Param>
<Param name="E1" dispName="$$18265$$Effects " VarType="stringid"></Param>

<Command>/**/ %C1%</Command>
<Command>/**/ %C2%</Command>
<Command>/**/ %C3%</Command>
<Command>/**/ %C4%</Command>
<Command>/**/ %C5%</Command>
<Expression>/**/ %E1%</Expression>

</Condition>

<Condition name="Units in Area Real (UnitType)">
<Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
<Param name="DstPoint" dispName="$$22410$$X" varType="area">0</Param>
      <Param name="Radius" dispName="$$22303$$Radius" VarType="float">10</Param>      
      <Param name="UnitType" dispName="$$22302$$Unit Type" varType="unittype"></Param>
      <Param name="Op" dispName="$$22297$$Operator" VarType="operator">==</Param>
      <Param name="Count" dispName="$$22304$$Count" VarType="float">1</Param>
      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=1000000){ if (kbGetUnitTypeName(all)=="%UnitType%") break;}</Command>
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <!-- <Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_%ProtoName%");</Command> -->
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=Qid+3){}</Command>
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetState(Qid,2);</Command>
      <Command>kbUnitQuerySetPosition(Qid, vector(%DstPoint%));</Command>
      <Command>kbUnitQuerySetMaximumDistance(Qid, %Radius%);</Command>
      <Command>kbUnitQueryExecute(Qid);</Command> 



      <Command>for(results=kbUnitQueryNumberResults(Qid);>=kbUnitQueryNumberResults(Qid)+3){break;}</Command>
      <Expression>results %Op% %Count%</Expression>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
      <Command>trUnitSelectClear();</Command>
      </Condition>


<Condition name="Player Unit Type Count">
<Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
<Param name="UnitType" dispName="$$22302$$Unit Type" varType="unittype"></Param>

      
      <Param name="Op" dispName="$$22297$$Operator" VarType="operator">==</Param>
      <Param name="Count" dispName="$$22304$$Count" VarType="float">1</Param>
      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=1000000){ if (kbGetUnitTypeName(all)=="%UnitType%") break;}</Command>
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <!-- <Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_%ProtoName%");</Command> -->
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=Qid+3){}</Command>
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetState(Qid,2);</Command>
      <Command>kbUnitQueryExecute(Qid);</Command>
      <Command>for(results=kbUnitQueryNumberResults(Qid);>=kbUnitQueryNumberResults(Qid)+3){break;}</Command>
      <Expression>results %Op% %Count%</Expression>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
      <Command>trUnitSelectClear();</Command>
      </Condition>

</Conditions>



  <Effects>


<Effect name="Army Deploy at UnitType of Player" > 
      <Param name="PlayerID" dispName="$$22301$$Player" varType="player">1</Param>
      <Param name="SrcArmy" dispName="$$22348$$Army" VarType="group">default</Param>
      <Param name="ProtoName" dispName="$$22434$$ProtoName" varType="protounit">Villager</Param>
      <Param name="Count" dispName="$$22435$$Count" varType="long">1</Param>
      <Param name="TargetUnitType" dispName="$$22338$$Unit Type Selected" varType="unittype"></Param>    
      <!-- We'll get the locations of all the targe units.
      First, we need to get the type of said unit -->
      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=10000){ if (kbGetUnitTypeName(all)=="%TargetUnitType%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=Qid+3){}</Command>
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetState(Qid,2);</Command> <!-- It seems that that 2 is with state=alive -->

      <Command>kbUnitQueryExecute(Qid);</Command>    
      <!-- Maybe we'll use this 
      int kbUnitQueryNumberResults(long queryID)
      Returns the number of results in the current query. -->
      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
      <Command>   trArmyDispatch("%SrcArmy%", "%ProtoName%", %Count%,  xsVectorGetX(kbUnitGetPosition(kbUnitQueryGetResult(Qid, ind))), 0, xsVectorGetZ(kbUnitGetPosition(kbUnitQueryGetResult(Qid, ind))), 0, false);</Command>

      <Command>}</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command>
      <Command>trUnitSelectClear();</Command>
</Effect>



<Effect name="Army Deploy at UnitType of Player in Area" > 
      <Param name="PlayerID" dispName="$$22301$$Player" varType="player">1</Param>
      <Param name="SrcArmy" dispName="$$22348$$Army" VarType="group">default</Param>
      <Param name="ProtoName" dispName="$$22434$$ProtoName" varType="protounit">Villager</Param>
      <Param name="Count" dispName="$$22435$$Count" varType="long">1</Param>
      <Param name="TargetUnitType" dispName="$$22338$$Unit Type Selected" varType="unittype"></Param>  
      <Param name="DstPoint" dispName="$$22410$$X" varType="area">0</Param>
      <Param name="Radius" dispName="$$22303$$Radius" VarType="float">10</Param>  
      <!-- We'll get the locations of all the targe units.
      First, we need to get the type of said unit -->
      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=1000000){ if (kbGetUnitTypeName(all)=="%TargetUnitType%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <!-- <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command> -->
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=Qid+3){}</Command>
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetState(Qid,2);</Command> <!-- It seems that that 2 is with state=alive -->

      <Command>kbUnitQuerySetPosition(Qid, vector(%DstPoint%));</Command>
      <Command>kbUnitQuerySetMaximumDistance(Qid, %Radius%);</Command>

      <Command>kbUnitQueryExecute(Qid);</Command>    
      <!-- Maybe we'll use this 
      int kbUnitQueryNumberResults(long queryID)
      Returns the number of results in the current query. -->
      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
      <Command>   trArmyDispatch("%SrcArmy%", "%ProtoName%", %Count%,  xsVectorGetX(kbUnitGetPosition(kbUnitQueryGetResult(Qid, ind))), 0, xsVectorGetZ(kbUnitGetPosition(kbUnitQueryGetResult(Qid, ind))), 0, false);</Command>

      <Command>}</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command>
      <Command>trUnitSelectClear();</Command>
</Effect>



<Effect name="QV Set UnitType Count of Army" > 
      <Param name="SrcArmy" dispName="$$22348$$Army" VarType="group">default</Param>
      <Param name="Player" dispName="Player of Army" VarType="player">1</Param>
      <Param name="UnitType" dispName="$$22302$$Unit Type" varType="unittype"></Param>  
      <Param name="QVName" dispName="QV" varType="string">QV1</Param>

      <Command>for (all=0; &lt;=10000){ if (kbGetUnitTypeName(all)=="%UnitType%") break;}</Command>
      <Command>trUnitSelectClear();</Command>      
      <Command>for(counter=-0;&lt;=0){}</Command>
      <Command>for(un=-1;&lt;=-1){}</Command>
      <Command>trArmySelect("%SrcArmy%");</Command>
      <Command>for(a=trGetNumberSelectedUnitIDs();>=999999){break;}</Command>    
      <Command>if (a != 0){xsSetContextPlayer(%Player%);</Command><!--if we have selected units--> <!-- &excl;= means !=-->
            <Command>for (i=0;&lt;=a){</Command><!--for every unit we have selected-->
                  <Command>un=trGetSelectedUnitID(i);</Command><!--ID of selected unit-->
                  <Command>if(kbUnitIsType(un,all)){</Command><!--if our unit is of unitType-->
                        <Command>counter=counter+1;</Command><!--the counter rises by one-->
                  <Command>}</Command><!--end if(kbUnitIsType(un,all)-->
            <Command>}</Command><!--end for(i=0;<=a)-->
      <Command>}</Command><!--end if (a!=0)-->

</Effect>



<Effect name="Change Units in Area (Center Area)">
<Param name="Position" dispName="$$22410$$X" VarType="area"></Param>

      <Param name="Dist" dispName="$$22298$$Distance" VarType="float">0</Param>
      <Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
      <Param name="FromProtoUnit" dispName="$$22314$$Source Unit" VarType="protounit">Villager</Param>
      <Param name="ToProtoUnit" dispName="$$22296$$Target Unit" varType="protounit">default</Param>
      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=20000){ if (kbGetUnitTypeName(all)=="%FromProtoUnit%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
       <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command> 
      <!--<Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_From_%FromProtoUnit%_To_%ToProtoUnit%");</Command>-->
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetPosition(Qid, vector(%Position%));</Command>
      <Command>kbUnitQuerySetMaximumDistance(Qid, %Dist%);</Command>

      <Command>kbUnitQueryExecute(Qid);</Command> 
      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
            <!--kbUnitQueryGetResult(Qid, ind)-->
            <Command>   trUnitSelectByID(kbUnitQueryGetResult(Qid, ind));</Command>
      <Command>}</Command>
      <Command>trUnitChangeProtoUnit("%ToProtoUnit%");</Command>
      <Command>trUnitSelectClear();</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
      


</Effect>


<Effect name="Change Units">
      <Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
      <Param name="FromProtoUnit" dispName="$$22314$$Source Unit" VarType="protounit">Villager</Param>
      <Param name="ToProtoUnit" dispName="$$22296$$Target Unit" varType="protounit">default</Param>
      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=20000){ if (kbGetUnitTypeName(all)=="%FromProtoUnit%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command> 
      <!-- <Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_From_%FromProtoUnit%_To_%ToProtoUnit%");</Command> -->
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>

      <Command>kbUnitQueryExecute(Qid);</Command> 

      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
            <!--kbUnitQueryGetResult(Qid, ind)-->
            <Command>   trUnitSelectByID(kbUnitQueryGetResult(Qid, ind));</Command>
      <Command>}</Command>
      <Command>trUnitChangeProtoUnit("%ToProtoUnit%");</Command>
      <Command>trUnitSelectClear();</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
</Effect>





<Effect name="Delete All Units of type">
      <Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
      <Param name="ProtoUnit" dispName="$$22314$$Source Unit" VarType="protounit">Villager</Param>



      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=20000){ if (kbGetUnitTypeName(all)=="%ProtoUnit%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command>
      <!-- <Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_From_%ProtoUnit%_To_%ProtoUnit%");</Command> -->
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>

      <Command>kbUnitQueryExecute(Qid);</Command> 

      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
            <!--kbUnitQueryGetResult(Qid, ind)-->
            <Command>trUnitSelectByID(kbUnitQueryGetResult(Qid, ind));</Command>
      <Command>}</Command>
      <Command>trUnitDelete(true);</Command>
      <Command>trUnitSelectClear();</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
</Effect>


<Effect name="Delete units of type (center Area)">
<Param name="Position" dispName="$$22410$$X" VarType="area"></Param>

      <Param name="Dist" dispName="$$22298$$Distance" VarType="float">0</Param>
      <Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
      <Param name="UnitType" dispName="$$22314$$Source Unit" VarType="unittype"></Param>




      <Command>trUnitSelectClear();</Command>
      <Command>for (all=0;&lt;=20000){ if (kbGetUnitTypeName(all)=="%UnitType%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command> 
      <!-- <Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_From_%ProtoUnit%_To_%ProtoUnit%");</Command>-->
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetPosition(Qid, vector(%Position%));</Command>
      <Command>kbUnitQuerySetMaximumDistance(Qid, %Dist%);</Command>

      <Command>kbUnitQueryExecute(Qid);</Command> 
      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
            <!--kbUnitQueryGetResult(Qid, ind)-->
            <Command>trUnitSelectByID(kbUnitQueryGetResult(Qid, ind));</Command>
      <Command>}</Command>
      <Command>trUnitDelete(true);</Command>
      <Command>trUnitSelectClear();</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command> 

</Effect>


<Effect name="Move Units from Area1 to Area2" > 
      
      <Param name="Area1" dispName="Area1" varType="area">0</Param>
      <Param name="Radius" dispName="$$22303$$Radius" VarType="float">10</Param>
      <Param name="Area2" dispName="Area2" varType="area">0</Param>
      <Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
      <Param name="UnitType" dispName="Target UnitType" varType="unittype">All</Param>
      <Param name="AttackMove" dispName="$$18986$$Attack Move" varType="bool">false</Param>
      <Command>for (all=0;&lt;=20000){ if (kbGetUnitTypeName(all)=="%UnitType%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command> 
      <!-- <Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_From_%ProtoUnit%_To_%ProtoUnit%");</Command>-->
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetPosition(Qid, vector(%Area1%));</Command>
      <Command>kbUnitQuerySetMaximumDistance(Qid, %Radius%);</Command>

      <Command>kbUnitQueryExecute(Qid);</Command> 
      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
            <!--kbUnitQueryGetResult(Qid, ind)-->
            <Command>trUnitSelectByID(kbUnitQueryGetResult(Qid, ind));</Command>
      <Command>}</Command>
      <Command>trUnitMoveToPoint(%Area2%, -1, %AttackMove%, false, 1);</Command>
      <Command>trUnitSelectClear();</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
</Effect>


<Effect name="Unit Create Multi at UnitType">
      <Param name="PlayerID" dispName="$$22301$$Player" varType="player">1</Param>
      <Param name="ProtoName" dispName="$$22434$$ProtoName" varType="protounit">Villager</Param>
      <Param name="TargetUnitType" dispName="$$22338$$Unit Type Selected" varType="unittype"></Param> 
      <Param name="Count"  dispName="$$22435$$Count" varType="long">0</Param>
      <Param name="ScenName" dispName="$$20509$$Name" varType="string">Default</Param>
      <Command>for (all=0;&lt;=10000){ if (kbGetUnitTypeName(all)=="%TargetUnitType%") break;}</Command>
      <Command>xsSetContextPlayer(%PlayerID%);</Command>
	  <Command>kbLookAtAllUnitsOnMap();</Command>
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command>
	  <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
	  <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetState(Qid,2);</Command>
      <Command>kbUnitQueryExecute(Qid);</Command>
      <Command>for (i=0; &lt;%Count%){</Command>
      <Command>trUnitCreate("%ProtoName%", "%ScenName%", xsVectorGetX(kbUnitGetPosition(kbUnitQueryGetResult(Qid, 0))), 0, xsVectorGetZ(kbUnitGetPosition(kbUnitQueryGetResult(Qid, 0))), 0, %PlayerID%);}</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
    </Effect>

<Effect name="Unit in Area Work at Unit">
      <Param name="PlayerID" dispName="$$22301$$Player" VarType="player">1</Param>
      <Param name="UnitType" dispName="$$22302$$Unit Type" varType="unittype"></Param>
      <Param name="Radius" dispName="$$22303$$Radius" VarType="float">10</Param>
      <Param name="Position" dispName="$$22410$$X" VarType="area"></Param>
      <Param name="DstObject" dispName="$$22296$$Target Unit" varType="unit">default</Param>
      <Param name="EventID" dispName="$$22362$$Trigger" varType="event">-1</Param>
      <Command>trUnitSelectClear();</Command>

      <Command>for (all=0;&lt;=20000){ if (kbGetUnitTypeName(all)=="%UnitType%") break;}</Command><!-- for (all=0;<=10000) for XS scripting -->
      <Command>xsSetContextPlayer(%PlayerID%);</Command> 
      <Command>kbLookAtAllUnitsOnMap();</Command>
      <Command>for(Qid=kbUnitQueryCreate("QDUA_%PlayerID%_TownCenter");>=99999){}</Command> 
      <!-- <Command>int Qid=kbUnitQueryCreate("QDUA_%PlayerID%_From_%ProtoUnit%_To_%ProtoUnit%");</Command>-->
      <Command>kbUnitQuerySetPlayerID(Qid, %PlayerID%);</Command>
      <Command>kbUnitQuerySetUnitType(Qid, all);</Command>
      <Command>kbUnitQuerySetPosition(Qid, vector(%Position%));</Command>
      <Command>kbUnitQuerySetMaximumDistance(Qid, %Radius%);</Command>

      <Command>kbUnitQueryExecute(Qid);</Command> 
      <Command>for(ind=0; &lt;kbUnitQueryNumberResults(Qid)){</Command>
            <!--kbUnitQueryGetResult(Qid, ind)-->
            <Command>trUnitSelectByID(kbUnitQueryGetResult(Qid, ind));</Command>
      <Command>}</Command>
      <Command>trUnitDoWorkOnUnit("%DstObject%",%EventID%);</Command>
      <Command>trUnitSelectClear();</Command>
      <Command>kbUnitQueryDestroy(Qid);</Command> 
   </Effect>

<!--This is an stock game trigger, I just changed the value of an string-->
<effect name="Modify Player Data">
      <param name="PlayerID" dispname="$$22301$$Player" vartype="player">1</param>
      <param name="Field" dispname="$$25417$$Field" vartype="playerdatafield">0</param>
      <param name="Param" dispname="$$22439$$Parameter" vartype="long">-1</param>
      <param name="Delta" dispname="$$25418$$Delta" vartype="float">1.0</param>
      <param name="Relativity" dispname="$$113173$$Relativity" vartype="purelativity">0</param>
      <command>trModifyPlayerData(%PlayerID%, %Field%, %Param%, %Delta%, %Relativity%);</command>
    </effect>



  </Effects>
</trigger>
1 Like

Also, here’s a slightly modified version of the scenario, including the same homecities and AI’s
lepanto.aoe2scenario (567.1 KB)
For at least a few loops, enemy ships didn’t get stuck. They always got stuck between those two islands near the Town Center shore.

Glad you sorted it out ! :3
Looking at the map, it looks like a ton of work, but much love put into it. Well done.

1 Like

Thanks to you. It wouldn’t have been possible without you, Alistair and others, when you helped me months ago.

1 Like