Chasing npc help?

Post here for help and support regarding LunaLua and SMBX2's libraries and features.

Moderator: Userbase Moderators

Hammerless Penguin
Snifit
Snifit
Posts: 203
Joined: Sat Sep 22, 2018 6:17 am
Flair: Just kicking that kirby to the curb!
Contact:

Chasing npc help?

Postby Hammerless Penguin » Thu Dec 23, 2021 7:05 pm

Im currently trying to make a new custom npc that chases the player around and im not sure what I should do to place in the lua file. I've tried

Code: Select all

Player.getNearest(x,y)
and

Code: Select all

function onTick()
-- ...
    snpc = ... -- self NPC
-- ...
    local p = Player.getNearest(snpc.momentum.x + snpc.momentum.w, snpc.momentum.y + snpc.momentum.h)
    if(p)
        -- Do some logic with player object "p"
    end
-- ...
end

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: Chasing npc help?

Postby Marioman2007 » Tue Dec 28, 2021 6:59 am

If you want the NPC to chase the player like a chasing koopa, then you could set isflying to true.

NoobSimBot
Goomba
Goomba
Posts: 2
Joined: Fri Apr 15, 2022 8:05 pm
Pronouns: he/him

Re: Chasing npc help?

Postby NoobSimBot » Fri Apr 15, 2022 8:10 pm

Marioman2007 wrote:
Tue Dec 28, 2021 6:59 am
If you want the NPC to chase the player like a chasing koopa, then you could set isflying to true.
I also have an NPC whose "isFlying" is set to True. Only problem is, despite having the Paratroopa algorithm in the .ini file of the NPC, it still
resorts to chasing the player and ignores the other options (Jump, Hover Left/Right, etc.)

Marioman2007
2025 Egg Hunter
2025 Egg Hunter
Posts: 544
Joined: Tue Aug 25, 2020 3:19 am
Flair: Dr. Bones
Pronouns: He/Him

Re: Chasing npc help?

Postby Marioman2007 » Sat Apr 16, 2022 5:57 am

NoobSimBot wrote:
Fri Apr 15, 2022 8:10 pm
Marioman2007 wrote:
Tue Dec 28, 2021 6:59 am
If you want the NPC to chase the player like a chasing koopa, then you could set isflying to true.
I also have an NPC whose "isFlying" is set to True. Only problem is, despite having the Paratroopa algorithm in the .ini file of the NPC, it still
resorts to chasing the player and ignores the other options (Jump, Hover Left/Right, etc.)
Because ini files only affect the editor.

NoobSimBot
Goomba
Goomba
Posts: 2
Joined: Fri Apr 15, 2022 8:05 pm
Pronouns: he/him

Re: Chasing npc help?

Postby NoobSimBot » Sat Apr 16, 2022 12:15 pm

Because ini files only affect the editor.
This one I learned it myself. The thing is, I want this NPC to actually care about the choice of algorithm in the editor, and behave as told.
I know I should look around in the .lua file of the NPC, but I don't know how to just make it so it acts like the other Parakoopas in
the editor.

Just trying to learn lua language is a really huge chore for me, hence my username.


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 3 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari