summary refs log tree commit diff stats
path: root/src/behaviour_system.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Improved eight-direction pathfindingStar Rauchenberger2021-07-061-20/+35
| | | | | | | | | | In the past, not using the "cardinal directions only" flag resulted in awkward and unintuitive paths. Two changes were made to the algorithm to improve these paths. One, nodes in the graph are now a pair of a position and the direction taken to get there. This way, a small penalty can be applied whenever a turn is taken, which should incentivise paths with fewer turns (which should be simpler). This change theoretically affects the cardinal mode as well, but in practice it is unlikely to change the paths that would've been generated. This also multiplies the search space by eight (four in cardinal mode), but so far it does not appear to be a significant resource drain. Two, the heuristic used in eight-directions mode is now octile distance, instead of dominant axis distance. Additionally, the real cost of moving diagonally is ~sqrt(2) instead of 1. This somewhat disincentivises diagonal movement, since it is no longer considered the same as cardinal movement (even though cardinal and diagonal movement occurs at the same speed), but the turning penalty makes moving diagonally more favourable than zigzagging cardinally to reach a diagonal destination. Most scripted movement in the game is likely to use cardinal mode because that mirrors the way most scripted movement in Mother 3 works, but in some cases (the Hinawa event on the cliff) diagonal movement just looks better, and thus it's useful to have the improved pathfinding algorithm.
* Added moonwalking to pathfinding behaviourStar Rauchenberger2021-07-061-0/+5
| | | | This flag will make the sprite appear to be walking backwards.
* Simplified collision detection outputKelly Rauchenberger2021-03-111-1/+1
| | | | It is no longer split into horizontal and vertical results. Also, the collision detection routine now does the work of calculating an adjusted position, instead of the caller (CharacterSystem) having to do it. This will be useful for #3.
* Added "let's switch places!" Claus spriteKelly Rauchenberger2021-03-091-14/+19
| | | | | | He will wander randomly until you get close, and will then run at you. Talking to him or bumping into him does nothing currently. If you move out of his range of interest he will go back to wandering at a walking pace. #10
* Handled case where a pathfollowing sprite overshoots its destinationKelly Rauchenberger2021-03-021-0/+15
| | | | This may happen due to lag or due to debugging with lldb. What happens is that 60 times a second, the engine will check whether the direction toward the current endpoint is equal to the direction in the pathfinding instruction, and if it isn't (because the sprite has gone past the endpoint) then it sets the sprite's position to the endpoint instantly so that the pathfinding can continue.
* Started writing the Mixolydia scene!Kelly Rauchenberger2021-03-011-0/+1
| | | | | | Looking pretty good so far. TODO: direction facing functions have inverted Y coordinate. confusion expression doesn't exist yet. rest of scene.
* Pathfinding should be more biased toward straight lines nowKelly Rauchenberger2021-02-281-2/+4
|
* Added A* pathfindingKelly Rauchenberger2021-02-271-1/+170
|
* Added a debug consoleKelly Rauchenberger2021-02-211-0/+2
| | | | | | | | Open it by pressing backtick, close it by hitting escape. Pressing backtick does not open it in release builds. Current shortcomings: opening it for the first time also types a backtick for some reason, but not on subsequent times. Also, it doesn't create a coroutine, so any script function that yields is going to fail. This also added a "is gameplay paused" flag to Game, which will be useful for adding a pause menu.
* Added sprite pausingKelly Rauchenberger2021-02-211-1/+1
| | | | | | All sprites are now paused when a cutscene starts and unpaused when it ends. Pausing means that the CharacterSystem and BehaviourSystem will not process them in their tick. This allows specific sprites to be unpaused during cutscenes if movement is needed. The player character is halted and made non-controllable by the script when the cutscene starts and made controllable again when it ends. It is important to remember that if interacting with a sprite that might be moving, you have to manually call Halt() on them in their script to make them stop moving.
* Added a randomly wandering Ionia to the mapKelly Rauchenberger2021-02-201-0/+32