Giter VIP home page Giter VIP logo

iflybayonet's Introduction

iflyBayonet

Adds a belt-equippable bayonet which attaches to bayonet-compatible weapons automatically without needing to create a whole new gun. Those bayonets can then be used in melee combat (if also equipping a compatible bayonet-luggable ranged weapon). Bayonets cannot be used alone; an invisible force holds them to the belt.

This mod also patches the average melee damage calculation and battle log to report use of the bayonet. It also creates an alert if a pawn equips a bayonet belt without also having a compatible weapon. If your pawns are equipping the belt willy-nilly and you don't like this, change your Apparel rules in Assign.

Bayonets are created at the smithing table and have most of their statistics taken from a combination of knives and spears. The cost is a bit more expensive than a knife (the model of the bayonet is that of a 1907 SMLE bayonet with quillion) and the damage is a bit less than a spear, being a bit more clunky.

Installation

Subscribe on Steam Workshop.

Technical information

For the technically minded, the mod specifically changes the bayonet-compatible weapon's "poke" melee attacks. It leaves other weapon types, like bashing with a stock, in, replacing any time a bayonet-compatible weapon pokes with a bayonet stab. This is done by patches in Harmony.

As a broad overview, the patches are grouped into a number of main sections:

  • Utilities

    • Determines whether the weapon is a bayonet compatible weapon (see Utilities and Utilities.IsNotCrapWeapon)
    • Determines whether a pawn can use the bayonet (Utilities.GetBayonetBeltIfValidWielder)
  • `Patch_MeleeCalc

    • Patches the melee damage calculations at VerbProperties.AdjustedMeleeDamageAmount if pawn is a valid wielder by changing the input parameters so that a pawn is attacking as if he is using the bayonet
    • Patches the melee armour penetration calculations so that stabs are taken as stabs rather than as bashes for that purpose.
    • Checks that replacement was successful in Pawn_MeleeVerbs.TryMeleeAttack
  • Patch_MeleeExplanation

    • Does string matching to generate and then replace the explanation such that it reflects use of the bayonet.
    • Patches here are difficult due to RimWorld code not calculating melee damage on Thing but, rather, on ThingDef. A truly effective patch would have to go in the middle of a method to execute properly.
    • This gets around that problem by patching the numbers and then updating the labels separately.
  • Patch_BayonetWield

    • When a weapon is equipped and it is a valid bayonet combination, the VerbProperties defining how to attack, the tool with which the attack is made, and the maneuver in which the attack is made (taken together, the BayonetPatch) are all replaced with the corresponding values for a bayonet. See Pawn_EquipmentTracker.AddEquipment. This is also triggered if a wielded weapon is complemented with a bayonet. See Pawn_ApparelTracker.Wear.
    • When a save game is loaded, there is no equip call; so patching is also done at Map.FinalizeInit to ensure that all pawns' weapons have their bayonets fixed.
    • When the weapon is dropped or bayonet belt unequipped, a call is made to revert the patches made so the weapon goes back to its original non-bayonet state.

An alert (at Alert_BayonetUnuseable), based on the code for the alert with shield belt wearers and ranged weapons, is also added so that players know if pawns are equipping items not compatible with the bayonet belt.

iflybayonet's People

Contributors

ifly6 avatar kevinw26 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.