Ranged Verb from hediffDef

Started by ilikegoodfood, October 10, 2018, 04:55:18 AM

Previous topic - Next topic

ilikegoodfood

#15
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

ilikegoodfood

#16
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.

ilikegoodfood

#17
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.

SargBjornson

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.

ilikegoodfood

#19
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.

ilikegoodfood

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.

ilikegoodfood

#21
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.

ilikegoodfood

#22
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?

SargBjornson

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 ;)

ilikegoodfood

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...

ilikegoodfood

#25
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.