Content Patcher

Content Patcher

463k Downloads

[Content Patcher] EditImage not properly working on Farmer Base sprites

kenny2892 opened this issue ยท 2 comments

commented

Describe the bug
Whenever the "EditImage" action gets applied to the farmer base sprite with a condition that is not a player configuration, it will render underneath the base sprite instead of replacing it. However, the Debug tool will display the sprite as though it had been replaced correctly.

The only times I found that it properly replaces the base sprite are when:
A. There are no conditions tied to the action.
B. When the only condition is a player configuration.

I have tried the following methods, and none have produced the correct results:
A. Applying a condition (tested Season, Day, DayEvent, LocationUniqueName, and PlayerGender) directly to the "EditImage" action.
B. Storing the "EditImage" action within a separate file and calling it via an "Include" action that has a condition.
C. Creating a Dynamic Token and using that as the condition on the "EditImage" action.
D. Using a Query as the condition on the "EditImage" action.

I also made another test mod to edit the furniture tilesheet and the pants sprite via "EditImage" with a season condition (just like how I tested the farmer base sprite), to see if other sprites had this same issue. It worked with no issues.

All testing was done on a fresh install of the game with only SMAPI, Content Patcher, and 1 test mod enabled at a time.
Here are all my test mods within a zip file:
All Test Mods.zip

To Reproduce
Using My Test Mods:

  1. Add one of the 4 test mods I have provided with "Error Produced" in the folder name.
  2. Load into a world during the spring season.
  3. The blue sprite should now be underneath the player's sprite instead of replacing the player's sprite.
  4. Use the Debug tool to examine the farmer_base or farmer_girl_base sprite and see that the player should only be blue.

From a new mod:

  1. Create a new Content Patcher Mod.
  2. Add an "EditImage" action to the content.json file that swaps out the player's body with a new sprite (such as a solid color).
  3. Apply a "When" condition for "Season": "spring" to the action.
  4. Load a save file that is in spring and see if the farmer base file has been properly edited.

Log file
SMAPI Log for "With No Conditions" Test Mod: https://smapi.io/log/26ebb87b57914b7d8905b5569215252e
SMAPI Log for "With Season Condition" Test Mod: https://smapi.io/log/ebac1b25db0d4178b3042c668706f2de
SMAPI Log for "Condition on Other Sprites" Test Mod: https://smapi.io/log/3946126bfd01469da3beefe6f427d4f9

Screenshots
The game working properly when using the test mod "Testing Farmer Sprite - No Errors A - With No Conditions":
aba4770b1032698f99001c76a404a44c

The game not working properly when using the test mod "Testing Farmer Sprite - Error Produced A - With Season Condition":
7fd58d31c72e6dce69e4a5491bcad87a

The game working properly when using the test mod "Testing When Condition on Other Sprites":
0bfe37a5ae5da7e92b86a7e9f136da23

commented

Similar issue but having conditions doesn't affect it:

Steps to reproduce

  1. Create the following patch. EditImage or Load actions produce the same result. With or without conditionals also produces the same result.
{
    "Action": "Load",
    "Target": "Characters/Farmer/farmer_girl_base",
    "FromFile": "assets/farmer_girl_base_A.png"
},
  1. Change "FromFile" to use the second sprite:
{
    "Action": "Load",
    "Target": "Characters/Farmer/farmer_girl_base",
    "FromFile": "assets/farmer_girl_base_B.png"
},
  1. Force reload the patch using the console command patch reload <modID>
  2. Change shirt/pants to see changes. This step wasn't required pre-1.6

Output
Before:
image
After reloading patches (unexpected result):
image
After restarting the game (expected result):
image

Edit Explanation / Legend

  • Blue pixel = Sprite A body;
  • Red pixel = Sprite A arms;
  • Green pixel = Sprite B body;
  • Magenta pixel = Sprite B arms;
  • Sprite A has its left arm removed;
  • Sprite B has its right arm removed;

Analysis

  • Added pixels aren't recolored to the skin tone (see left arm & left cheek) unless behind shirt(?) (see belly)
  • Transparent pixels aren't fully applied (see right arm)
  • Added body pixels are overlayed behind the base(?) body (see right cheek)
  • Switched body pixels are unaffected (see mouth/neck)

Sprites used
farmer_girl_base_A
farmer_girl_base_B

commented

Both issues should be fixed in the upcoming SMAPI 4.0.9 and Content Patcher 2.1.0. Feel free to reopen if it still happens for you with those versions. Thanks for reporting it!