@@ -41,16 +41,40 @@ LUA_FUNCTION(Lua_RoomTransitionIsRenderingBossIntro) {
4141 return 1 ;
4242}
4343
44+ static const int s_VersusScreenPlayerExtraPortraitLayers[4 ][2 ] = {
45+ {5 , 12 },
46+ {18 , 21 },
47+ {19 , 22 },
48+ {20 , 23 },
49+ };
50+
51+ // Previously, RoomTransition contained a single sprite for the first player's "extra portrait" (ie tainted eden's glitchy effect)
52+ // In REP+, with online co-op showing all players in the versus screen, this was replaced with an std::map of layer (int) to ANM2
53+ // For backward compatability this function returns a reference to player 1's extra portrait by default.
54+ // Also note that normally the game does not play the co-op version of the VS screen for local co-op.
55+ // I think it did for earlier versions of Rep+. It still loads all the (extra) portraits though, so mods could trigger the animaion.
4456LUA_FUNCTION (Lua_RoomTransitionGetPlayerExtraPortraitSprite) {
4557 RoomTransition* roomTransition = g_Game->GetRoomTransition ();
46- // Previously, RoomTransition contained a single sprite for the first player's "extra portrait" (ie tainted eden's glitchy effect)
47- // In REP+, with online co-op showing all players in the versus screen, this was replaced with an std::map of layer (int) to ANM2
48- // For backward compatability's sake, this function returns the sprite for layer 5 (player 1's portrait).
49- auto & map = *roomTransition->GetExtraLayerANM2s ();
50- if (map.count (5 ) == 0 ) {
58+ int playerIndex = (int )luaL_optinteger (L, 1 , 0 );
59+
60+ if (playerIndex < 0 || playerIndex > 3 ) {
5161 lua_pushnil (L);
62+ return 1 ;
63+ }
64+
65+ // The "alt" layer is for the "no shake" version of the portrait.
66+ // Only one or the other is ever populated in the map, as it is recreated from scratch in StartBossIntro.
67+ int layer = s_VersusScreenPlayerExtraPortraitLayers[playerIndex][0 ];
68+ int altLayer = s_VersusScreenPlayerExtraPortraitLayers[playerIndex][1 ];
69+
70+ auto & map = *roomTransition->GetExtraLayerANM2s ();
71+
72+ if (map.count (altLayer)) {
73+ lua::luabridge::UserdataPtr::push (L, &map[altLayer], lua::GetMetatableKey (lua::Metatables::SPRITE ));
74+ } else if (map.count (layer)) {
75+ lua::luabridge::UserdataPtr::push (L, &map[layer], lua::GetMetatableKey (lua::Metatables::SPRITE ));
5276 } else {
53- lua::luabridge::UserdataPtr::push (L, &map[ 5 ], lua::GetMetatableKey (lua::Metatables:: SPRITE ) );
77+ lua_pushnil (L );
5478 }
5579 return 1 ;
5680}
0 commit comments