Idle: Difference between revisions

Jump to navigation Jump to search
2,773 bytes added ,  9 June 2023
(idle: out of: let's GO)
Line 56: Line 56:
# The action is executed.
# The action is executed.
Technically, m->action was set to the stationary action. So although the action doesn't really do anything, there is still a "transition" between such stationary action and [[Water Plunge]], [[Squished]], [[Standing Death]], or [[Quicksand Death]]. So invariably, for all stationary actions, the infobox contains those 4 actions under "Transitions > Into" first (see top right of page if you don't know what I'm talking about).
Technically, m->action was set to the stationary action. So although the action doesn't really do anything, there is still a "transition" between such stationary action and [[Water Plunge]], [[Squished]], [[Standing Death]], or [[Quicksand Death]]. So invariably, for all stationary actions, the infobox contains those 4 actions under "Transitions > Into" first (see top right of page if you don't know what I'm talking about).
== check_common_idle_cancels ==
== check_common_idle_cancels==
Note: This is used only in Idle, [[Start Sleeping]], [[Coughing]], [[In Quicksand]], and [[Panting]].
Note: This is used only in Idle, [[Start Sleeping]], [[Coughing]], [[In Quicksand]], and [[Panting]].
# If Mario is on a steep cliff, he is pushed off (into [[freefall]]).
#If Mario is on a steep cliff, he is pushed off (into [[freefall]]).
# If Mario is hit by a shockwave, his action is set to the [[shockwave bounce]] action.
#If Mario is hit by a shockwave, his action is set to the [[shockwave bounce]] action.
# If A is pressed, his action is set to a jumping action:
#If A is pressed, his action is set to a jumping action:
## If Mario's quicksand depth is at least 11, then if Mario's holding an object, his action is set to [[Hold Quicksand Jump Land]], else [[Quicksand Jump Land]].
##If Mario's quicksand depth is at least 11, then if Mario's holding an object, his action is set to [[Hold Quicksand Jump Land]], else [[Quicksand Jump Land]].
## If Mario's floor is steep, his action is set to [[Steep Jump]], else [[Jump]].
##If Mario's floor is steep, his action is set to [[Steep Jump]], else [[Jump]].
# If Mario is off the floor, Mario's action is set to [[freefall]].
#If Mario is off the floor, Mario's action is set to [[freefall]].
# If Mario is above a slide, he [[Begin Sliding|begins sliding]].
#If Mario is above a slide, he [[Begin Sliding|begins sliding]].
# If Mario goes into first-person mode, his action is set to [[first person]].
#If Mario goes into first-person mode, his action is set to [[first person]].
# If the joystick is held in a direction, Mario's action is set to [[walking]].
#If the joystick is held in a direction, Mario's action is set to [[walking]].
# If B is pressed, Mario's action is set to [[punching]].
#If B is pressed, Mario's action is set to [[punching]].
# If Z is pressed, Mario's action is set to [[start crouching]].<ref>https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_actions_stationary.c#L20-L60</ref>
#If Z is pressed, Mario's action is set to [[start crouching]].<ref>https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_actions_stationary.c#L20-L60</ref>
==stationary_ground_step==
==stationary_ground_step==
https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_step.c#L236
https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_step.c#L236
Line 80: Line 80:
#Call mario_update_windy_ground:<ref>https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_step.c#L190</ref>
#Call mario_update_windy_ground:<ref>https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_step.c#L190</ref>
##If Mario's floor type is SURFACE_HORIZONTAL_WIND (like on the ship in Rainbow Ride):
##If Mario's floor type is SURFACE_HORIZONTAL_WIND (like on the ship in Rainbow Ride):
###Change Mario's velocity[0] and velocity[2] as if the wind was pushing Mario, based on the floor's "force" data, the global timer, and Mario's facing angle.
### Change Mario's velocity[0] and velocity[2] as if the wind was pushing Mario, based on the floor's "force" data, the global timer, and Mario's facing angle.
###return TRUE
### return TRUE
##else return FALSE
##else return FALSE
#If either step 3 or step 4 returned true, step_result = perform_ground_step():
#If either step 3 or step 4 returned true, step_result = perform_ground_step():
##Loop 4 times: ''Do a quarterstep''. The next intended position is Mario's position plus the de facto speed vector. Each time, set '''step_result''' to a '''(value)'''.
##Loop 4 times: ''Do a quarterstep''. The next intended position is Mario's position plus the de facto speed vector. Each time, set '''step_result''' to a '''(value)'''.
###Let ''floor'' be the (first) floor at the next intended position (very complicated). It must be at least -78 units below Mario's y position.
###Let lowerWall be a wall within 30 units of (24 units above the next intended position). <span style="color:green;">Wall push: Change the next intended position based on wall collisions.</span>
### Let upperWall be a wall within 60 units of (50 units above the next intended position). <span style="color:green;">Wall push: Change the next intended position based on wall collisions.</span>
###Let ''floor'' be the (first) floor at the next intended position (TODO? this is complicated). It must be at least -78 units below Mario's y position.
###Let ''ceilingHeight'' be based on the position 80 units above the next intended position and the floor height.
###If the next intended position is OOB, exit loop '''(WALL)'''
###If the next intended position is OOB, exit loop '''(WALL)'''
###If Mario is riding a shell and the floor height is less than the water level (which is -11000 by default)
###If Mario is riding a shell and the floor height is less than the water level (which is -11000 by default)
Line 91: Line 94:
####Set ''floor'' to the global water surface pseudo floor (very slippery, flags: 0, room: 0, vertices: (0, 0, 0), (0, 0, 0), (0, 0, 0), normal vector: (0, 1, 0) i.e. up)<ref>https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_step.c#L14</ref>
####Set ''floor'' to the global water surface pseudo floor (very slippery, flags: 0, room: 0, vertices: (0, 0, 0), (0, 0, 0), (0, 0, 0), normal vector: (0, 1, 0) i.e. up)<ref>https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario_step.c#L14</ref>
####<span style="color:gray;">Set the floor's originOffset to floor height (a comment says this has no effect)</span>
####<span style="color:gray;">Set the floor's originOffset to floor height (a comment says this has no effect)</span>
###If the floor is more than 100 units below Mario
### If the floor is more than 100 units below Mario
####If Mario's height + 160 units is at least the ceiling height, exit loop '''(WALL)'''
####If Mario's height + 160 units is at least the ceiling height, exit loop '''(WALL)'''
####Set Mario's position to the next intended position, Mario's floor to the floor, and Mario's floor height to the floor height; exit loop '''(LEFT GROUND)'''
####Set Mario's position to the next intended position, Mario's floor to the floor, and Mario's floor height to the floor height; exit loop '''(LEFT GROUND)'''
###If ''floor'' height + 160 units is at least the ceiling height, exit loop '''(WALL)'''
###If ''floor'' height + 160 units is at least the ceiling height, exit loop '''(WALL)'''
###Set Mario's position to the next intended position, Mario's floor to the floor, and Mario's floor height to the floor height
###Set Mario's position to the next intended position (<span style="color:dodgerblue;">but Mario's y position to the floor height</span>), Mario's floor to the floor, and Mario's floor height to the floor height
###Let upperWall be a wall within 60 units of (50 units above the next intended position). (This looks even more complicated than finding the floor).
###If the upperWall exists AND not(abs(atan2s(upperWall normal z, upperWall normal x) - Mario facing angle[1]) is between 0x2AAA and 0x5555), exit loop '''(WALL)''', else '''(WALL_CONTINUE)'''
###If the upperWall exists AND not(abs(atan2s(upperWall normal z, upperWall normal x) - Mario facing angle[1]) is between 0x2AAA and 0x5555), exit loop '''(WALL)''', else '''(WALL_CONTINUE)'''
###'''(NONE)'''
###'''(NONE)'''
## Update Mario's "terrain sound addend", graphics position, and graphics angle.
##Update Mario's "terrain sound addend", graphics position, and graphics angle.
## If step_result is (WALL_CONTINUE), set step_result to (WALL)
##If step_result is (WALL_CONTINUE), set step_result to (WALL)
## Return step_result
##Return step_result
# Else:
#Else:
## Set Mario's y position to the floor height. '''This is the cause of many [[Downwarp|downwarps]]'''.
##<span style="color:dodgerblue;">Set Mario's y position to the floor height.</span> '''This is the cause of many [[Downwarp|downwarps]]'''.
## Update Mario's graphics position and graphics angle.
##Update Mario's graphics position and graphics angle.
# Return step_result
#Return step_result
==resolve_and_return_wall_collisions==
A function that's called in the quarterstep code (see green text).
 
This function takes a '''Vec3s position''', '''f32 yOffset''', and '''f32 radius''' as arguments.
 
At times the position is modified, which in the case of stationary_ground_step, means changing the next intended position.
 
'''There's probably a better explanation, something something walls floors and ceilings.'''


https://github.com/n64decomp/sm64/blob/66018e9f3caaa67399218971d61366cb3f7ba7d7/src/game/mario.c#L521
#Let ''walls'' be an empty list (max 4 allocated entries)
#Inner function:
##Let x be (convert f32 to s16) <code>position->x</code>
##Let z be (convert f32 to s16) <code>position->z</code>
##If abs(x) or abs(z) is greater than or equal to LEVEL_BOUNDARY_MAX (i.e. 8192), return.
##A level consists of a 16x16 grid. These subgrids are called "cells" in the comments. An optimization is made filtering out surfaces not in the same cell as the position. When casting the position to an integer, round down. (This optimization is hopefully not important but just in case I'm typing this out).
##Check for walls belonging to objects and then walls that are part of level geometry.
##Code when checking one wall (there's actually a loop over the wall list):
###If radius > 200, set radius to 200.
###Let x be (f32) <code>position->x</code>, y be (f32) <code>position->y + yOffset</code>, z be (f32) <code>position->z</code>
###Let offset be (x*wallNormalX + y*wallNormalY + z*wallNormalZ + wallOriginOffset)
###Exclude walls where y is not in the range [wall.lowerY, wall.upperY]
###Exclude walls where offset is outside the range [-radius, radius]
###Exclude <insert complicated code>
###<span style="color:red;">If this is the camera</span>, ignore walls that have the SURFACE_FLAG_NO_CAM_COLLISION
###<span style="color:green;">Else</span>, ignore camera only surfaces and based on vanish cap, some other walls
###'''Add surfaceNormal.(x or z) * (radius - offset) to <code>position->x</code> and <code>position->z</code>'''. Since this function is called on each wall, multiple walls can do a push at the same time.
###'''If ''walls'' is not full (max 4 entries), add the wall being checked to ''walls'''''.
#Return the last item in the list (which is NULL if no wall was found)
#
#
{{actions}}
{{actions}}
<references />
<references />
246

edits

Navigation menu