custom "screw jump" doesn't scale correctly

Status
Not open for further replies.

SSG3

Oh, THAT Youtuber...
I'm trying to make a "Screw Jump" for a custom character, but it doesn't scale correctly. how can I get it to scale to the player's current size?

Here's the code extract:
Code:
if not (P_IsObjectOnGround(player.mo))
			and (player.canscrew == 1)
			and (player.justscrewed == 0)
			and (player.cmd.buttons & BT_CUSTOM2)
			and not (player.spectator)
			and not (player.pflags & PF_NIGHTSMODE)
			and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
			and not (player.mo.state == S_PLAY_DIE) then
				if (player.mo.flags2 & MF2_OBJECTFLIP)
					player.mo.momz = -10*FRACUNIT
				else
					player.mo.momz = 10*FRACUNIT
				end
				S_StartSound(player.mo, sfx_jump)
				S_StartSound(player.mo, sfx_fre001)
				P_SpawnGhostMobj(player.mo)
				player.cansrew = 2
				player.justscrewed = 1
			end
 
Last edited:
Replace the following code:

Code:
				if (player.mo.flags2 & MF2_OBJECTFLIP)
					player.mo.momz = -10*FRACUNIT
				else
					player.mo.momz = 10*FRACUNIT
				end

with this:

Code:
				P_SetObjectMomZ(player.mo, 10*FRACUNIT, false)

P_SetObjectMomZ is a special function that sets an object's momz for you, as well as automatically flipping it for reverse gravity and scaling it with the object's own scale.

For future reference purposes though, you COULD also have done this to scale your "Screw jump":

Code:
				if (player.mo.eflags & MFE_VERTICALFLIP)
					player.mo.momz = -FixedMul(10*FRACUNIT, player.mo.scale)
				else
					player.mo.momz = FixedMul(10*FRACUNIT, player.mo.scale)
				end

(I also note that you should check for MFE_VERTICALFLIP rather than MF2_OBJECTFLIP to determine whether an object is in reverse gravity. MFE_VERTICALFLIP controls flipping of physics and sprites, MF2_OBJECTFLIP merely forces flipped physics on but can be negated by other sources of reverse gravity)
 
Last edited:
Thanks. it worked! Also, I'm just making my own version of a "Metroid Sonic (samus clone)" which has gone on over about a few months, maybe more. just a double jump with custom 2... might make it more "Screw" like when i can (similar to the one i saw on you youtube with the prologue thing on CB)

That was just if you was wondering, that's all. Again, thanks for the help!

EDIT:
Sorry for bothering you again (and this part is more off-topic) , but the death message doesn't print when i kill someone with a projectile. instead, it print the hit message. here's the code:
Code:
addHook("HurtMsg", function(player, inflictor, source)
	if not inflictor then
		return false
	else
		source = inflictor.target
	end
	if source and source.player then
		if player.health >= 0 then
			if inflictor.type == MT_JETTBULLET then
				print(source.player.name.."'s fired bullet hit "..player.name..".")
				return true
			elseif inflictor.type == MT_TORPEDO then
				print(source.player.name.."'s super torpedo hit "..player.name..".")
				return true
			end
		elseif player.health <= 0
			if inflictor.type == MT_JETTBULLET then
				print(source.player.name.."'s fired bullet killed "..player.name..".")
				return true
			elseif inflictor.type == MT_TORPEDO then
				print(source.player.name.."'s super torpedo killed "..player.name..".")
				return true
			end
		end
	end
	return false
end)
 
Last edited:
Sorry for the double post... just bumping this thread go get some attention to the last post
 
IIRC the HurtMsg hook is run before the damage is actually applied. So what you wanna do to test for hurt vs killed is:

Code:
if damage >= 10000 or player.mo.health == 1 then
    -- Damage kills the player
else
    -- Merely a flesh wound!
end
 
I tried that method, and the console printed "attampt to compare argument with nil" on the line of "if damage >=1000 or player.mo.health == 1 then"... I think I've done it wrong... I replaced this:

Code:
if player.health >= 0 then

... with this:

Code:
if damage >=1000 or player.mo.health == 1 then

Am I supposed to do that?

And yeah... sorry for my noobishness. I'm just learning the code myself, so don't expect me to know what I'm doing. And what does IIRC stand for? I can't work it out myself.
 
Last edited:
Sorry again for the double post... gotta bump this topic again...

Due to the "Spam", I've gotta add more content... so, I've made a typo with the screw jump...

Code:
... from first post, with the IF statements..

                        and (player.cmd.buttons & BT_CUSTOM2)
			and not (player.spectator)
			and not (player.pflags & PF_NIGHTSMODE)
			and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
			and not (player.mo.state == S_PLAY_DIE) then
				if (player.mo.flags2 & MF2_OBJECTFLIP)
					player.mo.momz = -10*FRACUNIT
				else
					player.mo.momz = 10*FRACUNIT
				end
				S_StartSound(player.mo, sfx_jump)
				S_StartSound(player.mo, sfx_fre001)
				P_SpawnGhostMobj(player.mo)
				[B]player.cansrew[/B] = 2
				player.justscrewed = 1

I've now fixed that with player.canscrew = 2... That should adjust correctly now.
 
Last edited:
sorry for posting once again... this time it's the momentum of the attack that players instantly get, as if they performed an air drill... but i'm not sure if the variable P_INSTATHRUST should be used:

Code:
if not (P_IsObjectOnGround(player.mo)) and (player.jumping)
			and (player.canscrew ~= 2)
			and (player.isscrewing ~= 2)
			and (player.screwjumps ~= 5)
			and (player.screwjumping)
			and not (player.spectator)
			and not (player.pflags & PF_NIGHTSMODE)
			and not (player.mo.tracer and player.mo.tracer.type == MT_TUBEWAYPOINT)
			and not (player.mo.state == S_PLAY_DIE) then
				if (player.mo.eflags & MFE_UNDERWATER)
					P_SetObjectMomZ(player.mo, 5*FRACUNIT, false)
				else
					P_SetObjectMomZ(player.mo, 10*FRACUNIT, false)
					end
				S_StartSound(player.mo, sfx_fre800)
				player.screwjumps = $1 + 1
				player.isscrewing = 1
				if player.screwjumps >= 5
					player.canscrew = 2
					player.isscrewing = 2
				end
				player.stillscrewing = true
			end
			
			if (player.stillscrewing == true)
				P_SpawnGhostMobj(player.mo)
			end

If P_INSTATHRUST has to be used and I want it to make the player, at whatever speed or momentum they've gained, go at 20 FASTS/H constantly, where should I place it at?
 
Last edited:
Status
Not open for further replies.

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top