To try and keep this minimal, I'm going to explain only my most immediate issue.
I am attempting to make a hediffDef that grants a ranged verb to pawns, both animals and colonists alike. In order to facilitate the use of ranged verbs in animals I am using the RangeAnimalFramework (Steam Workshop (http://steamcommunity.com/sharedfiles/filedetails/?id=1263611490&searchtext=Range+Animal+Framework)) (Forum (https://ludeon.com/forums/index.php?topic=38290.0)) by BrokenValkyrie.
I have created a hediffDef, see below, that uses the standard HediffCompProperties_VerbGiver, which does not flag any errors. As far as I can tell by reading the C#, it isn't limited to tools.
<HediffDef ParentName="AddedBodyPartBase">
<defName>MM_ThermalLanceAssembly</defName>
<label>thermal lance assembly</label>
<labelNoun>a thermal lance assembly</labelNoun>
<!--<spawnThingOnRemoved>ArchotechArm</spawnThingOnRemoved>-->
<comps>
<li Class="HediffCompProperties_VerbGiver">
<verbs>
<li>
<verbClass>Verb_Shoot</verbClass>
<accuracyTouch>0.7</accuracyTouch>
<accuracyShort>0.8</accuracyShort>
<accuracyMedium>0.9</accuracyMedium>
<accuracyLong>0.85</accuracyLong>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>MM_PolarColossusProjectile</defaultProjectile>
<warmupTime>3</warmupTime>
<burstShotCount>0</burstShotCount>
<minRange>6</minRange>
<range>27</range>
<soundCast>ChargeLance_Fire</soundCast>
<soundCastTail>GunTail_Light</soundCastTail>
<muzzleFlashScale>12</muzzleFlashScale>
</li>
</verbs>
</li>
</comps>
<stages>
<li>
<statOffsets>
<ComfyTemperatureMin>-40</ComfyTemperatureMin>
<ComfyTemperatureMax>-10</ComfyTemperatureMax>
</statOffsets>
</li>
</stages>
<addedPartProps>
<solid>true</solid>
<partEfficiency>1.1</partEfficiency>
<betterThanNatural>true</betterThanNatural>
</addedPartProps>
</HediffDef>
Now, once the hediff is added to the pawn, it should add the Verb to their list of verbs. This is where the RangeAnimalFramework comes in. It contains a function, ARA_VerbChecker_Patch, that checks non-colonists for ranged verbs and adds them to the pawn's verb list. It also contains various functions that enable animal behaviors associated with ranged weapons.
Since ARA_VerbChecker_Patch is a prefix to the core TryGetAttackVerb, it should be called each time TryGetAttackVerb is called. If I understand the code correctly, TryGetAttackVerb is called each time a pawn tries to attack a target, therefore the new verb should be added to the animal's verb list and it should use the new verb.
This appears to not be the case.
Furthermore, once I can work out that the verb is correctly being added to the pawn and how to make sure that AnimalRangeFramework allows it to be used in animals, I will then need to override the core TryGetAttackVerb in order to make colonists recognize and use it.
Is my understanding of the code, as described above, correct so far?
If not, what am I getting wrong?
I also need help with why the verb isn't being added or detected by the AnimalRangeFramework.
And then I'll need help with creating a safe, functional override for TryGetAttackVerb, assuming that is the correct thing after all, or whatever else needs to be changed.
Thank you all very much in advance.
P.S.
On a slight side-note, I noticed while poking around inside of EPOE's files that they also had an addedBodyPart hediffDef that granted a ranged verb, but it was commented out. I suspect they tried to do the same at some point and abandoned the idea for some reason.
Ok, wild idea, but...
How about doing it upside-down? You modify the RangeAnimalFramework (adding new classes) to only work for a given pawn IF the pawn has a Hediff...
As far as I can tell, I shouldn't need to add any additional code to it. It should be called, get the verb-list and then assign the behaviors that are appropriate. I don't currently know why the verb isn't working.
Is it that the HediffCompProperties_VerbGiver only works for tools and not verbs? In that case, why am I not getting an error?
Is it that the verbs from HediffCompProperties_VerbGiver are not actually added to the animal, but are instead added to a separate list? In that case, which list, and how do I access it?
Once I know which list, it should be simple enough to do as you suggest and add in a clause to both ARA_VerbChecker_Patch and TryGetAttackVerb that calls verbs from that list in addition to what it already calls.
So, as you can see, my issue is that I don't know where to look right now, even if I wanted to add the verb in code given the hediff's existence.
Finally, something I've not looked into yet, is that I would want it to show up drafted colonists as if it were a held weapon, so you get the weapon icon, the shoot commands and hold-fire button as normal. That's for after though.
Quote from: SargBjornson on October 10, 2018, 05:27:57 AM
Ok, wild idea, but...
How about doing it upside-down? You modify the RangeAnimalFramework (adding new classes) to only work for a given pawn IF the pawn has a Hediff...
That is a good pointer though. I'll go and look into where the VerbGiver places the verb in more detail. I had assumed that it would end up in the same place as the verbs attached to the raceDef, but that may not be the case.
EDIT 1: All verbs are sent to this.VerbTracker, which is a list of verbs that that pawn has access to. Equipement verbs, pawn verbs, turret verbs, it doesn't matter what, it ends up there.
ARA_VerbCheck_Patch iterates through that list and returns false if the creature has a verb with a range greater than 1.1f. Looking through the harmony wiki, this terminates the patch and prevents the original method from being run entirely, which makes sense since, as animals don't use equipment, it is unnecessary.
At this point, at least for the animals, the alterations to the behavior tree take over and the animal prioritizes the use of ranged attacks. This also explains why they can't handle multiple ranged verbs with different ranges, because a pawn can only have one primary verb.
Now, all of this new-found understanding leads me to the exact same conundrum as before: Is it the VerbGiver failing to pass the verb on, which seems unlikely, or is the verbTracker.AllVerbs failing to update the verb list, which also seems extremely unlikely.
The behaviors should simply all work as is.
I think that I may have found the issue, at least part of it.
There is a separate function called GetHediffsVerbs that is invoked by ChooseMeleeVerb, but is not invoked by either ARA_VerbCheck_Patch or by TryGetAttackVerb.
In order to make it work, I would need to write a patch for ARA_VerbCheck_Patch that first invokes GetHediffsVerbs, then iterates through all of the verbs including those from the hediffs.
I would then also need to make an override for TryGetAttackVerb that checks for ranged attack verbs from the hediffs After checking equipment and before checking for Melee Verbs. By ordering it that way, the pawn would the equipment (gun) provided and only use their innate verb if they don't have a gun.
This does, however, lead to a question of how to handle multiple ranged verbs on a single pawn. I will eventually need to write a chooseRangedeVerb that works similarly to chooseMeleeVerb, selecting the most appropriate verb from the available list.
Now, all of that said, I have never written a patch for a patch, nor have I created a total override before. Do you have any advice on how to go about this?
Why do you need to patch it? Just clone it and make a different DLL for your mod! That way you can modify it as much as you want, and as long as you use a different namespace it won't conflict with any other mod using animals and ranged attacks! It's what I'm doing with Genetic Rim and Alpha Animals
Won't cloning it cause it to conflict with any other instance of AnimalRangeFramework?
I'm not sure how the priority patching system works and I'm not sure how that'd work, for instance, between our two mods, which both use different clones of it.
Surely using the base framework and then patching it would make compatibility easier?
huh, now that I think of it, the AnimalRangeFramework isn't called by namespace... I'll have to check my own mods to see if they actually work together...
Indeed.
I'll wait on your tests before I start writing additional patches. I'll need to re-organize my assembly either way.
Also, a future project I would like to target is compatibility with your own mod. It's very cool and the more unique aspects of my creatures should work really well with your work if properly implemented.
Currently looking for an artist too. My work is passable, but not good, and I've discovered that it can be a deal-breaker for my subscribers.
I have considered the issue at hand and have come up with two viable ways of organising it:
1) Create an additional prefix patch for TryGetAttackVerb and prioritize it so that triggers before ARA_VerbCheck_Patch. The prefix I create will then perform the job of both ARA_VerbCheck_Patch and TryGetAttackVerb, including the additional behavior that I need it to perform and then it will always return false, thus preventing the original functions from being called.
This will make the mod incompatible with anything else that modifies these functions.
2) Write a transpiler patch for each of the two separate functions that behave in exactly the same way as those functions, aside from the additional check. This should better maintain compatibility, but may be significantly harder to actually pull off.
I will then need to write some varient of the chooseMeleeVerb function that acts as a chooseRangeVerb, preferably giving the player UI control over which verb is executed, in order to allow for circumstances where multiple additional ranged verbs are added to a single pawn. I have no idea how to do this bit, but one step at a time.
EDIT: Is it even possible to run a transpiler patch on a prefix patch?
So, I have decided to go with the approach of using a transpiler patch to separately edit each of ARA_VebCheck_Patch and TryGetAttackVerb.
As such, I have begun to read into transpilers, using this tutorial (https://gist.github.com/pardeike/c02e29f9e030e6a016422ca8a89eefc9) and it's attached resources.
What I've created should now correctly find the required line in the code and insert a new block of code there. I have, however, no idea how to write that new block of code or what would be the most efficient form it could take.
Any and all help/advice would be appreciated.
Thanks.
Here is my current code:
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Reflection.Emit;
using Harmony;
using RimWorld;
using Verse;
using AnimalRangeAttack;
namespace MonsterMash
{
[HarmonyPatch(typeof(HarmonyPatch), "ARA_VerbCheck_Patch", null)]
class harmonyPatches_ARA_VerbCheck_Patch
{
private static IEnumerable<CodeInstruction> newCodeList;
static IEnumerable<CodeInstruction> Transpiler(MethodBase original, IEnumerable<CodeInstruction> instructions)
{
int startIndex = -1, targetIndex = -1;
var codes = new List<CodeInstruction>(instructions);
for (int i = 0; i < codes.Count; i++)
{
if (codes[i].opcode == OpCodes.Callvirt && codes[i + 1].opcode == OpCodes.Clt)
{
startIndex = i; //Provides the index of the callvirt before the call I need.
for (int j = startIndex; j < codes.Count; j++)
{
if (codes[j].opcode == OpCodes.Ldc_I4_1)
{
targetIndex = j; //Finds the first line of code that is run after the for loop.
break;
}
}
break;
}
}
codes.InsertRange(targetIndex - 1, newCode);
}
}
}
I ended up creating a separate help thread (https://ludeon.com/forums/index.php?topic=46129) for the transpiler side of things, which is why this has gone quite for a while. Please feel free to check it out too.
Regardless, I felt that I should post a duplicate of this (https://ludeon.com/forums/index.php?topic=46129.msg439518#msg439518) here too:
Quote from: ilikegoodfood on October 17, 2018, 09:07:09 AM
While this is a slight side-note, I have come to the realization that, even if I manage to get all these transpiler patches working, I may not want to.
The issue is that what I am working on is an implementation of pawn race and hediff verbs, so that people and animals may use ranged attacks from health effects. This will allow the implementation of body-mounted weaponry, such as an arm-mounted charge rifle, say.
While it is something that I personally would like to see the base game support, implementing it will cause a number of knock-on effects that will cause this small project to spiral out into a major framework.
A few examples of this are as follows:
The pawn UI will need to be adjusted so that you can tell a pawn with a ranged verb to hold fire.
The pawn UI will need to be adjusted so that, if the pawn has multiple ranged verbs, you can toggle between them.
Not sure if the old 'Brawler' trait is still the same, but if it is, then hediffs with ranged verbs should trigger their 'has ranged weapon equipped' bad thoughts.
If I do decide to get into this fully, and create what could be a fairly major framework, I would probably want to completely re-implement the RangeAnimalFramework (https://ludeon.com/forums/index.php?topic=38290.0) into it, so that they are a singular functioning part, instead of having one framework dependent on another.
While that should make my work easier in some cases, I have no idea how code-sharing rules and re-implementations of such things work. I have no idea if BrokenValkirie would be okay with that, or, on the other hand, if they may like to help out.
I am also aware that some of the code already exists. CombatExtended uses a weapon-swapping system that I could, with their permission, either copy or re-implement (they recently gave permission for the re-use of some of their other code in a specific mod, so I don't see that being a problem).
Obviously, compatibility is of utmost importance to me. technically speaking, using transpilers, CombatExtended could be remade in a such a way that it had complete compatibility. What I definitely don't want is to exclude many mods from being used with it.
This makes fully grasping the use of transpilers of paramount importance for such a project.
If I do decide to go ahead with it, and learn everything I need to, and get all the permissions, then I would probably also ask erdelf for help directly.
So, for right now, I need to learn how to get this stuff working and knock out a prototype, After that, I need to seriously consider if I am willing and able to commit to such a project. I would kind of like to, but I wouldn't like to be the sole author...
Damn, this idea turned out to be way harder than it looked!
Indeed. The base game was never designed to handle multiple ranged verbs, for both simplicity of code and gameplay. It was also, given that range combat is extremely rare in nature, never designed to implement ranged functions at the race level.
Currently, the only place it checks for ranged verbs is in the equipment. This would need to be re-written so that it looks in the pawn's race, hediffs and equipment.
Once it determines which verbs the pawn has access to, the processing would need to go in three separate directions: one for animals (inc. wild men) one for NPC equipment-capable pawns and a third for colonists. It should be possible to merge the animals and equipment-capable NPCs with a well placed IF function.
This route would have to catalog all of the available ranged verbs and select the most suitable using some kind of re-implementation of 'chooseMeleeVerb' such that they select the most suitable verb to use.
The colonist route would also need to catalog all available ranged verbs, but instead of using a 'chooseRangedVerb' function, they would need to be displayed as a stack of toggle-able weapons. The player can then use a 'swap weapon' button to switch the pawn between them.
Ideally, you would also add a UI block for once-use verbs, such that they occur only on player command, and they all have their own button. A pleasant side-effect of this is that it would allow you to add mode-switching weapons to the game.
An assault rifle that has a single-shot mode for higher accuracy and a once-use grenade launcher attachment would all become possible. It would greatly expand the tactical systems available within the game and to the modding community in general.
I would absolutely love to be able to have this to play with, and for others to play with, but I am a beginner modder of RimWorld, the only game I've ever seriously modded, with an entry-level understanding of C# and IL. I have the terrible feeling that it may well be beyond me, not because of skill, I can always learn more, but patience.
On the other hand, while digging into all this is both exhausting and exhilarating at the same time, I love doing something new and I love coding. I definitely won't be able to maintain my focus without a team though. I need people to bounce off-of and keep me going.
In fact, after having put in my first ever 80-hour work-week trying to get this working, and having made only limited progress, I am already starting to falter. I'm dreading having to take a few days to update my mod to 1.o when it comes out , just because I've over done it.
Another wild and probably quite stupid idea... How about adding a "dumb" equipment item? I know animals can be given equipment trackers by code...
While that could allow a simple implementation, it doesn't do what I want it to do. The Thermal Lance is a bio-mechanoid augment. It shouldn't work outside of a body and I want it to be install-able in not only the Polar Collossus, but also other animals and colonists.
I've also noticed in the XMLs for EPOE that they have a commented out arm-cannon, which shows me that others have tried and given up before. This just makes it more of an appealing challenge.
Also, it's not really too bad. Excluding the UI implementations, it's only actually two functions and a merger with the RangeAnimalFramework.
The UI changes probably account for more of the work than the actual code.
And it is something I would very much like to do. First step though, make a working transpiler... :P
I was just going through and updating my mod list, those that have been updated, and I noticed a bit of text in Jec's Tools description about weapon addons and racial magics. I think that they have already implemented everything I need...
EDIT: They 'may' have everything I need. Looking into it, they have implemented it differently and none of it may work on animals or NPCs. I'll be poking around and asking questions on their ludeon page.
Quote from: SargBjornson on October 10, 2018, 07:29:20 AM
huh, now that I think of it, the AnimalRangeFramework isn't called by namespace... I'll have to check my own mods to see if they actually work together...
You were very quick on the 1.0. Congratulations on it all going smoothly.
I was wandering how your tests have gone?
I've managed to get two of the three required transpiler patches working, with some help from Brrainz.
Not sure what to make of the guy. He seemed kind of impatient and disinterested. While what I have now, mostly, works, I don't really feel like I've learned what the difference between his version and mine is. I know enough to re-create it, but not understand it.
Also, he was saying that no-one bothers to patch patches, which is why I'm wondering how your modified AnimalRangeFramework is working alongside others.
All of this is probably about to become academic anyway, since JecTools seems to do what I need. I'll start investigating it more fully in a bit, and then I strongly suspect that it'll supersede the AnimalRangeFramework entirely in my mod.
EDIT:
It also looks like I can do this through the use of prefixes that are executed immediately after the AnimalRangeFramework ones. AnimalRangeFramework's Prefixes only cancel the sequence of patches and the main function if they find something and execute. Since they check the race's hediff's, if they fail to find any, they would then pass on to my prefix, which would be a duplicate in all regards except that it works only for the hediff verbs.
It feels like a rotten hack.
Also, is anyone even maintaining and updating the AnimalRangedFramework at the moment? I've been using your version and have had no responses from BrokenValkirie about it.
If not, then I might just recreate and alter the original patches.
I discovered both versions of the framework were working because I didn't change them at all XD I just added new projectile classes, but didn't tweak the main class. So basically it was duplicated, and I guess the game doesn't care if you have two external libraries with an identical class.
However, I'm having ALL sorts of problems due to interactions with other mods. For example, there is a mod that adds spent bullet casings every time a pawn fires a gun, and it is interacting weirdly with the framework.
AFAIK, the framework is 100% unmaintained, so if you decide to pick it up and improve it, I don't think anyone would complain.
Quote from: SargBjornson on October 21, 2018, 09:12:53 AM
However, I'm having ALL sorts of problems due to interactions with other mods. For example, there is a mod that adds spent bullet casings every time a pawn fires a gun, and it is interacting weirdly with the framework.
AFAIK, the framework is 100% unmaintained, so if you decide to pick it up and improve it, I don't think anyone would complain.
That is as I expected. The framework's habit of cancelling the patch sequence is just bad coding from a compatibility stand point.
Same with regards to the maintenance. I am not against maintaining and vastly expanding it, but I don't think I'm the right person for the job. I have an excellent concept-level understanding of code, it took me only 2 hours to learn to read IL, for instance, but I am a beginner coder. I'm not all that familiar with RimWorld's code and all the extra features, such as adding new damage types, verbs, comps and such, are still complete black boxes to me.
Now, I have joined the JecsTools Discord server and have asked some questions about things over there. I just need to wait for a detailed answer, but I'm certain that I will be able to use JecsTools instead of AmimalRangedFramework, and it already has a lot of extra features, including cooldown-timers on verbs, once-use verbs, bullet-time combat, bullet catching/redirecting, penetrating lasers, Damage-OverTime damageDefs and so forth.
I'll be completely rebuilding my mod if it works well with NPC pawns, which I think it does juts fine. All I'm doing is waiting for confirmation.
Working with you to understand the Jec'sTools features would speed things up a lot.
EDIT: I also added AlphaAnimals to my mod-list for 1.0 and it very much seems taht we have the same design goals for our two monster mods.
EDIT 2: The things that would need rebuilding are as follows:
- Carrion Crawler Acid Damage should be a DOT with a chance to spread if untreated. I may also go back to the idea of it spawning a slime-trail as it moves, which is functionally a trap that deals acid damage. I noticed that you know how to handle spawner code...
- Land Kraken should have an automatically self-recharging smoke-pop-belt called 'Ink Squirt'.
- Polar Colossus spawns with the 'Thermal Lance Assembly' archotech bodypart that grants the 'Thermal Lance' verb, a penetrating laser, to the installed create. This can be transplanted to other creatures or even colonists, but damage scales based on body-size. A dog's thermal lance would be far weaker than one powered by the elephantine polar colossus.
Quote from: SargBjornson on October 21, 2018, 09:12:53 AMHowever, I'm having ALL sorts of problems due to interactions with other mods. For example, there is a mod that adds spent bullet casings every time a pawn fires a gun, and it is interacting weirdly with the framework.
I had to perform a similar fix back in B18 for my CombatExtended compatibility patch. Assuming that it's done in the same way, the mod will be adding a new feature to, or watching for the use of Bullet_Base projectileDef.
Anything that uses a projectile, by default only guns, will then inherit those changes. The solution is to create a duplicate of the vanilla Bullet_Base and have all of your animals' projectiles use that as a parent. The changes should no longer effect them and they will operate as before.
This is the code for the one I use:
<ThingDef Name="MM_BulletBase" Abstract="True">
<category>Projectile</category>
<tickerType>Normal</tickerType>
<altitudeLayer>Projectile</altitudeLayer>
<thingClass>Bullet</thingClass>
<label>bullet</label>
<useHitPoints>False</useHitPoints>
<neverMultiSelect>True</neverMultiSelect>
<graphicData>
<shaderType>Transparent</shaderType>
</graphicData>
</ThingDef>
I hope this solves your problem.
If it doesn't, then the mod is targeting something else, possibly the Shoot verb. You'll need to find what it's making changes to and disconnect your projectiles from it, or make them specifically exempted from that alteration through a patch.
So, I've had a response from the developer of Jec'sTools and while they have all the beautiful ability definition system and ability user AI code, none of it is used in the animal think-tree, nor do they have any plans to enable such behavior in future.
They're also working on a complete overhaul of their documentation, so how things work and what on should be available some time i the next week.
Now, what this means for the two of us is that the AnimalRangeFramework really needs an advanced rebuild.
I have some idea of how that could work and what other things I would like to enable, but this would cause two things to happen:
- It wouldn't be limited to Animal Ranged Attacks, but would rather be a general expansion to the verb system.
- Any mod using the old AnimalRangeFramework would need to be rebuilt.
I am learning and having more example of the required code every day, but I'm still a beginner. I am not going to manage such a thing by myself, of that, I am certain.
EDIT:
I also just had a wild idea about fixing the verb list; add a postfix to verbTracker.getAllVerbs. All it would need to do is add any hediffverbs to the list before it gets returned and then everything, everywhere, would recognize verbs from hediffs as if they from the race or equipment.
Being utterly fundamental to everything, it might also nuke he abyssal-plains out of RimWorld.
EDIT 2:
Alternatively, I have just been given permission by the developer of Jec'sTools to create a fix that adds the ability user AI code to the animal think tree, with a promise that if it is an easy fix and works, he'll include it.
EDIT 3: Upon further investigation it would appear that Jec'sTools is not the way to go. I'll explain more fully tomorrow, but I've been at it for most of the last thirteen and half hours and must get some sleep.
Right then, I suppose I need to explain the flip-floping with regards to Jec'sTools.
Basically, all of the features, classes and ability use systems are attached to a hook in ThinkNode_ConditionalColonist. This means that all of their code, use cases, UI elements, etc. only effect colonists. While it doesn't seem to cause any errors moving that think node to a more general spot, because of the way all abilities are tied to active player use of the UI, it doesn't expand any other options either.
I tried to follow a tutorial to create my own ability for testing purposes, but Jecrell did say that all of the documentation is out of date and he will rebuild it soon. The tutorial is for an older version and following it causes a type-cast error.
Instead I downloaded the Star Wars and Werewolf mods and took a careful look at the XMLs for each of them, since the abilities are defined in XML. The werewolf mod, also the simpler one to explain, only uses the ability system in regards to the toggle-able were-state. It literally swaps the pawn def during game-play, to a werewolf def that uses vanilla verbs. This does have a system for AI werewolves to change state from pawn to werewolf and back again, by direct, conditional additions to the think tree that call the required classes.
The same occurs in the Star Wars mod. They have built an entire think tree to prioritize how and when to use what abilities, but they have no PawnKindDef for Jedi, Jedi Knights, Sith or anything like it, just a system for the player to interact. That said, they have used a Trait to define if something is or isn't a Jedi, so it should be possible for that trait to show up on non-colonist pawns, but that only enables the force-power system. You, the player, have to actively use the menus to level up the force user. I'm not sure if they have any AI-force users at all and if they do, they're using some other method to define their skill-set either randomly or based on presets.
All in all, while Jec'sTools can implement abilities to any pawn you wish, if you create a precise enough specification and build a custom think tree to determine the use of those abilities, it doesn't have any kind of generalized behavior. This is where the use of Verbs and the AnimalRangeFramework actually shine. The verbs will never be anything but a gun, because of the way vanilla verbs work, and will always have certain conditions, such as a minimum and maximum range.
You can then use these 'facts' to build a universally applicable behavior modification across the combat AI of all pawns, excluding colonists, that will always act, if not perfectly, in a reasonable way.
So, I am still left with two possible ways forwards, not that I'll know for sure until Jecrell completes the new documentation.
- Rebuild the RangedAnimalFramework to be more powerful, such as accounting for hediff verbs, applying to pawns and colonists etc, more compatibility friendly and smarter.
- Create a standardized think tree using Jec'sTools that can be applied in bulk to all animal pawns, a second one for all equipment-wielding pawns and a third for colonists. Essentially re-implementing RangedAnimalFramework as an extension of Jec'sTools.
In both cases I would have to split the logic into the three groups, non-equipment-capable, equipment-capable and daftable-colonist. In both cases I would need to create new think trees for the use of those abilities for those three groups, as well as alter manhunter, defendmaster and berserk logic.
If I re-implemented the RangedAnimalFramework independently, I wouldn't be dependent on Jec'sTools, their production cycle or their focus on horror and cosmic horror elements, however, I would have to implement a lot of code that they basically already have. They have a lot of useful functions for this sort of thing, including a fairly complete UI system, and it may actually be less work overall to make an extension to their tools than to duplicate a lot of their work. In an AnimalRangedFramework re-implementation, they would be using verbs, but in a Jec'sTools implementation they would be abilities. I would also have to lock the logic to a certain ability type, possibly a custom one or group of my own, to ensure consistency.
Either way, the result would be a new RangedVerbExtensionFramework.
In conclusion: I'm not sure what to do about it all, I don't feel I have the skills to do this, at least not yet, and you've been politely ignoring my attempts to recruit you into this whole mess.
What are your thoughts on all this?
Aww, I'm sorry ilikegoodfood, I didn't want to give the impression that I'm ignoring you. Sorry :(
I'm just incredibly overworked right now, both in my real job and in my hobby (modding RimWorld). Even if I wasn't, I'm an atrocious team player (yeah, luckily I'm a teacher, and self-employed, so I don't need to say that in any interviews XD), so I tend to avoid working together in modding. I try to help as much as I can, but being part of a modding group guarantees everyone will be fed up with me.
To be honest, I think you DO have the skills to pull it off. You seem to be a better programmer than me! Like I told you, I code by throwing shit at a problem till it seems to fix itself XD
Personally, I wouldn't use a ranged framework that was an extension of Jecstools, mainly because I don't want my mods to be dependent on yet another third party mod. That's why I try to reinvent the wheel almost every time I need something. It's more work, but I don't need to wait for other to update their code. An exception to this is Modcheck. I'd certainly use an updated standalone framework.
On a different note, [SYR] bullet casings was giving an error because one of its Harmony patches was looking for the pawns equipment when they fired. Since animals don't have equipment, it was giving the dreaded System.NullReferenceException: Object reference not set to an instance of an object. I noticed it only checked for guns with a muzzleFlashScale greater than 0, so I just made all animals not have a muzzleFlashScale, since it isn't really important at all. Saves me having to contact Syrchalis for such a minor thing ;)
Quote from: SargBjornson on October 22, 2018, 05:57:16 AMAww, I'm sorry ilikegoodfood, I didn't want to give the impression that I'm ignoring you. Sorry :(
I wasn't getting the impression that you were ignoring me, only that you were ignoring my attempted recruitment. I fully recognize that I have far more time to spare than the vast majority of people and when I get into something I tend to do that thing to the exclusion of most all else, save eating, playing D&D and drinking coffee.
I'm currently working on this only about half of the days in the week. On those days I'm putting in some 12 hours a day and on my 'off days' I'm still putting in 3-5 hours a day, this being one of them.
And I also consider myself a poor team player. I either am interested and do it myself, as much as I can, getting impatient when people can't keep up, or don't like what they're doing an don't involve myself. Still, having someone there to get regular feedback off of and bounce ideas off of is always helpful.
Quote from: SargBjornson on October 22, 2018, 05:57:16 AMPersonally, I wouldn't use a ranged framework that was an extension of Jecstools, mainly because I don't want my mods to be dependent on yet another third party mod. That's why I try to reinvent the wheel almost every time I need something. It's more work, but I don't need to wait for other to update their code. An exception to this is Modcheck. I'd certainly use an updated standalone framework.
This I can understand and agree with. It would also give me greater creative control and the whole re-creating the wheel thing is something I'm also frequently guilty of.
I suppose I'll get started on it at some point. Should do some prep for my next D&D session at some point too though, and I could do with a few days away from the coding.
It feels stupid really, I wanted a minor new feature for my mod, an optional one that I didn't even feel I needed that badly, but I wanted it, and now I'm signing up to create a major framework, using systems I have no real understanding of. That's me for you, a perfectionist to a a fault...
I have finally started seriously looking into how best to handle the creation of a replacement for the AnimalRangeFramework, and this is what I have found so far:
All combat behaviors use tryGetAttackVerb as a first port of call. If I want to maximize compatibility I would need to expand it's functionality with the following pseudo-code:
If(animal or wildman) {getAllVerbs and getHediffVerbs; If(rangedVerb) {chooseRangedVerb; return verb;}}
Else {getEquipementVerb, getAllVerbs and getHediffVerbs; If(!Colonist) {chooseRangedVerb; return verb;} else {return assignedVerb}}
rest of existing function.
I would then need to alter JobGiver_AIDefendMaster and JobGiver_Manhunter to incorporate the ranged behaviors of finding target at range, taking cover and such.
Finally I would need to make both the chooseRangedVerb function, which would have to approximate the effectiveness of a verb based on it's accuracy, burst count, and damage value, to create an estimatedEffectiveDPS, prioritizing explosives where required, and create a UI system that lists all the ranged verbs a Colonist could use as the primary verb, and a way for the player to toggle between them, thus setting the as yet non-existent assignedVerb, instead of using the primaryVerb, which is from the gun only (I should be able to learn some of this bit from CombatExtended).
I have a passing understanding of how some of these bits work, but am, still, hesitant as to how bets to go about it. I would like to use transpilers, since that would maintain complete compatibility with other mods, but even that could be done in different ways (and I still barely understand bits of them), so I'm not 100% sure what's best to do.
The result should be fairly similar to the current RangedAnimalFramework, only more compatibility friendly and able to incorporate hediffVerbs as well as animals.
I don't think I need the animal-specific projectile types either, as it should be possible to use the existing ones already made for Verb_Shoot. Any new Verb_Shoot variants that I create in future would then be usable by anything, be it a gun, raceDef or hediff.
I am very much lacking in an experienced sounding board though, so I'm going to bite the baseBulletLike and join the RimWorld Discord Servers. From what I've found out a lot of the modding chitchat happens there. Ultimately it's a confidence (and severe anxiety) thing and I'm going to have to just sit down and start writing code...
What are your thoughts on the matter?
EDIT: It has finally begun and the folks on the Discord are very helpful so far.