Home | Download | Discussion | Help | Site Map | New Posts | Sign in

Latest Site News

Theme Catchup2018 - posted on 1st May 2018 at 1:50 PM
Replies: 2 (Who?), Viewed: 187 times.
Instructor
Original Poster
#1 Old 13th May 2018 at 1:34 AM
Default How to create BuffInstance for a custom Buff
So I have this Buff. It used to work fine. But I have now added a BuffInstance class. And it gives me an error whenever I try to add the Buff. It worked fine before I created the BuffMindControlInstance. Help please.

Code:
public class BuffMindControl : Buff
{

public BuffMindControl(BuffData info) : base(info)
{
}



private const ulong kMindControlBuff =0xD3C61BD7B1BAF4A4;
public static ulong StaticGuid
{
get
{
return 0xD3C61BD7B1BAF4A4;
}
}

public override void OnAddition(BuffManager bm, BuffInstance bi, bool travelReaddition)
{
Sim actor = bm.Actor;
BuffInstanceMindControl servitude = bi as BuffInstanceMindControl;
servitude.ServitudeVfx = VisualEffect.Create("ep8AlienMesmerizeFx");
servitude.ServitudeVfx.ParentTo(actor, Sim.FXJoints.Head);
servitude.ServitudeVfx.Start();
VisitSituation.SetVisitToGreeted(actor);
VisitSituation situation = VisitSituation.FindVisitSituationInvolvingGuest(actor);
if (situation != null)
{
situation.RemoveCheck(actor, CheckType.InappropriateForVisitor);
situation.RemoveCheck(actor, CheckType.SelfRegarding);
}
Motives motives = actor.Motives;
motives.CreateMotive(CommodityKind.BeRepairman);
motives.CreateMotive(CommodityKind.BeMaid);

base.OnAddition(bm, bi, travelReaddition);
}
public override BuffInstance CreateBuffInstance()
{
return new BuffInstanceMindControl(this, BuffGuid, base.EffectValue, base.TimeoutSimMinutes);
}
public override void OnTimeout(BuffManager bm, BuffInstance bi, Buff.OnTimeoutReasons reason)
{
Sim actor = bm.Actor;
BuffInstanceMindControl servitude = bi as BuffInstanceMindControl;
if (servitude.ServitudeVfx != null)
{
servitude.ServitudeVfx.Dispose();
}
Motives motives = actor.Motives;
motives.RemoveMotive(CommodityKind.BeRepairman);
motives.RemoveMotive(CommodityKind.BeMaid);

(bi as BuffInstanceMindControl).Dispose(bm);
if (!actor.IsInActiveHousehold)
{
Sim.MakeSimGoHome(actor, false);
}

}

public override void OnRemoval(BuffManager bm, BuffInstance bi)
{


Sim actor = bm.Actor;
BuffInstanceMindControl servitude = bi as BuffInstanceMindControl;
if (servitude.ServitudeVfx != null)
{
servitude.ServitudeVfx.Dispose();
}
Motives motives = actor.Motives;
motives.RemoveMotive(CommodityKind.BeRepairman);
motives.RemoveMotive(CommodityKind.BeMaid);

(bi as BuffInstanceMindControl).Dispose(bm);
if (!actor.IsInActiveHousehold)
{
Sim.MakeSimGoHome(actor, false);
}
}


public class BuffInstanceMindControl : BuffInstance
{
public bool mHasTriggered;

public SimDescription mMasterSim;
public VisualEffect ServitudeVfx;
public BuffInstanceMindControl()
{
}

public BuffInstanceMindControl(Buff buff, BuffNames buffGuid, int effectValue, float timeoutCount) : base(buff, buffGuid, effectValue, timeoutCount)
{
}

public override BuffInstance Clone()
{
return new BuffMindControl.BuffInstanceMindControl(base.mBuff, base.mBuffGuid, base.mEffectValue, base.mTimeoutCount);
}



}



}
Advertisement
Instructor
Original Poster
#2 Old 13th May 2018 at 3:42 AM
Ok wait now the moodlet is working fine. I added the ulong values in clone() and createBuffInstance but the value won't get stored sigh.
Going to keep trying. I'll now add ID instead
Instructor
Original Poster
#3 Old 13th May 2018 at 4:08 AM
Ok now the value is also being stored properly :-) Everything's going fine.
Back to top