Shoot Bullets to player coordinate

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

Moderator: Userbase Moderators

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

Re: Shoot Bullets to player coordinate

Postby Emral » Thu Sep 19, 2019 8:31 am

'kay so... What I THINK is happening is that your bullet isn't configured to move opposite to its direction value somehow? Try to add the following bit of code to spawnAtDirection:

if directionVector.x ~= 0 then
n.direction = math.sign(directionVector.x)
end

You need to put this section before setting speedX, because setting direction afterwards does some weird stuff to speed I don't quite understand.
If that trick doesn't work... then I'm not sure.

ItsRealGaming[R]
Koopa
Koopa
Posts: 15
Joined: Sat Sep 14, 2019 9:00 am
Flair: R

Re: Shoot Bullets to player coordinate

Postby ItsRealGaming[R] » Tue Sep 24, 2019 6:01 am

Idk what about the frame... But let's move on something else... How would I make a custom block but it's a slope... Without replace a available one... Also, how would I make a one-way block?

P/s: How do I check for bumped block too?

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

Re: Shoot Bullets to player coordinate

Postby Emral » Tue Sep 24, 2019 6:17 am

Bumping routes through the onBlockHit function

function onBlockHit(eventObj, hitBlockObject, fromUpperSide, playerOrNil)
...
end

Use like onNPCHarm and onNPCKill.
For the block property settings, lua is required at the moment. You can manipulate them with Block.config

Examples:
Block.config[751].bumpable = true
Block.config[752].semisolid = true
Block.config[753].floorslope = 1 (or -1, depending on direction)

There's also ceilingslope (works same as floorslope), passthrough (nonsolid), pswitchable, sizeable, and lava (all booleans), as well as frames (int) and the 5 darkness related fields that also exist for NPCs and BGOs (lightoffsetx, lightoffsety, lightradius, lightbrightness, lightcolor)

ItsRealGaming[R]
Koopa
Koopa
Posts: 15
Joined: Sat Sep 14, 2019 9:00 am
Flair: R

Re: Shoot Bullets to player coordinate

Postby ItsRealGaming[R] » Tue Sep 24, 2019 6:41 am

Awesome... So does this work with 32x64 slope? Or I have to make 2 different pieces? Also can I do the uppersolid or bottomsolid or leftsolid... lol I'm dumb... Or should I use NPC...?

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

Re: Shoot Bullets to player coordinate

Postby Emral » Tue Sep 24, 2019 6:47 am

Bottomsolid and sidesolid are not supported by SMBX. You gotta do some weird hacks to get those working, and even then it's hard to make them work for players AND npcs.
Blocks resize automatically based on their image size. The slope flags just define the orientation of the collision triangle (which is then stretched to fit the image size).

ItsRealGaming[R]
Koopa
Koopa
Posts: 15
Joined: Sat Sep 14, 2019 9:00 am
Flair: R

Re: Shoot Bullets to player coordinate

Postby ItsRealGaming[R] » Tue Sep 24, 2019 6:50 am

Lol that's no big deal... I believe lua can implement pretty much thing... In the future, it will be possible :3. Thank for helping

ItsRealGaming[R]
Koopa
Koopa
Posts: 15
Joined: Sat Sep 14, 2019 9:00 am
Flair: R

Re: Shoot Bullets to player coordinate

Postby ItsRealGaming[R] » Tue Oct 01, 2019 8:50 am

How do I check for block collision? I use collision up/down/left/right but my custom npc stuck at ceiling slope (btw my custom is no gravity and speed = 0 with my old spawnAtDirection function)...

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

Re: Shoot Bullets to player coordinate

Postby Emral » Tue Oct 01, 2019 9:04 am

ItsRealGaming[R] wrote:
Tue Oct 01, 2019 8:50 am
How do I check for block collision? I use collision up/down/left/right but my custom npc stuck at ceiling slope (btw my custom is no gravity and speed = 0 with my old spawnAtDirection function)...
What are you trying to do? If you're trying to reflect it, look at rebound.lua in the scripts/npcs folder.That file is used by diagonal podoboos and boo snakes. For proper reflections you have to work with raycasts. If you're just trying to kill it or whatnot, the collidesBlockBottom/Top/Left/Right flags should work as long as the NPC has block collision enabled.

ItsRealGaming[R]
Koopa
Koopa
Posts: 15
Joined: Sat Sep 14, 2019 9:00 am
Flair: R

Re: Shoot Bullets to player coordinate

Postby ItsRealGaming[R] » Thu Oct 03, 2019 5:59 am

ok nvm... This is solved... But how can I make a custom powerup without replace or fix the current power...?

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

Re: Shoot Bullets to player coordinate

Postby Emral » Thu Oct 03, 2019 6:35 am

You must replace an existing powerup at the moment. If we had the ability to add more yet, there would be some in basegame.

kirbyhasn
Bit
Bit
Posts: 67
Joined: Sun Nov 28, 2021 1:30 am
Pronouns: kirbyhasn
Contact:

Re: Shoot Bullets to player coordinate

Postby kirbyhasn » Fri Dec 24, 2021 4:19 am

i think this might be good for tank levels
like player control a tank and shoot using mouse pointer to aim


Return to “LunaLua Help”

Who is online

Users browsing this forum: No registered users and 2 guests

SMWCentralTalkhausMario Fan Games GalaxyKafukaMarioWikiSMBXEquipoEstelari