Sims MX
19th Aug 2011, 04:32 AM
Hello!
I'm making a Hypochondriac trait for my game and I would like to create a list of possible diseases for my Sim. I made an XML for this, it looks something like this: <Disease>
<Name>SkinCancer</Name>
<Desc>SkinCancerDesc</Desc>
<Chance>0.2</Chance>
<WeighingTraits>HatesOutdoors</WeighingTraits>
<LighteningTraits>LovesTheOutdoors</LighteningTraits>
</Disease>Basically it means that Hypochondriac Sims have 20% of believing they suffer from Skin Cancer. This chance is increased to 30% if they Hate the Outdoors, or it is decreased to 10% if they Love the Outdoors.
When Sims go out and the "kChangedInsideOutsideStatus" event is triggered, I call an event delegate function. This is supposed to add the "Feeling Sick" moodlet. public static ListenerAction ChangedInsideOutsideStatus(Event e)
{
Sim sim = e.Actor as Sim;
if (sim != null && sim.HasTrait((TraitNames)(Hypochondriac)) && sim.IsOutside && !OccultVampire.IsNightTime())
{
if (RandomUtil.RandomChance01(TraitFunctions.GetChance(ActorSystems.TraitFunctions.HypochondriacTraitDisease.SkinCancer, sim))
{
sim.BuffManager.AddElement((ulong)(FeelingSick), Origin.FromTheSun);
}
}
return ListenerAction.Keep;
}As you can see it is a simple event listener. However, you may notice that I have a "GetChance" method. This, as it name implies, is supposed to get the chance for my disease.
I made a method to parse the data from my XML and then I made this "GetChance" method. It looks like this: public static float GetChance(TraitFunctions.HypochondriacTraitDisease disease, Sim sim)
{
float chance = 0f;
for (int i = 0; i < sDiseases.Count; i++)
{
DiseaseData data = sDiseases[i];
if (data.Disease == disease)
{
chance = data.Chance;
foreach(TraitNames trait in data.WeighingTraits)
{
if (sim.HasTrait(trait))
{
chance += 0.1f;
}
}
foreach(TraitNames trait in data.LighteningTraits)
{
if (sim.HasTrait(trait))
{
chance -= 0.1f;
}
}
}
}
return chance;
}The problem is that my Sims don't get any moodlets at all.
Help would be appreciated, thanks!
I'm making a Hypochondriac trait for my game and I would like to create a list of possible diseases for my Sim. I made an XML for this, it looks something like this: <Disease>
<Name>SkinCancer</Name>
<Desc>SkinCancerDesc</Desc>
<Chance>0.2</Chance>
<WeighingTraits>HatesOutdoors</WeighingTraits>
<LighteningTraits>LovesTheOutdoors</LighteningTraits>
</Disease>Basically it means that Hypochondriac Sims have 20% of believing they suffer from Skin Cancer. This chance is increased to 30% if they Hate the Outdoors, or it is decreased to 10% if they Love the Outdoors.
When Sims go out and the "kChangedInsideOutsideStatus" event is triggered, I call an event delegate function. This is supposed to add the "Feeling Sick" moodlet. public static ListenerAction ChangedInsideOutsideStatus(Event e)
{
Sim sim = e.Actor as Sim;
if (sim != null && sim.HasTrait((TraitNames)(Hypochondriac)) && sim.IsOutside && !OccultVampire.IsNightTime())
{
if (RandomUtil.RandomChance01(TraitFunctions.GetChance(ActorSystems.TraitFunctions.HypochondriacTraitDisease.SkinCancer, sim))
{
sim.BuffManager.AddElement((ulong)(FeelingSick), Origin.FromTheSun);
}
}
return ListenerAction.Keep;
}As you can see it is a simple event listener. However, you may notice that I have a "GetChance" method. This, as it name implies, is supposed to get the chance for my disease.
I made a method to parse the data from my XML and then I made this "GetChance" method. It looks like this: public static float GetChance(TraitFunctions.HypochondriacTraitDisease disease, Sim sim)
{
float chance = 0f;
for (int i = 0; i < sDiseases.Count; i++)
{
DiseaseData data = sDiseases[i];
if (data.Disease == disease)
{
chance = data.Chance;
foreach(TraitNames trait in data.WeighingTraits)
{
if (sim.HasTrait(trait))
{
chance += 0.1f;
}
}
foreach(TraitNames trait in data.LighteningTraits)
{
if (sim.HasTrait(trait))
{
chance -= 0.1f;
}
}
}
}
return chance;
}The problem is that my Sims don't get any moodlets at all.
Help would be appreciated, thanks!