Page 1 of 1

Weapon Modding

Posted: December 7th, 2016, 1:09 pm
by Executor_
While I've managed to figure out how to change melee weapons from diagonal to non-diagonal and vice versa:

Code: Select all

attackRange : 3 // can attack diagonally
attackRange : 2 // cannot attack diagonally
I can't seem to get changes to the validMods and statusEffect properties to work. Under ItemTemplate_WeaponRanged in the class list, they're defined as:

Code: Select all

validMods :  // System.Collections.Generic.List`1[ModSlot]
statusEffect :  // StatusEffect[]
ModSlot is an enumerated list:

Code: Select all

public enum ModSlot
{
	Barrel,
	UnderBarrel,
	Scope,
	Magazine,
	ShotgunChoke,
	MeleeGrip,
	MeleeWeight
}
So the following should work:

Code: Select all

validMods : [ 1, 3 ]

statusEffect : [ concussion ]
percentToApplyStatusEffect : 50
Yet it doesn't. I've tried dozens of variations with curly brackets and whatnot just in case, but that hasn't worked either. Has anyone had better luck modding these fields?

Re: Weapon Modding

Posted: January 3rd, 2017, 5:31 am
by natty_dread78
For the valid mods, you have to write the enum name, not the integer. For example:
validMods : [ Barrel, Scope, Magazine, UnderBarrel ].
I have tested it, it works.
For the status effects, I couldn't make it work either. I tried the 'burn', 'all tied up', 'knockdown' effects, with no success.

Re: Weapon Modding

Posted: January 3rd, 2017, 11:53 am
by Executor_
Try these override files, placed in the "Mods\Import\ItemTemplate\ItemTemplate_Equipment\ItemTemplate_Weapon\ItemTemplate_WeaponRanged" folder:

AssaultRifle_Tier_1_1.mson

Code: Select all

{
	description : "Test assault rifle 1"
	
	attackRange : 25
	optimalRange : 15
	pointBlankRange : 5
	
	modClass : None                                			// WeaponModClass enumeration
	validMods : [ Barrel, UnderBarrel ]    					  // ModSlot enumeration
}
AssaultRifle_Tier_1_2.mson

Code: Select all

{
	description : "Test assault rifle 2"
	
	attackRange : 30
	optimalRange : 25
	pointBlankRange : 20
	
	modClass : AssaultRifle                                 // WeaponModClass enumeration
	validMods : [ Barrel, UnderBarrel ]    					  // ModSlot enumeration
}
The first one will have no mod slots whatsoever, while the second one will have the four mod slots an assault rifle normally gets.

The reason your example seems to work is because you left the modClass field unchanged. It defaults to using modClass if the validMods array is null or zero-length, and since the deserializer is bugged, validMods will pretty much always end up being a zero-length array if you try to modify it.

Re: Weapon Modding

Posted: January 4th, 2017, 12:20 am
by natty_dread78
I see. So we are limited to using an existing modClass. That also explains why the status effects do not work. If the deserializer is bugged and fails to deserialize validMods, it probably also fails to deserialize the statusEffect array. When I tried to mod a weapon with a 100% status effect, I could see the "100 % chance to apply" text in the weapon card, but no status effect.

Re: Weapon Modding

Posted: January 4th, 2017, 3:36 am
by Executor_
The StatusEffect problem is a different issue. Only the ItemTemplate, DropSet, and UIAtlas classes have a FromString method written. When the deserializer attempts to call FromString on the StatusEffect class, it can't find the method, so it gives up trying to match the name (e.g "concussion") with an actual UnityEngine.Object.

Sidenote: The DropSet FromString method only retrieves from a MSON file, instead of looking thru memory for an already loaded DropSet like ItemTemplate does.

Re: Weapon Modding

Posted: January 4th, 2017, 5:28 am
by natty_dread78
Ok, so there's no hope. I guess no one is going to fix those bugs now. Too bad, they don't look to hard to fix. If I had the code (and the time), I might even have tried myself (I'm a dev).
It's a shame, really. I found that mson modding thing pretty well done. But with so many bugs, it's unusable.
Hexediting is still possible, tough, but it's a pain I guess. I haven't tried yet.

Re: Weapon Modding

Posted: January 4th, 2017, 6:08 am
by Executor_
While I doubt inXile will bother to fix the bugs, I'd say there's a good chance they will all get resolved. :mrgreen:

Re: Weapon Modding

Posted: January 4th, 2017, 6:40 am
by natty_dread78
I felt it coming ;) . Will you be sharing your patched exe :) ? Those shotguns are asking to have some status effects applied (stiffness, stunned...).

Re: Weapon Modding

Posted: January 4th, 2017, 7:46 am
by Executor_
Yeah, I'll share my changes once I'm finished. Some adjustments can take an inordinate amount of time to insert into the game though, so the process is slow.

Re: Weapon Modding

Posted: January 5th, 2017, 6:57 am
by natty_dread78
Cool, thxs! I'm looking forward to it.

Re: Weapon Modding

Posted: January 9th, 2017, 1:19 am
by Executor_
It's coming along nicely and I'm hoping to release the first version of the modded game this coming weekend.

Re: Weapon Modding

Posted: January 9th, 2017, 5:16 am
by natty_dread78
Great news!
By the way, I also tested the "knockback" and "knockDown" attributes, with no success.
I tested:

Code: Select all

knockback : true
knockbackDistance : 3.6
and

Code: Select all

knockDown : true
with no success.
At first I thought 'knockDown' worked because when I tested it on a shotgun, enemies were indeed knocked down. But a bit later it was no longer the case, so I assume the first time it was due to a classical random knock down (it seems any weapon can knock down more or less randomly).

Re: Weapon Modding

Posted: January 9th, 2017, 10:50 am
by Executor_
A weapon with knockdown enabled needs to do damage equal to at least 40% of the target's base health to knock them down.

It seems knockback can only work on PC characters.

Here's the relevant code:

Code: Select all

			float num = (float)amount / this.stats.GetMaxHP();
			if (weapon != null && weapon.knockback && mob != null && this is PC)
			{
				this.Knockback(mob, weapon.knockbackDistance, num);
				this.PlayTakeDamageSound(1f);
			}
			else if (weapon != null && weapon.knockDown && num >= 0.4f)
			{
				this.animManager.KnockDown(num, damageSourcePosition);
				this.PlayTakeDamageSound(num);
			}
			else
			{
				this.animManager.TakeDamage(num, this.struggle);
				this.PlayTakeDamageSound(num);
			}

Re: Weapon Modding

Posted: January 10th, 2017, 12:56 am
by natty_dread78
Thanks a lot for the explanation. Too bad, I found knockBack could be a nice improvement for the shotgun (witouth making them too OP).
The knockDown threshold, however, makes sense. I feared it would make the shotguns too OP, but with the threshold, it's ok.

Re: Weapon Modding

Posted: January 13th, 2017, 2:03 pm
by Executor_
http://i.imgur.com/iHSB5yp.jpg
http://i.imgur.com/C2beoPn.jpg
Valid mods changed and concussion effect added :D
Tested concussion effect on party members, was a success :twisted:

All done using an MSON file and a completely rewritten deserializer inserted into the game code.

Still need to do some work to get every object to always check for an override, and also stuff related to 'scene'/map-specific objects.

Re: Weapon Modding

Posted: January 15th, 2017, 11:16 pm
by Executor_
Ugh, an issue has cropped up and its caused a delay. I was hoping to resolve the problem of certain objects (like DropSets) not having MSON overrides applied. I intended to do so by adding a new field to the DropSet class to track whether it had ever had any overrides applied, and this field would be quickly checked right at the start of each of it's methods. However, UnityEngine being its usual pain-in-the-ass self, doesn't like that. Adding a field to the DropSet changes the object size, and UnityEngine starts whining about loaded data being corrupted.

If I want to 'add' new fields, I'll have to make some extensive changes to the backend, since I'll need to pair each UnityEngine Object (ie. DropSet, ItemTemplate, MobTemplate) with another object storing all the additional data. Thankfully, I can easily alter any private/protected fields and methods of the game's classes and make them public so I can access them from wherever.

I'm still hoping to release an intermediate version in a day or two (once I apply a bit more polish) that will have a band-aid solution for the time being. Right after a 'scene' (ie. map) finishes loading, I'll have the game check to see if each object has an override MSON file available, and if so, it'll apply it immediately. That should make the previously uneditable objects like DropSets, Traits, AIWeightTemplates alterable.

Re: Weapon Modding

Posted: January 16th, 2017, 1:34 am
by natty_dread78
Looks great! Just by having the effects working correctly will make your version a must have.
Yes, changing the objects' size is always risky, it's an open door to cores, memory leaks, save game compatibility, etc

Re: Weapon Modding

Posted: January 16th, 2017, 2:01 pm
by Executor_
OK, I'm getting very close to releasing the first version. Still need to do more tests to ensure the various object types import properly, as well as fixing the export logic and also test the custom Mods path option.

Some more screenshots:
http://i.imgur.com/TquLr4f.jpg DropSet for goat can edited
http://i.imgur.com/iiBZRSC.jpg DropSet for Quarex's scope edited
http://i.imgur.com/wZKYQNq.jpg Angela Deth's portrait changed
http://i.imgur.com/ns0Jdpq.jpg Vargas' portrait changed

Re: Weapon Modding

Posted: January 17th, 2017, 5:55 am
by Executor_
OK, updated game released, see this thread.