Page 1 of 1

Recreating the Boo's movement pattern

Posted: Thu Nov 03, 2022 8:32 pm
by InternetPeasent
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?

Re: Recreating the Boo's movement pattern

Posted: Thu Nov 03, 2022 9:22 pm
by Emral
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.

Re: Recreating the Boo's movement pattern

Posted: Thu Nov 03, 2022 9:59 pm
by InternetPeasent
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?

Re: Recreating the Boo's movement pattern

Posted: Thu Nov 03, 2022 10:28 pm
by Emral
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.