Skip to content

Respawn/Waypoints library for Lua

JugadorXEI requested to merge JugadorXEI/RingRacers:respawnWaypointsLib into master

Summary

This branch exposes waypoint_t, updates respawnvars_t to include all missing variables, as well as a refactor and moving it to a new file, exposes new members from player_t related to waypoints, and exposes all respawn and waypoint functions to Lua.

The reason the respawn lib and waypoint lib are grouped together into a single MR, is because they both depend on waypoint_t from being exposed. If this is too hard to merge into master/internal, I can separate it into two MRs - I just figured it made the most sense. All commits are still atomic and can be split as needed.

Fixes #12, #311.

It changes the following:

  • Exposes the following variables:
    • waypoint_t object:
      • get: mobj, onaline, nextwaypoints, prevwaypoints, nextwaypointdistances, prevwaypointdistances, numnextwaypoints, numprevwaypoints.
      • set: mobj, onaline
    • respawnvars_t object:
      • get and set (new): waypoint, pointangle, airtimer, truedeath, manual, fromringshooter, init, fast, returnspeed
    • player_t object:
      • get and set: currentwaypoint, nextwaypoint, bigwaypointgap, dropdashboost
      • set (could already be get before): distancetofinish and distancetofinishprev
  • Exposes the following functions:
    • k_respawn:
      • fixed_t K_RespawnOffset(player_t player, [bool flip])
      • nil K_RespawnAtWaypoint(player_t player, waypoint_t waypoint)
      • nil K_DoFault(player_t player)
      • nil K_DoIngameRespawn(player_t player)
      • int K_NextRespawnWaypointIndex(waypoint_t waypoint)
    • k_waypoint:
      • waypoint_t K_GetFinishLineWaypoint()
      • waypoint_t K_GetStartingWaypoint()
      • boolean K_GetWaypointIsFinishline(waypoint_t waypoint)
      • boolean K_GetWaypointIsShortcut(waypoint_t waypoint)
      • boolean K_GetWaypointIsEnabled(waypoint_t waypoint)
      • boolean K_GetWaypointIsSpawnpoint(waypoint_t waypoint)
      • int K_GetWaypointNextID(waypoint_t waypoint)
      • int K_GetWaypointID(waypoint_t waypoint)
      • waypoint_t K_GetWaypointFromID(int id)
      • int K_GetCircuitLength()
      • int K_GetTrackComplexity()
      • waypoint_t K_GetClosestWaypointToMobj(mobj_t mobj)
      • waypoint_t K_GetBestWaypointForMobj(mobj_t mobj, [waypoint_t waypoint])
      • boolean, table K_PathfindToWaypoint(waypoint_t sourcewaypoint, waypoint_t destinationwaypoint, [boolean useshortcuts], [boolean huntbackwards]).
        • Table is a representation of path_t and pathfindnode_t objects, with the following members: numnodes (int), array (table which contains nodedata (waypoint_t), gscore (int), hscore (int) for each node), totaldist (int). Every table henceforth is like this.
      • boolean, table K_PathfindThruCircuit(waypoint_t sourcewaypoint, fixed_t traveldistance, [boolean useshortcuts], [boolean huntbackwards])
      • boolean, table K_PathfindThruCircuitSpawnable(waypoint_t sourcewaypoint, fixed_t traveldistance, [boolean useshortcuts], [boolean huntbackwards])
      • waypoint_t K_GetNextWaypointToDestination(waypoint_t sourcewaypoint, waypoint_t destinationwaypoint, [boolean useshortcuts], [boolean huntbackwards])
      • waypoint_t K_SearchWaypointGraphForMobj(mobj_t mobj)
      • waypoint_t K_SearchWaypointHeapForMobj(mobj_t mobj)

Testing

Testing environment: ringracers_respawnWaypointsLib.exe -console -skipintro -warp RR_ROBOTNIKCOASTER +addfile respawnwaypoint.lua

A script was used, respawnwaypoint.lua, to test the following additions:

  • It contains a cvar respawnvarshuddebug that displays the following values in the HUD:
    • 1: Displays the player's respawnvars_t members.
    • 2: Displays the player's waypoint_t members.
    • 3: Displays the return values of K_GetFinishLineWaypoint, K_GetStartingWaypoint, K_GetClosestWaypointToMobj, K_GetCircuitLength, K_GetTrackComplexity, K_GetWaypointFromID, K_GetWaypointIsFinishline, K_GetWaypointIsShortcut, K_GetWaypointIsEnabled, K_GetWaypointIsSpawnpoint, K_GetWaypointID and K_GetWaypointNextID.
    • 4: Displays the return values of K_GetClosestWaypointToMobj, K_GetBestWaypointForMobj, K_NextRespawnWaypointIndex, K_RespawnOffset, and the player members distancetofinish, distancetofinishprev, bigwaypointgap and dropdashboost.
  • It contains the following commands:
    • setrespawnvalue arg1 arg2 arg3: Sets the player node (arg1)'s respawn member (arg2) to a value (arg3).
    • faultme: Faults the player using K_DoFault.
    • respawnme [arg1]: Respawns the player using K_DoIngameRespawn. If arg1 is passed, it will respawn the player to that waypoint ID using K_RespawnAtWaypoint.
    • testpathfindtowaypoint [arg1]: Tests K_PathfindToWaypoint and displays all nodes. arg1 allows to set how many waypoints from the current player waypoint to test pathfind to, defaults to 3.
    • testpathfindtodistance [arg1]: Tests K_PathfindThruCircuit and displays all nodes. arg1 allows to set how much distance to pathfind to, defauls to 1028.
    • testpathfindtodistancespawnable [arg1]: Same as above, but using K_PathfindThruCircuitSpawnable.
    • testpathfindtodest [arg1]: Tests K_GetNextWaypointToDestination and displays the returned waypoint's ID. arg1 allows to set how many waypoints from the current player waypoint to test pathfind to, defaults to 3.
    • iswaypointingraph [arg1]/iswaypointinheap [arg1]: Tests whether the player's current waypoint is in the graph or heap, respectively. arg1 allows to pass a specific waypoint ID to check instead.

Changelog:

  • Added missing respawnvars_t values from the player for Lua: waypoint, pointangle, airtimer, truedeath, manual, fromringshooter, init, fast, returnspeed.
  • Exposed waypoint_t for Lua.
  • Exposes player_t members currentwaypoint, nextwaypoint, bigwaypointgap and dropdashboost, and now distancetofinish and distancetofinishprev may be set as well.
  • Exposed all respawn and waypoint related functions to Lua.
Edited by JugadorXEI

Merge request reports

Loading