Advertisement
Guest User

Stardew Valley source code re: Strange Capsule

a guest
Jun 19th, 2016
3,346
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.42 KB | None | 0 0
  1. // my comments
  2.  
  3. StardewValley.Utility
  4. // at a 1% chance, if past year 1, create a new "0" Sound in the Night (SITN) event
  5. // for reference, meteorites and witches happen at 1% chance (no other criteria). fairy at 1% if not winter.
  6. //  owl statues would be created at 1% chance (i think) but that code is removed
  7. //     (the game finds a location when it does the owl event but then does nothing with it)
  8.  
  9.     if (random.NextDouble() < 0.01 && Game1.year > 1)
  10.     {
  11.         return new SoundInTheNightEvent(0);
  12.     }
  13.  
  14. StardewValley.Events/SoundInTheNightEvent
  15. // SITN event 0 marked as "crop Circle". may have originally been something else
  16.         public const int cropCircle = 0;
  17. ...
  18.             switch (this.behavior)
  19.             {
  20.             case 0:
  21.                 this.soundName = "UFO";
  22.                 this.message = "A strange sound was heard in the night...";
  23.                 for (int i = 50; i > 0; i--)
  24.                 {
  25.     // determine random placeable location. tries fifty times to find a possible location?
  26.                     this.targetLocation = new Vector2((float)random.Next(5, farm.map.GetLayer("Back").TileWidth - 4), (float)random.Next(5, farm.map.GetLayer("Back").TileHeight - 4));
  27.                     if (!farm.isTileLocationTotallyClearAndPlaceable(this.targetLocation))
  28.                     {
  29.                         return true;
  30.                     }
  31.                 }
  32.                 break;
  33. ...
  34.             switch (this.behavior)
  35.             {
  36.             case 0:
  37.             {
  38. // creates object 96 and sets a 'minutes until ready' count to 24000 - whatever the current time of day is
  39. // 60 mins/hour * 24 hours/day = approx 16 days to hatch?
  40.                 StardewValley.Object @object = new StardewValley.Object(this.targetLocation, 96, false);
  41.                 @object.minutesUntilReady = 24000 - Game1.timeOfDay;
  42.                 farm.objects.Add(this.targetLocation, @object);
  43.                 return;
  44.             }
  45.  
  46. StardewValley/Object
  47. public virtual bool minutesElapsed(int minutes, GameLocation environment)
  48. {
  49. ..
  50. // if object is 96 (or 97? there are three sprites for the capsule so maybe it cycles animations between 96/97..)
  51.                     case 96:
  52.                     case 97:
  53.                         this.minutesUntilReady -= minutes;
  54.                         this.showNextIndex = (this.parentSheetIndex == 96);
  55.                         if (this.minutesUntilReady <= 0)
  56.                         {
  57. // remove the 96 object (Strange Capsule) and replace it with 98 object (Empty Capsule)
  58.                             environment.objects.Remove(this.tileLocation);
  59.                             environment.objects.Add(this.tileLocation, new Object(this.tileLocation, 98, false));
  60.                         }
  61.                         break;
  62.  
  63. // setting up light
  64. public void initializeLightSource(Vector2 tileLocation)
  65. {
  66. // it gives off light identical to singing stone
  67.     if (this.name.Equals("Singing Stone") || this.name.Equals("Strange Capsule"))
  68.     {
  69.         this.lightSource = new LightSource(4, new Vector2(tileLocation.X * (float)Game1.tileSize + (float)(Game1.tileSize / 2), tileLocation.Y * (float)Game1.tileSize - (float)Game1.tileSize), 2f, Color.Violet, (int)(tileLocation.X * 2000f + tileLocation.Y));
  70.     }
  71. // when placed down by the player
  72. public virtual bool performDropDownAction(Farmer who)
  73. {
  74.             if (this.name.Contains("Strange Capsule"))
  75.             {
  76. // if placed by the player instead of the event, hatches after approximately 4 days
  77.                 this.minutesUntilReady = 6000 - Game1.timeOfDay;   
  78.             }
  79. BigCraftablesInformation.yaml
  80.     96: "Strange Capsule/0/-300/Crafting -9/There's something fleshy bobbing around in the fluid.../true/false/0" #!String
  81.     98: "Empty Capsule/0/-300/Crafting -9/Part of the glass is shattered./true/false/0" #!String
  82.  
  83. // nothing found in the 'interact with object' (like the Singing Stone or Hopper or whatever) code
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement