/* The legend of Zelda: Tears of the Kingdom Savegame Editor (Horse class) v20230610 by Marc Robledo 2023 horse data thanks to JonJaded, Ozymandias07 and Karlos007 */ function Horse(index, id, name, mane, saddles, reins, bond, specialType, statsStrength, statsSpeed, statsStamina, statsPull, iconPattern, iconEyeColor){ this.category='horses'; this.index=index; this.id=id; this.name=name; this.mane=mane; this.saddles=saddles; this.reins=reins; this.bond=bond; this.specialType=specialType; this.statsStrength=statsStrength; this.statsSpeed=statsSpeed; this.statsStamina=statsStamina; this.statsPull=statsPull; this.iconPattern=iconPattern; this.iconEyeColor=iconEyeColor; if( specialType!==Horse.TYPE_NORMAL && specialType!==Horse.TYPE_ZELDA && specialType!==Horse.TYPE_EPONA && specialType!==Horse.TYPE_GIANT_BLACK && specialType!==Horse.TYPE_GIANT_WHITE && specialType!==Horse.TYPE_SPOT && specialType!==Horse.TYPE_GOLD ) console.warn('unknown horse['+index+'].specialType value: '+specialType); Horse.buildHtmlElements(this); this.fixValues(true); } Horse.prototype.fixValues=function(ignoreEquipment){ if(this.id==='GameRomHorseZelda'){ this.specialType=Horse.TYPE_ZELDA; this._htmlSelectIconPattern.disabled=true; this._htmlSelectIconEyeColor.disabled=true; //this.temperament='wild'; }else if(this.id==='GameRomHorse00L'){ this.specialType=Horse.TYPE_GIANT_BLACK; if(!ignoreEquipment){ this.mane=this._htmlSelectMane.value=0x9cd4f27b; this.saddles=this._htmlSelectSaddles.value=0xf1435392; this.reins=this._htmlSelectReins.value=0x4dbf2061; } this._htmlSelectIconPattern.disabled=true; this._htmlSelectIconEyeColor.disabled=true; //this.temperament='wild'; }else if(this.id==='GameRomHorse01L'){ this.specialType=Horse.TYPE_GIANT_WHITE; if(!ignoreEquipment){ this.mane=this._htmlSelectMane.value=0x55365b10; this.saddles=this._htmlSelectSaddles.value=0xf1435392; this.reins=this._htmlSelectReins.value=0x4dbf2061; } this._htmlSelectIconPattern.disabled=true; this._htmlSelectIconEyeColor.disabled=true; //this.temperament='wild'; }else if(this.id==='GameRomHorseSpPattern'){ this.specialType=Horse.TYPE_SPOT; this._htmlSelectIconPattern.disabled=true; this._htmlSelectIconEyeColor.disabled=true; //this.temperament='wild'; //??? }else if(this.id==='GameRomHorseGold'){ this.specialType=Horse.TYPE_GOLD; this._htmlSelectIconPattern.disabled=true; this._htmlSelectIconEyeColor.disabled=true; //this.temperament='wild'; //??? }else if(this.id==='GameRomHorseEpona'){ this.specialType=Horse.TYPE_EPONA; this._htmlSelectIconPattern.disabled=true; this._htmlSelectIconEyeColor.disabled=true; //this.temperament='wild'; //??? }else{ this.specialType=Horse.TYPE_NORMAL; if(!ignoreEquipment && this.id==='GameRomHorse00S'){ this.mane=this._htmlSelectMane.value=0xbad4c4a9; this.saddles=this._htmlSelectSaddles.value=0x8c5bd272; this.reins=this._htmlSelectReins.value=0xe8fe6ab7; } this._htmlSelectIconPattern.disabled=false; this._htmlSelectIconEyeColor.disabled=false; //this.temperament='gentle'; //??? } } Horse.prototype.getItemTranslation=function(){ return Locale._(this.id); } Horse.prototype.save=function(){ SavegameEditor.writeString64('OwnedHorseList.ActorName', this.index, this.id); SavegameEditor.writeStringUTF8('OwnedHorseList.Name', this.index, this.name); SavegameEditor.writeU32('OwnedHorseList.Mane', this.index, this.mane); SavegameEditor.writeU32('OwnedHorseList.Saddle', this.index, this.saddles); SavegameEditor.writeU32('OwnedHorseList.Rein', this.index, this.reins); SavegameEditor.writeF32('OwnedHorseList.Familiarity', this.index, this.bond); SavegameEditor.writeU32('OwnedHorseList.HorseType', this.index, this.specialType); SavegameEditor.writeU32('OwnedHorseList.Toughness', this.index, this.statsStrength); SavegameEditor.writeU32('OwnedHorseList.Speed', this.index, this.statsSpeed); SavegameEditor.writeU32('OwnedHorseList.ChargeNum', this.index, this.statsStamina); SavegameEditor.writeU32('OwnedHorseList.HorsePower', this.index, this.statsPull); SavegameEditor.writeU32('OwnedHorseList.Body.Pattern', this.index, this.iconPattern); SavegameEditor.writeU32('OwnedHorseList.Body.EyeColor', this.index, this.iconEyeColor); } Horse.buildHtmlElements=function(item){ //build html elements item._htmlInputName=input('name-'+item.category+'-'+item.index, item.name); item._htmlInputName.addEventListener('change', function(){ var newVal=this.value; if(newVal.length>9) newVal=newVal.substr(0,9); if(!newVal) newVal='a'; item.name=newVal; }); item._htmlInputName.title=Locale._('Horse name'); item._htmlInputName.maxLength=9; item._htmlSelectMane=select('horse-mane-'+item.index, Horse.MANES, function(){ item.mane=this.value; }, item.mane); item._htmlSelectMane.title=Locale._('Mane'); item._htmlSelectSaddles=select('horse-saddles-'+item.index, Horse.SADDLES, function(){ item.saddles=this.value; }, item.saddles); item._htmlSelectSaddles.title=Locale._('Saddle'); item._htmlSelectReins=select('horse-reins-'+item.index, Horse.REINS, function(){ item.reins=this.value; }, item.reins); item._htmlSelectReins.title=Locale._('Reins'); item._htmlInputBond=inputFloat('bond-'+item.category+'-'+item.index,0,100,item.bond*100); item._htmlInputBond.addEventListener('change', function(){ item.bond=parseFloat(this.value) / 100; }); item._htmlInputBond.title=Locale._('Bond'); var stats=[ {value:1, name:'★★'}, {value:2, name:'★★★'}, {value:3, name:'★★★★'}, {value:4, name:'★★★★★'} ]; var statsStamina=[ {value:2, name:'★★'}, {value:3, name:'★★★'}, {value:4, name:'★★★★'}, {value:5, name:'★★★★★'}, {value:0, name:'Infinite'} ]; item._htmlInputStatsStrength=inputNumber('horse-stats-strength-'+item.index,100,350,item.statsStrength); item._htmlInputStatsStrength.addEventListener('change', function(){ item.statsStrength=parseInt(this.value); }); item._htmlInputStatsStrength.title=Locale._('Stats: Strength'); item._htmlSelectStatsSpeed=select('horse-stats-speed-'+item.index, stats, function(){ item.statsSpeed=parseInt(this.value); }, item.statsSpeed); item._htmlSelectStatsSpeed.title=Locale._('Stats: Speed'); item._htmlSelectStatsStamina=select('horse-stats-stamina-'+item.index, statsStamina, function(){ item.statsStamina=parseInt(this.value); }, item.statsStamina); item._htmlSelectStatsStamina.title=Locale._('Stats: Stamina'); item._htmlSelectStatsPull=select('horse-stats-pull-'+item.index, stats, function(){ item.statsPull=parseInt(this.value); }, item.statsPull); item._htmlSelectStatsPull.title=Locale._('Stats: Pull'); item._htmlSelectIconPattern=select('horse-icon-pattern-'+item.index, Horse.ICON_PATTERNS, function(){ item.iconPattern=parseInt(this.value); }, item.iconPattern); item._htmlSelectIconPattern.title=Locale._('Icon: pattern'); item._htmlSelectIconEyeColor=select('horse-icon-eye-color-'+item.index, Horse.ICON_EYE_COLORS, function(){ item.iconEyeColor=parseInt(this.value); }, item.iconEyeColor); item._htmlSelectIconEyeColor.title=Locale._('Icon: eye color'); } Horse.readAll=function(){ var horsesIds=SavegameEditor.readString64Array('OwnedHorseList.ActorName'); var validHorses=[]; for(var i=0; i