Rumia's Lua Abominations

Status
Not open for further replies.
"gamemap" is a global variable that returns the current map's number, so doing "mapheaderinfo[gamemap].typeoflevel" would work.

Also, there's another global variable called "maptol" that is exactly the same as what Zipper described except shorter
 
Is there a ceiling variant of MFE_JUSTHITFLOOR?

EDIT: Also, is there a way to change the player's height without changing the scale of the player? I've tried player.mo.height but it isn't working for some reason.
 
Last edited:
Unfortunately, there's no version of MFE_JUSTHITFLOOR for ceilings, so you'll have to make your own variable to check that. There's also no way to change a player mobj's height except by changing its scale or forcing it into a state that's hardcoded to have a height of 32*FRACUNIT instead of 48*FRACUNIT, like S_PLAY_PAIN.
 
The game auto-corrects the player's height every tic; if the player is spinning/in pain/flying then they use spin height, otherwise they use the normal player height. I'm not sure there's a good way around it at all for the time being tbh.
 
Is there any way to create a timer for a bot to follow player 1 input commands with?
 
I am working with BotAI, but I don't think you understood my question. I've tried adding a ThinkFrame hook for "sonic" to record button inputs from the player, and then have a time delay for when that button is pressed for "tails" in the BotAI hook but it ended up not working for some reason. I'd post what I made but somehow I accidentally deleted the script I was working on at the time and have no way of getting it back due to saving over it AND the backup that SLADE keeps.
 
Hi there once again, this time I was wondering how to detect when the player is spawning in the level so I can give them a shield when the level starts, and I was wondering how I could make it so Sonic can hang from a flying AI Tails.
 
Last edited:
The "PlayerSpawn" hook is totally the best for spawning a shield when a player spawns ...except that in 2.1.19 it doesn't run for spawning at a checkpoint. I've changed this for future versions but otherwise... maybe some kind of flag set by MobjSpawn for MT_PLAYER that is later detected by a ThinkFrame or MobjThinker hook?

As for a Tails bot flying Sonic, apparently the code for grabbing a flying player is hardcoded not to work if Tails is a bot and using the normal bot AI as opposed to be being conrolled by a player (see here)... so, you'll probably have to recreate the relevant code with a MobjCollide or MobjMoveCollide hook. Most of it looks like it can be translated to Lua at least.
 
Actually, it's far easier to just add an if nil check for a player.mobj variable, as those are all wiped each time the player dies or changes level. obviously, you'll want to set the variable to something afterwards.
 
Are there Lua equivalents to the following?

P_SetTarget
P_UnsetThingPosition
and P_SetThingPosition

if not, how would I go about recreating what they do?
 
The first is handled by just setting mobj.target = some mobj reference or nil. Exposing the function would add more complication when we can just make the direct assignment safe.

The latter two are not safe to expose, and are only done as part of movement. You should call either P_TryMove (checks each spot in the way) or P_TeleportMove (goes directly there) in order to handle the act of unsetting, moving, and then resetting a mobj. If you don't want any movement to happen, you can just set the coordinates of P_TeleportMove to be the current ones - but I don't really get WHY you'd want to do that, anyways.
 
Apologies for repeating what toaster said a little, I feel more has to be clarified on what the functions do and why you don't need to have access to them.

P_SetTarget is a function to do a mobj pointer assignment (usually mobj.target, but is also used for mobj.tracer and other points), while also marking it as a "reference" to the mobj (or removing the reference if it's assigned to a new mobj or nothing), so that when the mobj is removed, it doesn't immediately go away until all "references" to it have been cleared. This prevents certain problems from happening with pointers to mobjs that no longer exist. In Lua, the function is automatically used whenever you assign a new value to mobj.target or mobj.tracer and a bunch of other already existing mobj pointers. Custom Lua variables set to mobj_t meanwhile are automatically cleaned up if said mobjs no longer exist (I think). So you shouldn't need access to that function.

P_UnsetThingPosition and P_SetThingPosition are functions to unlink an object from the blockmap and sector lists, and relink it to them using the current position and flags. Therefore in the game it's only used if the x and y positions were modified, or if you changed whether an object uses the MF_NOBLOCKMAP or MF_NOSECTOR flags or not. Lua only allows you to change x/y using functions like P_TeleportMove/P_TryMove, and automatically uses the functions if you turn on or off those two flags. So you don't need access to those two functions either.
 
Last edited:
Hi again, can somebody please direct me to where the 2D mode is handled within the source code. Thank you.
 
Sorry for being late to respond!

There's no specific place in the source code I can think of that handles 2D mode in general (maybe you need to be more specific about what you want?), but just search for anything involving "MF2_TWOD" or "twodlevel" and you may find what you want.
 
For some reason I can't figure out, whenever Shadow runs down certain slopes with this script I made loaded, he starts accelerating infinitely to rediculous speeds as seen in this gif here, the same happens when using Metal Sonic's Maximum Overdrive.
The desired behavior is shown here. What am I doing wrong?
 
Characters like Shadow and Metal Sonic modify friction values during certain states (for Shadow, it's skating; for Metal, it's Overdrive). If I had to guess, your issue is that your script is optimized for characters with regular friction. The speed increases you make are balanced out by the friction values of most characters, but when there's less friction, your speed increases have more of an effect.
 
Status
Not open for further replies.

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

Back
Top