[Code Library] Replace Repair 2.1.1

Discuss and distribute tools and methods for modding.
Lemonymous
Posts: 55
Joined: Fri Mar 09, 2018 3:29 am

[Code Library] Replace Repair 2.1.1

Postby Lemonymous » Mon Aug 20, 2018 4:55 am

Replace Repair
This is not a mod itself, but a code library you can add to your mod, which will give you access to a few functions, allowing you to change the repair skill of pilots or mechs, or another condition of your choosing.

Replace Repair 2.1.1
    2.0 was a rewrite of the old library. It was prone to giving errors when used incorrectly, and was a bit hard to use due to it's functions with many parameters. It should hopefully be easier to get started with it now.
    There is now also better support for abilities that can change the repair skill dynamically for any given condition.

    Example Mod 2.1.1 - a working mod providing examples on how to use library.

Installation
    Place the extracted folder into your mod so it looks like this: ("NameOfMyMod" should be the actual name of your mod)
    /ITB/mods/NameOfMyMod/scripts/replaceRepair/

Updating mods to 2.x
    It should be as simple as replacing your old replaceRepair folder in your mod with the updated one. The console may tell you to update modApiExt.
    Most old function calls are preserved for backwards compatibility.

Full function list with documentation on how to use them can be found in /replaceRepair/api.lua

most likely to be used functions:

    Code: Select all

       repairApi:SetPilotRepairSkill(input)
       ====================================
       sets the repair skill for a pilot.
       input is a table with the following required fields:
       
       field       | type   | description
       ------------+--------+--------------------------------------
       Name        | string | displayed skill name for pilot
       Description | string | displayed skil description for pilot
       PilotSkill  | string | id of pilot skill
       Weapon      | string | id of weapon replacing repair skill
       Icon        | table  | path to icon (in game or mod)
       ------------+--------+--------------------------------------

       repairApi:load()
       ================
       loads the library.

Limitations:
  1. Since this library actually modifies the repair skill every time you use it, the tipimage will always finish the last skill that was initiated within the tipimage before showing a new one.
    There are no known ways to get around this delay.
  2. The origin of the tipimage will always be at Point(2,2) since that is the origin of the default repair skill.
    This can cause various effects to behave strangly, or not show up at all. Projectiles for example will always originate from this point even if the unit in the tipimage is not there.
    One way around this limitation is to give the weapon a CustomTipImage.
    This way you have total control over what is being shown. The origin will be the same though, so you have to employ tricks to create projectiles/etc going from an arbitrary origin to it's destination.
    If you want to learn more, you are welcome to join the ITB discord and discuss it in #modding-creation.
  3. There may be more limitations, so if you discover any, please let me know.


Current working mods using the library which you can check out to learn more:

Thanks to
- Mezzelo for testing and initial documentation.
- kartoFlane for modApiExt.
- Tosx for adding support for frozen, smoke and water icons, and general help in testing.


Changelog (using pre 2.0 versions is not recommended)

2.1.1 - Fixed all known bugs after rewrite.
2.1.0 - Added lava/acid icon overlays for custom repair icons.
2.0.0 - Complete rewrite. It is for the most part compatible with versions pre 2.0, however, it is recommended to update Replace Repair for all mods.
1.3.2 - Tosx added support for smoke and water overlay over custom icons.
1.3.1 - Tosx added support for frozen version of custom icons. What should happen while frozen is up to the user to decide.
1.3.0 - fixed a Test Mech error.
1.2.2 - First release on this forum.
Last edited by Lemonymous on Sun Apr 21, 2019 7:16 am, edited 6 times in total.
tosx
Posts: 42
Joined: Wed Mar 13, 2019 3:11 am

Re: [Code Library] Replace Repair

Postby tosx » Thu Apr 11, 2019 2:08 am

Okay, so with a lot of help from Lemonymous, I added some ungainly code to allow you to also replace the "frozen repair" icon.
- Previously, once your mech was frozen, the icon reverted to default.
- Now, you can include a second weapon image with "_frozen.png" on the end, and the utility will draw that icon when you're frozen. If you don't include a frozen image, the default is used.
- For instance if you have "customrepair.png", you can also have "customrepair_frozen.png".
- If you want to make your repair ability DO something different while frozen, that's still on you to add checks in your GetTargetArea and SkillEffect. For reference, see Kaz's Skill_Repair_Punch in weapons_base.lua.

Follow-on stuff (known inconsistencies):
- All weapon icons darken slightly after the unit has acted. Custom repair icon still does not.
- Everything on screen darkens even more when the options menu is opened. Custom repair icon still does not.
- Smoke and water prevent you from repairing. They also appear to darken and overlay symbols over your repair icon (which means there isn't a separate repair_smoke.png that can just be replaced, like with ice). I've included overlay images (in \img folder), but I'm not yet close to smart enough to know how to draw them in on top. If anyone else wants to take a stab, feel free to use the included images.

I put the files here for now:
replaceRepair (1.3.1) - Support for frozen repair icons
tosx
Posts: 42
Joined: Wed Mar 13, 2019 3:11 am

Re: [Code Library] Replace Repair

Postby tosx » Sat Apr 13, 2019 6:23 pm

Thanks to a ton MORE help from Lemonymous, smoke and water overlays now seem to be working! I've updated the link with version 1.3.2.

Follow-on stuff (known inconsistencies):
- All weapon icons darken slightly after the unit has acted. Custom repair icon still does not.
- Everything on screen darkens even more when the options menu is opened. Custom repair icon still does not.
- It was noticed that the frozen repair icon normally flashes yellow; the custom one will not.

replaceRepair (1.3.2) - Support for water and smoke overlays with custom repair icons
Lemonymous
Posts: 55
Joined: Fri Mar 09, 2018 3:29 am

Re: [Code Library] Replace Repair 2.1.1

Postby Lemonymous » Sun Apr 21, 2019 3:36 am

Library has been updated. It is recommended to update mods using Replace Repair pre 2.0 for best compatibility between all mods.

Who is online

Users browsing this forum: No registered users and 1 guest