Ticket #1184: garrisonfix-03042012.patch
File garrisonfix-03042012.patch, 6.9 KB (added by , 12 years ago) |
---|
-
binaries/data/mods/public/simulation/components/GarrisonHolder.js
1 1 function GarrisonHolder() {} 2 2 3 3 GarrisonHolder.prototype.Schema = 4 "<element name='Max' >" +4 "<element name='Max' a:help='Maximum number of entities which can be garrisoned inside this holder'>" + 5 5 "<data type='positiveInteger'/>" + 6 6 "</element>" + 7 "<element name='List' >" +7 "<element name='List' a:help='Classes of entities which are allowed to garrison inside this holder (from Identity)'>" + 8 8 "<attribute name='datatype'>" + 9 9 "<value>tokens</value>" + 10 10 "</attribute>" + 11 11 "<text/>" + 12 12 "</element>" + 13 "<element name='EjectHealth' >" +13 "<element name='EjectHealth' a:help='Percentage of maximum health below which point this entity no longer allows garrisoning'>" + 14 14 "<ref name='nonNegativeDecimal'/>" + 15 15 "</element>" + 16 "<element name='BuffHeal' >" +16 "<element name='BuffHeal' a:help='How many hit points will be restored every second'>" + 17 17 "<data type='positiveInteger'/>" + 18 "</element>"; 18 "</element>" + 19 "<optional>" + 20 "<element name='LoadingRange' a:help='The maximum distance from this garrison holder at which entities are allowed to garrison (should be at least 2 since entities cannot move directly onto the garrison holder)'>" + 21 "<ref name='nonNegativeDecimal'/>" + 22 "</element>" + 23 "</optional>"; 19 24 20 25 /** 21 26 * Initialize GarrisonHolder Component … … 30 35 }; 31 36 32 37 /** 38 * Return range at which entities can garrison here 39 */ 40 GarrisonHolder.prototype.GetLoadingRange = function() 41 { 42 var max = +(this.template.LoadingRange || 2); 43 return { "max": max, "min": 0 }; 44 }; 45 46 /** 33 47 * Return the list of entities garrisoned inside 34 48 */ 35 49 GarrisonHolder.prototype.GetEntities = function() -
binaries/data/mods/public/simulation/components/UnitAI.js
366 366 } 367 367 else 368 368 { 369 // TODO: this is probably bogus if the unit was 370 // unable to move at all - we need to do some range checks 371 // before actually garrisoning 369 // We do a range check before actually garrisoning 372 370 this.StopMoving(); 373 371 this.SetNextState("INDIVIDUAL.GARRISON.GARRISONED"); 374 372 } … … 1198 1196 var target = this.order.data.target; 1199 1197 // Check that we can still garrison here and that garrisoning succeeds 1200 1198 var cmpGarrisonHolder = Engine.QueryInterface(target, IID_GarrisonHolder); 1201 if (this.CanGarrison(target) && cmpGarrisonHolder.Garrison(this.entity))1199 if (this.CanGarrison(target) && this.CheckGarrisonRange(target) && cmpGarrisonHolder.Garrison(this.entity)) 1202 1200 { 1203 1201 this.isGarrisoned = true; 1204 1202 } … … 1972 1970 return cmpUnitMotion.IsInTargetRange(target, range.min, range.max); 1973 1971 }; 1974 1972 1973 UnitAI.prototype.CheckGarrisonRange = function(target) 1974 { 1975 var cmpGarrisonHolder = Engine.QueryInterface(target, IID_GarrisonHolder); 1976 var range = cmpGarrisonHolder.GetLoadingRange(); 1977 1978 var cmpUnitMotion = Engine.QueryInterface(this.entity, IID_UnitMotion); 1979 return cmpUnitMotion.IsInTargetRange(target, range.min, range.max); 1980 } 1981 1975 1982 /** 1976 1983 * Returns true if the target entity is visible through the FoW/SoD. 1977 1984 */ … … 2407 2414 this.SetHeldPosition(pos.x, pos.z); 2408 2415 2409 2416 this.SetStance(stance); 2410 if (stance == "stand" || stance == "defensive" || stance == "passive") 2417 // Stop moving if switching to stand ground 2418 // TODO: Also stop existing orders in a sensible way 2419 if (stance == "stand") 2411 2420 this.StopMoving(); 2412 2421 2413 2422 // Reset the range query, since the range depends on stance -
binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_bireme.xml
33 33 <EjectHealth>0</EjectHealth> 34 34 <List datatype="tokens">Support Infantry Cavalry</List> 35 35 <BuffHeal>1</BuffHeal> 36 <LoadingRange>10</LoadingRange> 36 37 </GarrisonHolder> 37 38 <Health> 38 39 <Max>800</Max> -
binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_fishing.xml
23 23 <EjectHealth>0</EjectHealth> 24 24 <List datatype="tokens">Support Infantry</List> 25 25 <BuffHeal>1</BuffHeal> 26 <LoadingRange>10</LoadingRange> 26 27 </GarrisonHolder> 27 28 <Identity> 28 29 <GenericName>Fishing Boat</GenericName> -
binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_merchant.xml
16 16 <EjectHealth>0</EjectHealth> 17 17 <List datatype="tokens">Support Infantry Cavalry</List> 18 18 <BuffHeal>1</BuffHeal> 19 <LoadingRange>10</LoadingRange> 19 20 </GarrisonHolder> 20 21 <Health> 21 22 <Max>400</Max> -
binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_quinquereme.xml
33 33 <EjectHealth>0</EjectHealth> 34 34 <List datatype="tokens">Support Infantry Cavalry Siege</List> 35 35 <BuffHeal>1</BuffHeal> 36 <LoadingRange>10</LoadingRange> 36 37 </GarrisonHolder> 37 38 <Health> 38 39 <Max>2000</Max> -
binaries/data/mods/public/simulation/templates/template_unit_mechanical_ship_trireme.xml
37 37 <EjectHealth>0</EjectHealth> 38 38 <List datatype="tokens">Support Infantry Cavalry Siege</List> 39 39 <BuffHeal>1</BuffHeal> 40 <LoadingRange>10</LoadingRange> 40 41 </GarrisonHolder> 41 42 <Health> 42 43 <Max>1400</Max>