Need help with a disjointed hitbox

DoubleATam

she/her
I'm a bit of a newcomer to this game, but I have past experience with programming and Lua, and i've already been working on some mods in the past month (following the wiki, forum posts, source code, and reusable mods). But I still don't really understand how to give a player a separate but like, seamlessly integrated hitbox? Such as for a melee attack. I didn't find anything in the base game that actually did that (and something like Amy's heart projectiles isn't a great substitute, either.)

I've barely managed to make an invisible/intangible object follow you as a sort of hitbox, but only kinda hackily, using P_TeleportMove in the player thinker, and it ends up one frame delayed behind the player (logically because the player only updates the position afterward), so I don't think that's correct.

Then again, I also don't have a good grasp on how to make a new object or projectile at all. I didn't find a good guide for it, and all the necessary information's currently scattered. (ADHD makes it really difficult to follow unclear instructions or finish complicated things. But I also tend to save asking for help for last...)
 
Maybe you need to use PreThinkFrame or PostthinkFrame or something?
 
Maybe you need to use PreThinkFrame or PostthinkFrame or something?
Timing-wise? Yeah I'm trying to figure out the execution order on the Lua hooks and physics updates. Let's see, after some testing and code skimming I belieeeeve... prethink, then playerthink, then each object updates one by one (thinker, then collide, then physics update (almost sounds backwards but i think it's normal?), then next object etc) (i think they're checked in the order they were created in? so the level objects are actually first?); then after every object thinker is done it does P_PlayerAfterThink (which includes followthink), then thinkframe, then some other minor things, then postthinkframe, then render. I'm probably slightly off though. It also seems like followmobj skips a typical thinker.

So from that overview it seems that it "lagging behind" is the "correct" behavior for a hitbox, just not visually? But only as long as the collision check happens immediately after the player's, which i don't think I have much control over but should be what's happening anyway... would it be any better if I set it as the follow object? I have no idea if that's a good idea or not. I'm probably overthinking it anyway.

(Maybe I should draw up a diagram if someone corrects me?)


I guess my next question is if there's any suggestions for how to get an object to cause the same reactions as if a player object directly hit an enemy... But I guess I probably have no choice but to simply replicate the bounce on the player and the damage on the enemy through a collision hook. It seems like that's what something like Katmint's Instashield mod does. I'm slowly gathering information still, I guess next I just have to implement it and check if it works.
 

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

Back
Top