[B18]Range Animal Framework

Started by BrokenValkyrie, January 18, 2018, 05:51:13 AM

Previous topic - Next topic

WalkingProblem

Quote from: BrokenValkyrie on January 24, 2018, 11:19:25 PM
Due to the way code is loaded, only one copy of .dll file is loaded, many copies of AnimalRangeUnlocker.dll can loaded. Similar reason why many copy of Harmony.dll doesn't mess up rimworld.

I decided to split the content and make the current framework standalone. Mod will be renamed to range animal framework. Although its probably one of the lightest framework. Currently the frame works unlocks range verb for animals, provide new behavior range animals. Provide two custom projectile base to better support range animals.

Range mega spider is just an example of what the mod can do. The patch and code will be moved to their respective animal.

Kk, I will study it and see how to implement for my mods. Thanks thanks

ilikegoodfood

I'm completely new to modding and have just started creating a mod that aims to add a variety of weird and wonderful monsters to the RimWorld, varying from over-sized versions of existing or extinct creatures, to tech-infused cyborgs and fantasy inspired theme-park attractions gone wrong.

The first creature that I'm creating is the Inferno Beetle, which should be able to fire incendiary launcher shots.
I understand that in order to do that, I need to include this mod into my own, either as dll in the Assembly (which is what I've currently got), or by copying over certain parts of the XML.

I'm struggling to work out exactly what bits I need, if any other parts, and how to set the creature to actually use the attack. Could someone please explain it to me?

Thanks in advance.

EDIT: I have almost everything about the creature working, so this should be one of the final details.

Harry_Dicks

Are you trying to have an animal use the incendiary launcher, or have an animal have a ranged attack that is similar to the incendiary launcher?

ilikegoodfood

#18
QuoteAre you trying to have an animal use the incendiary launcher, or have an animal have a ranged attack that is similar to the incendiary launcher?

I managed to get it working perfectly.
I transferred over the AnimalRangeUnlocker.dll to my Assemblies folder, transfered the AnimalRangedJob.xml to my JobDefs and am currently implementing the patch for CE.
EDIT 2: I'll be looking into compatibility with "A Dog Said", "Combat Extended", "Giddy Up" and "Run and Gun".
I'm unlikely to catch up in a timely fashion on compatibility lists if once I have a backlog of creatures, so it makes sense to get them all sorted and in a routine from the start. It also gives me longer to come up with another creature, since I started with only one creature idea.

I created a new shoot verb for the Inferno Beetle that fires an incendiary launcher projectile, using the bullet type from the base game.
My animal effectively has an in-built Incendiary Launcher from the base game, and with nearly double the accuracy, since the creatures don't benefit from shooting skills.

I tested it and it very nicely burned the quicktest colonists.

Not sure if I'll publish the mod with only one monster, (here's a link to my help thread), but when I do publish it, I'll be sure to let you all know to add the Monster Mash to the list of mods that are using this fantastic tool.

Thank you very much.

Harry_Dicks

Quote from: ilikegoodfood on January 30, 2018, 03:59:05 PM
I managed to get it working perfectly.

-snip-

I tested it and it very nicely burned the quicktest colonists.

Nice! I think if you decide you are finished working on your mod, that you should release it. It may not be a lot to you, but I can guarantee that if you don't mind, others will use yours as a "framework" (am I using that word correctly?) and build some of their own creatures with the work you've done! That is just my suggestion, at least. Why not give back to such a great community, and put a little more good in the world? ;)

ilikegoodfood

QuoteI think if you decide you are finished working on your mod, that you should release it.

I have finished the one creature, but I hope to come up with and add many more once I sort out a production routine.

I would like to sort out compatibility with "A Dog Said", "Combat Extended", "Giddy Up" and "Run and Gun", before adding any more creatures (I haven't come up with a second yet anyway).
It would allow me to create a creature, process the compatibility mods for it and then create a new creature. A simple routine that shouldn't be too hard to follow. I feel like if I wait with the compatibility until I have more creatures, I'll loathe having to work on them all as a big bath of duplicate code.

EDIT: I think that, once I've sorted all of the compatibilities for the Inferno Beetle, I may well release a one-monster alpha.

BrokenValkyrie

Giddy up, and "run and gun" supports animal range attack. Animal don't run and gun often, I'll try to work on it sometime within the next week.

ilikegoodfood

#22
I think that I have the Combat Extended Patch working as I want it too, all except for a single pair of errors, that may be to do with this mod, and not my patch.

So, using the CE_Patch from the Megaspider sample mod as a guide, and updating it to match CE's core patch for the Incendiary Launcher, I get the following verb addition for the shot:
<li Class="PatchOperationAdd">
<xpath>*/ThingDef[defName = "InfernoBeetle"]</xpath>
<value>
<!--Accuracy needs to be high, because well animal don't have shooting skill-->
<verbs>
<li Class="CombatExtended.VerbPropertiesCE">
<recoilAmount>0.5</recoilAmount>
<verbClass>Verb_Shoot</verbClass>
<!--<verbClass>CombatExtended.Verb_ShootCE</verbClass>-->
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_30x64mmFuel_Incendiary</defaultProjectile>
<warmupTime>2.5</warmupTime>
<range>15</range>
<burstShotCount>0</burstShotCount>
<soundCast>Pawn_BigInsect_Call</soundCast>
<soundCastTail>GunTail_Medium</soundCastTail>
<muzzleFlashScale>1</muzzleFlashScale>
<targetParams>
<canTargetLocations>true</canTargetLocations>
</targetParams>
</li>
</verbs>
</value>
</li>


Now as you can see, I have two possible verbClass lines, that each present a different error when used.
The currently active one (<verbClass>Verb_Shoot</verbClass>) allows the creature to target enemies and behave accordingly, but I get a System.InvalidCastException when it tries to fire the shot.
The commented-out option (<verbClass>CombatExtended.Verb_ShootCE</verbClass>) Throws up an AI error when the Inferno Beetle turns manhunter.

I believe that what has happened, is that the way the shot is called, the verb, has been changed from the a17 to the b18 version of CE, so it no longer recognizes Verb_Shoot, however, the JobDef provided by this Range Animal Framework requires it. This bit is an educated guess, as I'm still very new to this.

Could someone please help me squash this bug-duo?

Thanks in advance.

Here's the error logs:
Verb_Shoot
Exception ticking InfernoBeetle22076: System.InvalidCastException: Cannot cast from source type to destination type.
  at Verse.Verb_LaunchProjectile.TryCastShot () [0x00000] in <filename unknown>:0
  at Verse.Verb_Shoot.TryCastShot () [0x00000] in <filename unknown>:0
  at Verse.Verb.TryCastNextBurstShot () [0x00000] in <filename unknown>:0
  at Verse.Verb.WarmupComplete () [0x00000] in <filename unknown>:0
  at Verse.Verb_LaunchProjectile.WarmupComplete () [0x00000] in <filename unknown>:0
  at Verse.Verb_Shoot.WarmupComplete () [0x00000] in <filename unknown>:0
  at Verse.Stance_Warmup.Expire () [0x00000] in <filename unknown>:0
  at Verse.Stance_Busy.StanceTick () [0x00000] in <filename unknown>:0
  at Verse.Stance_Warmup.StanceTick () [0x00000] in <filename unknown>:0
  at Verse.Pawn_StanceTracker.StanceTrackerTick () [0x00000] in <filename unknown>:0
  at Verse.Pawn.Tick () [0x00000] in <filename unknown>:0
  at Verse.TickList.Tick () [0x00000] in <filename unknown>:0
Verse.Log:Error(String)
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update()


CombatExtended.Verb_ShootCE
Exception in Verse.AI.ThinkNode_Priority TryIssueJobPackage: System.NullReferenceException: Object reference not set to an instance of an object
at CombatExtended.Verb_LaunchProjectileCE.CanHitTargetFrom (Verse.IntVec3,Verse.LocalTargetInfo,string&) <0x001f3>
at CombatExtended.Verb_LaunchProjectileCE.CanHitTargetFrom (Verse.IntVec3,Verse.LocalTargetInfo) <0x00056>
at CombatExtended.Verb_ShootCE.CanHitTargetFrom (Verse.IntVec3,Verse.LocalTargetInfo) <0x00088>
at AnimalRangeAttack.ARA_AttackTargetFinder.CanShootAtFromCurrentPosition (Verse.AI.IAttackTarget,Verse.AI.IAttackTargetSearcher,Verse.Verb) <0x000b0>
at AnimalRangeAttack.ARA_AttackTargetFinder.BestAttackTarget (Verse.AI.IAttackTargetSearcher,Verse.AI.TargetScanFlags,System.Predicate`1<Verse.Thing>,single,single,Verse.IntVec3,single,bool) <0x004f4>
at AnimalRangeAttack.ARA__ManHunter_Patch.Prefix (RimWorld.JobGiver_Manhunter&,Verse.AI.Job&,Verse.Pawn&) <0x002bd>
at (wrapper dynamic-method) RimWorld.JobGiver_Manhunter.TryGiveJob_Patch1 (object,Verse.Pawn) <0x00072>
at Verse.AI.ThinkNode_JobGiver.TryIssueJobPackage (Verse.Pawn,Verse.AI.JobIssueParams) <0x00021>
at Verse.AI.ThinkNode_Priority.TryIssueJobPackage (Verse.Pawn,Verse.AI.JobIssueParams) <0x000a2>

Verse.Log:Error(String)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Conditional:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Tagger:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Subtree:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.ThinkNode_Priority:TryIssueJobPackage(Pawn, JobIssueParams)
Verse.AI.Pawn_JobTracker:DetermineNextJob(ThinkTreeDef&)
Verse.AI.Pawn_JobTracker:TryFindAndStartJob()
Verse.AI.Pawn_JobTracker:EndCurrentJob(JobCondition, Boolean)
Verse.AI.MentalStateHandler:TryStartMentalState(MentalStateDef, String, Boolean, Boolean, Pawn)
Verse.AI.Pawn_MindState:StartManhunterBecauseOfPawnAction(String)
Verse.AI.Pawn_MindState:Notify_DamageTaken(DamageInfo)
Verse.Pawn_HealthTracker:PreApplyDamage(DamageInfo, Boolean&)
Verse.Pawn:PreApplyDamage(DamageInfo, Boolean&)
Verse.Thing:TakeDamage(DamageInfo)
CombatExtended.BulletCE:Impact(Thing)
CombatExtended.ProjectileCE:TryCollideWith(Thing)
CombatExtended.ProjectileCE:CheckCellForCollision(IntVec3)
CombatExtended.ProjectileCE:CheckForCollisionBetween()
CombatExtended.ProjectileCE:Tick()
Verse.TickList:Tick()
Verse.TickManager:DoSingleTick()
Verse.TickManager:TickManagerUpdate()
Verse.Game:UpdatePlay()
Verse.Root_Play:Update()

ilikegoodfood

My mod, with only one creature right now, is up, both here on the Forums and the Steam Workshop.

Since it uses the Range Animal Framework and since you've been helping me with it, I thought you might like to know.
Thank you for the help.

CrazyMalk

Oh man! Why didn't I discover this before! Amazing!

Harry_Dicks

Quote from: CrazyMalk on February 01, 2018, 12:39:01 PM
Oh man! Why didn't I discover this before! Amazing!

Because it just came out, silly! ::)

CrazyMalk

Ha! Now it makes sense! I always tried to use the mechanoid/custom gun technique!

ilikegoodfood

I have a small question for you BrokenValkyrie...

Does this mod add support to animals for defensive ability, similar to smokepop belts and/or shields?
If it doesn't, would this be something that you are interested in adding to the framework?

The reason I'm asking is because I recently made the Land Kraken for my Monster Mash mod, and it would be cool if it could squirt ink (mechanically a smokepop belt) to defend itself from bullets.

Harry_Dicks

Mister or Miss BrokenValkyrie, I think it's really strange how a handful of mods that I had been looking at, all happened to be yours or maintained by you! I wanted to ask, would you please consider putting your other mods onto dropbox as well? I am very interested in these mods especially: Dermal Regenerator, both Beast Men patches, Dragons, Disinfectant Stand, and definitely Septic Tank. I actually made a post a long time ago asking about if we could have a septic tank, and dubwise said he didn't want it in the mod anymore.

Anyway, I would hope that you would please consider my request. I also wanted to thank you for all of your mods that you put out, and I definitely appreciate your work. I think other users would appreciate your work posted off of Steam as well! Thanks ;D

ilikegoodfood

#29
I have discovered an unidentified bug with my duplicate of the MegaSpider RangeAttack's patch to add the shoot verb.

I've been trying to solve it over on on my own thread. The following quote is of my latest post, but it should also act as a link back to the others, which includes the code, if you need it.

Thanks for your help.

EDIT: Managed to find a workaround by isolating each PathOperationAdd in their own sub-sequence. It's tacky but it works for now.

Quote from: ilikegoodfood on February 18, 2018, 06:57:52 AM
wwWrith, do you remeber that when we switched the patch operation for the RangeAnimalFramwork from <success>Always</success> to <success>Normal</success>, we received a log for a phantom error that didn't seem to have any impact, so we ignored it?

Well, further investigation of the current issue shows that the error is preventing the patch sequence from continuing.
This means that, if I have more than one animal with a ranged attack, only the first one listed is implemented.
The code is an exact copy, with different figures, from the template mod provided by BrokenValkyrie along with the RangeAnimalFramework, the MegaSpider Range Attack mod. That mod only adds a range attack to a single creature, so I suspect he/she/other may be unaware of the issue.

I'm going to re-subscribe to the Dragon mod, since it has multiple creatures, and see if that presents a solution.
Unfortunately, because of the way that RangeAnimalFramework calculates attack jobs, I'm probably going to have to remove the ranged attack from the Sanguine Drake anyway, but this bug really need squashing first.

Thanks again for your help.

EDIT: There was a tiny variation, one line to be exact, but that hasn't solved the issue.
I'm beginning to wonder if it's an issue with my using the inclusive assembly instead of making a direct reference to a separately installed mod, as all of BrokenValkyrie's sub-mods do. I'm going to quote this whole discussion (not much of a discussion with only 1 poster at the moment :P) over and ask for help directly.
He/other/she hasn't responded to my previous question yet though... We'll see.