1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Mobiles running effect issue

Discussion in 'Script Support' started by Piotr, Mar 19, 2017.

  1. Piotr
    Offline

    Piotr New Member

    Joined:
    Oct 1, 2016
    Messages:
    17
    Likes Received:
    1
    Hi,

    I noticed that mobiles in general don't use their run effect (animation). They seem to be always walking, even if I improve their movement speed, they just walk very fast (actually giving the impression of teleporting towards a target) in warmode.

    I want the monsters, bandits and animals to use their run animation. Just like a player does.
    I know how to modify their default active and passive speed, but can't figure out how to get rid of this weird forced walk effect...

    Any ideas?
     
  2. Vorspire
    Offline

    Vorspire Vita-Nex: Core
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    907
    Likes Received:
    166
    The client is responsible for the walking/running animations, if you [move any mobile to a tile next to it, you'll see the client makes it look like it's "walking".

    I believe in order for the client to interpret a one-tile move as a running movement, it would have to know about it for creatures - this could maybe be done by including the Direction.Running flag when the AI tells the creature to move. If I remember correctly, AI just uses the direction as a way to point the creature before moving it.

    This is just a theory though, if it works, let me know :p
    I'll test it myself at some point tonight.
     
  3. Vorspire
    Offline

    Vorspire Vita-Nex: Core
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    907
    Likes Received:
    166
    • Thanks! Thanks! x 1
    • Two Thumbs Up Two Thumbs Up x 1
    • Optimistic Optimistic x 1
  4. Dexter_Lexia
    Online

    Moderator ServUO Developer

    Joined:
    Jul 3, 2014
    Messages:
    2,347
    Likes Received:
    107
    Nice! But you didn't give them enough time to get back to you!
     
  5. timginter
    Offline

    timginter Member

    Joined:
    Jun 21, 2016
    Messages:
    49
    Likes Received:
    2
    Did you manage to get it working, Vorspire? For me mobiles are still walking in warmode
     
  6. Dexter_Lexia
    Online

    Moderator ServUO Developer

    Joined:
    Jul 3, 2014
    Messages:
    2,347
    Likes Received:
    107
    They only run if they are fast enough, so to speak.
     
  7. timginter
    Offline

    timginter Member

    Joined:
    Jun 21, 2016
    Messages:
    49
    Likes Received:
    2
    Yes, I have a mob with speed ActiveSpeed: 0.150, PassiveSpeed: 0.4 and still it just stays in WarMode and sort of flows towards the enemy in combat position instead of a clear run animation. I was wondering if it's something with my animations, but when I reverse the logic in Vorspire's code mobiles do run when idle. Just not in WarMode
     
  8. GriffonSpade
    Offline

    GriffonSpade Member

    Joined:
    Oct 21, 2016
    Messages:
    276
    Likes Received:
    11
    Hey Vorspire, I was looking at the merge request, and I noticed that it only looks like it uses the run animation when at or exceeding run speed. Shouldn't it use the run animation whenever it exceeds walking speed instead to prevent 'bouncing/teleporting'?
     
  9. GriffonSpade
    Offline

    GriffonSpade Member

    Joined:
    Oct 21, 2016
    Messages:
    276
    Likes Received:
    11
    A few things:

    1) Does this move creatures? If so, more edits might be needed to cover all movement types.

    if (m_Path.Follow(run, 1))

    2) How about these two lines instead of your version?

    bool mounted = m_Mobile.Mounted || m_Mobile.Flying;
    bool running = (mounted && delay < Mobile.WalkMount) || (!mounted && delay < Mobile.WalkFoot);

    (Your version down here)

    var mounted = m_Mobile.Mounted || m_Mobile.Flying;
    var running = (mounted && delay <= Mobile.WalkMount) || (!mounted && delay <= Mobile.RunFoot);

    It seems almost certain the issue is arising from that pathing stuff in walkmobilerange(). I don't really know how that stuff is working. Simply overriding bRun to true doesn't work, so it is not properly implementing the run flag.
     
    #9 GriffonSpade, Apr 1, 2017
    Last edited: Apr 1, 2017
  10. Vorspire
    Offline

    Vorspire Vita-Nex: Core
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    907
    Likes Received:
    166
    The edits I implemented work fine, they match what would be observed by a player's movement.

    Take a look at how the Wanderer handles its movement without AI, it uses a similar technique with appending the Running direction flag.
    If you make a wanderer use a human body, it will run properly, same for any NPC using the new AI edits.

    I did notice something though, the client doesn't seem to have running animations for most bodies when they are in war mode, so they still appear to be walking.
     
  11. timginter
    Offline

    timginter Member

    Joined:
    Jun 21, 2016
    Messages:
    49
    Likes Received:
    2
    That must be the reason I couldn't see them running. Do you know if there's a way to force the client to use normal running animation instead of a dedicated, non existent warmode-running animation?
     
  12. Vorspire
    Offline

    Vorspire Vita-Nex: Core
    Admin ServUO Developer

    Joined:
    Jul 29, 2013
    Messages:
    907
    Likes Received:
    166
    Unfortunately not, unless there's a way to never notify the client when a BaseCreature changes to War Mode.
    If the client doesn't think the mobile is in War Mode, then it won't use those animations.
     
  13. GriffonSpade
    Offline

    GriffonSpade Member

    Joined:
    Oct 21, 2016
    Messages:
    276
    Likes Received:
    11
    No running animations for warmode, huh. Seems like a hell of an oversight. And not just reusing the normal running animations either. Seems like that would be the thing to do.

    If a non-mounted creature is moving at 201-399 ms, it should use the run animation, rather than walk, right? Because Walk speed uses 400 ms to execute, so even holding the button down, the fastest speed is 400 ms, right? In player behavior, it would be like repeatedly tapping to move while running?

    I noticed in a lot of places that it has it set to not run within 5 tiles of the target, and claims that this is 'like OSI'. What if this relates to warmode being activated on OSI? ie if it's more than X tiles away, warmode is false, but if within X tiles, it's true.
    I don't recall OSI's behavior, so does it do this, or does it just walk all the time, or something else? It also might just be intended for following the master.

    Edit: Thinking back, I recall getting mobiles to run back in runUO2.5/.6. There was an issue with them 'bouncing' when they stopped to fight, though.
    --- Double Post Merged, Apr 1, 2017 ---
    Here's my WalkMobileRange that makes them run. Perhaps you can suss out the difference that made it work. Note that the turning shennanigans were my ad hoc solution to make them stop bouncing if they were. Perhaps someone better with coding can make it unnecessary to do the turning while preserving the running.

    Code (C#):
    1.  
    2. //GS
    3.      public virtual bool ShouldRun()
    4.      {
    5.        if ( m_Mobile.AllowedStealthSteps > 0 )
    6.          return false;
    7.  
    8.        return m_Mobile.CanRun;
    9.      }
    10.  
    11.      public virtual bool WalkMobileRange(Mobile m, int iWantDist)
    12.      {
    13.        bool bRun = ShouldRun();
    14.        return WalkMobileRange(m, 1, bRun, iWantDist, iWantDist);
    15.      }
    16.  
    17.      public virtual bool WalkMobileRange(Mobile m, int iWantDistMin, int iWantDistMax)
    18.      {
    19.        bool bRun = ShouldRun();
    20.        return WalkMobileRange(m, 1, bRun, iWantDistMin, iWantDistMax);
    21.      }
    22.    
    23.      public virtual bool WalkMobileRange(Mobile m, bool bRun, int iWantDistMin, int iWantDistMax)
    24.      {
    25.        return WalkMobileRange(m, 1, bRun, iWantDistMin, iWantDistMax);
    26.      }
    27.    
    28.      public virtual bool WalkMobileRange(Mobile f, int iSteps, bool bRun, int iWantDistMin, int iWantDistMax)
    29.      {
    30.        BaseCreature m = m_Mobile as BaseCreature;
    31.  
    32.        if (m.Deleted)
    33.          return false;
    34.  
    35.        if ( f == null || f.Deleted || !f.Alive || f.Map != m.Map )
    36.          return false;
    37.  
    38.        int iOldDist = (int)m.GetDistanceToSqrt(f);
    39.  
    40.        // Already where I want to be
    41.        if ( iOldDist >= iWantDistMin && iOldDist <= iWantDistMax )
    42.        {
    43.          CheckTurn(f);
    44.          return true;
    45.        }
    46.  
    47.        // I'm either too close or too far
    48.        // I'm unable to move!
    49.        if ( BlockingMove() || m.DisallowAllMoves)
    50.        {
    51.          CheckTurn(f);
    52.          return false;
    53.        }
    54.  
    55.        // Walk to my target
    56.        for (int i = 0; i < iSteps; i++)
    57.        {
    58.          // Get the current distance
    59.          int iCurrDist = (int)m.GetDistanceToSqrt(f);
    60.  
    61.          if (iCurrDist < iWantDistMin || iCurrDist > iWantDistMax)
    62.          {
    63.            bool needCloser = (iCurrDist > iWantDistMax);
    64.  
    65.            if (needCloser && m_Path != null && m_Path.Goal == f)
    66.            {
    67.              if (m_Path.Follow(bRun, 1))
    68.                m_Path = null;
    69.            }
    70.            else
    71.            {
    72.              Direction dirTo;
    73.  
    74.              if (needCloser)
    75.                dirTo = m.GetDirectionTo(f);
    76.              else
    77.                dirTo = f.GetDirectionTo(m);
    78.  
    79.              // Add the run flag
    80.              if (bRun)
    81.                dirTo = dirTo | Direction.Running;
    82.  
    83.              if (!DoMove(dirTo, true))
    84.              {
    85.                if (needCloser)
    86.                {
    87.                  m_Path = new PathFollower(m, f);
    88.                  m_Path.Mover = new MoveMethod(DoMoveImpl);
    89.  
    90.                  if (m_Path.Follow(bRun, 1))
    91.                    m_Path = null;
    92.                }
    93.                else
    94.                {
    95.                  m.Direction = m.GetDirectionTo(f);
    96.                  m_Path = null;
    97.                }
    98.              }
    99.              else
    100.              {
    101.                m_Path = null;
    102.              }
    103.            }
    104.          }
    105.        }
    106.  
    107.        // Am I where I want to be now?
    108.        int iNewDist = (int)m.GetDistanceToSqrt(f);
    109.  
    110.        if (iNewDist >= iWantDistMin && iNewDist <= iWantDistMax)
    111.          return true;
    112.        return false;
    113.      }
    114.  
    115.      public virtual void CheckTurn( Mobile f )
    116.      {
    117.        BaseCreature m = m_Mobile as BaseCreature;
    118.        if ( f == null )
    119.          return;
    120.      
    121.        if ( Core.TickCount <= m.LastMoveTime + 1000 )
    122.          return;
    123.  
    124.        if ( Core.TickCount <= NextTurn )
    125.          return;
    126.  
    127.        Direction d = m.GetDirectionTo(f);
    128.        if ( d != m.Direction && (BlockingMove() || m.DisallowAllMoves || Core.TickCount >= m.LastMoveTime + 2000) )
    129.        {
    130.          NextTurn = Core.TickCount + 1000;
    131.          m.Direction = d;
    132.        }
    133.        else if ( Core.TickCount < m.LastMoveTime + 2000 )
    134.        {
    135.          d = (Direction)((int)d + Utility.RandomList(-1, +1));
    136.          Timer.DelayCall(TimeSpan.FromMilliseconds(1), new TimerStateCallback(Turn), f);
    137.          NextTurn = Core.TickCount + 1000;
    138.          m.Direction = d;
    139.        }
    140.      }
    141.  
    142.      public virtual void Turn(object o)
    143.      {
    144.        BaseCreature m = m_Mobile as BaseCreature;
    145.        if ( m == null || m.Deleted || !m.Alive || m.Map == null || m.Map == Map.Internal )
    146.          return;
    147.        Mobile f = o as Mobile;
    148.        if ( f == null || f.Deleted || !f.Alive || f.Map == null || f.Map == Map.Internal )
    149.          return;
    150.        if ( m.Map != f.Map )
    151.          return;
    152.        m.Direction = m.GetDirectionTo(f);  
    153.      }
    154.  
    155.      public virtual bool BlockingMove()
    156.      {
    157.        if ( m_Mobile.Spell == null || !m_Mobile.Spell.IsCasting || m_Mobile.Target != null )
    158.          return false;
    159.        if ( m_Mobile.Spell != null && m_Mobile.Spell.IsCasting )
    160.          return true;
    161.        return false;
    162.      }
    163.  
     
    #13 GriffonSpade, Apr 1, 2017
    Last edited: Apr 1, 2017
  14. timginter
    Offline

    timginter Member

    Joined:
    Jun 21, 2016
    Messages:
    49
    Likes Received:
    2
    I think I remember SunUO using normal running animations until a mob had to walk. I'll have a look if it disabled WarMode in combat if the enemy was further than a few tiles or something
     
  15. timginter
    Offline

    timginter Member

    Joined:
    Jun 21, 2016
    Messages:
    49
    Likes Received:
    2
    Can anyone confirm it's fixed in newer ServUO releases than 54? I'm planning on merging the newest repo, but need to prepare a few file.

    Weird thing I noticed is that mobiles still run when they are running away with low hp, but not when they run towards the enemy. WarMode has nothing to do with it since mobiles running away still have WarMode on, event guarding pets have WarMode on and they seem to run fine. Really strange
     
Similar Threads: Mobiles running
Forum Title Date
Script Support Bad Mobiles Oct 31, 2017
Script Support Mobiles and Boats Jul 10, 2017
Custom Releases blackrock Mobiles Mar 26, 2017
Script Support New mobiles help Feb 1, 2017
Script Support Utilizing mobiles as "animation containers" Jan 16, 2017
Script Support Hued tag to items/mobiles Sep 23, 2016
Script Support Working on LOT mobiles, sound issues Jun 26, 2016