Ludeon Forums

RimWorld => Mods => Mod bugs => Topic started by: Dingo on October 03, 2016, 07:38:47 AM

Title: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 03, 2016, 07:38:47 AM
Bug description: in Hot Coffee (https://steamcommunity.com/sharedfiles/filedetails/?id=764752651) (made by Toasty with collaboration from me) we implemented a rottable comp in our coffee XML.

Expected behaviour: it's expected that coffee, after production, remains fresh for 12 hours and then disappears according to this code:

<comps>
<li Class="CompProperties_Rottable">
<daysToRotStart>0.5</daysToRotStart>
<rotDestroys>true</rotDestroys>
</li>
</comps>


Current behaviour: Coffee will never rot. It is constantly in a state of "spoils in X hours/days".

This behaviour is independent of mod lists. It is the same if you have 50 mods or just Hot Coffee installed.

Current version of Hot Coffee (direct download) (https://drive.google.com/uc?export=download&id=0Bz2imWwZydMqUl8yLTEzbzY0ek0)
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 03, 2016, 08:14:57 AM
Does the rottable comp work for vanilla items for you without any mods? does it still work for vanilla with hot coffee installed?
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 03, 2016, 08:31:15 AM
Yes to both questions (I tested it myself, tested again just now + reported by a Steam user). I suspect this is because it's a drug, but I'm not sure.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 03, 2016, 08:32:21 AM
So what we are saying is if a mod item uses comp_rottable its not working?
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 03, 2016, 08:34:14 AM
I don't know of any other mods that do this with a drug XML so I can't say for sure. Right now I can definitely say if a mod drug (has CompProperties_Drug) has the rottable comp it doesn't work.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Haplo on October 04, 2016, 06:05:26 AM
Did you add the <Ticker>Rare</Ticker> to your XML? I'm rather sure that Comp_Rottable needs this ticker to work..
Compare it with another item from Core, as I can't look into it right now to give the exact name of it.. ( Not home yet :) )
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 04, 2016, 06:32:56 AM
It does have rare tick, I checked that.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 04, 2016, 10:07:38 AM
Quote from: Haplo on October 04, 2016, 06:05:26 AM
Did you add the <Ticker>Rare</Ticker> to your XML? I'm rather sure that Comp_Rottable needs this ticker to work..
Compare it with another item from Core, as I can't look into it right now to give the exact name of it.. ( Not home yet :) )

I did not have tickerType rare, thanks! Can you expand on what this does? I see it can be Never, Normal, Rare or Long.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 04, 2016, 11:05:39 AM
wat? yes you did it was in the abstract....wasnt it, i swear i saw it.....its the first thing i checked.

Also its how the "thing" ticks, normal is every tick, rare is 250 ticks, long is something longer than 250 that i cant remember but might be like 2000....:D
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 04, 2016, 11:07:11 AM
You're old, skully. Too old for this town. Also please do expand :(
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 04, 2016, 11:09:04 AM
See above.

Your def had a parentName abstract set, I thought the tickertype was set in that.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 04, 2016, 11:11:35 AM
Yes im right:

RawCoffeeBeans has a parent of PlantFoodRawBase which has a parent of OrganicProductBase which has <tickerType>Rare</tickerType> in it.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 04, 2016, 11:15:57 AM
Quote from: Dingo on October 03, 2016, 07:38:47 AMCurrent behaviour: Coffee will never rot. It is constantly in a state of "spoils in X hours/days".

Quote from: skullywag on October 04, 2016, 11:11:35 AM
Yes im right:

RawCoffeeBeans has a parent of PlantFoodRawBase which has a parent of OrganicProductBase which has <tickerType>Rare</tickerType> in it.

Who said anything about coffee BEANS? ;)
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Shinzy on October 04, 2016, 12:24:28 PM
Quote from: Dingo on October 04, 2016, 11:15:57 AM
Quote from: Dingo on October 03, 2016, 07:38:47 AMCurrent behaviour: Coffee will never rot. It is constantly in a state of "spoils in X hours/days".

Quote from: skullywag on October 04, 2016, 11:11:35 AM
Yes im right:

RawCoffeeBeans has a parent of PlantFoodRawBase which has a parent of OrganicProductBase which has <tickerType>Rare</tickerType> in it.

Who said anything about coffee BEANS? ;)

The purest snortable ground-coffee powder
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 04, 2016, 01:03:52 PM
ohhhh i see, i really misread that OP. ugh.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 04, 2016, 02:03:34 PM
So, just to clarify for any aspiring modders who might run into this thread in the year 3016:

The reason the rottable comp doesn't work outside of the tickerType=Rare scenario is probably due to this code (and correct me if I'm wrong here, guys) in CompRottable within the C# assembly -

public override void CompTickRare()
{
float rotProgress = this.RotProgress;
float num = 1f;
float temperatureForCell = GenTemperature.GetTemperatureForCell(this.parent.PositionHeld);
num *= GenTemperature.RotRateAtTemperature(temperatureForCell);
this.RotProgress += Mathf.Round(num * 250f);
if (this.Stage == RotStage.Rotting && this.PropsRot.rotDestroys)
{
if (Find.SlotGroupManager.SlotGroupAt(this.parent.Position) != null)
{
Messages.Message("MessageRottedAwayInStorage".Translate(new object[]
{
this.parent.Label
}).CapitalizeFirst(), MessageSound.Silent);
LessonAutoActivator.TeachOpportunity(ConceptDefOf.SpoilageAndFreezers, OpportunityType.GoodToKnow);
}
this.parent.Destroy(DestroyMode.Vanish);
return;
}
bool flag = Mathf.FloorToInt(rotProgress / 60000f) != Mathf.FloorToInt(this.RotProgress / 60000f);
if (flag)
{
if (this.Stage == RotStage.Rotting && this.PropsRot.rotDamagePerDay > 0f)
{
this.parent.TakeDamage(new DamageInfo(DamageDefOf.Rotting, GenMath.RoundRandom(this.PropsRot.rotDamagePerDay), null, null, null));
}
else if (this.Stage == RotStage.Dessicated && this.PropsRot.dessicatedDamagePerDay > 0f && this.ShouldTakeDessicateDamage())
{
this.parent.TakeDamage(new DamageInfo(DamageDefOf.Rotting, GenMath.RoundRandom(this.PropsRot.dessicatedDamagePerDay), null, null, null));
}
}
}


I have to assume this is done to save system resources, since the Rare ticker doesn't apply to every tick.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 04, 2016, 02:16:32 PM
Thats exactly what it is.
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Zhentar on October 04, 2016, 06:55:10 PM
tickerType validation warnings would be a good suggestion for the 'make modding easier thread'
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: skullywag on October 05, 2016, 03:11:57 AM
"Thing has a comp that requires ticking, ticking is set to none" type deal?
Title: Re: [A15] CompProperties_Rottable Not Working
Post by: Dingo on October 05, 2016, 03:13:53 AM
"Cannot initialize CompRottable in Food.xml - tickerType undefined, expected Rare" type deal, maybe? Of course could be another comp.