Ticket #1200: limit_pathing.diff
File limit_pathing.diff, 3.6 KB (added by , 10 years ago) |
---|
-
binaries/data/mods/public/art/actors/fauna/boar.xml
11 11 <animation file="quadraped/boar_run.dae" name="Run" speed="8"/> 12 12 <animation file="quadraped/boar_death.dae" name="Death" speed="75"/> 13 13 </animations> 14 <mesh> skeletal/boar.dae</mesh>14 <mesh>justshutupskeletal/boar.dae</mesh> 15 15 </variant> 16 16 </group> 17 17 <group> -
source/simulation2/components/CCmpUnitMotion.cpp
107 107 static const CColor OVERLAY_COLOUR_LONG_PATH(1, 1, 1, 1); 108 108 static const CColor OVERLAY_COLOUR_SHORT_PATH(1, 0, 0, 1); 109 109 110 /** 111 * Define how many paths you can query in how many seconds for one unit 112 */ 113 static const int MAX_NUMBER_OF_PATHS = 15; 114 static const fixed MIN_TIME_BETWEEN_PATHS = fixed::FromInt(20); 115 110 116 static const entity_pos_t g_GoalDelta = entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/4; // for extending the goal outwards/inwards a little bit 111 117 112 118 class CCmpUnitMotion : public ICmpUnitMotion … … 123 129 124 130 DEFAULT_COMPONENT_ALLOCATOR(UnitMotion) 125 131 132 fixed m_Time; 133 fixed m_PathRequestTimes [MAX_NUMBER_OF_PATHS]; 134 126 135 bool m_DebugOverlayEnabled; 127 136 std::vector<SOverlayLine> m_DebugOverlayLongPathLines; 128 137 std::vector<SOverlayLine> m_DebugOverlayShortPathLines; … … 289 298 290 299 virtual void Init(const CParamNode& paramNode) 291 300 { 301 m_Time = fixed::Zero(); 302 for (int i = 0; i < MAX_NUMBER_OF_PATHS; i++) 303 m_PathRequestTimes[i] = -MIN_TIME_BETWEEN_PATHS; 304 292 305 m_FormationController = paramNode.GetChild("FormationController").ToBool(); 293 306 294 307 m_Moving = false; … … 644 657 645 658 if (m_PathState == PATHSTATE_WAITING_REQUESTING_LONG) 646 659 { 660 for (int i = MAX_NUMBER_OF_PATHS - 1; i > 0; --i) 661 m_PathRequestTimes[i] = m_PathRequestTimes[i-1]; 662 m_PathRequestTimes[0] = m_Time; 663 LOGWARNING(L"Time of oldest path: %f, Current time: %f", m_PathRequestTimes[MAX_NUMBER_OF_PATHS - 1].ToFloat(), m_Time.ToFloat()); 664 647 665 m_LongPath = path; 648 666 m_ShortPath.m_Waypoints.clear(); 649 667 … … 793 811 void CCmpUnitMotion::Move(fixed dt) 794 812 { 795 813 PROFILE("Move"); 814 m_Time += dt; 796 815 797 816 if (m_State == STATE_STOPPING) 798 817 { … … 819 838 return; 820 839 } 821 840 822 case PATHSTATE_FOLLOWING:823 841 case PATHSTATE_FOLLOWING_REQUESTING_SHORT: 824 842 case PATHSTATE_FOLLOWING_REQUESTING_SHORT_APPEND: 825 843 case PATHSTATE_FOLLOWING_REQUESTING_LONG: 844 case PATHSTATE_FOLLOWING: 826 845 { 827 846 // TODO: there's some asymmetry here when units look at other 828 847 // units' positions - the result will depend on the order of execution. … … 1315 1334 bool CCmpUnitMotion::MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange, entity_id_t target) 1316 1335 { 1317 1336 PROFILE("MoveToPointRange"); 1337 if (m_PathRequestTimes[MAX_NUMBER_OF_PATHS - 1] > m_Time - MIN_TIME_BETWEEN_PATHS) 1338 return false; 1318 1339 1319 1340 CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); 1320 1341 if (!cmpPosition || !cmpPosition->IsInWorld()) … … 1466 1487 bool CCmpUnitMotion::MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange) 1467 1488 { 1468 1489 PROFILE("MoveToTargetRange"); 1490 if (m_PathRequestTimes[MAX_NUMBER_OF_PATHS - 1] > m_Time - MIN_TIME_BETWEEN_PATHS) 1491 { 1492 LOGWARNING(L"Pathing denied"); 1493 return false; 1494 } 1469 1495 1470 1496 CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle()); 1471 1497 if (!cmpPosition || !cmpPosition->IsInWorld())