- Timestamp:
- 06/18/11 00:13:39 (14 years ago)
- Location:
- ps/trunk
- Files:
-
- 1 added
- 16 edited
-
binaries/data/mods/public/gui/session/input.js (modified) (1 diff)
-
binaries/data/mods/public/gui/session/session.js (modified) (1 diff)
-
binaries/data/mods/public/gui/session/session.xml (modified) (2 diffs)
-
binaries/data/mods/public/gui/session/unit_commands.js (modified) (7 diffs)
-
binaries/data/mods/public/maps/scenarios/Combat_demo.xml (modified) (1 diff)
-
binaries/data/mods/public/maps/scenarios/Pathfinding_demo.xml (modified) (1 diff)
-
binaries/data/mods/public/simulation/components/Attack.js (modified) (1 diff)
-
binaries/data/mods/public/simulation/components/GuiInterface.js (modified) (2 diffs)
-
binaries/data/mods/public/simulation/components/Promotion.js (modified) (1 diff)
-
binaries/data/mods/public/simulation/components/UnitAI.js (modified) (23 diffs)
-
binaries/data/mods/public/simulation/helpers/Commands.js (modified) (1 diff)
-
binaries/data/mods/public/simulation/helpers/Entity.js (added)
-
binaries/data/mods/public/simulation/helpers/Setup.js (modified) (1 diff)
-
binaries/data/mods/public/simulation/templates/template_unit_support.xml (modified) (1 diff)
-
source/simulation2/components/CCmpRangeManager.cpp (modified) (1 diff)
-
source/simulation2/components/ICmpRangeManager.cpp (modified) (1 diff)
-
source/simulation2/components/ICmpRangeManager.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/binaries/data/mods/public/gui/session/input.js
r9468 r9631 1146 1146 } 1147 1147 1148 // Performs the specified stance 1149 function performStance(entity, stanceName) 1150 { 1151 if (entity) 1152 { 1153 var selection = g_Selection.toList(); 1154 Engine.PostNetworkCommand({ 1155 "type": "stance", 1156 "entities": selection, 1157 "name": stanceName 1158 }); 1159 } 1160 } 1161 1148 1162 // Set the camera to follow the given unit 1149 1163 function setCameraFollow(entity) -
ps/trunk/binaries/data/mods/public/gui/session/session.js
r9600 r9631 236 236 { 237 237 var guiName = "Group"; 238 g_Groups.update(); 238 239 for (var i = 0; i < 10; i++) 239 240 { 240 241 var button = getGUIObjectByName("unit"+guiName+"Button["+i+"]"); 241 242 var label = getGUIObjectByName("unit"+guiName+"Label["+i+"]").caption = i; 242 g_Groups.update();243 243 if (g_Groups.groups[i].getTotalCount() == 0) 244 244 button.hidden = true; -
ps/trunk/binaries/data/mods/public/gui/session/session.xml
r9600 r9631 406 406 </object> 407 407 </repeat> 408 </object> 409 410 <!-- ================================ ================================ --> 411 <!-- Stance Selection (Temporary location) --> 412 <!-- ================================ ================================ --> 413 <object name="unitStancePanel" 414 sprite="bottomMiddle" 415 size="50 50 300 106" 416 type="text" 417 > 418 <object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="sessionToolTipBottom" 419 cell_id="4" tooltip="Stances"/> 420 421 <object size="56 12 100% 100%"> 422 <repeat count="5"> 423 <object name="unitStanceButton[n]" hidden="true" style="iconButton" type="button" size="0 0 36 36" tooltip_style="sessionToolTipBottomBold" z="100"> 424 <object name="unitStanceIcon[n]" type="image" ghost="true" size="3 3 33 33"/> 425 </object> 426 </repeat> 427 </object> 408 428 </object> 409 429 … … 639 659 </object> 640 660 641 <object name="unitStancePanel"642 style="goldPanelFrilly"643 size="0 100%-56 100% 100%"644 type="text"645 >646 <object size="-5 -2 59 62" type="image" sprite="snIconSheetTab" tooltip_style="sessionToolTipBottom"647 cell_id="4" tooltip="Stances"/>648 649 [stance commands]650 </object>651 652 661 <object name="unitResearchPanel" 653 662 style="goldPanelFrilly" -
ps/trunk/binaries/data/mods/public/gui/session/unit_commands.js
r9385 r9631 7 7 const CONSTRUCTION = "Construction"; 8 8 const COMMAND = "Command"; 9 const STANCE = "Stance"; 9 10 10 11 // Constants … … 14 15 15 16 // The number of currently visible buttons (used to optimise showing/hiding) 16 var g_unitPanelButtons = {"Selection": 0, "Queue": 0, "Formation": 0, "Garrison": 0, "Training": 0, "Construction": 0, "Command": 0 };17 var g_unitPanelButtons = {"Selection": 0, "Queue": 0, "Formation": 0, "Garrison": 0, "Training": 0, "Construction": 0, "Command": 0, "Stance": 0}; 17 18 18 19 // Unit panels are panels with row(s) of buttons … … 121 122 numberOfItems = 16; 122 123 } 123 if (guiName == "Formation")124 else if (guiName == "Formation") 124 125 { 125 126 if (numberOfItems > 16) 126 127 numberOfItems = 16; 128 } 129 else if (guiName == "Stance") 130 { 131 if (numberOfItems > 5) 132 numberOfItems = 5; 127 133 } 128 134 else if (guiName == "Queue") … … 154 160 var entType = ((guiName == "Queue")? item.template : item); 155 161 var template; 156 if (guiName != "Formation" && guiName != "Command" )162 if (guiName != "Formation" && guiName != "Command" && guiName != "Stance") 157 163 { 158 164 template = GetTemplateData(entType); … … 191 197 break; 192 198 199 case STANCE: 193 200 case FORMATION: 194 201 var tooltip = toTitleCase(item); … … 265 272 icon.sprite = "formation"; 266 273 } 274 } 275 else if (guiName == "Stance") 276 { 277 var stanceSelected = Engine.GuiInterfaceCall("StanceSelected", { 278 "ents": g_Selection.toList(), 279 "stance": item 280 }); 281 282 icon.cell_id = i; 283 if (stanceSelected) 284 icon.sprite = "snIconSheetStanceButton"; 285 else 286 icon.sprite = "snIconSheetStanceButtonDisabled"; 267 287 } 268 288 else if (guiName == "Command") … … 369 389 function (item) { performFormation(entState.id, item); } ); 370 390 391 var stances = ["violent","aggressive","passive","defensive","stand"]; 392 if (isUnit(entState) && !isAnimal(entState) && !entState.garrisonHolder && stances.length) 393 setupUnitPanel("Stance", usedPanels, entState, stances, 394 function (item) { performStance(entState.id, item); } ); 395 371 396 if (entState.buildEntities && entState.buildEntities.length) 372 397 { -
ps/trunk/binaries/data/mods/public/maps/scenarios/Combat_demo.xml
r8800 r9631 41 41 } 42 42 ], 43 "RevealMap": true 43 "RevealMap": true, 44 "DefaultStance": "defensive" 44 45 } 45 46 ]]></ScriptSettings> -
ps/trunk/binaries/data/mods/public/maps/scenarios/Pathfinding_demo.xml
r8800 r9631 42 42 ], 43 43 "RevealMap": true, 44 "DefaultStance": " holdfire",44 "DefaultStance": "defensive", 45 45 "GameType": "endless" 46 46 } -
ps/trunk/binaries/data/mods/public/simulation/components/Attack.js
r9391 r9631 246 246 247 247 Engine.PostMessage(data.target, MT_Attacked, 248 { "attacker": this.entity, "target": data.target });248 { "attacker": this.entity, "target": data.target, "type": data.type }); 249 249 250 250 PlaySound("attack_impact", this.entity); -
ps/trunk/binaries/data/mods/public/simulation/components/GuiInterface.js
r9600 r9631 299 299 }; 300 300 301 GuiInterface.prototype.StanceSelected = function(player, data) 302 { 303 for each (var ent in data.ents) 304 { 305 var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 306 if (cmpUnitAI) 307 { 308 if (cmpUnitAI.GetStanceName() == data.stance) 309 return true; 310 } 311 } 312 return false; 313 }; 314 301 315 GuiInterface.prototype.SetSelectionHighlight = function(player, cmd) 302 316 { … … 554 568 555 569 "CanMoveEntsIntoFormation": 1, 570 "StanceSelected": 1, 556 571 557 572 "SetSelectionHighlight": 1, -
ps/trunk/binaries/data/mods/public/simulation/components/Promotion.js
r9391 r9631 66 66 var cmpCurrentUnitAI = Engine.QueryInterface(this.entity, IID_UnitAI); 67 67 var cmpPromotedUnitAI = Engine.QueryInterface(promotedUnitEntity, IID_UnitAI); 68 cmpPromotedUnitAI.SetHeldPosition(cmpCurrentUnitAI.GetHeldPosition()); 69 if (cmpCurrentUnitAI.GetStanceName()) 70 cmpPromotedUnitAI.SetStance(cmpCurrentUnitAI.GetStanceName()); 68 71 cmpPromotedUnitAI.Cheer(); 69 72 var orders = cmpCurrentUnitAI.GetOrders(); -
ps/trunk/binaries/data/mods/public/simulation/components/UnitAI.js
r9605 r9631 7 7 "<choice>" + 8 8 "<value>aggressive</value>" + 9 "<value> holdfire</value>" +10 "<value> noncombat</value>" +9 "<value>defensive</value>" + 10 "<value>passive</value>" + 11 11 "</choice>" + 12 12 "</element>" + … … 60 60 // dynamic stance changes). 61 61 var g_Stances = { 62 "violent": { 63 targetVisibleEnemies: true, 64 targetAttackers: true, 65 respondFlee: false, 66 respondChase: true, 67 respondStandGround : false, 68 respondHoldGround : false, 69 respondChaseToHell : true, 70 }, 62 71 "aggressive": { 63 72 targetVisibleEnemies: true, … … 65 74 respondFlee: false, 66 75 respondChase: true, 67 }, 68 "holdfire": { 69 targetVisibleEnemies: false, 76 respondStandGround : false, 77 respondHoldGround : false, 78 }, 79 "defensive": { 80 targetVisibleEnemies: true, 70 81 targetAttackers: true, 71 82 respondFlee: false, 72 respondChase: true, 73 }, 74 "noncombat": { 83 respondChase: false, 84 respondStandGround : false, 85 respondHoldGround : true, 86 }, 87 "passive": { 75 88 targetVisibleEnemies: false, 76 89 targetAttackers: true, 77 90 respondFlee: true, 78 91 respondChase: false, 92 respondStandGround : false, 93 respondHoldGround : false, 94 }, 95 "stand": { 96 targetVisibleEnemies: true, 97 targetAttackers: true, 98 respondFlee: false, 99 respondChase: false, 100 respondStandGround : true, 101 respondHoldGround : false, 79 102 }, 80 103 }; … … 115 138 }, 116 139 140 "StanceChanged": function(msg) { 141 if (this.StanceSpecificQuery(this.stance,true)) 142 return; 143 }, 144 117 145 // Formation handlers: 118 146 … … 155 183 } 156 184 185 this.SetHeldPosition(this.order.data.x, this.order.data.z); 157 186 this.MoveToPoint(this.order.data.x, this.order.data.z); 158 187 this.SetNextState("INDIVIDUAL.WALKING"); … … 218 247 this.attackType = type; 219 248 249 if (this.CheckTargetRange(this.order.data.target, IID_Attack, this.attackType)) 250 { 251 // We are already at the target 252 // so try attacking it from here. 253 this.StopMoving(); 254 if (this.IsAnimal()) 255 this.SetNextState("ANIMAL.COMBAT.ATTACKING"); 256 else 257 this.SetNextState("INDIVIDUAL.COMBAT.ATTACKING"); 258 } 220 259 // Try to move within attack range 221 if (this.MoveToTargetRange(this.order.data.target, IID_Attack, this.attackType))260 else if ((!this.GetStance().respondStandGround || this.order.data.force) && this.MoveToTargetRange(this.order.data.target, IID_Attack, this.attackType)) 222 261 { 223 262 // We've started walking to the given point … … 228 267 } 229 268 else 230 { 231 // We are already at the target, or can't move at all, 232 // so try attacking it from here. 233 // TODO: need better handling of the can't-reach-target case 234 this.StopMoving(); 235 if (this.IsAnimal()) 236 this.SetNextState("ANIMAL.COMBAT.ATTACKING"); 237 else 238 this.SetNextState("INDIVIDUAL.COMBAT.ATTACKING"); 239 } 269 this.FinishOrder(); 240 270 }, 241 271 … … 253 283 } 254 284 255 this.PushOrderFront("Attack", { "target": this.order.data.target });285 this.PushOrderFront("Attack", { "target": this.order.data.target, "force": false }); 256 286 return; 257 287 } … … 485 515 // so immediately check whether there's anybody nearby to attack. 486 516 // (If anyone approaches later, it'll be handled via LosRangeUpdate.) 487 if (this.losRangeQuery) 488 { 489 var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 490 var ents = rangeMan.ResetActiveQuery(this.losRangeQuery); 491 if (this.GetStance().targetVisibleEnemies) 492 { 493 if (this.RespondToTargetedEntities(ents)) 494 return true; // (abort the FSM transition since we may have already switched state) 495 } 496 } 517 if (this.StanceSpecificQuery(this.stance)) 518 return true; 497 519 498 520 // Nobody to attack - stay in idle … … 552 574 }, 553 575 576 "StanceChanged": function(msg) { 577 if (this.StanceSpecificQuery(this.stance)) 578 return; 579 }, 554 580 }, 555 581 … … 601 627 "enter": function () { 602 628 this.SelectAnimation("move"); 629 this.StartTimer(1000, 1000); 630 }, 631 632 "leave": function() { 633 this.StopTimer(); 634 }, 635 636 "Timer": function(msg) { 637 if (!this.ChaseTargetedEntity(this.order.data.target, this.order.data.force)) 638 { 639 this.StopMoving(); 640 this.FinishOrder(); 641 642 // we return to our position 643 if (this.GetStance().respondHoldGround) 644 this.WalkToHeldPosition(); 645 } 603 646 }, 604 647 605 648 "MoveCompleted": function() { 606 649 this.SetNextState("ATTACKING"); 650 }, 651 652 "Attacked": function(msg) { 653 // If we're attacked by a close enemy, we should try to defend ourself 654 if (this.GetStance().targetAttackers && msg.data.type == "Melee") 655 { 656 this.RespondToTargetedEntities([msg.data.attacker]); 657 } 607 658 }, 608 659 }, … … 641 692 } 642 693 643 // Can't reach it - try to chase after it 644 if (this.MoveToTargetRange(this.order.data.target, IID_Attack, this.attackType)) 694 if (this.ChaseTargetedEntity(this.order.data.target)) 645 695 { 646 this.SetNextState("COMBAT.CHASING"); 696 if (this.MoveToTargetRange(this.order.data.target, IID_Attack, this.attackType)) 697 { 698 this.SetNextState("COMBAT.CHASING"); 699 return; 700 } 701 } 702 703 } 704 705 // Can't reach it, or it doesn't exist any more - give up 706 if (this.FinishOrder()) 707 return; 708 709 // see if we can switch to a new nearby enemy 710 if (this.StanceSpecificQuery(this.stance, true)) 711 return; 712 713 // we return to our position 714 if (this.GetStance().respondHoldGround) 715 { 716 if (this.WalkToHeldPosition()) 647 717 return; 648 }649 718 } 650 651 // Can't reach it, or it doesn't exist any more - give up652 this.FinishOrder();653 654 // TODO: see if we can switch to a new nearby enemy655 719 }, 656 720 … … 662 726 "enter": function () { 663 727 this.SelectAnimation("move"); 664 }, 665 728 this.StartTimer(1000, 1000); 729 }, 730 731 "leave": function() { 732 this.StopTimer(); 733 }, 734 735 "Timer": function(msg) { 736 if (!this.ChaseTargetedEntity(this.order.data.target)) 737 { 738 this.StopMoving(); 739 this.FinishOrder(); 740 741 // we return to our position 742 if (this.GetStance().respondHoldGround) 743 this.WalkToHeldPosition(); 744 } 745 }, 746 666 747 "MoveCompleted": function() { 667 748 this.SetNextState("ATTACKING"); … … 1304 1385 UnitAI.prototype.SetupRangeQuery = function(owner) 1305 1386 { 1306 var cmpVision = Engine.QueryInterface(this.entity, IID_Vision);1307 if (!cmpVision)1308 return;1309 1310 1387 var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 1311 1388 var playerMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_PlayerManager); 1312 1389 1313 1390 if (this.losRangeQuery) 1314 1391 rangeMan.DestroyActiveQuery(this.losRangeQuery); 1315 1392 1316 var range = cmpVision.GetRange();1317 1318 1393 var players = []; 1319 1394 1320 1395 if (owner != -1) 1321 1396 { … … 1335 1410 } 1336 1411 } 1337 1338 this.losRangeQuery = rangeMan.CreateActiveQuery(this.entity, 0, range, players, IID_DamageReceiver); 1412 1413 var range = this.StanceSpecificRange(); 1414 1415 this.losRangeQuery = rangeMan.CreateActiveQuery(this.entity, 0, range.max, players, IID_DamageReceiver); 1339 1416 rangeMan.EnableActiveQuery(this.losRangeQuery); 1340 } ;1417 } 1341 1418 1342 1419 //// FSM linkage functions //// … … 1834 1911 } 1835 1912 1913 UnitAI.prototype.CheckTargetDistanceFromHeldPosition = function(target, type) 1914 { 1915 var cmpRanged = Engine.QueryInterface(this.entity, IID_Attack); 1916 var range = cmpRanged.GetRange(type); 1917 1918 var cmpPosition = Engine.QueryInterface(target, IID_Position); 1919 if (!cmpPosition || !cmpPosition.IsInWorld()) 1920 return false; 1921 1922 var cmpVision = Engine.QueryInterface(this.entity, IID_Vision); 1923 if (!cmpVision) 1924 return false; 1925 var halfvision = cmpVision.GetRange() / 2; 1926 1927 var pos = cmpPosition.GetPosition(); 1928 var dx = this.heldPosition.x - pos.x; 1929 var dz = this.heldPosition.z - pos.z; 1930 var dist = Math.sqrt(dx*dx + dz*dz); 1931 1932 return dist < halfvision + range.max; 1933 }; 1934 1935 UnitAI.prototype.CheckTargetIsInVisionRange = function(target) 1936 { 1937 var cmpVision = Engine.QueryInterface(this.entity, IID_Vision); 1938 if (!cmpVision) 1939 return false; 1940 var range = cmpVision.GetRange(); 1941 1942 var distance = DistanceBetweenEntities(this.entity,target); 1943 1944 return distance < range; 1945 } 1946 1836 1947 UnitAI.prototype.GetBestAttack = function() 1837 1948 { … … 1853 1964 if (this.CanAttack(target)) 1854 1965 { 1855 this.PushOrderFront("Attack", { "target": target }); 1966 this.PushOrderFront("Attack", { "target": target, "force": false }); 1967 return true; 1968 } 1969 } 1970 return false; 1971 }; 1972 1973 /** 1974 * Try to find one of the given entities which can be attacked, 1975 * within zone. 1976 * Returns true if it found something to attack. 1977 */ 1978 UnitAI.prototype.AttackEntityInZone = function(ents) 1979 { 1980 var type = this.GetBestAttack(); 1981 for each (var target in ents) 1982 { 1983 if (this.CanAttack(target) && this.CheckTargetDistanceFromHeldPosition(target, type)) 1984 { 1985 this.PushOrderFront("Attack", { "target": target, "force": false }); 1856 1986 return true; 1857 1987 } … … 1873 2003 return this.AttackVisibleEntity(ents); 1874 2004 2005 if (this.GetStance().respondStandGround) 2006 return this.AttackVisibleEntity(ents); 2007 2008 if (this.GetStance().respondHoldGround) 2009 return this.AttackEntityInZone(ents); 2010 1875 2011 if (this.GetStance().respondFlee) 1876 2012 { … … 1881 2017 return false; 1882 2018 }; 2019 2020 /* 2021 * Try to chase targeted entity given our current stance 2022 */ 2023 UnitAI.prototype.ChaseTargetedEntity = function(ent, force) 2024 { 2025 if (this.GetStance().respondChase) 2026 { 2027 if (this.CheckTargetIsInVisionRange(ent)) 2028 { 2029 return true; 2030 } 2031 } 2032 2033 if (this.GetStance().respondChaseToHell || force) 2034 { 2035 //if ( TODO : Check ent is not in Shroud of Darkness) 2036 { 2037 return true; 2038 } 2039 } 2040 2041 if (this.GetStance().respondHoldGround) 2042 { 2043 if (this.CheckTargetDistanceFromHeldPosition(ent, this.attackType)) 2044 { 2045 return true; 2046 } 2047 } 2048 2049 return false; 2050 2051 } 1883 2052 1884 2053 //// External interface functions //// … … 2022 2191 } 2023 2192 2024 this.AddOrder("Attack", { "target": target }, queued);2193 this.AddOrder("Attack", { "target": target, "force": true }, queued); 2025 2194 }; 2026 2195 … … 2107 2276 else 2108 2277 error("UnitAI: Setting to invalid stance '"+stance+"'"); 2278 } 2279 2280 UnitAI.prototype.SwitchToStance = function(stance) 2281 { 2282 var cmpPosition = Engine.QueryInterface(this.entity, IID_Position); 2283 if (!cmpPosition || !cmpPosition.IsInWorld()) 2284 return; 2285 var pos = cmpPosition.GetPosition(); 2286 this.SetHeldPosition(pos.x, pos.z); 2287 2288 this.SetStance(stance); 2289 if (stance == "stand" || stance == "defensive" || stance == "passive") 2290 this.StopMoving(); 2291 2292 UnitFsm.ProcessMessage(this, {"type": "StanceChanged", "stance": stance}); 2293 } 2294 2295 UnitAI.prototype.StanceSpecificQuery = function(stance, disable) 2296 { 2297 if (!g_Stances[stance]) 2298 { 2299 error("UnitAI: Setting to invalid stance '"+stance+"'"); 2300 return false; 2301 } 2302 2303 if (!this.losRangeQuery) 2304 return false; 2305 2306 var range = this.StanceSpecificRange(); 2307 2308 var rangeMan = Engine.QueryInterface(SYSTEM_ENTITY, IID_RangeManager); 2309 var ents = rangeMan.ModifyRangeActiveQuery(this.losRangeQuery, range.min, range.max); 2310 2311 if (disable && !this.IsAnimal()) 2312 rangeMan.DisableActiveQuery(this.losRangeQuery); 2313 2314 return this.RespondToTargetedEntities(ents); 2315 }; 2316 2317 UnitAI.prototype.StanceSpecificRange = function() 2318 { 2319 var ret = { "min": 0, "max": 0 }; 2320 if (this.GetStance().respondStandGround) 2321 { 2322 var cmpRanged = Engine.QueryInterface(this.entity, IID_Attack); 2323 if (!cmpRanged) 2324 return ret; 2325 var range = cmpRanged.GetRange(cmpRanged.GetBestAttack()); 2326 ret.min = range.min; 2327 ret.max = range.max; 2328 } 2329 else if (this.GetStance().respondChase) 2330 { 2331 var cmpVision = Engine.QueryInterface(this.entity, IID_Vision); 2332 if (!cmpVision) 2333 return ret; 2334 var range = cmpVision.GetRange(); 2335 ret.max = range; 2336 } 2337 else if (this.GetStance().respondHoldGround) 2338 { 2339 var cmpRanged = Engine.QueryInterface(this.entity, IID_Attack); 2340 if (!cmpRanged) 2341 return ret; 2342 var range = cmpRanged.GetRange(cmpRanged.GetBestAttack()); 2343 var cmpVision = Engine.QueryInterface(this.entity, IID_Vision); 2344 if (!cmpVision) 2345 return ret; 2346 var halfvision = cmpVision.GetRange() / 2; 2347 ret.max = range.max + halfvision; 2348 } 2349 return ret; 2109 2350 }; 2110 2351 … … 2112 2353 { 2113 2354 return g_Stances[this.stance]; 2355 }; 2356 2357 UnitAI.prototype.GetStanceName = function() 2358 { 2359 return this.stance; 2114 2360 }; 2115 2361 … … 2253 2499 }; 2254 2500 2501 UnitAI.prototype.SetHeldPosition = function(x, z) 2502 { 2503 this.heldPosition = {"x": x, "z": z}; 2504 }; 2505 2506 UnitAI.prototype.GetHeldPosition = function(pos) 2507 { 2508 return this.heldPosition; 2509 }; 2510 2511 UnitAI.prototype.WalkToHeldPosition = function() 2512 { 2513 if (this.heldPosition) 2514 { 2515 this.Walk(this.heldPosition.x, this.heldPosition.z, false); 2516 return true; 2517 } 2518 return false; 2519 }; 2520 2255 2521 Engine.RegisterComponentType(IID_UnitAI, "UnitAI", UnitAI); -
ps/trunk/binaries/data/mods/public/simulation/helpers/Commands.js
r9527 r9631 259 259 if (cmpPromotion) 260 260 cmpPromotion.IncreaseXp(cmpPromotion.GetRequiredXp() - cmpPromotion.GetCurrentXp()); 261 } 262 break; 263 264 case "stance": 265 for each (var ent in cmd.entities) 266 { 267 var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 268 if (cmpUnitAI) 269 cmpUnitAI.SwitchToStance(cmd.name); 261 270 } 262 271 break; -
ps/trunk/binaries/data/mods/public/simulation/helpers/Setup.js
r8865 r9631 15 15 { 16 16 var cmpUnitAI = Engine.QueryInterface(ent, IID_UnitAI); 17 cmpUnitAI.S etStance(settings.DefaultStance);17 cmpUnitAI.SwitchToStance(settings.DefaultStance); 18 18 } 19 19 } -
ps/trunk/binaries/data/mods/public/simulation/templates/template_unit_support.xml
r9010 r9631 9 9 </Minimap> 10 10 <UnitAI> 11 <DefaultStance> noncombat</DefaultStance>11 <DefaultStance>passive</DefaultStance> 12 12 </UnitAI> 13 13 <Cost> -
ps/trunk/source/simulation2/components/CCmpRangeManager.cpp
r9362 r9631 458 458 459 459 return (tag_t)id; 460 } 461 462 virtual std::vector<entity_id_t> ModifyRangeActiveQuery(tag_t tag, 463 entity_pos_t minRange, entity_pos_t maxRange) 464 { 465 std::map<tag_t, Query>::iterator it = m_Queries.find(tag); 466 if (it == m_Queries.end()) 467 { 468 LOGERROR(L"CCmpRangeManager: ModifyRangeActiveQuery called with invalid tag %d", tag); 469 std::vector<entity_id_t> r; 470 return r; 471 } 472 473 Query& q = it->second; 474 q.minRange = minRange; 475 q.maxRange = maxRange; 476 return ResetActiveQuery(tag); 460 477 } 461 478 -
ps/trunk/source/simulation2/components/ICmpRangeManager.cpp
r8679 r9631 37 37 DEFINE_INTERFACE_METHOD_5("ExecuteQuery", std::vector<entity_id_t>, ICmpRangeManager, ExecuteQuery, entity_id_t, entity_pos_t, entity_pos_t, std::vector<int>, int) 38 38 DEFINE_INTERFACE_METHOD_5("CreateActiveQuery", ICmpRangeManager::tag_t, ICmpRangeManager, CreateActiveQuery, entity_id_t, entity_pos_t, entity_pos_t, std::vector<int>, int) 39 DEFINE_INTERFACE_METHOD_3("ModifyRangeActiveQuery", std::vector<entity_id_t>, ICmpRangeManager, ModifyRangeActiveQuery, ICmpRangeManager::tag_t, entity_pos_t, entity_pos_t) 39 40 DEFINE_INTERFACE_METHOD_1("DestroyActiveQuery", void, ICmpRangeManager, DestroyActiveQuery, ICmpRangeManager::tag_t) 40 41 DEFINE_INTERFACE_METHOD_1("EnableActiveQuery", void, ICmpRangeManager, EnableActiveQuery, ICmpRangeManager::tag_t) -
ps/trunk/source/simulation2/components/ICmpRangeManager.h
r9362 r9631 103 103 104 104 /** 105 * Modify an active query's range parameters and execute a ResetActiveQuery. 106 * @param tag identifier of query. 107 * @param minRange non-negative minimum distance in metres (inclusive). 108 * @param maxRange non-negative maximum distance in metres (inclusive); or -1.0 to ignore distance. 109 * @return list of entities matching the query, ordered by increasing distance from the source entity. 110 */ 111 virtual std::vector<entity_id_t> ModifyRangeActiveQuery(tag_t tag, 112 entity_pos_t minRange, entity_pos_t maxRange) = 0; 113 114 /** 105 115 * Destroy a query and clean up resources. This must be called when an entity no longer needs its 106 116 * query (e.g. when the entity is destroyed).
Note:
See TracChangeset
for help on using the changeset viewer.
