Recreating the Boo's movement pattern

Post here for help and support regarding LunaLua and SMBX2's libraries and features.
InternetPeasent
Shy Guy
Shy Guy
Posts: 7
Joined: Sat Sep 04, 2021 12:33 pm
Pronouns: he/him
Contact:

Recreating the Boo's movement pattern

Postby InternetPeasent » Thu Nov 03, 2022 8:32 pm

Heyo! Currently, I am attempting to recreate the Telly from Mega Man 2, and I need to make it move like the boo does (without stopping when you look at it).
I tried using the chasing code in the docs, but 1. it can't move vertically 2. Even if it could, it would only be able to move in 8 directions.
Can anyone help me out here?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9718
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Recreating the Boo's movement pattern

Postby Emral » Thu Nov 03, 2022 9:22 pm

If you want it to be just like the boo, you can use boo.lua.

npc-n.lua (this code does not need to be changed. NPC_ID is automatically filled in by the file name):

Code: Select all

local boo = require("npcs/ai/boo")

// npc initialization code

boo.register(NPC_ID, function() return true end)
The 2nd argument of boo.register is a function defining the condition under which it should chase. By just returning true, it will always chase.

InternetPeasent
Shy Guy
Shy Guy
Posts: 7
Joined: Sat Sep 04, 2021 12:33 pm
Pronouns: he/him
Contact:

Re: Recreating the Boo's movement pattern

Postby InternetPeasent » Thu Nov 03, 2022 9:59 pm

Enjl wrote:
Thu Nov 03, 2022 9:22 pm
If you want it to be just like the boo, you can use boo.lua.

npc-n.lua (this code does not need to be changed. NPC_ID is automatically filled in by the file name):

Code: Select all

local boo = require("npcs/ai/boo")

// npc initialization code

boo.register(NPC_ID, function() return true end)
The 2nd argument of boo.register is a function defining the condition under which it should chase. By just returning true, it will always chase.
I pasted the code into my NPC's main AI, but it just freezes in place. Is it supposed to go in the "on tick" function instead? If not, are there any other properties that are required of the AI to work properly?

Emral
Cute Yoshi Egg
Cute Yoshi Egg
Posts: 9718
Joined: Mon Jan 20, 2014 12:58 pm
Flair: Phoenix

Re: Recreating the Boo's movement pattern

Postby Emral » Thu Nov 03, 2022 10:28 pm

Ah, my bad. I misread the function

function() return player end

Boo condition returns the chase target. If there is none, it stands still. My bad.
Oh, also you need some NPC Config flags.
maxspeedx, maxspeedy, accelx, accely, decelx, decely. They're all numbers.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 0 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari