This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Pages1
#1
Help / Re: Null pointer exception - need an extra set of eyes
January 04, 2018, 12:10:43 AM #2
Help / Null pointer exception - need an extra set of eyes
January 03, 2018, 06:29:31 PM
Hello all, I lead a small team and we are working on a new mod - Pharma, a pharmaceutical mod. One of our buildings, a Sprayer, is having a null pointer exception and we could use some extra eyes to see what we are doing wrong. We get a null pointer exception when the building is completed, but not when placed just as a blueprint.
Code Select
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Verse;
using Verse.AI;
using RimWorld;
namespace Pharma
{
[StaticConstructorOnStartup]
public abstract class Building_IngestibleSprayer : Building
{
// ==================================
/// <summary>
/// Do something after the object is spawned into the world
/// </summary>
public override void SpawnSetup(Map map, bool respawningAfterLoad)
{
base.SpawnSetup(map, respawningAfterLoad);
powerComp = base.GetComp<CompPowerTrader>();
powerComp.PowerOn = true;
}
/// <summary>
/// To save and load actual values (savegame-data)
/// </summary>
public override void ExposeData()
{
base.ExposeData();
}
#region Destroy
// ==================================
/// <summary>
/// Clean up when this is destroyed
/// </summary>
public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
{
base.Destroy(mode);
}
#endregion
/// <summary>
/// This string will be shown when the object is selected (focus)
/// </summary>
/// <returns></returns>
public override string GetInspectString()
{
StringBuilder stringBuilder = new StringBuilder();
string baseString = base.GetInspectString();
if (!baseString.NullOrEmpty())
{
stringBuilder.Append(base.GetInspectString());
stringBuilder.AppendLine();
}
// return the complete string
return stringBuilder.ToString().TrimEndNewlines();
}
public abstract bool IsAcceptableAmmoToSpray(ThingDef thing);
public virtual bool TrySpray(Pawn p)
{
bool administer;
administer = false;
if (!Pharma_Utility.PawnHasIngestibleEffect(p, FindAmmoInAnyHopper()))
{
administer = true;
}
if (administer)
{
Spray(p);
return true;
}
return false;
}
public override void Tick()
{
/*
base.Tick();
Map map = base.Map;
//Pawn[] pawns = Pharma_Utility.GetPawnsInRange(range);
if (this.CanDispenseNow)
{
foreach (Pawn p in map.mapPawns.AllPawnsSpawned)
{
if (!TrySpray(p))
{
Log.Message("Could not spray pawn with thing.");
}
}
}
*/
}
public CompPowerTrader powerComp;
private List<IntVec3> cachedAdjCellsCardinal;
public static int CollectDuration = 50;
public bool CanDispenseNow
{
get
{
return this.powerComp.PowerOn && this.HasEnoughAmmoInHoppers();
}
}
private List<IntVec3> AdjCellsCardinalInBounds
{
get
{
if (this.cachedAdjCellsCardinal == null)
{
this.cachedAdjCellsCardinal = (from c in GenAdj.CellsAdjacentCardinal(this)
where c.InBounds(base.Map)
select c).ToList();
}
return this.cachedAdjCellsCardinal;
}
}
public virtual ThingDef DispensableDef
{
get
{
ThingDef spraydef = FindAmmoInAnyHopper().def;
if (IsAcceptableAmmoToSpray(spraydef))
{
return spraydef;
}
return null;
}
}
public virtual bool HasEnoughAmmoInHoppers()
{
float num = 0f;
for (int i = 0; i < this.AdjCellsCardinalInBounds.Count; i++)
{
IntVec3 c = this.AdjCellsCardinalInBounds[i];
Thing thing = null;
Thing thing2 = null;
List<Thing> thingList = c.GetThingList(base.Map);
for (int j = 0; j < thingList.Count; j++)
{
Thing thing3 = thingList[j];
if (IsAcceptableAmmoToSpray(thing3.def))
{
thing = thing3;
}
if (thing3.def == ThingDefOf.Hopper)
{
thing2 = thing3;
}
}
if (thing != null && thing2 != null)
{
num += (float)thing.stackCount * thing.def.ingestible.nutrition;
}
if (num >= base.def.building.nutritionCostPerDispense)
{
return true;
}
}
return false;
}
public virtual Building AdjacentReachableHopper(Pawn reacher)
{
for (int i = 0; i < this.AdjCellsCardinalInBounds.Count; i++)
{
IntVec3 c = this.AdjCellsCardinalInBounds[i];
Building edifice = c.GetEdifice(base.Map);
if (edifice != null && edifice.def == ThingDefOf.Hopper && reacher.CanReach(edifice, PathEndMode.Touch, Danger.Deadly, false, TraverseMode.ByPawn))
{
return (Building_Storage)edifice;
}
}
return null;
}
public void Spray(Pawn pawn)
{
//this.TryGetComp<CompProperties_DrugSprayer>().range;
//Props.ingestible.Ingested(pawn, 0f);
FindAmmoInAnyHopper().Ingested(pawn, 0f);
}
public virtual Thing FindAmmoInAnyHopper()
{
for (int i = 0; i < this.AdjCellsCardinalInBounds.Count; i++)
{
Thing thing = null;
Thing thing2 = null;
List<Thing> thingList = this.AdjCellsCardinalInBounds[i].GetThingList(base.Map);
for (int j = 0; j < thingList.Count; j++)
{
Thing thing3 = thingList[j];
if (IsAcceptableAmmoToSpray(thing3.def))
{
thing = thing3;
}
if (thing3.def == ThingDefOf.Hopper)
{
thing2 = thing3;
}
}
if (thing != null && thing2 != null)
{
return thing;
}
}
return null;
}
}
}
Code Select
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Verse.AI;
using Verse;
using RimWorld;
namespace Pharma
{
/*
public static class Pharma_ThingDefOf
{
public static ThingDef DrugSprayer;
}*/
/// <summary>
/// Drug sprayer building
/// </summary>
/// <seealso cref="Verse.Building" />
[StaticConstructorOnStartup]
public class Building_DrugSprayer : Building_IngestibleSprayer
{
public Building_DrugSprayer()
{
this.TryGetComp<CompDrugSprayer>().SetRange(10f);
}
public override bool IsAcceptableAmmoToSpray(ThingDef thing)
{
if(thing.IsDrug)
{
return true;
}
return false;
}
}
public class CompDrugSprayer : ThingComp
{
public void SetRange(float newrange)
{
Props.range = newrange;
}
private CompProperties_DrugSprayer Props
{
get
{
return (CompProperties_DrugSprayer)base.props;
}
}
}
public class CompProperties_DrugSprayer : CompProperties_IngestibleSprayer
{
public CompProperties_DrugSprayer()
{
compClass = typeof(CompDrugSprayer);
}
}
public class CompProperties_IngestibleSprayer : CompProperties
{
public float range;
}
}
Code Select
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using Verse;
using RimWorld;
namespace Pharma
{
public class Pharma_Utility
{
/// <summary>
/// Check if pawn has the effect of ingestible active.
/// TODO Fix this code, possible if ingestible gives more than one effect then it wont return false even if main drug effect not active, only additional effects.
/// </summary>
/// <param name="pawn">The pawn.</param>
/// <param name="ingestible">The ingestible.</param>
/// <returns></returns>
public static bool PawnHasIngestibleEffect(Pawn pawn, Thing ingestible)
{
// check the hediffs for drug effect
foreach (var ingestoutcome in (ingestible.def.ingestible.outcomeDoers))
{
if (pawn.health.hediffSet.HasHediff(ingestoutcome.ChangeType<IngestionOutcomeDoer_GiveHediff>().hediffDef))
{
return true;
}
}
return false;
}
/*
public static void AdministerDrugEffect(Pawn pawn, Thing drug)
{
foreach (var outcomedoer in drug.def.ingestible.outcomeDoers)
{
outcomedoer.DoIngestionOutcome(pawn, drug);
}
}*/
}
}
#3
Help / Re: Launch pods inro missiles?
January 03, 2018, 03:24:35 PMQuote from: dburgdorf on January 03, 2018, 09:50:17 AMQuote from: AllyJamy on January 02, 2018, 04:37:27 PMI can open the source code with dnSpy. But I don't know what to change.
I think this is your problem. I certainly mean no offense, but you seem to have bitten off more than you can chew. The mod you're trying to create will require C# coding, and if that's not something with which you're familiar, there's a fair amount you're going to have to teach yourself before you can actually create it.
This. Its not something you can do in a day, or even likely a week, given where you are starting from.
#5
Help / Re: Issue with nobody dying in combat
December 22, 2017, 01:12:17 PM
what mods are you running? Hard to debug with no information.
#6
Mods / Re: [HELP WANTED] 2 man team looking to bring on second artist and programmer
December 20, 2017, 05:12:37 PM
A drug expansion mod. Pharma - short for pharmaceutical - focuses on drug related game play. Other than the obvious inclusion of a bunch of new drugs, there will also be buildings, events, ect. that build on the drug-based theme.
#7
Mods / [HELP WANTED] 2 man team looking to bring on second artist and programmer
December 19, 2017, 09:20:27 PM
Hello! I am Daxx, the progammer and team lead for a new mod - Pharma
We are currently 1 artist and 1 programmer. We are looking to bring on a second programmer (C# know-how required) and a second artist to help speed up mod production. If interested, please shoot me a message on steam - http://steamcommunity.com/id/BDG_Daxx
You can view our progress here: https://trello.com/b/Vu3T3pQh/rimworld-pharma
If you have any questions, suggestions, feedback, comments, ect. don't hesitate to contact me on steam or here on the forums. Thanks!
We are currently 1 artist and 1 programmer. We are looking to bring on a second programmer (C# know-how required) and a second artist to help speed up mod production. If interested, please shoot me a message on steam - http://steamcommunity.com/id/BDG_Daxx
You can view our progress here: https://trello.com/b/Vu3T3pQh/rimworld-pharma
If you have any questions, suggestions, feedback, comments, ect. don't hesitate to contact me on steam or here on the forums. Thanks!

#8
Help / Re: Is fermentation barrel hardcoded to take wort?
December 19, 2017, 08:12:05 PM
of course there is
Thank you!

#9
Help / Is fermentation barrel hardcoded to take wort?
December 18, 2017, 01:25:46 PM
Hello, I'm trying to add distillation in my mod. The process would be *identical* to how beer is made, just re textured and with a different item (eg. not wort). I've looked through the code a bit, and it looks like the Building_FermentationBarrel function
On top of that, I noticed that there is a specific task for filling the fermentation barrel. I have not looked into that, but I can only imagine there could be a problem of pawns bringing the wrong object as defined in the task to my new building.
TLDR: How do I change the input/output item for fermentation barrel? XML is prefered but I could make a DLL and just mirror the appropriate classes if it turns out that's not possible, and would love some pointers if I need to go in that direction.
Code Select
AddWort(Thing wort)
function takes a Thing object, which goes to reason that any Thing object defined in an xml could be that object, despite the variables being named wort. But I can't find any leads in either the Building_Production.xml Fermentation Barrel Thingdef that would specify what kind of thing it takes.On top of that, I noticed that there is a specific task for filling the fermentation barrel. I have not looked into that, but I can only imagine there could be a problem of pawns bringing the wrong object as defined in the task to my new building.
TLDR: How do I change the input/output item for fermentation barrel? XML is prefered but I could make a DLL and just mirror the appropriate classes if it turns out that's not possible, and would love some pointers if I need to go in that direction.
#10
Bugs / Smokeleaf Addiction causes cancer, instead of the smoking of a joint.
December 15, 2017, 10:02:22 PM
I am trying to create a mod that adds smokeleaf brownies (among other things). The brownie uses the vanilla smokeleaf addiction / tolerance defs as its own (since they are both smokeleaf, similar to how Psychite is done for different drugs having the same base drug addiction). However, the Smokeleaf *Addiction & Chemical* causes Asthma and Carcinoma, not the joint item itself.
In the current implementation, my smokeleaf brownies will be forced to cause cancer and asthma, which doesn't make much sense. The Asthma and Carcinoma should be moved into the SmokeleafHigh HediffDef.
In the current implementation, my smokeleaf brownies will be forced to cause cancer and asthma, which doesn't make much sense. The Asthma and Carcinoma should be moved into the SmokeleafHigh HediffDef.
#11
Help / Were to find .dll files for rimworld?
December 13, 2017, 12:52:57 PM
I'm trying to make a mod that adds a new plant that spreads on its own rapidly and deals damage when walked on. I read here that iLspy can be used to look into the .dll files, but I can't seem to find them (windows). Anybody know where they are held or if there is any good documentation on their functions?
Pages1