11/*
2- Animal Crossing: New Leaf Save Editor v20170728
2+ Animal Crossing: New Leaf Save Editor v20170826
33 by Marc Robledo 2015-2017
44
55 A lot of thanks to:
66 * SciresM for breaking the numeric encryption used in the game
77 * Thulinma for Pattern structure (check out his editor pattern http://www.thulinma.com/acnl/ )
88 * NeoKamek for his work on LeafTools and other help
9+ * slattz for various contributions
910 * jexom for documenting grass deterioration
1011 * froggestspirit for extracting acre information and item list
1112 * sprungit/shokolad-town for compiling hair style and color thumbnails
@@ -69,7 +70,7 @@ var Offsets={
6970 PLAYER_TPCTEXT : 0x6b24 ,
7071 PLAYER_PLAYTIME : 0x6b90 ,
7172 PLAYER_POCKETS : 0x6bb0 ,
72- PLAYER_ENCYCLOPEDIA : 0x6c00 ,
73+ PLAYER_CATALOG : 0x6c00 , //starts with encyclopedia
7374 PLAYER_BANK : 0x6b6c ,
7475 PLAYER_MEDALS : 0x6b7c ,
7576 PLAYER_WALLET : 0x6e38 ,
@@ -174,7 +175,7 @@ const OffsetsPlus={
174175 PLAYER_TPCTEXT : 0x6b38 ,
175176 PLAYER_PLAYTIME : 0x6bb0 ,
176177 PLAYER_POCKETS : 0x6bd0 ,
177- PLAYER_ENCYCLOPEDIA : 0x6c20 ,
178+ PLAYER_CATALOG : 0x6c20 , //starts with encyclopedia
178179 PLAYER_BANK : 0x6b8c ,
179180 PLAYER_MEDALS : 0x6b9c ,
180181 PLAYER_WALLET : 0x6f08 ,
@@ -422,6 +423,8 @@ addEvent(window,'load',function(){
422423
423424
424425function Town ( ) {
426+ this . maxBuildings = savegame . readByte1 ( Offsets . MAP_BUILDINGS - 4 ) ;
427+
425428 this . treeSize = savegame . readByte1 ( parseInt ( Offsets . TOWN_TREESIZE ) ) ; //01-07
426429 this . grassType = savegame . readByte1 ( Offsets . TOWN_GRASSTYPE ) ; //00-02
427430 this . grassTypeIsland = savegame . readByte1 ( Offsets . ISLAND_GRASSTYPE ) ; //00-02
@@ -436,8 +439,6 @@ function Town(){
436439 this . nativeFruit = savegame . readByte1 ( Offsets . TOWN_NATIVEFRUIT ) ;
437440
438441
439-
440-
441442 this . townId1 = savegame . readByte1 ( Offsets . TOWN_ID1 ) ;
442443 this . townId2 = savegame . readByte1 ( Offsets . TOWN_ID2 ) ;
443444 this . name = savegame . readU16String ( Offsets . TOWN_NAME , 9 ) ;
@@ -535,7 +536,9 @@ Town.prototype.searchTownIdReferences=function(){
535536Town . prototype . refreshIdSpans = function ( ) {
536537 el ( 'town-id' ) . innerHTML = '0x' + intToHex ( this . townId2 ) + intToHex ( this . townId1 ) ;
537538}
538- Town . prototype . save = function ( ) {
539+ Town . prototype . save = function ( ) {
540+ savegame . storeByte ( Offsets . MAP_BUILDINGS - 4 , this . maxBuildings ) ;
541+
539542 savegame . storeByte ( Offsets . TOWN_NATIVEFRUIT , this . nativeFruit ) ;
540543 savegame . storeByte ( Offsets . TOWN_GRASSTYPE , this . grassType ) ;
541544 savegame . storeByte ( Offsets . ISLAND_GRASSTYPE , this . grassTypeIsland ) ;
@@ -797,7 +800,11 @@ function click(evt,itemGridObj,firstClick){
797800 currentEditingItem = itemSlot ;
798801
799802 if ( mouseHeld == 1 ) {
800- if ( el ( 'items' ) . value >= itemGridObj . minItem && el ( 'items' ) . value <= itemGridObj . maxItem ) {
803+ if (
804+ ( el ( 'items' ) . value >= itemGridObj . minItem && el ( 'items' ) . value <= itemGridObj . maxItem )
805+ ||
806+ ( el ( 'items' ) . value == 0x33a7 && itemGridObj . nItems === 1 && itemGridObj . minItem !== Offsets . MIN_SONG )
807+ ) {
801808 if ( itemGridObj . inside && itemSlot . id == el ( 'items' ) . value && itemSlot . flag1 == el ( 'flag1' ) . decimalValue && itemSlot . flag2 == el ( 'flag2' ) . decimalValue ) {
802809 var rotation = itemSlot . flag2 >> 4 ;
803810
@@ -1369,10 +1376,10 @@ Building.prototype.set=function(newId){
13691376 this . y = 0 ;
13701377
13711378 if ( this . tr ) {
1372- if ( this . type === 'island' )
1373- el ( 'buildings-island' ) . removeChild ( this . tr ) ;
1374- else
1379+ if ( this . type === 'map' ) {
13751380 el ( 'buildings' ) . removeChild ( this . tr ) ;
1381+ town . maxBuildings -- ; //not tested yet
1382+ }
13761383 this . tr = null ;
13771384 }
13781385 } else if ( this . tr ) {
@@ -1544,6 +1551,7 @@ function addBuilding(){
15441551 for ( var i = 0 ; i < allBuildings . length ; i ++ )
15451552 allBuildings [ i ] . disabled = ( allBuildings [ i ] . group !== 0 ) ;
15461553
1554+ town . maxBuildings ++ ;
15471555 MarcDialogs . open ( 'building' )
15481556 }
15491557 slot -- ;
@@ -2213,12 +2221,21 @@ Player.prototype.unlockEmotions=function(){
22132221}
22142222Player . prototype . fillEncyclopedia = function ( ) {
22152223 MarcDialogs . confirm ( 'Do you want to fill encyclopedia up for this player?<br/>' + getWarningMessage ( ) , function ( ) {
2216- var encyclopediaOffset = currentPlayer . offset + Offsets . PLAYER_ENCYCLOPEDIA ;
2224+ var encyclopediaOffset = currentPlayer . offset + Offsets . PLAYER_CATALOG ;
22172225 for ( var i = 0 ; i < Constants . FULL_ENCYCLOPEDIA . length ; i ++ )
22182226 savegame . storeByte ( encyclopediaOffset + i , Constants . FULL_ENCYCLOPEDIA [ i ] ) ;
22192227 MarcDialogs . alert ( 'Encyclopedia was filled for this player.' ) ;
22202228 } ) ;
22212229}
2230+ Player . prototype . fillCatalog = function ( ) {
2231+ MarcDialogs . confirm ( 'Do you want to fill catalog up for this player?<br/>' + getWarningMessage ( ) , function ( ) {
2232+ var catalogOffset = currentPlayer . offset + Offsets . PLAYER_CATALOG ;
2233+ var maxInts = plusMode ?180 :136 ;
2234+ for ( var i = 0 ; i < maxInts ; i ++ )
2235+ savegame . storeByte4 ( catalogOffset + i * 4 , 0xffffffff ) ;
2236+ MarcDialogs . alert ( 'Catalog was filled for this player.' ) ;
2237+ } ) ;
2238+ }
22222239
22232240
22242241function changeTPCPic ( ) {
0 commit comments