spacechase0 / StardewValleyMods

New home for my stardew valley mod source code
Other
115 stars 141 forks source link

[Spacecore] Skill books transpiler request for custom skills #475

Open Pet-Slime opened 2 weeks ago

Pet-Slime commented 2 weeks ago

I am not good with transpilers, else I would make the pull request / feature myself.

That said, skillbooks are hardcoded in their drops. I would like to make a request for someone to make a transplier so skillbooks are not hardcoded in their drops.

Places a transpiler is needed...

An example in the fishingRod code...

  public void openTreasureMenuEndFunction(int remainingFish)
   {
       Farmer farmer = lastUser;
       farmer.gainExperience(5, 10 * (clearWaterDistance + 1));
       farmer.UsingTool = false;
       farmer.completelyStopAnimatingOrDoingAction();
       bool num = treasureCaught;
       doneFishing(farmer, consumeBaitAndTackle: true);
       List<Item> list = new List<Item>();
       if (remainingFish == 1)
       {
           list.Add(CreateFish());
       }
       float num2 = 1f;
       if (num)
       {
           Game1.player.stats.Increment("FishingTreasures", 1);
           while (Game1.random.NextDouble() <= (double)num2)
           {
               num2 *= (goldenTreasure ? 0.6f : 0.4f);
               if (Game1.IsSpring && !(farmer.currentLocation is Beach) && Game1.random.NextDouble() < 0.1)
               {
                   list.Add(ItemRegistry.Create("(O)273", Game1.random.Next(2, 6) + ((Game1.random.NextDouble() < 0.25) ? 5 : 0)));
               }
               if (numberOfFishCaught > 1 && farmer.craftingRecipes.ContainsKey("Wild Bait") && Game1.random.NextBool())
               {
                   list.Add(ItemRegistry.Create("(O)774", 2 + ((Game1.random.NextDouble() < 0.25) ? 2 : 0)));
               }
               if (Game1.random.NextDouble() <= 0.33 && farmer.team.SpecialOrderRuleActive("DROP_QI_BEANS"))
               {
                   list.Add(ItemRegistry.Create("(O)890", Game1.random.Next(1, 3) + ((Game1.random.NextDouble() < 0.25) ? 2 : 0)));
               }
               while (Utility.tryRollMysteryBox(0.08 + Game1.player.team.AverageDailyLuck() / 5.0))
               {
                   list.Add(ItemRegistry.Create((Game1.player.stats.Get(StatKeys.Mastery(2)) != 0) ? "(O)GoldenMysteryBox" : "(O)MysteryBox"));
               }
               if (Game1.player.stats.Get(StatKeys.Mastery(0)) != 0 && Game1.random.NextDouble() < 0.05)
               {
                   list.Add(ItemRegistry.Create("(O)GoldenAnimalCracker"));
               }
               if (goldenTreasure && Game1.random.NextDouble() < 0.5)
               {
                   switch (Game1.random.Next(13))
                   {
                       case 0:
                           list.Add(ItemRegistry.Create("(O)337", Game1.random.Next(1, 6)));
                           break;
                       case 1:
                           list.Add(ItemRegistry.Create("(O)SkillBook_" + Game1.random.Next(5)));
                           break;
spacechase0 commented 2 weeks ago

When I do this I'll probably make it opt-in, since you might not want your skills droppable from vanilla sources (or at all if it's a story locked skill like with S&S)

Pet-Slime commented 2 weeks ago

When I do this I'll probably make it opt-in, since you might not want your skills droppable from vanilla sources (or at all if it's a story locked skill like with S&S)

That's 100% fair. Maybe have it be a context tag on the skill book which is turn added to a list during load. The transpiler would then pull from that list.

Going even farther: could have a context tag for each drop. Like "skillbook_drop_fishing" to add it to the fishing list. That way it could be added to each drop source separately.

That would turn allow story locked skills to then add the context tag and update the list once unlocked, or any skill once special conditions are met.