Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Test Subject
Original Poster
#1 Old 19th May 2018 at 2:46 PM Last edited by clang2 : 20th May 2018 at 4:32 AM.
Default (Resolved) Needing help factoring -1 on skills
When a sim doesn't have a skill, the skill comes back as -1

Using this:
this.mActorsAthleticSkill = this.Actor.SkillManager.GetSkill<Athletic>(SkillNames.Athletic);
this.mTargetsAthleticSkill = this.Target.SkillManager.GetSkill<Athletic>(SkillNames.Athletic);
this.mActorsMartialArtsSkill = this.Actor.SkillManager.GetSkill<MartialArts>(SkillNames.MartialArts);
this.mTargetsMartialArtsSkill = this.Target.SkillManager.GetSkill<MartialArts>(SkillNames.MartialArts);
int num = Math.Abs(this.mActorsAthleticSkill.SkillLevel + this.mActorsMartialArtsSkill.SkillLevel);
int num2 = Math.Abs(this.mTargetsAthleticSkill.SkillLevel + this.mTargetsMartialArtsSkill.SkillLevel);
Then:
if (num > num2)

Doesn't work if either sim has a -1 (doesn't have the skill at all) in that particular skill.
Anybody know how to get around that?
Advertisement
Space Pony
#2 Old 19th May 2018 at 3:49 PM
Hi clang2,

if you want to count -1 and 0 both as 0 then this would be an easy way.

int num = Math.Max(0,this.mActorsAthleticSkill.SkillLevel) + Math.Max(0,this.mActorsMartialArtsSkill.SkillLevel);
int num2 = Math.Max(0,this.mTargetsAthleticSkill.SkillLevel) + Math.Max(0,this.mTargetsMartialArtsSkill.SkillLevel);
Test Subject
Original Poster
#3 Old 20th May 2018 at 12:56 AM
Quote: Originally posted by Battery
Hi clang2,

if you want to count -1 and 0 both as 0 then this would be an easy way.

int num = Math.Max(0,this.mActorsAthleticSkill.SkillLevel) + Math.Max(0,this.mActorsMartialArtsSkill.SkillLevel);
int num2 = Math.Max(0,this.mTargetsAthleticSkill.SkillLevel) + Math.Max(0,this.mTargetsMartialArtsSkill.SkillLevel);


I can see why this should have worked because it sets the -1 to 0... but it didn't work, so a sim that doesn't have the skill is still not able to complete the interaction (completely stops the interaction) even though they can initiate it.
What the interaction does is takes both skills from both sims and figures out who has the greater total skill then determines a winner based on that. I'd like that to include those without the actual skills too because I am also going to, later on, factor in hunger, energy, and possibly meditation state as well... maybe a few other things, so they all play a factor in the winner.
So, a sim may have a martialarts skill of 1 and an athletic skill of 1 compared to another sim who may not have martial arts skill or athletics skill, but the first sim could still lose if they have no energy or are too hungry.
I've looked in the martial arts skill itself, but I am still not sure how to implement the 'no skill' thing just yet.
Test Subject
Original Poster
#4 Old 20th May 2018 at 1:12 AM
I think I see a work around with something like skill == null.
Will mash it together and see how it goes
Test Subject
Original Poster
#5 Old 20th May 2018 at 4:15 AM
This works:
thanks for your help, Battery! I wouldn't have had a good path to understanding without it. Much appreciated.
Target.Autonomy.DecrementAutonomyDisabled();
if (mActorsAthleticSkill == null)
{
Athletic athletic = this.Actor.SkillManager.AddElement(SkillNames.Athletic) as Athletic;
athletic = mActorsAthleticSkill;
}
if (mTargetsAthleticSkill == null)
{
Athletic athletic2 = this.Target.SkillManager.AddElement(SkillNames.Athletic) as Athletic;
athletic2 = mTargetsAthleticSkill;
}
if (mActorsMartialArtsSkill == null)
{
MartialArts martialArts = this.Actor.SkillManager.AddElement(SkillNames.MartialArts) as MartialArts;
martialArts = mActorsMartialArtsSkill;

}
if (mTargetsMartialArtsSkill== null)
{
MartialArts martialArts2 = this.Target.SkillManager.AddElement(SkillNames.MartialArts) as MartialArts;
martialArts2 = mTargetsMartialArtsSkill;
}
this.mActorsAthleticSkill = this.Actor.SkillManager.GetSkill<Athletic>(SkillNames.Athletic);
this.mTargetsAthleticSkill = this.Target.SkillManager.GetSkill<Athletic>(SkillNames.Athletic);
this.mActorsMartialArtsSkill = this.Actor.SkillManager.GetSkill<MartialArts>(SkillNames.MartialArts);
this.mTargetsMartialArtsSkill = this.Target.SkillManager.GetSkill<MartialArts>(SkillNames.MartialArts);

int num = Math.Max(0,this.mActorsAthleticSkill.SkillLevel) + Math.Max(0,this.mActorsMartialArtsSkill.SkillLevel);
int num2 = Math.Max(0,this.mTargetsAthleticSkill.SkillLevel) + Math.Max(0,this.mTargetsMartialArtsSkill.SkillLevel);
Back to top