Page 1 of 1

Link Up Slash

Posted: Sat Dec 09, 2017 4:15 pm
by fern
Is there a way I could make Link perform the up slash automatically.

I have this as a placeholder:

Code: Select all

function onTick()
	if player.jumpKeyPressing or player.altJumpKeyPressing or player.speedY ~= 0 then
		player.upKeyPressing = true
	end
end
It works, but it's not great when you're standing in front of signs/doors.

Re: Link Up Slash

Posted: Sat Dec 09, 2017 7:40 pm
by PixelPest
Look for a field here that has to do with it and try that maybe: http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets

Re: Link Up Slash

Posted: Sun Dec 10, 2017 12:42 pm
by Emral
PixelPest wrote:Look for a field here that has to do with it and try that maybe: http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Or try the correct spot.
Offset 0x44 is true/-1 when a player stands in front of the NPC and the little exclamation point appears. It does not distinguish between players, though, so what you want to do:

Code: Select all

function onTick()
	local npcBlock = false
	for k,v in ipairs(NPC.getIntersecting(player.x, player.y, player.x + player.width, player.y + player.height)) do
		if v.friendly and v:mem(0x44, FIELD_WORD) == -1 then
			npcBlock = true
			break
		end
	end
	if not (player:isGroundTouching() or npcBlock) then
		player.upKeyPressing = true
	end
end
Be careful: This will ALSO lock the up key when swimming and in fairy state. Refer to pixelpest's link for flags which you can use to exclude those scenarios.

Re: Link Up Slash

Posted: Sun Dec 10, 2017 5:08 pm
by fern
Enjl wrote:
PixelPest wrote:Look for a field here that has to do with it and try that maybe: http://wohlsoft.ru/pgewiki/SMBX_Player_Offsets
Or try the correct spot.
Offset 0x44 is true/-1 when a player stands in front of the NPC and the little exclamation point appears. It does not distinguish between players, though, so what you want to do:

Code: Select all

function onTick()
	local npcBlock = false
	for k,v in ipairs(NPC.getIntersecting(player.x, player.y, player.x + player.width, player.y + player.height)) do
		if v.friendly and v:mem(0x44, FIELD_WORD) == -1 then
			npcBlock = true
			break
		end
	end
	if not (player:isGroundTouching() or npcBlock) then
		player.upKeyPressing = true
	end
end
Be careful: This will ALSO lock the up key when swimming and in fairy state. Refer to pixelpest's link for flags which you can use to exclude those scenarios.
Thank you for this, just one question. Is there a simpler way, such as forcing a certain sprite? I tried player:setCurrentSpriteIndex(4,10, true) , but it didn't work.

The only reason I want him to press up is because I don't want him crouching when he jumps. People told me you can change animations with PGE Calibrator, but I can't get it to work, I was only able to resize the hitboxes.

Re: Link Up Slash

Posted: Sun Dec 10, 2017 7:29 pm
by Emral
"Pressing up" and "Not crouching" are two very different things. Can't you just set downKeyPressing to false when in midair?
If you mean the jump sprite you can set player:mem(0x114, FIELD_WORD, n) when jumping where n is the new frame you want it to be, though you do have to go through the PGE calibrator which is explained here.

Re: Link Up Slash

Posted: Sun Dec 10, 2017 7:52 pm
by fern
Enjl wrote:"Pressing up" and "Not crouching" are two very different things. Can't you just set downKeyPressing to false when in midair?
If you mean the jump sprite you can set player:mem(0x114, FIELD_WORD, n) when jumping where n is the new frame you want it to be, though you do have to go through the PGE calibrator which is explained here.
I've already tried setting player:mem(0x114, FIELD_WORD) to the jump sprite when player.speedY ~= 0 and it doesn't work. I've also tried using PGE Calibrator, but the animations don't load, only changing hitboxes works. Unless I'm doing something wrong. :?:

How exactly do you change the animations? Do you just set them up like this and save the INI? Because this is what I've been doing, and then I load them into Lua using Level.loadPlayerHitboxes(). Is there a different function for loading the animations?
Image

EDIT: I do have downKeyPressing set to false in midair to prevent the player from using the downward slash, but the crouching sprite is part of his jump animation.

Re: Link Up Slash

Posted: Sun Dec 10, 2017 8:01 pm
by Hoeloe
fern wrote: I've already tried setting player:mem(0x114, FIELD_WORD) to the jump sprite when player.speedY ~= 0 and it doesn't work.
Yes it does, but you have to do it from within onDraw, not onTick.

Re: Link Up Slash

Posted: Sun Dec 10, 2017 8:17 pm
by fern
Hoeloe wrote:
fern wrote: I've already tried setting player:mem(0x114, FIELD_WORD) to the jump sprite when player.speedY ~= 0 and it doesn't work.
Yes it does, but you have to do it from within onDraw, not onTick.
Ahhhhh, well that fixes the sprite, thank you! However, the character still uses the crouching hitbox. :(
I notice the sprite begins under the floor and when it gets to the top of the jump, it shifts up.
I tried setting player:mem(0x12E, FIELD_BOOL, false) but he still crouches in midair.

EDIT: Could someone tell me if I'm using PGE Calibrator correctly?

Re: Link Up Slash

Posted: Mon Dec 11, 2017 5:43 am
by Hoeloe
Try setting player.height.

Re: Link Up Slash

Posted: Mon Dec 11, 2017 7:57 pm
by fern
Hoeloe wrote:Try setting player.height.
I just tried this and it makes the character get stuck and slide under the floor. I also tried PlayerSettings.hitboxHeight and PlayerSettings.hitboxDuckHeight and they both seemed to have no effect.

I also tried PlayerSettings:setSpriteOffsetY() and it gave me the following error:
Image

Code: Select all

local function correctJump()
	if player.speedY ~= 0 and not player:isGroundTouching() and player:mem(0x114,FIELD_WORD) == 5 then
		player:mem(0x114, FIELD_WORD, 10)
		player:mem(0x12E, FIELD_BOOL, false)
		PlayerSettings:setSpriteOffsetY(5,5,11)
	end
end

Re: Link Up Slash

Posted: Mon Dec 11, 2017 8:23 pm
by Hoeloe
fern wrote:
Hoeloe wrote:Try setting player.height.
I just tried this and it makes the character get stuck and slide under the floor.
This is because the character's position is at the top left of the sprite. If you extend the height, it extends the hitbox down, meaning your hitbox goes into the floor. You need to not just extend the hitbox, but also move the player up by the same amount you extended it.

Re: Link Up Slash

Posted: Mon Dec 11, 2017 8:30 pm
by The0x539
fern wrote:I also tried PlayerSettings:setSpriteOffsetY() and it gave me the following error:
Because you're trying to invoke setSpriteOffsetY on the PlayerSettings class. You're supposed to call it from a PlayerSettings object. You can get a PlayerSettings object by calling player:getCurrentPlayerSetting(). Stick the result into a variable and do stuff with it.

Re: Link Up Slash

Posted: Mon Dec 11, 2017 8:47 pm
by fern
Hoeloe wrote:
fern wrote:
Hoeloe wrote:Try setting player.height.
I just tried this and it makes the character get stuck and slide under the floor.
This is because the character's position is at the top left of the sprite. If you extend the height, it extends the hitbox down, meaning your hitbox goes into the floor. You need to not just extend the hitbox, but also move the player up by the same amount you extended it.
That's what I thought about doing, but I thought changing player.x onDraw() was gonna shoot him up in the air, but it worked, thank you!

Re: Link Up Slash

Posted: Mon Dec 11, 2017 8:48 pm
by fern
The0x539 wrote:
fern wrote:I also tried PlayerSettings:setSpriteOffsetY() and it gave me the following error:
Because you're trying to invoke setSpriteOffsetY on the PlayerSettings class. You're supposed to call it from a PlayerSettings object. You can get a PlayerSettings object by calling player:getCurrentPlayerSetting(). Stick the result into a variable and do stuff with it.
It's all good now, but this is good to know, thank you!