Monsters Mod - New to Modding

Started by ilikegoodfood, January 30, 2018, 08:44:45 AM

Previous topic - Next topic

ilikegoodfood

I have long wanted to make a mod for RimWorld, but have struggled to decide what to make.
I have recently decided to and started to make a mod called Monster Mash, with the aim to add a number of exotic and dangerous creatures to RimWorld.

I've been searching around in tutorials and on the forums to determine exactly what it is I need in order to make the mod and to make it compatible with other mods (I know, that can mostly be left for later).

So far, I have a copy of the Megascarab, which I am converting into the Inferno Beetle, a large fire-breathing insect that eats trees and can be milked for chemfuel.
I'm trying to work out what all of the various files and other bits and pieces that I'll need to make it work. So far, I think I need the following:

  • Races_Animal_Insect - currently what I'm working in/on.
  • a definition for its Egg
  • the animal range unlocker mod (LINK). I have created an Assemblies folder and transfered the AnimalRangeUnlocker.dll and Harmony library dll, but don't yet know how to use them.
  • the ModCheck for compatibility (LINK) - I have it in, but will get to that later.
  • Core graphics and sound collection for reference. - Got.

So:
Is there anything else that I'm going to need that I have missed?
Does anyone here know how to define a ranged creature tool using Animal Range Unlocker?
What key steps will I always need to go through to consistently create an animal?

That you all for humoring and helping a new modder.

wwWraith

Quote from: ilikegoodfood on January 30, 2018, 08:44:45 AM
the animal range unlocker mod (LINK). I have created an Assemblies folder and transfered the AnimalRangeUnlocker.dll and Harmony library dll, but don't yet know how to use them.

I think you should download the Mega Spider submod from that thread and use it as an example. It was made for this purpose. Though you'll probably want to change patching to just def additions.

For general examples look for other mods that add animals, preferably some simpler ones to make the things clearer.

I didn't make animal mods myself, but your todo list looks ok for me. So just start and test, most probably you'll learn what to do on encountering errors.
Think about it. Think around it. Perhaps you'll get some new good idea even if it would be completely different from my words.

ilikegoodfood

#2
QuoteI think you should download the Mega Spider submod from that thread and use it as an example. It was made for this purpose. Though you'll probably want to change patching to just def additions.

I have already done so and am going to look at it once I have the base creature working. Thanks for the suggestion.

QuoteFor general examples look for other mods that add animals, preferably some simpler ones to make the things clearer.

I am using the Megafauna mod and core files as an example for the moment. So far, I have a functioning giant beetle that eats tree and can turn manhunter if attacked (10% chance).

As a beginner, it is somewhat difficult to make heads or tails out what some of the values actually mean, such as "MateMtbHours". It clearly regulates mating frequency, but exactly what that corresponds to in-game is hard to know, so I just picked a value near a similar animal.

The base graphic of my creature has the body and the chem-fuel glands on it, and I want to draw them in different colors. Does that mean that I have to separate them and draw the glands over the body?
Boomrats and Boomalopes have different colored body-sections, so I'll check against them...

wwWraith

Mtb stands for "Mean Time Between", though I can't provide exact details of its usage. I think most other tags will become clear in the process.
Think about it. Think around it. Perhaps you'll get some new good idea even if it would be completely different from my words.

ilikegoodfood

#4
I have an almost working creature. Just two bits left to complete:

QuoteThough you'll probably want to change patching to just def additions.

I'm really not sure how to do that at the moment. I've asked over on the mod's page.

And I keep getting an error that I don't know how to solve:

Failed to find any texture while constructing Multi(initPath=Things/Pawn/Animal/InfernoBeetle/InfernoBeetlePack, color=RGBA(1.000, 1.000, 1.000, 1.000), colorTwo=RGBA(1.000, 1.000, 1.000, 1.000))
EDIT: I have discovered what the error is - I have classed the animal as a pack animal, so it needs graphics for the packs themselves.

Otherwise, here is the Inferno Beetle:

[attachment deleted by admin: too old]

wwWraith

Quote from: ilikegoodfood on January 30, 2018, 12:31:57 PM
QuoteThough you'll probably want to change patching to just def additions.

I'm really not sure how to do that at the moment. I've asked over on the mod's page.

Patching means editing things in the already existing defs. But as you are creating your own new def, you can just add these things (what was added in the said example) directly in it. So instead of using a patch with something like


<Operation Class="PatchOperationAdd">
<xpath>Defs/ThingDef[defName = "InfernoBeetle"]</xpath>
<value>
<verbs>
<li>
<verbClass>Verb_Shoot</verbClass>
<accuracyTouch>0.8</accuracyTouch>
<accuracyShort>1</accuracyShort>
<accuracyMedium>0.95</accuracyMedium>
<accuracyLong>0.8</accuracyLong>
<!-- etc. -->
</li>
</verbs>
</value>
</Operation>


you just add these verbs into your InfernoBeetle ThingDef. If you want to understand it better, try https://gist.github.com/Zhentar/4a1b71cea45b9337f70b30a21d868782.
Think about it. Think around it. Perhaps you'll get some new good idea even if it would be completely different from my words.

ilikegoodfood

#6
So, if I have understood any of this correctly, then my AnimalRangePatch should read like so:
<?xml version="1.0" encoding="UTF-8"?>

<Patch>
<Operation Class="PatchOperationAdd">
<xpath>Defs/ThingDef[defName = "InfernoBeetle"]</xpath>
<value>
<!--Accuracy needs to be high, because well animal don't have shooting skill-->
<verbs>
<li>
<verbClass>Verb_Shoot</verbClass>
<accuracyTouch>0.8</accuracyTouch>
<accuracyShort>1</accuracyShort>
<accuracyMedium>0.95</accuracyMedium>
<accuracyLong>0.8</accuracyLong>
<hasStandardCommand>true</hasStandardCommand>
<defaultProjectile>Bullet_IncendiaryLauncher</defaultProjectile>
<warmupTime>3.5</warmupTime>
<burstShotCount>1</burstShotCount>
<minRange>4</minRange>
<range>16</range>
<soundCast>Pawn_BigInsect_Call</soundCast>
<muzzleFlashScale>2</muzzleFlashScale>
<!--Commanility determines how frequent this range verb is chosen.-->
<commonality>1</commonality>
</li>
</verbs>
</value>
</Operation>
</Patch>


This adds a single high-accuracy Incendiary Launcher attack to the creature.
As far as I can tell, with the AnimalRangeUnlocker.dll in my assemblies folder, this should be it?

Testing now...

EDIT: I also needed the AnimalRangedJob.XML so that the creature knew how to behave, which was in accordance with the information on the mod page.
Once I worked that out and put it in correctly, it worked perfectly and my three test colonists were badly burned fighting one self-defending Inferno Beetle. :D

So, I have my first ever fully functioning mod.
Next steps are, in the following order:

  • Compatibility for "A Dog Said", "Combat Extended", "Giddy Up" and "Run and Gun".
  • More creatures.

ilikegoodfood

I've got the animal and it's shot working, but still have an issue with the Combat Extended Compatibility Patch, which I have been discussing over of the Range Animal Framework thread (LINK).

If someone reading this knows of a solution, I would very much appreciate it.

Quote from: ilikegoodfood on January 31, 2018, 02:05:22 PM
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()


BrokenValkyrie

#8
I strongly suggest creating your own projectile, rather than use combat extended. Those projectile require ammunition, something animal don't have. I strongly suspect this to be the cause of the error.

If you have workshop I recommend looking at some of the supported mod.

Here is how projectile is defined for dragon, abstract class is from the framework. Take note of the thingClass from the Frame work, the assembly has two projectile class that produce smoke on impact.


<ThingDef Name="ARA_FireProjectile" Abstract="True">
<label>flame</label>
<category>Projectile</category>
<tickerType>Normal</tickerType>
<altitudeLayer>Projectile</altitudeLayer>
<useHitPoints>False</useHitPoints>
<neverMultiSelect>True</neverMultiSelect>
<thingClass>AnimalRangeAttack.Projectile_Fire</thingClass>
<graphicData>
<shaderType>TransparentPostLight</shaderType>
</graphicData>
</ThingDef>
<ThingDef ParentName="ARA_FireProjectile">
<defName>ARA_DragonFireBreathAlpha</defName>
<graphicData>
<shaderType>TransparentPostLight</shaderType>
<texPath>Things/Special/Fire/FireA</texPath>
<graphicClass>Graphic_Single</graphicClass>
</graphicData>
<projectile>
<flyOverhead>false</flyOverhead>
<speed>16</speed>
<damageDef>Flame</damageDef>
<damageAmountBase>3</damageAmountBase>
<explosionRadius>0.5</explosionRadius>
<explosionChanceToStartFire>0.1</explosionChanceToStartFire>
<soundExplode>FlameThrower</soundExplode>
</projectile>
</ThingDef>


Run and Gun is already compatible with range animal framework, you can't do anything to make it more compatible. As for giddy up, I think you just have to ensure the animal centered is right so the colonist look right when they sit on top of it.

ilikegoodfood

#9
I had briefly considered considered that CE uses ammunition, but I had assumed that would be part of the weapon and not required for the projectile itself.

Thanks you for the suggestion.
I'll try create the projectile and test it today.

EDIT:
QuoteRun and Gun is already compatible with range animal framework
I was going to ask if that was automatically compatible or if I needed to create a patch for it. The pre-emptive answer you provided solves that.

QuoteAs for giddy up, I think you just have to ensure the animal centered is right so the colonist look right when they sit on top of it.
Thanks, I know. I don't use the mod in my games (yet), but I know a little about that one already.

EDIT 2: "It's alive. It's ALIVE!"
Thank you very much for the suggestion about the custom projectile. Once I sorted the bugs in my projectile it worked perfectly in both Vanilla and CE.
Might I suggest that you add a note to the OP in the Ranged Animal Framework, specifying that you should always create your own projectiles for comparability purposes. It could save other newcomers the issues that I have experienced.