Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Quick Reply
Search this Thread
Instructor
Original Poster
#1 Old 15th Aug 2015 at 3:43 PM
Revive! Chocolate Maker with Custom Skill
Hi guys, I know I had abandoned the project for a really long time (I checked my last modding thread for this project and the last reply was 8 months ago!) I just can't refrain myself from half-baking a ton of mods and coming back to them each some time later...

Ok, enough babbling.
Following JunJayMDM's advice on creating a totally new object instead of inheriting the original NectarMaker class, and doing it successfully, I'm now working on a custom skill (such ambitious things should be left to the great modder Arsil I guess, but I'm willing to take on a challenge hehe )

Code:
//Code for loading skill XML data
		public static bool HasBeenLoaded = false;

		//Tunables
		[Tunable]
		public static bool kInstantiator = true;
		[Tunable]
		public static int kChocolateurRequirement = 200;
		[Tunable]
		public static int kComboMasterRequirement = 75;
		[Tunable]
		public static int kDescendantOfBillyBonkaRequirement = 75;

		static Simsmatthew_Confectionery_Bootstrap()
		{
			LoadSaveManager.ObjectGroupsPreLoad += Simsmatthew_Confectionery_Bootstrap.OnPreload;
		}

		public static void OnPreload()
		{
			try
			{
				if (HasBeenLoaded) return; 
				HasBeenLoaded = true;

				XmlDbData data = XmlDbData.ReadData(new ResourceKey(0xB44CA80EFAC5097A, 0xA8D58BE5, 0x00000000), false);

				if (data == null)
				{
					return;
				}

				SkillManager.ParseSkillData(data, true);

			}
			catch (Exception)
			{				
			}
		}


The skill loader method is courteously provided by Inge back when Simlogical was still up, I haven't tried it in game to see if the loader works yet, but there are a few points:
- the static bool HasBeenLoaded won't survive save and reload. Won't the ParseSkillData do things redundantly? And is there a point in checking whether HasBeenLoader is true or false, given the fact that it's always false on a new load (as it is static)

- I saw this in Arsil's Programming Skill mod:
Code:
public override bool ExportContent(IPropertyStreamWriter writer)
		{
			base.ExportContent(writer);
			writer.WriteInt32(842187465u, this.mScrappedProjects);
			writer.WriteInt32(842187466u, this.NumMods);
			writer.WriteBool(842187469u, this.mSpotlessReputationIsNew);
			writer.WriteBool(842187470u, this.mMasterModderIsNew);
			writer.WriteInt32(842187467u, this.NumFreeSoftwareProjects);
			writer.WriteBool(842187471u, this.mFreeSoftwarePhilanthropistIsNew);
			writer.WriteInt32(842187468u, this.NumFreelanceWorks);
			writer.WriteInt32(842187464u, this.mMoneyMade);
			writer.WriteInt32(842187472u, this.currentProject);
			writer.WriteFloat(842187473u, this.softwareProgress);
			return true;
		}
		public override bool ImportContent(IPropertyStreamReader reader)
		{
			base.ImportContent(reader);
			reader.ReadInt32(842187465u, out this.mScrappedProjects, 0);
			reader.ReadInt32(842187466u, out this.NumMods, 0);
			reader.ReadBool(842187469u, out this.mSpotlessReputationIsNew, true);
			reader.ReadBool(842187470u, out this.mMasterModderIsNew, true);
			reader.ReadInt32(842187467u, out this.NumFreeSoftwareProjects, 0);
			reader.ReadBool(842187471u, out this.mFreeSoftwarePhilanthropistIsNew, true);
			reader.ReadInt32(842187468u, out this.NumFreelanceWorks, 0);
			reader.ReadInt32(842187464u, out this.mMoneyMade, 0);
			reader.ReadInt32(842187472u, out this.currentProject, 0);
			reader.ReadFloat(842187473u, out this.softwareProgress, 0f);
			return true;
		}


Code:
private const uint kHashProgrammingSkill = 3453423142u;
		private const uint kHashMoneyMade = 842187464u;
		private const uint kHashScrappedProjects = 842187465u;
		private const uint kHashModsMade = 842187466u;
		private const uint kHashFSPMade = 842187467u;
		private const uint kHashFreelanceMade = 842187468u;
		private const uint kHashSpotlessReputationIsNew = 842187469u;
		private const uint kHashMasterModderIsNew = 842187470u;
		private const uint kHashFreeSoftwarePhilanthropistIsNew = 842187471u;
		private const uint kHashCurrentProject = 842187472u;
		private const uint kHashSoftwareProgress = 842187473u;

- How do you get the uint of mScrappedProject as 842187465u, for example? Tried to look for online converters and S3PE, no results.
- If I wish to access the reader.ReadInt32(uint, variable), can I do a simple conversion (not a cast) for the uint value, like:
Code:
Converter.ToUInt(variable)


- What is the significance of ExportContent and ImportContent? MergeTravelData method is definitely for the cloning process when a Sim travels, to transfer the skill data.

Hopefully Arsil will pop up and answer questions, but for general ones regarding uint, I'd appreciate anyone's help!! :D
Advertisement
Icy Spicy
#2 Old 15th Aug 2015 at 3:55 PM
I cannot help with the modding but I can cheer for you! I am so freaking happy that the chocolate maker is back on track :lovestruc
Inventor
#3 Old 18th Aug 2015 at 12:20 PM Last edited by Arsil : 21st Aug 2015 at 8:37 AM.
They are just sequential numbers, they must be all different inside the skill but don't need to be unique
(I purposely left the same hashing used by the writing skill for the moneyMade field and verified that there's no conflict).

Of course the id for the skill itself must be unique.

hasBeenLoaded is used to avoid to re-parse/re-add the skill if you go back to the main menu and start a new game
or if you travel, go to UNI or move into another world (probably nothing will happen anyway, but why wasting time?).
It doesn't have to be persistable because the skill is re-added every time you start the game (like the default ones).
EDIT: actually, if I've used OnPreLoad too (I don't remember), the custom skill is added the first time a game is
loaded or a new one is created, not when you start the game.

export/import methods are used to save/load data when traveling and/or moving into another world/savegame
(and maybe also when you export/import a Sim to the Bin/Library/WhateverIsCalled).
Back to top