Wrong Para-Koopas/Para-Goombas Chasing AI

Description: Report bugs of SMBX-38A here.
Forum rules: https://wohlsoft.ru/forum/viewtopic.php?f=64&t=1069
Moderators: Yoshi021, Lx Xzit, 5438A38A, Moderators, Semi-moderatos

Lx Xzit M
Topic author, Moderator
Moderator
Avatar
Lx Xzit M
Topic author, Moderator
Moderator
Reputation: 403
Posts: 762
Joined: 9 Nov 2015
Website Youtube channel URL

Post #1by Lx Xzit » 26 Jun 2018, 5:52

While I was doing some tests I found things that really needs to be fixed with Hover / Chasing behaviours, especially the last one. This applies for all the kind of para-goombas and para-koopas.

Chasing AI
What are the problems with the current chasing AIs? They are very inaccurate, they do not have any speed limits (meaning the can go at the speed of light) and will get stuck in almost every edge. These things make the chasing pretty inaccurate.

I made a deep research over SMBX 1.3 and found that their chasing AIs are actually very interesting: when the NPC is under the player and it's horizontally close (A distance minor than 5 blocks) it will try to move away from the player until gains altitudes and stabilish itself in the process. I also could noticce that the acceleration is much more slower than in SMBX 1.4.4. Knowing this, I made a chasing AI which tries to be a recreation to SMBX 1.3's AI.

Spoiler
Red: original Chasing AI
Green: Custom AI
Image

The code can explain the things better that I could, please give it a look:
Spoiler

Code: Select all

with npc(sysval(param1))

   'Speed limits
   if .xsp => 3.2 then
      .xsp = 3.2
      elseif .xsp <= -3.2 then
      .xsp = -3.2
      elseif .ysp => 3.4 then
      .ysp = 3.4
      elseif .ysp <= -3.4 then
      .ysp = -3.4
   end if
   
   'First frames control
   .ivala = .ivala + 1
   
   'Collision with Block
   if .ysp = 0 and .ivala > 2 then
      .ysp = -3.6
      elseif .xsp = 0 and .ivala = 0 then
      .xsp = 1
   end if
   
   'Horizontal movement
   if char(1).x > .x - char(1).pwidth + 32 + 6 then
      if .ivalc = 0 then
         .xsp = .xsp + 0.048   
      end if   
      if .facing = 1 then
         .facing = 0
      end if
   elseif char(1).x < .x + 32 - 6 then
      if .ivalc = 0 then
         .xsp = .xsp - 0.048   
      end if
      if .facing = 0 then
         .facing = 1
      end if
   end if
      
   'Vertical movement (sighly different to the horizontal one)
   if char(1).y > .y - char(1).pheight + 32 then
      .ivalc = 0
      .ysp = .ysp + 0.056   
      .ivalc = 0
      elseif char(1).y < .y + char(1).pheight + 32*4 then
      .ysp = .ysp - 0.036   
      
      'If the npc is under the player and it's close, it'll will try to move away. The ivalc control is to prevent two movements of x axis at the same time
      if char(1).x > .x - char(1).pwidth - 32*4 + 32 and char(1).x < .x + 32*4 then   
         if .x > char(1).x then
            .xsp = .xsp + 0.048   
         elseif .x < char(1).x then
            .xsp = .xsp - 0.048
         end if
         .ivalc = 1
      else
         .ivalc = 0
      end if
   end if
end with

Here's the example level:
Flying AI.zip
(4.18 KiB) Downloaded 199 times


Another little suggestion:
I noticed that in SMBX 1.4 the Para-Goombas and Para-Koopas jumps actually a bit mor (in comparison to SMBX 1.3). I'd suggest add a jump of a Y speed of -8 instead of -9 which is the current one) in this way it would stand exact the same as SMBX 1.3.

Return to “SMBX-38A Bug reports”

Who is online (over the past 5 minutes)

Users browsing this forum: 3 guests