Skip to content

v3.5

Choose a tag to compare

@BurnerAccount-dec BurnerAccount-dec released this 15 Nov 05:09
· 9 commits to main since this release

3.4 was published on GitHub; this section is everything after it.

  • Save states, in the engine, for every game: leave a level half played and come back to exactly that (src/lua/save_states.cpp, the Lua table saveStates). While a level runs, its state is written to savestates.lua in the save folder every 5 seconds, when the level is left (the game mode leaves updateGame) and when the game is closed; loading the same level again (the key is the path it was loaded from) puts it back in the first frame the level runs, also after the game was closed and started again. Kept: every object of objects.world (place, angle, speed, at rest or not, and every number, string and flag in its table: strength, damage sprite, start number, ...), the script variables in saveStates.globals (the bird queue, shots fired, the score, the timers, the camera zoom), the tables in saveStates.tables (the score table, the camera), the objects saveStates.objectGlobals point to (the flying and the selected bird) and the camera function; what was destroyed is removed again (also from birds, otherBirds and levelGoals). A restart (a level loaded again within saveStates.restartWindow seconds of leaving it, or after saveStates.forget(), which the mod's restart button calls), finishing and failing a level clear the state. Objects the scripts made after the level began (the halves of a Blue Bird, debris) are not part of it. Everything is a field of the saveStates table that a script may change (enabled, file, autosave, restartWindow, readyVariable, the lists of variables, skipWhen), plus save(), apply(), has(), forget() and clearAll(); see docs/SCRIPTING.md. The variable names are the ones the games share (the Classic, Seasons, HD, Rio, Space and Star Wars game scripts all use the same bird queue and score variables). Checked on Angry Birds 1.6.2, level 1-1, with two separate runs of the game: in the first a Red Bird was removed, two blocks given 3 and 5 strength, a block moved, a damage sprite set and the score table set to 1234; in the second, started from nothing, the log said the state was put back and the blocks had their strength and sprite, the bird was gone and the score was 2334 (1234 and the 1100 of the weak block that then broke); leaving to the menu wrote the state; a restart left no state to put back. Not yet tried in the other games.

  • Hooks for the remaining Box2D joints: createJoint types 6 to 11 (pulley, gear, mouse, line / wheel, friction, rope). The game editors only know distance, weld, revolute, prismatic and the destroy-attached link (types 1 to 5); the other joints Box2D has can now be made from Lua with the same call, take their fields from the table, write objects.joints[name] and can be changed with setJointParameters (gear ratio, mouse target / force, friction limits, motor and limits of the line / wheel joint). The line joint exists in the bundled Box2D 2.1 (Classic, Seasons, Space), its successor the wheel joint (with a suspension spring) in 2.2 (Rio, Star Wars, Friends); type 9 makes whichever the game's Box2D has. The rope joint is new to 2.1: Box2D 2.2 has it, and it was back-ported to the bundled 2.1.1 (b2RopeJoint, same solver as 2.2.0 written for the 2.1 joint interface, marked as an altered version in its source), so type 11 works in every game. A gear joint is destroyed together with either joint it couples (including when a body is removed), the mouse joint pulls against a fixed body made on first use. Reference and an example in docs/SCRIPTING.md, "Extra joint types". Checked with new tests on both Box2D versions (a pulley lifts the light side, a gear carries a hinge's rotation, a mouse joint brings a body to its target and moves it when the target changes, a line / wheel joint keeps the body on its axis, a rope stops a falling weight at its length, removing a gear's base body leaves no joints behind) and on level 1-1 through Lua (createJoint{type = 8, ...} moved a wood block from y = -11.21 to the target -15.21 and lifted the pig tower with it).