[Help]XML <ResearchMod>

Started by mrofa, March 28, 2015, 04:01:20 AM

Previous topic - Next topic

mrofa

So from purly xml stand point is it possible to change <MaxHealth> with research mod?
Or do i need to do it in dll ?
All i do is clutter all around.

Latta

You need to use C# because there is no such ResearchModDef.

mrofa

All i do is clutter all around.

skullywag

ah now i see why you were asking, i put my omniturret code in the other thread, the source is in the mod though if you need it.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mrofa

I had done something like this
public static class ResearchMods
    {
        public static void WallReinforcment()
        {
            (
               from x in DefDatabase<ThingDef>.GetNamed("ClutterSIlverWall", true).statBases
               where x.stat == StatDefOf.MaxHealth
               select x).First<StatModifier>().value = 700f;
             
        }
           
    }


Problem i have with it is that it works all the time, so if i do this research and then load a game that dont have this research done, that loaded game will have that 700f, thrugh it only stay untill i restart the game itself.

All i do is clutter all around.

skullywag

yeah it runs on game load and whenever any research is completed, so put a variable to hold when its been run, check the code i put.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mrofa

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Verse.AI;
using Verse;
using Verse.Sound;
using RimWorld;

namespace ClutterModule
{
    public static class ResearchMods
    {
        public static bool WallResearch = false;

        public static void WallReinforcment()
        {
            if (!WallResearch)
                {
                    List<ThingDef> list = (
                            from t in DefDatabase<ThingDef>.AllDefsListForReading
                            where t.category == EntityCategory.Building && t.building != null && t.BaseMaxHealth < 700 && t.defName == "ClutterSIlverWall"
                            select t).ToList();
                    foreach (var c in list)
                    {
                        c.SetStatBaseValue(StatDefOf.MaxHealth, 700f);
                    }
                }
            WallResearch = true;
             
        }
           
    }
}


It still have the same problem.
All i do is clutter all around.

skullywag

Try:


sing System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Verse.AI;
using Verse;
using Verse.Sound;
using RimWorld;

namespace ClutterModule
{
    public static class ResearchMods
    {
        public static bool WallResearch = false;

        public static void WallReinforcment()
        {
            if (!WallResearch)
                {
                    List<ThingDef> list = (
                            from t in DefDatabase<ThingDef>.AllDefsListForReading
                            where t.category == EntityCategory.Building && t.building != null && t.BaseMaxHealth < 700 && t.defName == "ClutterSIlverWall"
                            select t).ToList();
                    foreach (var c in list)
                    {
                        c.statBases.MaxHealth = 700f);
                    }
                }
            WallResearch = true;
             
        }
           
    }
}


youre changing the statdef that everything relies on, the above just changes the def.
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mrofa

#8
Statbases is a list it dont contain the health stuff
Thats why its so tricky :p
ThingDefs dont contain health and Thing health is read only, so i need to use statbases
All i do is clutter all around.

skullywag

ah i see the problem now, youre right....tricky...ill have a bash....
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

skullywag

what about something like:


using System;
using System.Linq;
using System.Collections.Generic;
using RimWorld;
namespace Verse
{
public static class OmniResearchModsSpecial
{
        public static bool runonce;
        public static void OmniTurretCooling()
        {
            if (runonce == false)
            {
                List<ThingDef> list = (
                        from t in DefDatabase<ThingDef>.AllDefsListForReading
                        where t.category == EntityCategory.Item && t.building != null && t.building.turretBurstCooldownTicks > 0
                        select t).ToList();
                foreach (var c in list)
                {
                    c.building.turretBurstCooldownTicks -= 10;
                    foreach(var s in c.statBases)
                    {
                        if(s.stat == StatDefOf.MarketValue)
                        {
                            s.value = 200f;
                        }
                    }
                }
            }
            runonce = true;
        }
    }
}
Skullywag modded to death.
I'd never met an iterator I liked....until Zhentar saved me.
Why Unity5, WHY do you forsake me?

mrofa

It works like the rest of them:p
I will look more into the stat factor thingy since the statbase seems to persistant.
All i do is clutter all around.