Page 18 of 21

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 12:21 am
by karlito31
AliceInChains wrote:
April 14th, 2019, 9:28 am
Edit: I also tried to set Atlas and name directly to a .png file in the Sprite folder (without extension) but the icon still won't show up in Character skill tab (trying to add a new icon to a newly created skill: skill shows, but without icon)
I've had exactly the same problem. For a week I was smashing my head seeking a solution, but an icon for my Silent Move skill did not want to appear. In the end, I added my icon to the original WL2_Icons.png through the code. Every time I launch the game, my icon is added to WL2_Icons.png. Then you have to create a new object of "UISpriteData" type with the required coordinates, size and name of the new sprite and add it to the UIAtlas.spriteList. The name must correspond with the name assigned to the skill.spriteName ) Obviously, this requires a direct intervention in Assembly_CSharp.dll, but I did not find another way. Now everything works great. If you decide to use the Assembly approach, I can post the code later when I return home. In any case, if the executor_ has no solution to the problem through the modding interface, dnSpy is the best (and possibly the easiest) option.

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 12:46 am
by Executor_
The built-in icon files are only exported for reference purposes, they aren't designed to be modified. The patch notes for 0.9.2 explained how to add new icons:
  • can create new UIAtlas, the game's sprite databases
    • place picture files in a "Sprite" directory in "Import", valid extensions: PNG, JPG, JPEG
    • modded game will create a new UIAtlas from the image, with the UIAtlas having one item in the spriteList with the same name
    • refer to the picture as the filename without extension
    • eg. if you have testShotgun.png in your "Mods\Import\Sprite\" folder

      Code: Select all

      {
      	atlas : testShotgun
      	spriteName : testShotgun
      }
    • game probably resizes images automatically
    • don't forget about transparencies when creating pictures so that they look OK against the background

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 1:03 am
by karlito31
Yes, but that doesn't work for skills, I think. I was creating new atlases in code from my "image.png" using all available functions (create, fromstring, my own variations, etc) and adding it to my skill, along with sprite name, same as atlas name, but icon never showed up. Only when I added it to WL2_Icons.png and placed new UISpriteData to iconAtlas instance, icon finaly showed up. I might be completely wrong here, obviously.

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 2:07 am
by AliceInChains
Executor_ wrote:
April 15th, 2019, 12:46 am
The built-in icon files are only exported for reference purposes, they aren't designed to be modified. The patch notes for 0.9.2 explained how to add new icons:
Doesn't work for Skill icons then. I did do exactly that after altering the WL2_Icons.png + .mson files had the icon not show up. It does work perfectly for changing icons of items in inventory/on character (black leather pants really are black leather now).
karlito31 wrote:
April 15th, 2019, 12:21 am
If you decide to use the Assembly approach, I can post the code later when I return home. In any case, if the executor_ has no solution to the problem through the modding interface, dnSpy is the best (and possibly the easiest) option.
If you could, that would be great.

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 5:08 am
by karlito31
OK, here it is:
You will need dnSpy for this. Open Assembley-CSharp.dll and add this code either as a new class or as a function within existing class, like GameOverseer class. Make it static for simplicity purposes.

public static class ModImages
{

public static void AddSkillIcon()
{
Texture2D originalImage = ModIO.LoadImage(Application.dataPath + "\\Resources\\WL2_Icons.png");
Texture2D secondImage = ModIO.LoadImage(Application.dataPath + "\\Resources\\sneak.png");
Color[] bytes = originalImage.GetPixels(0, 0, originalImage.width, originalImage.height);
Color[] bytes2 = secondImage.GetPixels(0, 0, secondImage.width, secondImage.height);
Texture2D combinedImage = new Texture2D(originalImage.width, originalImage.height + 128);
combinedImage.SetPixels(0, 128, originalImage.width, originalImage.height, bytes, 0);
combinedImage.SetPixels(0, 0, secondImage.width, secondImage.height, bytes2, 0);
combinedImage.Apply();
byte[] bytes3 = combinedImage.EncodeToPNG();
File.WriteAllBytes(Application.dataPath + "/Combined.png", bytes3);
UIAtlas iconAtlas = MonoBehaviourSingleton<GUIManager>.GetInstance(false).iconAtlas;
iconAtlas.spriteMaterial.mainTexture = combinedImage;
UISpriteData uispriteData = new UISpriteData();
uispriteData.name = "sneak";
uispriteData.SetRect(0, originalImage.height, 128, 128);
uispriteData.width = 128;
uispriteData.height = 128;
iconAtlas.spriteList.Add(uispriteData);
}
}
In short, we are loading original WL2_Icons.png and custom image (sneak.png here) at runtime and combine them in one new image. File.WriteAllBytes(Application.dataPath + "/Combined.png", bytes3) is here just to test it and see if combining went OK. If all went well you should get something like this:
Image

After combination we are createing new UiSpriteData and assigning important properties like name, position within big image ( uispriteData.SetRect(0, originalImage.height, 128, 128);) and size (width, height). Than we add that UISpriteData to instance of "iconAtlas" which must be instantiated exactly like in code above (Unity internal rules). Now, you need to call this function somwhere, and I did it in GameOverseer class within PreGameInit() function which looks like this:
public static void PreGameInit()
{
... (all existing code) +
ModImages.AddSkillIcon();
}
And that is it.
Start game and if yor skill sprite name corespond with name you gave it in code above, you should get
Image
or
Image

The name of Atlas is irelevant.
Obviously, you can skip runtime image combination mumbo jumbo and prepare WL2_Icons.png in Photoshop in advance keeping track of exact pixel position of your added sprite in mind. In that case your function will look like this:
public static class ModImages
{

public static void AddSkillIcon()
{

Texture2D combinedImage = ModIO.LoadImage(Application.dataPath + "\\Resources\\WL2_Icons.png");
UIAtlas iconAtlas = MonoBehaviourSingleton<GUIManager>.GetInstance(false).iconAtlas;
iconAtlas.spriteMaterial.mainTexture = combinedImage;
UISpriteData uispriteData = new UISpriteData();
uispriteData.name = "sneak";
uispriteData.SetRect(///pixel position X///, ///pixel position Y///, 128, 128); ///<-- x and y of starting position in big picture in pixels.
uispriteData.width = 128;
uispriteData.height = 128;
iconAtlas.spriteList.Add(uispriteData);
}
}
Path can be whatever you like, here it is in Resource directory (Application.dataPath + "\\Resources\\WL2_Icons.png");.

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 5:41 am
by AliceInChains
karlito31 wrote:
April 15th, 2019, 5:08 am
OK, here it is:
You will need dnSpy for this. Open Assembley-CSharp.dll and add this code either as a new class or as a function within existing class, like GameOverseer class. Make it static for simplicity purposes.
Great, many thanks! I am somewhat familiar with scripting/coding but not so much with this, so it probably would have taken me quite some time to figure out. Being able to adjust attributes, link them with skills, removing some of the current non-skills (like all ass skills, brute force), splitting/combining skills, and adding new ones will greatly improve the playability of this game. Being able to use different icons will definitely help with that, as having the same icons for different skills is a bit annoying.

Then again, being able to change all sorts of aspects in the game is exactly what's preventing me from just playing... Salutations and curses to you Executor_ :lol:

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 6:00 am
by Executor_
0.9.4z now available here

MODDING
  • will now actually read the atlas field for Skills and Attributes; base game was always assuming WL2_Icons

Unless you're using karlito31's code, don't try to modify WL2_Icons, WL2_HUD, WL2_Equipment, etc. The exported MSONs for those files are only intended for reference purposes.

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 15th, 2019, 6:15 am
by karlito31
Small addendum.
My presented function, in it's current form is totally crude. It can add only one icon with set hard coded name ("sneak" in this example) as a sprite name. One should expand it to read whole folder and collect all image names and place it in array, than combine them all and create as many sprites (UISpriteData) as there are image files in directory. I didnt need it so I left it as is. Anyway, here is latest 0.9.4z patch so no need for this at all. :)

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 16th, 2019, 10:38 pm
by InputEnd
Hi all, new to modding wasteland2, and need some help, my Assembly-Sharp.dll is larger than specified per the instructions, and the delta patcher keeps failing, what am I doing wrong, and how do I fix it?

Re: Wasteland 2: now with improved modding capabilities!

Posted: April 17th, 2019, 11:45 pm
by Executor_
Are you definitely using the Director's Cut version of the game? Also, what operating system (Windows/MacOS/Linus) are you playing on?

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 1st, 2019, 8:50 am
by crimsoncorporation
I noticed one thing regarding the status effects "stunned" vs "vomiting", and I wonder if there's a bug with vomiting (you get vomiting by using the unique brawling weapon "Upchucker").

Stunned results in -3 Speed and -3 Awareness
Vomiting results in -3 Combat Initiative (and -2m optimal range)

So for the purpose of the resulting Combat Initiative the effect should be the same.

When one of my melee Rangers (that have the relevant Brute Force perks) stun their enemies, it is very often immediately noticeable in the changing combat order. So it's clear that it works.

However, with Vomiting that is never the case, the afflicted character never gets shuffled back in the combat order, as I think it should be. Is it possible that's a bug?

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 1st, 2019, 11:12 pm
by Executor_
From what I recall, there's a number of StatusEffects with the "Stunned" name. The one applied by the Applied Force line of perks, Status_Trait_AppliedForce, doesn't actually modify any stats. The perk itself modifies the combatActionTimer property, which is what leads to a change in combat order. NPCs in the base game/pre-0.9.5 don't have Attributes like Speed or Awareness, so any StatusEffect applied to them that only alters Attribute scores won't do anything. Vomiting modifies Combat Initiative, but that won't change the combat order until after the NPC's next turn.

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 17th, 2019, 12:24 am
by crimsoncorporation
Ok, thanks for looking into it. That sadly makes the Upchucker rather useless, but maybe that can be adressed with a mod down the line. In general it could be interesting to have melee weapons that focus more on status effects rather than damage.

I found another bug regarding Intelligence. Intelligence gets modified sometimes, for example with the rat in RNC, or with the manic-depressive quirk. However I found out that the modified intelligence does not seem to affect the skill points one gets when a promotion is received. For example, my manic-depressive leader has 8 INT, and had a phase with +2 INT for a total of 10. She however still only received 4 skill points instead of 5. If I recall correctly it's the same with Ralphy, who has 3 INT, but 4INT if he uses Animal Whisperer on the rat. (not 100% sure in Ralphy's case, as it's been a while and I did not monitor it specifically at the time)

Then there's another minor bug: When a psychopath falls unconscious during battle and gets revived afterwards, the bonus does not reset to its original state (as it would if the psychopath stays conscious), instead he/she gets to keep it. No biggie, but this clearly does not seem to work as intended. (I suppose the idea is that the psychopath should keep the bonus if he/she gets revived during battle)

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 17th, 2019, 3:25 am
by crimsoncorporation
I should mention this is all as of version 0.9.4y, but I suppose this hasn't changed in version 0.9.4z.

And another one: The "On The Mend" perk for some reason only activates sometimes when healing, not always. It's been a while since I chose this perk, but as far as I remember this should be activating 100% of the time.

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 17th, 2019, 8:41 am
by Executor_
crimsoncorporation wrote:
May 17th, 2019, 12:24 am
I found another bug regarding Intelligence. Intelligence gets modified sometimes, for example with the rat in RNC, or with the manic-depressive quirk. However I found out that the modified intelligence does not seem to affect the skill points one gets when a promotion is received. For example, my manic-depressive leader has 8 INT, and had a phase with +2 INT for a total of 10. She however still only received 4 skill points instead of 5. If I recall correctly it's the same with Ralphy, who has 3 INT, but 4INT if he uses Animal Whisperer on the rat. (not 100% sure in Ralphy's case, as it's been a while and I did not monitor it specifically at the time)
Working as intended. Also how the base game functions. Temporary Intelligence changes, such as those from StatusEffects or items, don't affect skillPointsPerLevel. If you go to "Mods\Export\BaseStat\Attribute\intelligence.mson", you can see that useBaseValue is set to true for skillPointsPerLevel.
crimsoncorporation wrote:
May 17th, 2019, 12:24 am
Then there's another minor bug: When a psychopath falls unconscious during battle and gets revived afterwards, the bonus does not reset to its original state (as it would if the psychopath stays conscious), instead he/she gets to keep it. No biggie, but this clearly does not seem to work as intended. (I suppose the idea is that the psychopath should keep the bonus if he/she gets revived during battle)
Makes sense. Same logic should also apply to Zeroed. I'll take a look through all the perks to see if any others need it.
crimsoncorporation wrote:
May 17th, 2019, 3:25 am
And another one: The "On The Mend" perk for some reason only activates sometimes when healing, not always. It's been a while since I chose this perk, but as far as I remember this should be activating 100% of the time.
I've got a bugfix listed in my 0.9.5 changelog: "Trait_OnTheMend not giving a bonus when healed by others". I'll try to test it thoroughly to see if there are other issues still.

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 27th, 2019, 12:57 pm
by Bigwilleh
Is there any way to obtain detailed information about what the game is doing at a given time, preferably via an in-game developer console?

I am running with a mod that, among other things, has doubled action point and action point cost scaling across the board (with halved speed to compensate) to increase the versatility of what can and can't be implemented with weapon firing modes. However, I am having the following 3 critical issues with the mod and I can't figure out why:

1. Mob type actors are sometimes loading default templates rather than imported ones, which have incorrect hitpoints and action points. I have checked the import logs and fixed all cases of bypassed import errors, and the situation has not been resolved. The issue seems to occur in non-randomized encounters, such as the wreckers' stronghold.

2. No mob seems to be able to fire ranged weapons. Instead of shooting, they play the start of turn animation. At first I thought this was due to the action points issue resulting from the above issue, but when I found mobs that definitely had correct action points, the issue persists. The game is not what I would call entertaining without mobs that shoot back.

3. The game occasionally enters an irrecoverable soft hang when changing areas. When this occurs, the loading bar stops at half and ceases to progress permanently, but all other game processes continue to run as normal (mouse input continues to register, sound continues to play, and the OS does not recognize the process as not responding).

What I'm hoping for is the ability to a) probe the stats and actions of active actors, and b) probe the loading process to determine what the game is trying to load when the soft hangs occur.

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 28th, 2019, 12:58 am
by Executor_
There isn't any built-in developer console in Unity like in Unreal. I've implemented a very limited one in 0.9.5 so far that displays exceptions as they occur. In the meantime, have you looked at the output_log.txt file in the "\Wasteland 2 Director's Cut\Build\WL2_Data\" folder? That's where the game writes exceptions to when they happen.

Could you email me the mod so I could take a look at it? executor115@hotmail.com
I have some ideas as to what might be causing your issues, but I'd actually need to test in-game to confirm.

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 29th, 2019, 9:24 pm
by Bigwilleh
I've since resolved the first two points on the list.

That said, I still haven't figured out exactly where the issue is with the loading screen hang beyond that its a null pointer reference (although I have at least confirmed that it seems to happen more often with specific guns in my bag, but I don't know why).

The output_log entry that consistently occurs when it happens looks like this:

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

NullReferenceException: Object reference not set to an instance of an object
at Trait.IsAllowedItems (System.Collections.Generic.List`1 items) [0x00000] in <filename unknown>:0

at Trait.GetStat (.StatCalc& stat, SituationBits situationBits, .PC pc, System.Collections.Generic.List`1 items) [0x00000] in <filename unknown>:0

at PCTemplate.CalculateStat (System.String statName, Int32 startValue, System.Collections.Generic.List`1 items) [0x00000] in <filename unknown>:0

at PCTemplate.RecalculateTraitModifiers () [0x00000] in <filename unknown>:0

at PCTemplate.GetActiveTraits (Boolean recache) [0x00000] in <filename unknown>:0

at PCInventory._RefreshWearables () [0x00000] in <filename unknown>:0

at PCInventory.RefreshEquipment (Boolean wearables, Boolean weapons) [0x00000] in <filename unknown>:0

at PCInventory.RefreshEquipment () [0x00000] in <filename unknown>:0

at PCInventory.Init (.PC pc) [0x00000] in <filename unknown>:0

at PC.Init () [0x00000] in <filename unknown>:0

at CNPC.Init () [0x00000] in <filename unknown>:0

at Game.SpawnCNPC (.PCTemplate template, Vector3 position, Quaternion rotation) [0x00000] in <filename unknown>:0

at Game.SpawnParty () [0x00000] in <filename unknown>:0

at Game+<PrivateLoadMap>d__123.MoveNext () [0x00000] in <filename unknown>:0

(Filename: Line: -1)

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 30th, 2019, 1:13 am
by Executor_
0.9.4za now available here

UPDATED GAME BUG FIXES
  • Resolved game crash while finding equipped items on a character
  • Trait_OnTheMend should work properly again
MODDING
  • MSON overrides, when modifying a GameObject or Component field, won't change the value unless searching for an object with a different name than the existing one; this should prevent unintentionally replacing field values with similarly named objects

Re: Wasteland 2: now with improved modding capabilities!

Posted: May 30th, 2019, 7:23 am
by Bigwilleh
Executor_ wrote:
May 30th, 2019, 1:13 am
0.9.4za now available here

UPDATED GAME BUG FIXES
  • Resolved game crash while finding equipped items on a character
  • Trait_OnTheMend should work properly again
MODDING
  • MSON overrides, when modifying a GameObject or Component field, won't change the value unless searching for an object with a different name than the existing one; this should prevent unintentionally replacing field values with similarly named objects
That was quick.

I shall now see if this works.

Also for reference, the solution to the mobs sitting grunting instead of shooting their guns was rolling back to .94v, hopefully za will work. Will report momentarily.

EDIT: Just confirmed, the mobs in this patch do their thing with grunting like they've just aggrod instead of shooting their guns.

It does not appear to occur consistently however. I reloaded the save an immediately changed zones with identical inventory, and the game loaded properly.

The output log seems to register an audio problem when its happening:

No audio category with name UIMasterVolume

(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)