Ticket #1200: limit_pathing.diff

File limit_pathing.diff, 3.6 KB (added by sanderd17, 10 years ago)
  • binaries/data/mods/public/art/actors/fauna/boar.xml

     
    1111        <animation file="quadraped/boar_run.dae" name="Run" speed="8"/>
    1212        <animation file="quadraped/boar_death.dae" name="Death" speed="75"/>
    1313      </animations>
    14       <mesh>skeletal/boar.dae</mesh>
     14      <mesh>justshutupskeletal/boar.dae</mesh>
    1515    </variant>
    1616  </group>
    1717  <group>
  • source/simulation2/components/CCmpUnitMotion.cpp

     
    107107static const CColor OVERLAY_COLOUR_LONG_PATH(1, 1, 1, 1);
    108108static const CColor OVERLAY_COLOUR_SHORT_PATH(1, 0, 0, 1);
    109109
     110/**
     111 * Define how many paths you can query in how many seconds for one unit
     112 */
     113static const int MAX_NUMBER_OF_PATHS = 15;
     114static const fixed MIN_TIME_BETWEEN_PATHS = fixed::FromInt(20);
     115
    110116static const entity_pos_t g_GoalDelta = entity_pos_t::FromInt(TERRAIN_TILE_SIZE)/4; // for extending the goal outwards/inwards a little bit
    111117
    112118class CCmpUnitMotion : public ICmpUnitMotion
     
    123129
    124130    DEFAULT_COMPONENT_ALLOCATOR(UnitMotion)
    125131
     132    fixed m_Time;
     133    fixed m_PathRequestTimes [MAX_NUMBER_OF_PATHS];
     134
    126135    bool m_DebugOverlayEnabled;
    127136    std::vector<SOverlayLine> m_DebugOverlayLongPathLines;
    128137    std::vector<SOverlayLine> m_DebugOverlayShortPathLines;
     
    289298
    290299    virtual void Init(const CParamNode& paramNode)
    291300    {
     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
    292305        m_FormationController = paramNode.GetChild("FormationController").ToBool();
    293306
    294307        m_Moving = false;
     
    644657
    645658    if (m_PathState == PATHSTATE_WAITING_REQUESTING_LONG)
    646659    {
     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
    647665        m_LongPath = path;
    648666        m_ShortPath.m_Waypoints.clear();
    649667
     
    793811void CCmpUnitMotion::Move(fixed dt)
    794812{
    795813    PROFILE("Move");
     814    m_Time += dt;
    796815
    797816    if (m_State == STATE_STOPPING)
    798817    {
     
    819838        return;
    820839    }
    821840
    822     case PATHSTATE_FOLLOWING:
    823841    case PATHSTATE_FOLLOWING_REQUESTING_SHORT:
    824842    case PATHSTATE_FOLLOWING_REQUESTING_SHORT_APPEND:
    825843    case PATHSTATE_FOLLOWING_REQUESTING_LONG:
     844    case PATHSTATE_FOLLOWING:
    826845    {
    827846        // TODO: there's some asymmetry here when units look at other
    828847        // units' positions - the result will depend on the order of execution.
     
    13151334bool CCmpUnitMotion::MoveToPointRange(entity_pos_t x, entity_pos_t z, entity_pos_t minRange, entity_pos_t maxRange, entity_id_t target)
    13161335{
    13171336    PROFILE("MoveToPointRange");
     1337    if (m_PathRequestTimes[MAX_NUMBER_OF_PATHS - 1] > m_Time - MIN_TIME_BETWEEN_PATHS)
     1338        return false;
    13181339
    13191340    CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
    13201341    if (!cmpPosition || !cmpPosition->IsInWorld())
     
    14661487bool CCmpUnitMotion::MoveToTargetRange(entity_id_t target, entity_pos_t minRange, entity_pos_t maxRange)
    14671488{
    14681489    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    }
    14691495
    14701496    CmpPtr<ICmpPosition> cmpPosition(GetEntityHandle());
    14711497    if (!cmpPosition || !cmpPosition->IsInWorld())