Ticket #52: Triggers.8.patch
File Triggers.8.patch, 52.4 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/maps/scripts/TriggerHelper.js
1 // Contains standardized functions suitable for using in trigger scripts. 2 // Do not use them in any other simulation script. 3 4 var TriggerHelper = {}; 5 6 TriggerHelper.GetPlayerIDFromEntity = function(ent) 7 { 8 var cmpPlayer = Engine.QueryInterface(ent, IID_Player); 9 if (cmpPlayer) 10 return cmpPlayer.GetPlayerID(); 11 return -1; 12 } 13 14 TriggerHelper.GetOwner = function(ent) 15 { 16 var cmpOwnership = Engine.QueryInterface(ent, IID_Ownership); 17 if (cmpOwnership) 18 return cmpOwnership.GetOwner(); 19 return -1; 20 } 21 22 /** 23 * Can be used to "force" a building to spawn a group of entities. 24 * Only works for buildings that can already train units. 25 * @param source Entity id of the point where they will be spawned from 26 * @param template Name of the template 27 * @param count Number of units to spawn 28 * @param owner Player id of the owner of the new units. By default, the owner 29 * of the source entity. 30 */ 31 TriggerHelper.SpawnUnits = function(source, template, count, owner) 32 { 33 var r = []; // array of entities to return; 34 var cmpFootprint = Engine.QueryInterface(source, IID_Footprint); 35 var cmpPosition = Engine.QueryInterface(source, IID_Position); 36 if (!cmpPosition || !cmpPosition.IsInWorld()) 37 { 38 error("tried to create entity from a source without position"); 39 return r; 40 } 41 if (owner == null) 42 owner = TriggerHelper.GetOwner(source); 43 44 for (var i = 0; i < count; i++) 45 { 46 var ent = Engine.AddEntity(template); 47 var cmpEntPosition = Engine.QueryInterface(ent, IID_Position); 48 if (!cmpEntPosition) 49 { 50 error("tried to create entity without position"); 51 continue; 52 } 53 var cmpEntOwnership = Engine.QueryInterface(ent, IID_Ownership); 54 if (cmpEntOwnership) 55 cmpEntOwnership.SetOwner(owner); 56 r.push(ent); 57 var pos; 58 if (cmpFootprint) 59 pos = cmpFootprint.PickSpawnPoint(ent); 60 // TODO this can happen if the player build on the place 61 // where our trigger point is 62 // We should probably warn the trigger maker in some way, 63 // but not interrupt the game for the player 64 if (!pos || pos.y < 0) 65 pos = cmpPosition.GetPosition(); 66 cmpEntPosition.JumpTo(pos.x, pos.z); 67 } 68 return r; 69 } 70 71 /** 72 * Spawn units from all trigger points with this reference 73 * If player is defined, only spaw units from the trigger points 74 * that belong to that player 75 * @param ref Trigger point reference name to spawn units from 76 * @param template Template name 77 * @param count Number of spawned entities per Trigger point 78 * @param owner Owner of the spawned units. Default: the owner of the origins 79 * @return A list of new entities per origin like 80 * {originId1: [entId1, entId2], originId2: [entId3, entId4], ...} 81 */ 82 TriggerHelper.SpawnUnitsFromTriggerPoints = function(ref, template, count, owner) 83 { 84 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 85 var triggerPoints = cmpTrigger.GetTriggerPoints(ref); 86 var r = {}; 87 for (var point of triggerPoints) 88 r[point] = TriggerHelper.SpawnUnits(point, template, count, owner || null); 89 return r; 90 } 91 92 /** 93 * Returs a function that can be used to filter an array of entities by player 94 */ 95 TriggerHelper.GetPlayerFilter = function(playerID) 96 { 97 return function(entity) { 98 var cmpOwnership = Engine.QueryInterface(entity, IID_Ownership); 99 return cmpOwnership && cmpOwnership.GetOwner() == playerID; 100 } 101 }; 102 103 /** 104 * Shows a message in the top center of the screen 105 */ 106 TriggerHelper.PushGUINotification = function(player, message) 107 { 108 var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface); 109 cmpGUIInterface.PushNotification({"player": player, "message": message}); 110 } 111 112 /** 113 * Returns the resource type that can be gathered from an entity 114 */ 115 TriggerHelper.GetResourceType = function(entity) 116 { 117 var cmpResourceSupply = Engine.QueryInterface(entity, IID_ResourceSupply); 118 if (!cmpResourceSupply) 119 return undefined; 120 return cmpResourceSupply.GetType(); 121 } 122 123 /** 124 * Wins the game for a player 125 */ 126 TriggerHelper.SetPlayerWon = function(playerID) 127 { 128 var cmpEndGameManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_EndGameManager); 129 cmpEndGameManager.MarkPlayerAsWon(playerID); 130 } 131 132 /** 133 * Defeats a player 134 */ 135 TriggerHelper.DefeatPlayer = function(playerID) 136 { 137 var playerEnt = GetPlayerEntityByID(playerID); 138 Engine.PostMessage(playerEnt, MT_PlayerDefeated, { "playerId": playerID } ); 139 } 140 141 Engine.RegisterGlobal("TriggerHelper", TriggerHelper); -
binaries/data/mods/public/maps/skirmishes/Gallic
1 Trigger.prototype.InitGame = function() 2 { 3 this.attackSize = 1; // attack with 1 soldier 4 this.attackTime = 60*1000; // attack in 1 minute 5 this.DoAfterDelay(this.attackTime, "SpawnAndAttack", {}); 6 }; 7 8 Trigger.prototype.SpawnAndAttack = function() 9 { 10 var rand = Math.random(); 11 // randomize spawn points 12 var spawnPoint = rand > 0.5 ? "B" : "C"; 13 var intruders = TriggerHelper.SpawnUnitsFromTriggerPoints(spawnPoint, "units/rome_legionnaire_marian", this.attackSize, 4); 14 for (var origin in intruders) 15 { 16 var playerID = TriggerHelper.GetOwner(+origin); 17 var cmd = null; 18 warn(uneval(this.GetTriggerPoints("A"))); 19 for (var target of this.GetTriggerPoints("A")) 20 { 21 if (TriggerHelper.GetOwner(target) == playerID) 22 { 23 var cmpPosition = Engine.QueryInterface(target, IID_Position); 24 if (!cmpPosition || !cmpPosition.IsInWorld) 25 continue; 26 cmd = cmpPosition.GetPosition(); 27 break; 28 } 29 } 30 if (!cmd) 31 continue; 32 cmd.type = "attack-walk"; 33 cmd.entities = intruders[origin]; 34 cmd.queued = true; 35 ProcessCommand(4, cmd); 36 } 37 // enlarge the attack time and size 38 // multiply with a number between 1 and 3 39 rand = rand * 2 + 1; 40 this.attackTime *= rand; // 41 this.attackSize = Math.round(this.attackSize * rand); 42 this.DoAfterDelay(this.attackTime, "SpawnAndAttack", {}); 43 }; -
binaries/data/mods/public/maps/skirmishes/Gallic
18 18 <Type>default</Type> 19 19 <Colour r="0.219608" g="0.247059" b="0.356863"/> 20 20 <Height>21.0885</Height> 21 <Shininess>250</Shininess>22 21 <Waviness>0.830078</Waviness> 23 22 <Murkiness>0.871094</Murkiness> 24 23 <Tint r="0.592157" g="0.639216" b="0.756863"/> … … 31 30 <Contrast>1.03906</Contrast> 32 31 <Saturation>1.05859</Saturation> 33 32 <Bloom>0.1999</Bloom> 34 <PostEffect> hdr</PostEffect>33 <PostEffect>default</PostEffect> 35 34 </Postproc> 36 35 </Environment> 37 36 <Camera> 38 <Position x="31 9.998" y="82.8692" z="281.119"/>37 <Position x="317.2" y="94.8147" z="272.543"/> 39 38 <Rotation angle="0"/> 40 39 <Declination angle="0.610865"/> 41 40 </Camera> … … 42 41 <ScriptSettings><![CDATA[ 43 42 { 44 43 "CircularMap": true, 45 "Description": "Defend your Gallic outpost against attacks from your treacherous neighbors!\ u000a\u000aEach player begins the match with a wooden palisade and some guard towers atop a low embankment.",44 "Description": "Defend your Gallic outpost against attacks from your treacherous neighbors!\n\nEach player begins the match with a wooden palisade and some guard towers atop a low embankment.", 46 45 "GameType": "conquest", 47 46 "Keywords": [], 48 47 "LockTeams": false, … … 92 91 "z": 0 93 92 } 94 93 } 94 }, 95 { 96 "AI": "", 97 "Civ": "rome", 98 "Colour": { 99 "b": 0, 100 "g": 0, 101 "r": 0 102 }, 103 "Name": "Roman Intruders" 95 104 } 96 105 ], 97 106 "Preview": "gallic_fields.png", 98 "RevealMap": false 107 "RevealMap": false, 108 "TriggerScripts": [ 109 "scripts/TriggerHelper.js", 110 "skirmishes/Gallic Fields (3).js" 111 ] 99 112 } 100 113 ]]></ScriptSettings> 101 114 <Entities> … … 102 115 <Entity uid="11"> 103 116 <Template>other/palisades_rocks_end</Template> 104 117 <Player>1</Player> 105 <Position x="29 5.88685" z="356.25528"/>118 <Position x="294.88245" z="356.23978"/> 106 119 <Orientation y="0.798"/> 107 120 </Entity> 108 121 <Entity uid="12"> … … 121 134 <Entity uid="14"> 122 135 <Template>other/palisades_rocks_straight</Template> 123 136 <Player>1</Player> 124 <Position x="29 2.38743" z="360.26392"/>137 <Position x="291.22764" z="360.21152"/> 125 138 <Orientation y="2.35621"/> 126 139 </Entity> 127 140 <Entity uid="15"> … … 168 181 <Entity uid="22"> 169 182 <Template>other/palisades_rocks_end</Template> 170 183 <Player>1</Player> 171 <Position x="303. 05506" z="348.4564"/>184 <Position x="303.45963" z="346.65308"/> 172 185 <Orientation y="0.78141"/> 173 186 </Entity> 174 187 <Entity uid="23"> 175 188 <Template>other/palisades_rocks_straight</Template> 176 189 <Player>1</Player> 177 <Position x="307. 17038" z="344.4105"/>190 <Position x="307.9816" z="343.59192"/> 178 191 <Orientation y="-0.85848"/> 179 192 <Obstruction group="25"/> 180 193 </Entity> … … 1110 1123 </Entity> 1111 1124 <Entity uid="204"> 1112 1125 <Template>actor|props/special/eyecandy/campfire.xml</Template> 1113 <Position x=" 234.88781" z="354.48206"/>1126 <Position x="314.00892" z="344.64301"/> 1114 1127 <Orientation y="-0.68833"/> 1115 1128 </Entity> 1116 1129 <Entity uid="207"> … … 1137 1150 <Entity uid="211"> 1138 1151 <Template>other/palisades_rocks_straight</Template> 1139 1152 <Player>2</Player> 1140 <Position x="659. 87806" z="317.39954"/>1153 <Position x="659.07789" z="317.60355"/> 1141 1154 <Orientation y="2.35621"/> 1142 1155 </Entity> 1143 1156 <Entity uid="212"> 1144 1157 <Template>other/palisades_rocks_straight</Template> 1145 1158 <Player>2</Player> 1146 <Position x="67 5.45868" z="302.58637"/>1159 <Position x="676.4245" z="301.6601"/> 1147 1160 <Orientation y="2.35621"/> 1148 1161 </Entity> 1149 1162 <Entity uid="213"> … … 1155 1168 <Entity uid="214"> 1156 1169 <Template>other/palisades_rocks_end</Template> 1157 1170 <Player>2</Player> 1158 <Position x="66 3.99408" z="312.55082"/>1171 <Position x="662.63178" z="313.97724"/> 1159 1172 <Orientation y="0.85485"/> 1160 1173 </Entity> 1161 1174 <Entity uid="215"> 1162 1175 <Template>other/palisades_rocks_end</Template> 1163 1176 <Player>2</Player> 1164 <Position x="67 1.18451" z="306.51273"/>1177 <Position x="672.49067" z="304.99943"/> 1165 1178 <Orientation y="0.98328"/> 1166 1179 </Entity> 1167 1180 <Entity uid="216"> … … 6651 6664 <Entity uid="1183"> 6652 6665 <Template>gaia/geology_metal_temperate_slabs</Template> 6653 6666 <Player>0</Player> 6654 <Position x="465. 51719" z="895.96827"/>6667 <Position x="465.05253" z="896.6153"/> 6655 6668 <Orientation y="-2.38521"/> 6656 6669 </Entity> 6657 6670 <Entity uid="1186"> … … 6663 6676 <Entity uid="1187"> 6664 6677 <Template>gaia/geology_metal_temperate_slabs</Template> 6665 6678 <Player>0</Player> 6666 <Position x="308. 97324" z="519.42872"/>6679 <Position x="308.34995" z="518.51514"/> 6667 6680 <Orientation y="0.52384"/> 6668 6681 </Entity> 6669 6682 <Entity uid="1188"> … … 6710 6723 </Entity> 6711 6724 <Entity uid="1195"> 6712 6725 <Template>actor|props/special/eyecandy/campfire.xml</Template> 6713 <Position x=" 749.89032" z="252.34638"/>6726 <Position x="682.956" z="303.30494"/> 6714 6727 <Orientation y="2.35621"/> 6715 6728 </Entity> 6716 6729 <Entity uid="1196"> 6717 6730 <Template>actor|props/special/eyecandy/campfire.xml</Template> 6718 <Position x="5 52.42939" z="833.2547"/>6731 <Position x="521.8979" z="722.24482"/> 6719 6732 <Orientation y="2.35621"/> 6720 6733 </Entity> 6721 6734 <Entity uid="1199"> … … 6779 6792 <Entity uid="1208"> 6780 6793 <Template>other/palisades_rocks_end</Template> 6781 6794 <Player>3</Player> 6782 <Position x="51 0.82416" z="726.23407"/>6795 <Position x="511.0652" z="724.964"/> 6783 6796 <Orientation y="0.70745"/> 6784 6797 </Entity> 6785 6798 <Entity uid="1209"> … … 16533 16546 <Entity uid="2847"> 16534 16547 <Template>other/palisades_angle_spike</Template> 16535 16548 <Player>2</Player> 16536 <Position x="6 60.00635" z="309.53974"/>16549 <Position x="659.4004" z="310.76008"/> 16537 16550 <Orientation y="-1.15148"/> 16538 16551 </Entity> 16539 16552 <Entity uid="2848"> … … 17374 17387 <Position x="753.04261" z="99.05979"/> 17375 17388 <Orientation y="1.04381"/> 17376 17389 </Entity> 17377 <Entity uid="2999">17378 <Template>units/rome_legionnaire_marian</Template>17379 <Player>0</Player>17380 <Position x="970.68488" z="556.81086"/>17381 <Orientation y="3.03232"/>17382 </Entity>17383 <Entity uid="3000">17384 <Template>units/rome_legionnaire_marian</Template>17385 <Player>0</Player>17386 <Position x="972.51838" z="558.22272"/>17387 <Orientation y="2.35621"/>17388 </Entity>17389 <Entity uid="3001">17390 <Template>units/rome_legionnaire_marian</Template>17391 <Player>0</Player>17392 <Position x="973.98511" z="559.8733"/>17393 <Orientation y="2.35621"/>17394 </Entity>17395 <Entity uid="3002">17396 <Template>units/rome_legionnaire_marian</Template>17397 <Player>0</Player>17398 <Position x="975.47876" z="561.45289"/>17399 <Orientation y="2.35621"/>17400 </Entity>17401 <Entity uid="3003">17402 <Template>units/rome_legionnaire_marian</Template>17403 <Player>0</Player>17404 <Position x="977.06482" z="563.13013"/>17405 <Orientation y="2.35621"/>17406 </Entity>17407 <Entity uid="3004">17408 <Template>units/rome_legionnaire_marian</Template>17409 <Player>0</Player>17410 <Position x="978.44092" z="564.00824"/>17411 <Orientation y="2.35621"/>17412 </Entity>17413 <Entity uid="3005">17414 <Template>units/rome_legionnaire_marian</Template>17415 <Player>0</Player>17416 <Position x="980.35376" z="565.84992"/>17417 <Orientation y="2.35621"/>17418 </Entity>17419 <Entity uid="3006">17420 <Template>units/rome_legionnaire_marian</Template>17421 <Player>0</Player>17422 <Position x="972.39826" z="554.17463"/>17423 <Orientation y="2.35621"/>17424 </Entity>17425 <Entity uid="3007">17426 <Template>units/rome_legionnaire_marian</Template>17427 <Player>0</Player>17428 <Position x="973.7862" z="555.21351"/>17429 <Orientation y="2.35621"/>17430 </Entity>17431 <Entity uid="3008">17432 <Template>units/rome_legionnaire_marian</Template>17433 <Player>0</Player>17434 <Position x="975.35413" z="556.52253"/>17435 <Orientation y="2.35621"/>17436 </Entity>17437 <Entity uid="3009">17438 <Template>units/rome_legionnaire_marian</Template>17439 <Player>0</Player>17440 <Position x="977.14277" z="557.90491"/>17441 <Orientation y="2.35621"/>17442 </Entity>17443 <Entity uid="3010">17444 <Template>units/rome_legionnaire_marian</Template>17445 <Player>0</Player>17446 <Position x="979.14362" z="560.13013"/>17447 <Orientation y="2.35621"/>17448 </Entity>17449 <Entity uid="3011">17450 <Template>units/rome_legionnaire_marian</Template>17451 <Player>0</Player>17452 <Position x="981.0542" z="562.00068"/>17453 <Orientation y="2.35621"/>17454 </Entity>17455 <Entity uid="3012">17456 <Template>units/rome_legionnaire_marian</Template>17457 <Player>0</Player>17458 <Position x="77.18448" z="734.07874"/>17459 <Orientation y="2.35621"/>17460 </Entity>17461 <Entity uid="3013">17462 <Template>units/rome_legionnaire_marian</Template>17463 <Player>0</Player>17464 <Position x="81.05483" z="729.54395"/>17465 <Orientation y="2.35621"/>17466 </Entity>17467 <Entity uid="3014">17468 <Template>units/rome_legionnaire_marian</Template>17469 <Player>0</Player>17470 <Position x="84.24665" z="726.56165"/>17471 <Orientation y="2.35621"/>17472 </Entity>17473 <Entity uid="3015">17474 <Template>units/rome_legionnaire_marian</Template>17475 <Player>0</Player>17476 <Position x="87.00104" z="723.6255"/>17477 <Orientation y="2.35621"/>17478 </Entity>17479 <Entity uid="3016">17480 <Template>units/rome_legionnaire_marian</Template>17481 <Player>0</Player>17482 <Position x="89.71207" z="721.23298"/>17483 <Orientation y="2.35621"/>17484 </Entity>17485 <Entity uid="3017">17486 <Template>units/rome_legionnaire_marian</Template>17487 <Player>0</Player>17488 <Position x="92.41475" z="718.40687"/>17489 <Orientation y="2.35621"/>17490 </Entity>17491 <Entity uid="3018">17492 <Template>units/rome_legionnaire_marian</Template>17493 <Player>0</Player>17494 <Position x="76.13277" z="728.19819"/>17495 <Orientation y="2.35621"/>17496 </Entity>17497 <Entity uid="3019">17498 <Template>units/rome_legionnaire_marian</Template>17499 <Player>0</Player>17500 <Position x="79.16231" z="724.68097"/>17501 <Orientation y="2.35621"/>17502 </Entity>17503 <Entity uid="3020">17504 <Template>units/rome_legionnaire_marian</Template>17505 <Player>0</Player>17506 <Position x="82.15836" z="722.10785"/>17507 <Orientation y="2.35621"/>17508 </Entity>17509 <Entity uid="3021">17510 <Template>units/rome_legionnaire_marian</Template>17511 <Player>0</Player>17512 <Position x="84.53042" z="719.02094"/>17513 <Orientation y="2.35621"/>17514 </Entity>17515 <Entity uid="3022">17516 <Template>units/rome_legionnaire_marian</Template>17517 <Player>0</Player>17518 <Position x="86.45192" z="717.38465"/>17519 <Orientation y="2.35621"/>17520 </Entity>17521 <Entity uid="3023">17522 <Template>units/rome_legionnaire_marian</Template>17523 <Player>0</Player>17524 <Position x="89.43009" z="714.60633"/>17525 <Orientation y="2.35621"/>17526 </Entity>17527 <Entity uid="3024">17528 <Template>units/rome_centurio_imperial</Template>17529 <Player>0</Player>17530 <Position x="92.5489" z="711.15864"/>17531 <Orientation y="2.35621"/>17532 </Entity>17533 17390 <Entity uid="3025"> 17534 17391 <Template>actor|props/flora/grass_temp_field.xml</Template> 17535 17392 <Position x="141.20521" z="450.51584"/> … … 21341 21198 <Entity uid="3811"> 21342 21199 <Template>skirmish/structures/default_civil_centre</Template> 21343 21200 <Player>1</Player> 21344 <Position x=" 239.23588" z="381.94343"/>21345 <Orientation y=" 2.35621"/>21201 <Position x="315.77839" z="370.3028"/> 21202 <Orientation y="-2.36886"/> 21346 21203 <Actor seed="16580"/> 21347 21204 </Entity> 21348 21205 <Entity uid="3812"> 21349 21206 <Template>skirmish/structures/default_civil_centre</Template> 21350 21207 <Player>3</Player> 21351 <Position x="52 7.66474" z="848.21656"/>21352 <Orientation y=" 2.35621"/>21208 <Position x="523.39856" z="748.0907"/> 21209 <Orientation y="-2.34481"/> 21353 21210 <Actor seed="17534"/> 21354 21211 </Entity> 21355 21212 <Entity uid="3816"> 21356 21213 <Template>skirmish/structures/default_civil_centre</Template> 21357 21214 <Player>2</Player> 21358 <Position x=" 767.4936" z="271.0109"/>21359 <Orientation y=" 2.35621"/>21215 <Position x="685.83143" z="328.27808"/> 21216 <Orientation y="-2.35285"/> 21360 21217 <Actor seed="55570"/> 21361 21218 </Entity> 21362 21219 <Entity uid="3817"> 21363 21220 <Template>skirmish/units/default_support_female_citizen</Template> 21364 21221 <Player>1</Player> 21365 <Position x=" 316.14179" z="361.27659"/>21366 <Orientation y=" 2.35621"/>21222 <Position x="286.50174" z="351.76655"/> 21223 <Orientation y="-2.43998"/> 21367 21224 <Actor seed="30368"/> 21368 21225 </Entity> 21369 21226 <Entity uid="3818"> 21370 21227 <Template>skirmish/units/default_support_female_citizen</Template> 21371 21228 <Player>1</Player> 21372 <Position x=" 319.06141" z="362.49521"/>21373 <Orientation y=" 2.35621"/>21229 <Position x="288.83237" z="348.57682"/> 21230 <Orientation y="-2.39516"/> 21374 21231 <Actor seed="60030"/> 21375 21232 </Entity> 21376 21233 <Entity uid="3819"> 21377 21234 <Template>skirmish/units/default_support_female_citizen</Template> 21378 21235 <Player>1</Player> 21379 <Position x=" 321.54096" z="365.64322"/>21380 <Orientation y=" 2.35621"/>21236 <Position x="291.62256" z="345.56531"/> 21237 <Orientation y="-2.19112"/> 21381 21238 <Actor seed="47546"/> 21382 21239 </Entity> 21383 21240 <Entity uid="3820"> 21384 21241 <Template>skirmish/units/default_support_female_citizen</Template> 21385 21242 <Player>1</Player> 21386 <Position x=" 323.98121" z="367.75641"/>21387 <Orientation y=" 2.35621"/>21243 <Position x="294.58683" z="343.1308"/> 21244 <Orientation y="-2.32752"/> 21388 21245 <Actor seed="1760"/> 21389 21246 </Entity> 21390 21247 <Entity uid="3821"> 21391 21248 <Template>skirmish/units/default_infantry_ranged_b</Template> 21392 21249 <Player>1</Player> 21393 <Position x=" 314.0546" z="367.51511"/>21394 <Orientation y=" 2.35621"/>21250 <Position x="288.53586" z="342.8498"/> 21251 <Orientation y="-2.52224"/> 21395 21252 <Actor seed="55684"/> 21396 21253 </Entity> 21397 21254 <Entity uid="3822"> 21398 21255 <Template>skirmish/units/default_infantry_ranged_b</Template> 21399 21256 <Player>1</Player> 21400 <Position x=" 317.72864" z="371.85798"/>21401 <Orientation y=" 2.35621"/>21257 <Position x="291.71335" z="339.68445"/> 21258 <Orientation y="-2.46946"/> 21402 21259 <Actor seed="1248"/> 21403 21260 </Entity> 21404 21261 <Entity uid="3823"> 21405 21262 <Template>skirmish/units/default_infantry_melee_b</Template> 21406 21263 <Player>1</Player> 21407 <Position x=" 309.72019" z="372.82026"/>21408 <Orientation y=" 2.35621"/>21264 <Position x="282.46702" z="348.87024"/> 21265 <Orientation y="-2.15017"/> 21409 21266 <Actor seed="54924"/> 21410 21267 </Entity> 21411 21268 <Entity uid="3824"> 21412 21269 <Template>skirmish/units/default_infantry_melee_b</Template> 21413 21270 <Player>1</Player> 21414 <Position x=" 314.19504" z="376.1663"/>21415 <Orientation y=" 2.35621"/>21271 <Position x="285.23688" z="345.27958"/> 21272 <Orientation y="-2.3676"/> 21416 21273 <Actor seed="47532"/> 21417 21274 </Entity> 21418 21275 <Entity uid="3825"> 21419 21276 <Template>skirmish/units/default_cavalry</Template> 21420 21277 <Player>1</Player> 21421 <Position x="30 9.51676" z="363.01691"/>21278 <Position x="301.85553" z="330.77414"/> 21422 21279 <Orientation y="2.35621"/> 21423 21280 <Actor seed="29612"/> 21424 21281 </Entity> … … 21425 21282 <Entity uid="3826"> 21426 21283 <Template>skirmish/units/special_starting_unit</Template> 21427 21284 <Player>1</Player> 21428 <Position x=" 323.20731" z="377.55848"/>21429 <Orientation y=" 2.35621"/>21285 <Position x="299.36615" z="337.60267"/> 21286 <Orientation y="-2.3836"/> 21430 21287 <Actor seed="1602"/> 21431 21288 </Entity> 21432 21289 <Entity uid="3827"> 21433 21290 <Template>skirmish/units/special_starting_unit</Template> 21434 21291 <Player>2</Player> 21435 <Position x="6 93.55298" z="336.7509"/>21436 <Orientation y=" 2.35621"/>21292 <Position x="668.57801" z="280.49256"/> 21293 <Orientation y="-2.54137"/> 21437 21294 <Actor seed="25036"/> 21438 21295 </Entity> 21439 21296 <Entity uid="3828"> 21440 21297 <Template>skirmish/units/default_support_female_citizen</Template> 21441 21298 <Player>2</Player> 21442 <Position x="6 94.90522" z="326.74988"/>21443 <Orientation y=" 2.35621"/>21299 <Position x="661.33979" z="286.86234"/> 21300 <Orientation y="-2.47521"/> 21444 21301 <Actor seed="32418"/> 21445 21302 </Entity> 21446 21303 <Entity uid="3829"> 21447 21304 <Template>skirmish/units/default_support_female_citizen</Template> 21448 21305 <Player>2</Player> 21449 <Position x="6 91.91431" z="323.88428"/>21450 <Orientation y=" 2.35621"/>21306 <Position x="657.65174" z="289.3094"/> 21307 <Orientation y="-2.48824"/> 21451 21308 <Actor seed="35654"/> 21452 21309 </Entity> 21453 21310 <Entity uid="3830"> 21454 21311 <Template>skirmish/units/default_support_female_citizen</Template> 21455 21312 <Player>2</Player> 21456 <Position x="6 89.04792" z="321.44837"/>21457 <Orientation y=" 2.35621"/>21313 <Position x="654.4134" z="291.68458"/> 21314 <Orientation y="-2.5247"/> 21458 21315 <Actor seed="36594"/> 21459 21316 </Entity> 21460 21317 <Entity uid="3831"> 21461 21318 <Template>skirmish/units/default_support_female_citizen</Template> 21462 21319 <Player>2</Player> 21463 <Position x="6 86.10358" z="318.28064"/>21464 <Orientation y=" 2.35621"/>21320 <Position x="664.43836" z="284.97123"/> 21321 <Orientation y="-2.40302"/> 21465 21322 <Actor seed="47756"/> 21466 21323 </Entity> 21467 21324 <Entity uid="3832"> 21468 21325 <Template>skirmish/units/default_infantry_ranged_b</Template> 21469 21326 <Player>2</Player> 21470 <Position x="6 85.26685" z="324.64563"/>21471 <Orientation y=" 2.35621"/>21327 <Position x="659.04743" z="284.47364"/> 21328 <Orientation y="-2.3304"/> 21472 21329 <Actor seed="17548"/> 21473 21330 </Entity> 21474 21331 <Entity uid="3833"> 21475 21332 <Template>skirmish/units/default_infantry_ranged_b</Template> 21476 21333 <Player>2</Player> 21477 <Position x="6 88.90973" z="328.2623"/>21478 <Orientation y=" 2.35621"/>21334 <Position x="661.84583" z="282.5123"/> 21335 <Orientation y="-2.25824"/> 21479 21336 <Actor seed="57312"/> 21480 21337 </Entity> 21481 21338 <Entity uid="3834"> 21482 21339 <Template>skirmish/units/default_infantry_melee_b</Template> 21483 21340 <Player>2</Player> 21484 <Position x="6 82.29615" z="327.98316"/>21485 <Orientation y=" 2.35621"/>21341 <Position x="650.94666" z="289.72001"/> 21342 <Orientation y="-2.43978"/> 21486 21343 <Actor seed="14636"/> 21487 21344 </Entity> 21488 21345 <Entity uid="3835"> 21489 21346 <Template>skirmish/units/default_infantry_melee_b</Template> 21490 21347 <Player>2</Player> 21491 <Position x="6 85.56696" z="331.46177"/>21492 <Orientation y=" 2.35621"/>21348 <Position x="654.04712" z="286.56611"/> 21349 <Orientation y="-2.34855"/> 21493 21350 <Actor seed="31084"/> 21494 21351 </Entity> 21495 21352 <Entity uid="3836"> 21496 21353 <Template>skirmish/units/default_cavalry</Template> 21497 21354 <Player>2</Player> 21498 <Position x="6 78.50678" z="321.68516"/>21499 <Orientation y=" 2.35621"/>21355 <Position x="647.3246" z="294.96366"/> 21356 <Orientation y="-0.79264"/> 21500 21357 <Actor seed="18606"/> 21501 21358 </Entity> 21502 21359 <Entity uid="3837"> 21503 21360 <Template>skirmish/units/default_cavalry</Template> 21504 21361 <Player>3</Player> 21505 <Position x=" 516.73243" z="741.3246"/>21362 <Position x="484.73737" z="727.24762"/> 21506 21363 <Orientation y="2.35621"/> 21507 21364 <Actor seed="59048"/> 21508 21365 </Entity> … … 21509 21366 <Entity uid="3838"> 21510 21367 <Template>skirmish/units/special_starting_unit</Template> 21511 21368 <Player>3</Player> 21512 <Position x="5 31.98261" z="755.25342"/>21513 <Orientation y=" 2.35621"/>21369 <Position x="503.17258" z="711.00068"/> 21370 <Orientation y="-2.29906"/> 21514 21371 <Actor seed="27278"/> 21515 21372 </Entity> 21516 21373 <Entity uid="3839"> 21517 21374 <Template>skirmish/units/default_support_female_citizen</Template> 21518 21375 <Player>3</Player> 21519 <Position x=" 524.79883" z="739.31244"/>21520 <Orientation y=" 2.35621"/>21376 <Position x="489.29926" z="723.40064"/> 21377 <Orientation y="-2.40946"/> 21521 21378 <Actor seed="59166"/> 21522 21379 </Entity> 21523 21380 <Entity uid="3840"> 21524 21381 <Template>skirmish/units/default_support_female_citizen</Template> 21525 21382 <Player>3</Player> 21526 <Position x=" 527.6792" z="741.84394"/>21527 <Orientation y=" 2.35621"/>21383 <Position x="492.23334" z="720.72028"/> 21384 <Orientation y="-2.35325"/> 21528 21385 <Actor seed="64072"/> 21529 21386 </Entity> 21530 21387 <Entity uid="3841"> 21531 21388 <Template>skirmish/units/default_support_female_citizen</Template> 21532 21389 <Player>3</Player> 21533 <Position x=" 529.89551" z="744.12824"/>21534 <Orientation y=" 2.35621"/>21390 <Position x="494.82197" z="717.45392"/> 21391 <Orientation y="-2.43023"/> 21535 21392 <Actor seed="43676"/> 21536 21393 </Entity> 21537 21394 <Entity uid="3842"> 21538 21395 <Template>skirmish/units/default_support_female_citizen</Template> 21539 21396 <Player>3</Player> 21540 <Position x=" 531.95746" z="746.8393"/>21541 <Orientation y=" 2.35621"/>21397 <Position x="497.54026" z="714.9253"/> 21398 <Orientation y="-2.3855"/> 21542 21399 <Actor seed="1922"/> 21543 21400 </Entity> 21544 21401 <Entity uid="3843"> 21545 21402 <Template>skirmish/units/default_infantry_ranged_b</Template> 21546 21403 <Player>3</Player> 21547 <Position x=" 523.41059" z="746.25391"/>21548 <Orientation y=" 2.35621"/>21404 <Position x="490.90238" z="713.38813"/> 21405 <Orientation y="-2.38874"/> 21549 21406 <Actor seed="13916"/> 21550 21407 </Entity> 21551 21408 <Entity uid="3844"> 21552 21409 <Template>skirmish/units/default_infantry_ranged_b</Template> 21553 21410 <Player>3</Player> 21554 <Position x=" 526.80774" z="749.2635"/>21555 <Orientation y=" 2.35621"/>21411 <Position x="493.89939" z="710.90583"/> 21412 <Orientation y="-2.30419"/> 21556 21413 <Actor seed="12714"/> 21557 21414 </Entity> 21558 21415 <Entity uid="3845"> 21559 21416 <Template>skirmish/units/default_infantry_melee_b</Template> 21560 21417 <Player>3</Player> 21561 <Position x=" 519.40992" z="749.89112"/>21562 <Orientation y=" 2.35621"/>21418 <Position x="485.82453" z="718.97492"/> 21419 <Orientation y="-2.51786"/> 21563 21420 <Actor seed="4366"/> 21564 21421 </Entity> 21565 21422 <Entity uid="3846"> 21566 21423 <Template>skirmish/units/default_infantry_melee_b</Template> 21567 21424 <Player>3</Player> 21568 <Position x=" 522.232" z="753.85303"/>21569 <Orientation y=" 2.35621"/>21425 <Position x="488.66263" z="715.99323"/> 21426 <Orientation y="-2.11153"/> 21570 21427 <Actor seed="11530"/> 21571 21428 </Entity> 21572 21429 <Entity uid="3847"> … … 21828 21685 <Orientation y="-2.44382"/> 21829 21686 <Actor seed="8060"/> 21830 21687 </Entity> 21688 <Entity uid="3884"> 21689 <Template>gaia/geology_metal_alpine_slabs</Template> 21690 <Player>0</Player> 21691 <Position x="621.19056" z="674.04084"/> 21692 <Orientation y="2.35621"/> 21693 <Actor seed="12993"/> 21694 </Entity> 21695 <Entity uid="3885"> 21696 <Template>gaia/geology_metal_alpine_slabs</Template> 21697 <Player>0</Player> 21698 <Position x="409.23316" z="284.92985"/> 21699 <Orientation y="2.35621"/> 21700 <Actor seed="15772"/> 21701 </Entity> 21702 <Entity uid="3886"> 21703 <Template>gaia/geology_metal_alpine_slabs</Template> 21704 <Player>0</Player> 21705 <Position x="810.04609" z="415.72138"/> 21706 <Orientation y="2.35621"/> 21707 <Actor seed="25542"/> 21708 </Entity> 21709 <Entity uid="3887"> 21710 <Template>special/trigger_point_A</Template> 21711 <Player>1</Player> 21712 <Position x="292.92002" z="368.14585"/> 21713 <Orientation y="2.35621"/> 21714 <Actor seed="26096"/> 21715 </Entity> 21716 <Entity uid="3888"> 21717 <Template>special/trigger_point_A</Template> 21718 <Player>2</Player> 21719 <Position x="662.54566" z="323.72318"/> 21720 <Orientation y="2.35621"/> 21721 <Actor seed="18425"/> 21722 </Entity> 21723 <Entity uid="3889"> 21724 <Template>special/trigger_point_A</Template> 21725 <Player>3</Player> 21726 <Position x="523.7657" z="723.42896"/> 21727 <Orientation y="2.35621"/> 21728 <Actor seed="37001"/> 21729 </Entity> 21730 <Entity uid="3890"> 21731 <Template>special/trigger_point_B</Template> 21732 <Player>1</Player> 21733 <Position x="75.07139" z="728.80024"/> 21734 <Orientation y="2.35621"/> 21735 <Actor seed="24830"/> 21736 </Entity> 21737 <Entity uid="3891"> 21738 <Template>special/trigger_point_B</Template> 21739 <Player>1</Player> 21740 <Position x="386.49943" z="977.79816"/> 21741 <Orientation y="2.92797"/> 21742 <Actor seed="38620"/> 21743 </Entity> 21744 <Entity uid="3892"> 21745 <Template>special/trigger_point_B</Template> 21746 <Player>2</Player> 21747 <Position x="999.63575" z="573.85212"/> 21748 <Orientation y="-2.25284"/> 21749 <Actor seed="19865"/> 21750 </Entity> 21751 <Entity uid="3893"> 21752 <Template>special/trigger_point_C</Template> 21753 <Player>3</Player> 21754 <Position x="674.91651" z="973.77472"/> 21755 <Orientation y="3.08518"/> 21756 <Actor seed="27478"/> 21757 </Entity> 21758 <Entity uid="3894"> 21759 <Template>special/trigger_point_C</Template> 21760 <Player>1</Player> 21761 <Position x="134.2328" z="198.3071"/> 21762 <Orientation y="0.8109"/> 21763 <Actor seed="20758"/> 21764 </Entity> 21765 <Entity uid="3895"> 21766 <Template>special/trigger_point_C</Template> 21767 <Player>2</Player> 21768 <Position x="823.534" z="126.00896"/> 21769 <Orientation y="2.35621"/> 21770 <Actor seed="7871"/> 21771 </Entity> 21831 21772 </Entities> 21832 21773 <Paths/> 21833 </Scenario> 21834 No newline at end of file 21774 </Scenario> -
binaries/data/mods/public/simulation/components/Foundation.js
202 202 // (via CCmpTemplateManager). Now we need to remove that temporary 203 203 // blocker-disabling, so that we'll perform standard unit blocking instead. 204 204 cmpObstruction.SetDisableBlockMovementPathfinding(false, false, -1); 205 206 // Call the related trigger event 207 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 208 cmpTrigger.CallEvent("ConstructionStarted", {"foundation": this.entity, "template": this.finalTemplateName}); 205 209 } 206 210 207 211 // Switch foundation to scaffold variant -
binaries/data/mods/public/simulation/components/ProductionQueue.js
288 288 "timeTotal": time*1000, 289 289 "timeRemaining": time*1000, 290 290 }); 291 292 // Call the related trigger event 293 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 294 cmpTrigger.CallEvent("TrainingQueued", {"playerid": cmpPlayer.GetPlayerID(), "unitTemplate": templateName, "count": count, "metadata": metadata, "trainerEntity": this.entity}); 291 295 } 292 296 else if (type == "technology") 293 297 { … … 324 328 "timeTotal": time*1000, 325 329 "timeRemaining": time*1000, 326 330 }); 331 332 // Call the related trigger event 333 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 334 cmpTrigger.CallEvent("ResearchQueued", {"playerid": cmpPlayer.GetPlayerID(), "technologyTemplate": templateName, "researcherEntity": this.entity}); 327 335 } 328 336 else 329 337 { -
binaries/data/mods/public/simulation/components/TechnologyManager.js
348 348 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 349 349 var ents = cmpRangeManager.GetEntitiesByPlayer(playerID); 350 350 351 // Call the related trigger event 352 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 353 cmpTrigger.CallEvent("ResearchFinished", {"player": playerID, "tech": tech}); 354 351 355 for (var component in modifiedComponents) 352 356 { 353 357 Engine.PostMessage(SYSTEM_ENTITY, MT_TemplateModification, { "player": playerID, "component": component, "valueNames": modifiedComponents[component]}); -
binaries/data/mods/public/simulation/components/Trigger.js
1 function Trigger() {}; 2 3 Trigger.prototype.Schema = 4 "<a:component type='system'/><empty/>"; 5 6 /** 7 * Events we're able to receive and call handlers for 8 */ 9 Trigger.prototype.eventNames = 10 [ 11 "StructureBuilt", 12 "ConstructionStarted", 13 "TrainingFinished", 14 "TrainingQueued", 15 "ResearchFinished", 16 "ResearchQueued", 17 "PlayerCommand", 18 "Interval", 19 "Range", 20 ]; 21 22 Trigger.prototype.Init = function() 23 { 24 this.triggerPoints = {}; 25 26 // Each event has its own set of actions determined by the map maker. 27 for each (var eventName in this.eventNames) 28 this["On" + eventName + "Actions"] = {}; 29 30 // To prevent the lose of trigger variables after a save, they "should" be defined in "InitTriggers" function, which is the starting point of a trigger script 31 this.DoAfterDelay(0, "InitGame", {}); 32 }; 33 34 Trigger.prototype.InitGame = function() 35 { 36 }; 37 38 Trigger.prototype.RegisterTriggerPoint = function(ref, ent) 39 { 40 if (!this.triggerPoints[ref]) 41 this.triggerPoints[ref] = []; 42 this.triggerPoints[ref].push(ent); 43 }; 44 45 Trigger.prototype.RemoveRegisteredTriggerPoint = function(ref, ent) 46 { 47 if (!this.triggerPoints[ref]) 48 return; 49 var i = this.triggerPoints[ref].indexOf(ent); 50 if (i != -1) 51 this.triggerPoints[ref].splice(i, 1); 52 }; 53 54 Trigger.prototype.GetTriggerPoints = function(ref) 55 { 56 return this.triggerPoints[ref] || []; 57 }; 58 59 /** Binds the "action" function to one of the implemented events. 60 * 61 * @param event Name of the event (see the list in init) 62 * @param action Functionname of a function available under this object 63 * @param Extra Data for the trigger (enabled or not, delay for timers, range for range triggers ...) 64 * 65 * Interval triggers example: 66 * data = {enabled: true, interval: 1000, delay: 500} 67 * 68 * Range trigger: 69 * data.entities = [id1, id2] * Ids of the source 70 * data.players = [1,2,3,...] * list of player ids 71 * data.minRange = 0 * Minimum range for the query 72 * data.maxRange = -1 * Maximum range for the query (-1 = no maximum) 73 * data.requiredComponent = 0 * Required component id the entities will have 74 * data.enabled = false * If the query is enabled by default 75 */ 76 Trigger.prototype.RegisterTrigger = function(event, action, data) 77 { 78 var eventString = event + "Actions"; 79 if (!this[eventString]) 80 { 81 warn("Trigger.js: Invalid trigger event \"" + event + "\".") 82 return; 83 } 84 if (this[eventString][action]) 85 { 86 warn("Trigger.js: Trigger has been registered before. Aborting..."); 87 return; 88 } 89 // clone the data to be sure it's only modified locally 90 // We could run into triggers overwriting each other's data otherwise. 91 // F.e. getting the wrong timer tag 92 data = data || {"enabled": false}; 93 var newData = {}; 94 for (var key in data) 95 newData[key] = data[key]; 96 data = newData 97 98 this[eventString][action] = data; 99 100 // setup range query 101 if (event == "OnRange") 102 { 103 if (!data.entities) 104 { 105 warn("Trigger.js: Range triggers should carry extra data"); 106 return; 107 } 108 data.queries = []; 109 for (var ent of data.entities) 110 { 111 var cmpTriggerPoint = Engine.QueryInterface(ent, IID_TriggerPoint); 112 if (!cmpTriggerPoint) 113 { 114 warn("Trigger.js: Range triggers must be defined on trigger points"); 115 continue; 116 } 117 data.queries.push(cmpTriggerPoint.RegisterRangeTrigger(action, data)); 118 } 119 } 120 121 if (data.enabled) 122 this.EnableTrigger(event, action); 123 }; 124 125 // Disable trigger 126 Trigger.prototype.DisableTrigger = function(event, action) 127 { 128 var eventString = event + "Actions"; 129 if (!this[eventString][action]) 130 { 131 warn("Trigger.js: Disabling unknown trigger"); 132 return; 133 } 134 var data = this[eventString][action]; 135 // special casing interval and range triggers for performance 136 if (event == "OnInterval") 137 { 138 if (!data.timer) // don't disable it a second time 139 return; 140 var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); 141 cmpTimer.CancelTimer(data.timer); 142 data.timer = null; 143 } 144 else if (event == "OnRange") 145 { 146 if (!data.queries) 147 { 148 warn("Trigger.js: Range query wasn't set up before trying to disable it."); 149 return; 150 } 151 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 152 for (var query of data.queries) 153 cmpRangeManager.DisableActiveQuery(query); 154 } 155 156 data.enabled = false; 157 }; 158 159 // Enable trigger 160 Trigger.prototype.EnableTrigger = function(event, action) 161 { 162 var eventString = event + "Actions"; 163 if (!this[eventString][action]) 164 { 165 warn("Trigger.js: Enabling unknown trigger"); 166 return; 167 } 168 var data = this[eventString][action]; 169 // special casing interval and range triggers for performance 170 if (event == "OnInterval") 171 { 172 if (data.timer) // don't enable it a second time 173 return; 174 if (!data.interval) 175 { 176 warn("Trigger.js: An interval trigger should have an intervel in its data") 177 return; 178 } 179 var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); 180 var timer = cmpTimer.SetInterval(this.entity, IID_Trigger, "DoAction", data.delay || 0, data.interval, {"action" : action}); 181 data.timer = timer; 182 } 183 else if (event == "OnRange") 184 { 185 if (!data.queries) 186 { 187 warn("Trigger.js: Range query wasn't set up before"); 188 return; 189 } 190 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 191 for (var query of data.queries) 192 cmpRangeManager.EnableActiveQuery(query); 193 } 194 195 data.enabled = true; 196 }; 197 198 /** 199 * This function executes the actions bound to the events 200 * It's either called directlty from other simulation scripts, 201 * or from message listeners in this file 202 * 203 * @param event Name of the event (see the list in init) 204 * @param data Data object that will be passed to the actions 205 */ 206 Trigger.prototype.CallEvent = function(event, data) 207 { 208 var eventString = "On" + event + "Actions"; 209 210 if (!this[eventString]) 211 { 212 warn("Trigger.js: Unknown trigger event called:\"" + event + "\"."); 213 return; 214 } 215 216 for (var action in this[eventString]) 217 { 218 if (this[eventString][action].enabled) 219 this.DoAction({"action": action, "data":data}); 220 } 221 }; 222 223 // Handles "OnStructureBuilt" event. 224 Trigger.prototype.OnGlobalConstructionFinished = function(msg) 225 { 226 this.CallEvent("StructureBuilt", {"building": msg.newentity}); // The data for this one is {"building": constructedBuilding} 227 }; 228 229 // Handles "OnTrainingFinished" event. 230 Trigger.prototype.OnGlobalTrainingFinished = function(msg) 231 { 232 this.CallEvent("TrainingFinished", msg); 233 // The data for this one is {"entities": createdEnts, 234 // "owner": cmpOwnership.GetOwner(), 235 // "metadata": metadata} 236 // See function "SpawnUnits" in ProductionQueue for more details 237 }; 238 239 /** 240 * Execute a function after a certain delay 241 * @param time The delay expressed in milleseconds 242 * @param action Name of the action function 243 * @param data Data object that will be passed to the action function 244 */ 245 Trigger.prototype.DoAfterDelay = function(miliseconds, action, data) 246 { 247 var cmpTimer = Engine.QueryInterface(SYSTEM_ENTITY, IID_Timer); 248 return cmpTimer.SetTimeout(SYSTEM_ENTITY, IID_Trigger, "DoAction", miliseconds, {"action": action, "data": data}); 249 }; 250 251 /** 252 * Called by the trigger listeners to exucute the actual action. Including sanity checks. 253 */ 254 Trigger.prototype.DoAction = function(msg) 255 { 256 if (this[msg.action]) 257 this[msg.action](msg.data || null); 258 else 259 warn("Trigger.js: called a trigger action '" + msg.action + "' that wasn't found"); 260 }; 261 262 Engine.RegisterSystemComponentType(IID_Trigger, "Trigger", Trigger); -
binaries/data/mods/public/simulation/components/TriggerPoint.js
1 function TriggerPoint() {}; 2 3 TriggerPoint.prototype.Schema = 4 "<optional>" + 5 "<element name='Reference'>" + 6 "<text/>" + 7 "</element>" + 8 "</optional>"; 9 10 TriggerPoint.prototype.Init = function() 11 { 12 if (this.template && this.template.Reference) 13 { 14 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 15 cmpTrigger.RegisterTriggerPoint(this.template.Reference, this.entity); 16 } 17 this.currentCollections = {}; 18 this.actions = {}; 19 }; 20 21 TriggerPoint.prototype.OnDestroy = function() 22 { 23 if (this.template && this.template.EntityReference) 24 { 25 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 26 cmpTrigger.RemoveRegisteredTriggerPoint(this.template.Reference, this.entity); 27 } 28 }; 29 30 /** 31 * @param action Name of the action function defined under Trigger 32 * @param data The data is an object containing information for the range query 33 * Some of the data has sendible defaults (mentionned next to the object) 34 * data.players = [1,2,3,...] * list of player ids 35 * data.minRange = 0 * Minimum range for the query 36 * data.maxRange = -1 * Maximum range for the query (-1 = no maximum) 37 * data.requiredComponent = -1 * Required component id the entities will have 38 * data.enabled = false * If the query is enabled by default 39 */ 40 TriggerPoint.prototype.RegisterRangeTrigger = function(action, data) 41 { 42 43 if (data.players) 44 var players = data.players; 45 else 46 { 47 var numPlayers = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager).GetNumPlayers(); 48 var players = []; 49 for (var i = 0; i < numPlayers; i++) 50 players.push(i); 51 } 52 var minRange = data.minRange || 0; 53 var maxRange = data.maxRange || -1; 54 var cid = data.requiredComponent || -1; 55 56 var cmpRangeManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 57 var tag = cmpRangeManager.CreateActiveQuery(this.entity, minRange, maxRange, players, cid, cmpRangeManager.GetEntityFlagMask("normal")); 58 59 this.currentCollections[tag] = []; 60 this.actions[tag] = action; 61 return tag; 62 }; 63 64 TriggerPoint.prototype.OnRangeUpdate = function(msg) 65 { 66 var collection = this.currentCollections[msg.tag]; 67 if (!collection) 68 return; 69 70 for (var ent of msg.removed) 71 { 72 var index = collection.indexOf(ent); 73 if (index > -1) 74 collection.splice(index, 1); 75 } 76 77 for each (var entity in msg.added) 78 collection.push(entity); 79 80 var r = {"currentCollection": collection.slice()}; 81 r.added = msg.added; 82 r.removed = msg.removed; 83 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 84 cmpTrigger.DoAction({"action":this.actions[msg.tag], "data": r}); 85 }; 86 87 88 Engine.RegisterComponentType(IID_TriggerPoint, "TriggerPoint", TriggerPoint); -
binaries/data/mods/public/simulation/components/interfaces/Trigger.js
1 Engine.RegisterInterface("Trigger"); -
binaries/data/mods/public/simulation/components/interfaces/TriggerPoint.js
1 Engine.RegisterInterface("TriggerPoint"); 2 -
binaries/data/mods/public/simulation/helpers/Commands.js
31 31 32 32 // Now handle various commands 33 33 if (commands[cmd.type]) 34 { 35 var cmpTrigger = Engine.QueryInterface(SYSTEM_ENTITY, IID_Trigger); 36 if (cmpTrigger) 37 cmpTrigger.CallEvent("PlayerCommand", {"player": player, "cmd": cmd}); 34 38 commands[cmd.type](player, cmd, data); 39 } 35 40 else 36 41 error("Invalid command: unknown command type: "+uneval(cmd)); 37 42 } -
binaries/data/mods/public/simulation/templates/special/trigger_point_A.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>A</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_a.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_B.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>B</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_b.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_C.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>C</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_c.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_D.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>D</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_d.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_E.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>E</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_e.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_F.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>F</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_f.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_G.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>G</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_g.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_H.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>H</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_h.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_I.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>I</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_i.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_J.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>J</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_j.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/special/trigger_point_K.xml
1 1 <?xml version="1.0" encoding="utf-8"?> 2 2 <Entity parent="template_trigger_point"> 3 <TriggerPoint> 4 <Reference>K</Reference> 5 </TriggerPoint> 3 6 <VisualActor> 4 7 <Actor>props/special/common/marker_object_char_k.xml</Actor> 5 8 </VisualActor> -
binaries/data/mods/public/simulation/templates/template_trigger_point.xml
-
source/simulation2/Simulation2.cpp
Property changes on: binaries/data/mods/public/simulation/templates/template_trigger_point.xml ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +application/xml \ No newline at end of property
702 702 703 703 if (!m->m_StartupScript.empty()) 704 704 GetScriptInterface().LoadScript(L"map startup script", m->m_StartupScript); 705 706 // Load the trigger script after we have loaded the simulation and the map. 707 if (GetScriptInterface().HasProperty(m->m_MapSettings.get(), "TriggerScripts")) 708 { 709 std::vector<std::string> scriptNames; 710 GetScriptInterface().GetProperty(m->m_MapSettings.get(), "TriggerScripts", scriptNames); 711 for (u32 i = 0; i < scriptNames.size(); i++) 712 { 713 std::string scriptName = "maps/" + scriptNames[i]; 714 LOGMESSAGE(L"Loading trigger script '%s'", scriptName.c_str()); 715 m->m_ComponentManager.LoadScript(scriptName.data()); 716 } 717 } 705 718 } 706 719 707 720 int CSimulation2::ProgressiveLoad()