Ludeon Forums

RimWorld => Mods => Topic started by: picollo on July 09, 2015, 10:30:26 AM

Title: Upgradeable stuff?
Post by: picollo on July 09, 2015, 10:30:26 AM
I was wondering if It is possibile to make upgradeable items, which would get better via researching technologies.

Let's take batteries for example.

Basic battery: Stores up to X power (dont remember exact numbers).

Research: Better batteries I: Batteries store 5% more power. with same cost.

What I've been thinking is to create late game techs, which you could research multiple times to slightly improve capacity of your buildings.
Research Better Batteries X 10 times, and each battery will have 50% bigger storage capacity.

Something similar is done with turrets, when you increase number of bullets turret shots in one burst.

I know I could create additional battery for each technology, but having 10 batteries, 10 solar panels, etc. could be a little bit irritating.
Title: Re: Upgradeable stuff?
Post by: Lonely Rogue on July 10, 2015, 02:47:14 AM
Turrets do it, with gun turret cooling. Take a look at the coding for that.
Title: Re: Upgradeable stuff?
Post by: skullywag on July 10, 2015, 04:03:30 AM
its called a researchmod, the gun turret cooling one looks like:


using System;
using System.Linq;
namespace Verse
{
public static class ResearchModsSpecial
{
  public static void GunTurretCooling()
  {
  (
  from x in DefDatabase<ThingDef>.GetNamed("Gun_TurretImprovised", true).Verbs
  where x.isPrimary
  select x).First<VerbProperties>().burstShotCount = 4;
  }
  }
}



<ResearchProjectDef>
<defName>GunTurretCooling</defName>
<label>gun turret cooling</label>
<description>Gun turrets fire four shots in a burst instead of three.</description>
<totalCost>1000</totalCost>
    <researchMods>
      <li>
        <specialAction>ResearchModsSpecial.GunTurretCooling</specialAction>
      </li>
    </researchMods>
</ResearchProjectDef>


The code (and the classname) can be whatever you want, for any c# people, dont use researcmodspecial use a different classname and reference it in the xml to avoid conflicts.
Title: Re: Upgradeable stuff?
Post by: picollo on July 10, 2015, 05:06:31 AM
DDawgSierra- I know turret coolikg does similar stuff. However I was in work, and just got an idea of it, and couldn't look at the code. Despite that my coding skill is quite low. SO any hint like  skullywag gave me will increase my work like 10 times.


Skullywag, Thanks for clarification.
I'll look at this code, and try to do some basic work.

If I wanted to decrease amount of coding, can I set (in this case) number of shots as variable, and use one function for multiple technologies?

Something like:
using System;
using System.Linq;
namespace Verse

{
public static class ResearchModsSpecial
{
  public static void GunTurretCooling( int ShotNumber)
  {
                           
  (
  from x in DefDatabase<ThingDef>.GetNamed("Gun_TurretImprovised", true).Verbs
  where x.isPrimary
  select x).First<VerbProperties>().burstShotCount = ShotNumber;
  }
  }
}



<ResearchProjectDef>
<defName>GunTurretCooling</defName>
<label>gun turret cooling</label>
<description>Gun turrets fire four shots in a burst instead of three.</description>
<totalCost>1000</totalCost>
    <researchMods>
      <li>
        <specialAction>ResearchModsSpecial.GunTurretCooling(4)</specialAction>
      </li>
    </researchMods>
</ResearchProjectDef>
<ResearchProjectDef>
<defName>GunTurretCooling</defName>
<label>gun turret cooling</label>
<description>Gun turrets fire five shots in a burst instead of four.</description>
<totalCost>1000</totalCost>
    <researchMods>
      <li>
        <specialAction>ResearchModsSpecial.GunTurretCooling(5)</specialAction>
      </li>
    </researchMods>
</ResearchProjectDef>


I know that it probably is buggy as hell, bbut you should get idea of my concept. This solution should reduce code amount, and in addition make this mod more customisable.
Title: Re: Upgradeable stuff?
Post by: skullywag on July 10, 2015, 05:21:15 AM
Hmm not sure, best thing is to just try it.
Title: Re: Upgradeable stuff?
Post by: picollo on July 10, 2015, 05:24:21 AM
Definetely will do!

Thanks anyway.
Title: Re: Upgradeable stuff?
Post by: Lonely Rogue on July 10, 2015, 09:09:54 AM
I was just trying to be helpful. I'm not the best modder in the world, I was trying to point out something you would find helpful. *feels miffed*
Title: Re: Upgradeable stuff?
Post by: DaemonDeathAngel on July 10, 2015, 01:32:01 PM
Look at Superior Crafting. It upgrades battery efficiency with each research tier within Power.
Title: Re: Upgradeable stuff?
Post by: picollo on July 10, 2015, 03:21:43 PM
Ahh, so it was already done :)
Superior Crafting overwhelemd me with too heavy changes, so I haven't ever looked for details of this mod. Thanks for the hint!
Title: Re: Upgradeable stuff?
Post by: DaemonDeathAngel on July 10, 2015, 04:13:54 PM
No problem. I have been talking to the mod maker of Superior Crafting lately, and you think it's overwhelming now, it's going to be insane when he's done.
Title: Re: Upgradeable stuff?
Post by: picollo on July 10, 2015, 06:58:58 PM
Just when I checked this mod it's complete overhaul of whole game. With (as for me) too much of crafting things which are used to craft other things which will  be used to craft components to some usefull stuff. Chain of production like in Settlers or Knights and Merchants. And I appreciate simplicity of crafting in vanilla Rimworld.