RimWorld

RimWorld

Range Animal Framework
 This topic has been pinned, so it's probably important
Hatena  [developer] 21 Apr, 2024 @ 5:06pm
(For Modders)How to use Range Animal Framework
(machine translation)

This mod allows animals to have long-range attacks by simply adding a <verbs> description to the animal's ThingDef.
For the description of <verbs>, please refer to guns and other long-range weapons.

<verbs> <li> <!-- verb --> </li> </verbs>
< >
Showing 1-8 of 8 comments
Hatena  [developer] 21 Apr, 2024 @ 5:06pm 
But there are a few things to keep in mind.
Bringing the description of the long-range weapon as it is, there are no settings for hit rate and cooldown time.
This is because in the case of weapons, they are described in <statBases>.
So change the description of <statBases> as follows and put it in <verbs>.

<AccuracyTouch>0.80</AccuracyTouch> <AccuracyShort>0.75</AccuracyShort> <AccuracyMedium>0.45</AccuracyMedium> <AccuracyLong>0.35</AccuracyLong> <RangedWeapon_Cooldown>1.6</RangedWeapon_Cooldown>

<accuracyTouch>0.80</accuracyTouch> <accuracyShort>0.75</accuracyShort> <accuracyMedium>0.45</accuracyMedium> <accuracyLong>0.35</accuracyLong> <defaultCooldownTime>1.6</defaultCooldownTime>

Since v1.5, explosive attacks do not require a hit ratio setting.
The <forcedMissRadius> that should have been originally set in <verbs> works.
Hatena  [developer] 21 Apr, 2024 @ 5:07pm 
Also, at least since v1.5, there is no need to change <thingClass> in the ThingDef in Projectile, since the null check for weapons is done when generating the battle log in vanilla.
Previously, there were Defs and Classes for error avoidance, but these are now obsolete.
If you were using them, change them.
Hatena  [developer] 21 Apr, 2024 @ 5:07pm 
If <verbClass> is Verb_ShootBeam or Verb_ArcSprayIncinerator, the error occurs because there is no null check.
I have crated AnimalRangeAttack.Verb_ShootBeam and AnimalRangeAttack.Verb_ArcSprayIncinerator to deal with this, please use this one.


If you are creating an original Verb or Projectile class, remember to check that the weapon is not null.
In many cases, it tries to get a weapon in EquipmentSource.def, but a null error occurs because animals cannot normally have weapons.
Last edited by Hatena; 21 Apr, 2024 @ 5:08pm
Hatena  [developer] 21 Apr, 2024 @ 5:08pm 
Tips
Do you want your animal to have multiple long range attacks?
OK, that's easy to create too.


If you want the attack to vary with distance, simply write the following.

<verbs> <li> <!-- first verb --> </li> <li> <!-- second verb --> </li> </verbs>

In this case, describe the attack with the shorter <range> on top.
This is because when looking for attacks, priority is given from the top.
Hatena  [developer] 21 Apr, 2024 @ 5:09pm 
Starting with v1.5, a trivial option is the DefModExtension.
DefModExtension settings can also be easily implemented by simply adding a description to the xml.


Multiple attacks can be set up at the same distance.(like a melee attack)
In the past, a specific Verb was always selected at a certain distance because of the search for an effective Verb based on the maximum range.
But, by setting <allowRandomVerb> to true, it will be chosen randomly according to the <commonality> set in Verb.
(The default value for <commonality> is 1, the higher the number, the more likely it is to be selected.)

<verbs> <li> <!-- first verb --> <commonality>1<commonality> <range>19.9</range> </li> <li> <!-- second verb --> <commonality>0.5<commonality> <minRange>9.9</minRange> <range>36.9</range> </li> </verbs> <modExtensions> <li Class="AnimalRangeAttack.ARADefModExtension"> <allowRandomVerb>true</allowRandomVerb> </li> </modExtensions>

For example, if the Def is set like this, the specification is that between distances 9.9 and 19.9, the first verb and second verb are selected in the ratio of 1 : 0.5.


Since <allowRandomVerb> is false by default, Verb selection for unset animals remains conventional.
Hatena  [developer] 21 Apr, 2024 @ 5:10pm 
Animals actively try to use cover when attacking at long range.
This is tactically the correct course of action, but what would you think if a creature like an absolute powerhouse with a huge body was attacking you while hiding behind a cover?
Clever but lame, in my opinion.
So I created a <wantCover> setting.

<modExtensions> <li Class="AnimalRangeAttack.ARADefModExtension"> <allowRandomVerb>true</allowRandomVerb> <wantCover>false</wantCover> </li> </modExtensions>

By setting <wantCover> to false, the animal will not use the cover.
Also, since the default value of <wantCover> is true, you do not need to write DefModExtension if you do not want such a setting.
Hatena  [developer] 21 Apr, 2024 @ 5:11pm 
The DefModExtension up to this point was an option for ThingDef, but I also created one for PawnKindDef.

<modExtensions> <li Class="AnimalRangeAttack.ARADefModExtension"> <allowRangeAttackOfRace>false</allowRangeAttackOfRace> </li> </modExtensions>

By adding this description to the PawnKindDef, you can now create a Pawn that has a long range attack as a ThingDef but cannot use long range attacks in the PawnKindDef setting.
This means that as a races, they have a long-range attack, but they may or may not be able to use it depending on their PawnKindDef.

In a sense, it could be said to be a useless Pawn, but if you can create a DLL, PawnKindDef can be changed later, so you could create a spec like Awakening.


<allowRangeAttackOfRace> also has a default value of true, so you do not need to describe it if you do not need this feature.
Hatena  [developer] 21 Apr, 2024 @ 5:12pm 
That's all so far.
If you have any other feature requests, please comment.
I can't promise that I will implement that, but consider it.


At this time, I have no intention of implementing a feature like Pokemon battles, where you can direct a specific attack among multiple attacks.
< >
Showing 1-8 of 8 comments
Per page: 1530 50