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!
Inventor
#51 Old 3rd Feb 2012 at 11:05 PM
Quote: Originally posted by Jbob
If I make a change in PizzaDelivery Service Do I also need to make the same change in PizzaDeliverySituation?


you mean, changing the Name? yes, you need. change to MyPizzaDelivery and MyPizzaDeliverySituation.

Quote: Originally posted by Jbob
I don't see a place to change the routing in PizzaDelivery however I can change the routing here in PizzaDeliverySituation:


exactly, if you need to change how the npc works, you need to change the ServiceSituation script.

each NPC has his own situation.

Quote: Originally posted by Jbob
I have no idea if I can make a reference to the BackDoor or Pool


this time, it's not "reference", but function. If you try to write "this.Target.", after the last Dot, will appear a List of functions available for your NPC. There is several routing functions available.

try the this.Target.RouteAway(
Advertisement
Lab Assistant
Original Poster
#52 Old 4th Feb 2012 at 1:28 AM
So far all my changes have been in the Butler Script So I need to make those same changes int he Butlersituation Script? I am confused you say "If you try to write "this.Target.", after the last Dot, will appear a List of functions available for your NPC. There is several routing functions available." The list of functions shows up in game or while I am writing the script?


{
Door door = (Door) null;
Sim sim = this.Actor;
if (!this.Target.RouteAway(this.Actor, Sim.MinDistanceFromDoorWhenVisiting, Sim.MaxDistanceFromDoorWhenVisiting, ref door, true, true, (Dictionary<Sims3.SimIFace.Route.RouteOption, bool>) null, Service.kMaxDistanceToRouteFromServiceCarToLotWithoutTeleporting))
return false;
if (door != null)
door.RingBell();
Sim simForPizza = this.FindSimForPizza(sim);
if (simForPizza != null)
{

or


{
Door door = (Door) null;
Sim sim = this.Actor;
if (!this.Target.(this.Actor, Sim.MinDistanceFromDoorWhenVisiting, Sim.MaxDistanceFromDoorWhenVisiting, ref door, true, true, (Dictionary<Sims3.SimIFace.Route.RouteOption, bool>) null, Service.kMaxDistanceToRouteFromServiceCarToLotWithoutTeleporting))
return false;
if (door != null)
door.RingBell();
Sim simForPizza = this.FindSimForPizza(sim);
if (simForPizza != null)
{
Lab Assistant
Original Poster
#53 Old 4th Feb 2012 at 1:33 AM
quick question when I save a project do I save all or just save class1.cs

I was hoping to create a template or master copy of a project that is game ready so I can just load that and start working.

Like I said earlier I have to start a new project then save it before VS will let me change the frame work. I seem to recall reading somewhere on the forums where I can go into the (i think) csproj file and add some scripting there.
Field Researcher
#54 Old 4th Feb 2012 at 4:23 AM
The functions will show up when your typing is what he means.


Also, a project is a compilation of solutions which are the programs (in this case script). The save all and save doesn't really matter if you have only one cs file. Either save function works. Personally, I always use save all.

As for the templates, I do the same thing for my scripts. You should have no problem making a template for Sims 3 coding and then using that instead of having to reimport everything and setup your using statements.
Lab Assistant
Original Poster
#55 Old 4th Feb 2012 at 7:13 PM Last edited by Jbob : 4th Feb 2012 at 8:25 PM. Reason: Got it down to no errors and no warnings.
Error 1 'JbobIntelligentButler.JbobIntelligentButler' does not contain a definition for 'sJbobIntelligentButler' Documents and Settings\Jbob_Intelligent Butler\Jbob_Intelligent Butler\Class1.cs 144 46 Jbob_Intelligent Butler

Error 4 'Sims3.Gameplay.Services.ServiceType' does not contain a definition for 'JbobIntelligentButler' Documents and Settings\Jbob_Intelligent Butler\Jbob_Intelligent Butler\Class1.cs 199 75 Jbob_Intelligent Butler

Error 10 The type or namespace name 'JbobIntelligentButlerSituation' could not be found (are you missing a using directive or an assembly reference?) Documents and Settings\bob_Intelligent Butler\Jbob_Intelligent Butler\Class1.cs 323 13 Jbob_Intelligent Butler

Error 11 'Sims3.Gameplay.Services.ServiceType' does not contain a definition for 'JbobIntelligentButlerBartenderService' and no extension method 'JbobIntelligentButlerBartenderService' accepting a first argument of type 'Sims3.Gameplay.Services.ServiceType' could be found (are you missing a using directive or an assembly reference?) Documents and Settings\Jbob_Intelligent Butler\Jbob_Intelligent Butler\Class1.cs 381 36 Jbob_Intelligent Butler

Error 12 'Sims3.Gameplay.Services.ServiceType' does not contain a definition for 'JbobIntelligentButlerBartenderService' Documents and Settings\Jbob_Intelligent Butler\Jbob_Intelligent Butler\Class1.cs 475 75 Jbob_Intelligent Butler

So far looks error free, Now I could use a hand in editing the code I need to edit out reference to shift time and a few other things
Field Researcher
#56 Old 4th Feb 2012 at 7:49 PM
Can't really help much without seeing the code that those errors occur at...

Error 4:

If you look in reflector and go to the SerivceType you can see all the services that you can use. You'll have to make your own SerivceType to do that. What you're trying to do is to use JbobIntelligentButler but that doesn't exist in ServiceType. If you use Reflector, you can see that really all it does is returns a enumerator.



Error 10:
The issue is exactly what it says. No JBobButlerSituation exists. I'm assuming the code originally called for ButlerSituation which is derived from BabysitterSituationBase. If you want to create a JBobButlerSituation you'll have to go to Sims3Gameplay.Serivices.ButlerSituation in Reflector to see what that does and do something similar to that and make a code based off of that or even BabysitterSituationBase, like what EAxian did.

Error 11 & 12:
Same thing as Error 10.

Error 1:
If you would post the line of code that gives you that error, I could help you with that one.
Lab Assistant
Original Poster
#57 Old 4th Feb 2012 at 8:38 PM Last edited by Jbob : 4th Feb 2012 at 10:19 PM.
Now I built this Not sure if it would work this way but I have all the Butler functions first then I followed that on with the Bartender functions. So you will see it close out Butler and then come in with a new namespace of "JbobIntelligentButlerBartenderService" I am not sure if this is the correct way to do this but so far I have no errors in the script at this time. I am going to try and BOLD the areas I think need to be edited out.

// Type: Sims3.Gameplay.Services.Butler
// Assembly: Sims3GameplaySystems, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Assembly location: Documents and Settings\Sims 3 Modding\Sims3GameplaySystems.dll
// Type: Sims3.Gameplay.Services.BartenderService
// Assembly: Sims3GameplaySystems, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Assembly location: Documents and Settings\Sims 3 Modding\Sims3GameplaySystems.dll

using Sims3.Gameplay.Services;
using Sims3.Gameplay;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.CAS;
using Sims3.Gameplay.Core;
using Sims3.Gameplay.Interfaces;
using Sims3.Gameplay.Objects;
using Sims3.Gameplay.Scenarios;
using Sims3.Gameplay.Skills;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using System.Collections.Generic;

namespace JbobIntelligentButler
{
public class JbobIntelligentButler : Service, IAmCleaningService
{
private static readonly string sLocalizationKey = "Sims3.Gameplay.Services".Substring(6).Replace('.', '/') + "/Butler";
private static string kButlerBook = "HowToServeAndNotBeServed";
[Tunable]
private static Service.ServiceTuning kServiceTuning = new Service.ServiceTuning();
[TunableComment("If any of the CTYAE Sims get below this hunger value, Butler starts cooking")]
[Tunable]
private static float kMinHungerBeforeStartCooking = -20f;
[Tunable]
[TunableComment("How often the butler will cook in minutes. This prevents the butler from Autonomously cooking continuously. Only used when successfully cooked")]
private static float kTimeBetweenSuccessfulCookingSessions = 40f;
[TunableComment("When you interrupt a butler while he's cooking, he'll try to continue cooking. But, if he hasn't cooked anything after this time, he'll restart the meal from scratch.")]
[Tunable]
private static float kTimeBeforeRestartCooking = 20f;
[TunableComment("How old leftovers can be out in minutes before the butler will put it away")]
[Tunable]
private static float kTimeWaitBeforePutawayLeftovers = 60f;
[TunableComment("Multiplier for interactions in a room where a sim is sleeping")]
[Tunable]
private static float kUseObjectInSameRoomAsSleeperMultiplier = 0.1f;
[TunableComment("If Butler's relationship with any YAE falls below this level, he will quit")]
[Tunable]
private static float kRelationshipLevelForQuit = -50f;
[TunableComment("Butler can start cooking this many hours before the target sim wakes up. This allows the butler to have food ready when the sleeping sim wakes up")]
[Tunable]
private static float kTimeCanStartCookBeforeSimWakes = 1.8f;
[Tunable]
[TunableComment("Chance you get the good advice moodlet when asking for advice from the butler")]
private static float kChanceGetGoodAdviceMoodlet = 25f;
[TunableComment("Length of time (in hours) that the butler waits before routing to lot")]
[Tunable]
private static float kDelayBeforeArriving = 0.5f;
private static JbobIntelligentButler sButler = (JbobIntelligentButler)null;

protected override Service.ServiceTuning Tuning
{
get
{
return JbobIntelligentButler.kServiceTuning;
}
}

public static float MinHungerBeforeStartCooking
{
get
{
return JbobIntelligentButler.kMinHungerBeforeStartCooking;
}
}

public static float TimeBetweenSuccessfulCookingSessions
{
get
{
return JbobIntelligentButler.kTimeBetweenSuccessfulCookingSessions;
}
}

public static float TimeBeforeRestartCooking
{
get
{
return JbobIntelligentButler.kTimeBeforeRestartCooking;
}
}

public static float TimeWaitBeforePutawayLeftovers
{
get
{
return JbobIntelligentButler.kTimeWaitBeforePutawayLeftovers;
}
}

public static float UseObjectInSameRoomAsSleeperMultiplier
{
get
{
return JbobIntelligentButler.kUseObjectInSameRoomAsSleeperMultiplier;
}
}

public static float RelationshipLevelForQuit
{
get
{
return JbobIntelligentButler.kRelationshipLevelForQuit;
}
}

public static float TimeCanStartCookBeforeSimWakes
{
get
{
return JbobIntelligentButler.kTimeCanStartCookBeforeSimWakes;
}
}

public static float ChanceGetGoodAdviceMoodlet
{
get
{
return JbobIntelligentButler.kChanceGetGoodAdviceMoodlet;
}
}

public static float DelayBeforeArriving
{
get
{
return JbobIntelligentButler.kDelayBeforeArriving;
}
}

public static JbobIntelligentButler Instance
{
get
{
return JbobIntelligentButler.sButler;
}
}

public override ServiceType ServiceType
{
get
{
return ServiceType.Butler;
}
}

public override List<CommodityKind> ServiceMotives
{
get
{
return new List<CommodityKind>((IEnumerable<CommodityKind>) new CommodityKind[6]
{
CommodityKind.LookAfterBabyOrToddler,
CommodityKind.LookAfterChild,
CommodityKind.BabysitterClean,
CommodityKind.BeMaid,
CommodityKind.BeButler,
CommodityKind.BeBartender
});
}
}

public override bool IsPaidWeekly
{
get
{
return true;
}
}

static JbobIntelligentButler()
{
}

public JbobIntelligentButler()
{
if (!GameUtils.IsInstalled(ProductVersion.EP3))
JbobIntelligentButler.sButler = (JbobIntelligentButler)null;
else
JbobIntelligentButler.sButler = this;
}

private static string LocalizeString(string name, params object[] parameters)
{
return Localization.LocalizeString(JbobIntelligentButler.sLocalizationKey + ":" + name, parameters);
}

public static void Create()
{
if (ServiceNPCSpecifications.ValidForCurrentWorld(ServiceType.Butler))
{
if (JbobIntelligentButler.sButler == null)
{
JbobIntelligentButler butler = new JbobIntelligentButler();
}
else
JbobIntelligentButler.sButler.PostLoadFixup();
}
else
JbobIntelligentButler.DestroyButler();
}

public static void Destroy()
{
JbobIntelligentButler.DestroyButler();
}

private static void DestroyButler()
{
Service.Destroy((Service)JbobIntelligentButler.sButler);
JbobIntelligentButler.sButler = (JbobIntelligentButler)null;
}

public static void RemoveButlersFromLot(Lot lot)
{
Butler instance = Butler.Instance;
if (instance == null || !instance.IsServiceRequested(lot) && !instance.IsAnySimAssignedToLot(lot))
return;
foreach (Sim actor in instance.GetSimsAssignedToLot(lot))
{
ButlerSituation butlerSituation = ServiceSituation.FindServiceSituationInvolving(actor) as ButlerSituation;
if (butlerSituation != null)
butlerSituation.SetToLeave();
}
}

protected override bool NeedsAssignment(Lot lot)
{
if (this.IsServiceRequested(lot))
return !this.IsAnySimAssignedToLot(lot);
else
return false;
}

protected override ServiceSituation InternalCreateSituation(Lot assignedLot, Sim createdSim, int cost, ObjectGuid requestingSim)
{
if (assignedLot.MoveInScenario is Rodents)
{
ServiceSituation serviceSituation = assignedLot.MoveInScenario.SetupSituation((Service)this, createdSim);
assignedLot.MoveInScenario = (Scenario)null;
return serviceSituation;
}
else
{
createdSim.SimDescription.ShowSocialsOnSim = true;
createdSim.CanBeFired = true;
return (ServiceSituation)new ButlerSituation((Service)this, assignedLot, createdSim, cost);
}
}

public override void UpdateCreatedSim(Sim sim)
{
Skill skill1 = sim.SkillManager.AddElement(SkillNames.Handiness);
Skill skill2 = sim.SkillManager.AddElement(SkillNames.Cooking);
Skill skill3 = sim.SkillManager.AddElement(SkillNames.Bartending);
int maxSkillLevel = skill1.MaxSkillLevel;
for (int index = 0; index < maxSkillLevel; ++index)
{
skill3.ForceGainPointsForLevelUp();
skill2.ForceGainPointsForLevelUp();
skill1.ForceGainPointsForLevelUp();
}
Book book = (Book)BookGeneralData.GetBookGeneralByTitle(JbobIntelligentButler.kButlerBook);
Inventory inventory = sim.Inventory;
if (inventory == null)
return;
inventory.DestroyItems();
if (inventory.TryToAdd((IGameObject)book))
return;
book.Destroy();
}

protected override void SetServiceNPCProperties(SimDescription simDescription)
{
simDescription.CanBeKilledOnJob = true;
simDescription.Marryable = true;
simDescription.Contactable = true;
simDescription.ShowSocialsOnSim = true;
}

protected override void SetTraits(SimDescription simDescription)
{
TraitManager traitManager = simDescription.TraitManager;
traitManager.AddElement(TraitNames.Neat);
traitManager.AddElement(TraitNames.Brave);
traitManager.AddElement(TraitNames.FamilyOriented);
List<Trait> validTraits = AgingManager.GetValidTraits(simDescription, false, false, true);
for (int index = 0; index < 2; ++index)
{
if (validTraits.Count > 0)
{
Trait randomObjectFromList = RandomUtil.GetRandomObjectFromList<Trait>(validTraits);
traitManager.AddElement(randomObjectFromList.Guid);
validTraits.Remove(randomObjectFromList);
}
}
}

public override string GetServiceTopic(Sim serviceSim)
{
return "Butler Service";
}

public override bool CanRequestServiceFromPhone(Lot lot)
{
if (base.CanRequestServiceFromPhone(lot) && GameUtils.GetCurrentWorldType() != WorldType.Vacation)
return lot.CommercialLotSubType != CommercialLotSubType.kEP1_BaseCamp;
else
return false;
}

public static void AskToCook(Sim sim)
{
ButlerSituation butlerSituation = ServiceSituation.FindServiceSituationInvolving(sim) as ButlerSituation;
if (butlerSituation == null)
return;
butlerSituation.PrepareFood(false);
}
}
}

namespace JbobIntelligentButlerBartenderService
{
public class JbobIntelligentButlerBartenderService : Service
{
[PersistableStatic(false)]
public static ulong sFirstBartender = 0UL;
[PersistableStatic(false)]
public static int sNumAdditionalBartendersRequested = 0;
[PersistableStatic(false)]
public static int sNumAdditionalBartenders = 0;

[Tunable]
[TunableComment("Min Bartending Skil")]
private static int kMinBartendingSkill = 5;
[TunableComment("Max Handiness Skil")]
[Tunable]
private static int kMaxBartendingSkill = 10;
[Tunable]
[TunableComment("Max number of bartender NPCs on a lot.")]
private static int kMaxNumBartendersPerLot = 10;
[Tunable]
private static Service.ServiceTuning kServiceTuning = new Service.ServiceTuning();
[Tunable]
[TunableComment("Length of time (in hours) that bartender waits before routing to lot.")]
private static float kDelayBeforeArriving = 0.25f;
[TunableComment("Length of time (in hours) that bartender waits before leaving the lot, after his work is done.")]
[Tunable]
private static float kDelayBeforeLeaving = 0.3f;
[TunableComment("Number of Sim hours the bartender will work before seeing if the party is dead.")]
[Tunable]
private static float kShiftTime = 4f;
[TunableComment("Number of Sim hours the bartender will work after their shift time has expired, but guests are still on the lot. This will repeat until all guests that aren't staying over leave.")]
[Tunable]
private static float kExtendedShiftTime = 1f;
[Tunable]
[TunableComment("Extra time (in hours) to wait before leaving if the service NPC is socialized with")]
private static float kExtraWaitTimeAfterSocializing = 0.5f;
private static JbobIntelligentButlerBartenderService sBartenderService
;

public static JbobIntelligentButlerBartenderService Instance
{
get
{
return JbobIntelligentButlerBartenderService.sBartenderService;
}
}

public override ServiceType ServiceType
{
get
{
return ServiceType.Bartender;
}
}

public override List<CommodityKind> ServiceMotives
{
get
{
return new List<CommodityKind>((IEnumerable<CommodityKind>)new CommodityKind[2]
{
CommodityKind.BeBartender,
CommodityKind.BeButler
});
}
}

public static int MaxNumBartendersPerLot
{
get
{
return JbobIntelligentButlerBartenderService.kMaxNumBartendersPerLot;

}
}

protected override Service.ServiceTuning Tuning
{
get
{
return JbobIntelligentButlerBartenderService.kServiceTuning;
}
}

public static Service.ServiceTuning GetServiceTuning
{
get
{
return JbobIntelligentButlerBartenderService.kServiceTuning;
}
}

public static float DelayBeforeArriving
{
get
{
return JbobIntelligentButlerBartenderService.kDelayBeforeArriving;
}
}

public static float DelayBeforeLeaving
{
get
{
return JbobIntelligentButlerBartenderService.kDelayBeforeLeaving;
}
}

public static float ShiftTime
{
get
{
return JbobIntelligentButlerBartenderService.kShiftTime;

}
}

public static float ExtendedShiftTime
{
get
{
return JbobIntelligentButlerBartenderService.kExtendedShiftTime;

}
}

public static float ExtraWaitTimeAfterSocializing
{
get
{
return JbobIntelligentButlerBartenderService.kExtraWaitTimeAfterSocializing;
}
}

static JbobIntelligentButlerBartenderService()
{
}

public JbobIntelligentButlerBartenderService()
{
if (!GameUtils.IsInstalled(ProductVersion.EP3))
JbobIntelligentButlerBartenderService.sBartenderService = (JbobIntelligentButlerBartenderService)null;
else
JbobIntelligentButlerBartenderService.sBartenderService = this;
}

public static void Create()
{
if (ServiceNPCSpecifications.ValidForCurrentWorld(ServiceType.Bartender))
{
if (JbobIntelligentButlerBartenderService.sBartenderService == null)
{
JbobIntelligentButlerBartenderService bartenderService = new JbobIntelligentButlerBartenderService();
}
else
JbobIntelligentButlerBartenderService.sBartenderService.PostLoadFixup();
}
else
JbobIntelligentButlerBartenderService.DestroyBartenderService();
}

public static void Destroy()
{
JbobIntelligentButlerBartenderService.DestroyBartenderService();
}

private static void DestroyBartenderService()
{
Service.Destroy((Service)JbobIntelligentButlerBartenderService.sBartenderService);
JbobIntelligentButlerBartenderService.sBartenderService = (JbobIntelligentButlerBartenderService)null;
}

protected override bool NeedsAssignment(Lot lot)
{
bool flag1 = this.IsServiceRequested(lot);
bool flag2 = this.IsAnySimAssignedToLot(lot);
if (flag1 && !flag2)
return true;
if (!flag1 && flag2)
return JbobIntelligentButlerBartenderService.sNumAdditionalBartenders < JbobIntelligentButlerBartenderService.sNumAdditionalBartendersRequested;
else
return false;
}

public override bool CanRequestServiceFromPhone(Lot lot)
{
if (!base.CanRequestServiceFromPhone(lot))
return false;
int num = 0;
foreach (Sim sim in lot.GetSims())
{
if (sim.Service is BartenderService)
++num;
}
return num < BartenderService.MaxNumBartendersPerLot;
}

protected override ServiceSituation InternalCreateSituation(Lot assignedLot, Sim createdSim, int cost, ObjectGuid requestingSim)
{
createdSim.CanBeFired = true;
return (ServiceSituation)new BartenderServiceSituation((Service)this, assignedLot, createdSim, cost);

}

public override void UpdateCreatedSim(Sim sim)
{
Skill skill = sim.SkillManager.AddElement(SkillNames.Bartending);
if (skill == null)
return;
int @int = RandomUtil.GetInt(JbobIntelligentButlerBartenderService.kMinBartendingSkill, JbobIntelligentButlerBartenderService.kMaxBartendingSkill);
skill.ForceSkillLevelUp(@int);
}

protected override void SetServiceNPCProperties(SimDescription simDescription)
{
simDescription.MotivesDontDecay = true;
simDescription.CanBeKilledOnJob = true;
simDescription.Marryable = true;
simDescription.CanStartFires = false;
simDescription.Contactable = true;
}

protected override void SetTraits(SimDescription simDescription)
{
List<TraitNames> randomList = new List<TraitNames>((IEnumerable<TraitNames>)new TraitNames[3]
{
TraitNames.Flirty,
TraitNames.Schmoozer,
TraitNames.Athletic
});
for (int index = 0; index < 2; ++index)
{
TraitNames randomObjectFromList = RandomUtil.GetRandomObjectFromList<TraitNames>(randomList);
simDescription.TraitManager.AddElement(randomObjectFromList);
randomList.Remove(randomObjectFromList);

}
}

public override string GetServiceTopic(Sim serviceSim)
{
return "Bartender Service";
}
}
}
Lab Assistant
Original Poster
#58 Old 4th Feb 2012 at 9:12 PM
In Butler situation to make changes in cooking I am looking at this area:

private bool BeginCooking()
{
if (this.Parent.Worker.CurrentInteraction is ICookingInteraction)
return false;
List<Sim> randomList = this.Parent.ValidHungryHouseholdMembers();
this.mNumSimsToCookFor = randomList.Count;
Recipe.MealQuantity quantity = Recipe.MealQuantity.Single;
Recipe.MealDestination destination = Recipe.MealDestination.SurfaceOnly;
if (this.mNumSimsToCookFor > 1)<--is there a way to make it check for number of sims on lot as well as keep it default of (1)?
{
quantity = Recipe.MealQuantity.Group;
destination = Recipe.MealDestination.SurfaceAndCallToMeal;
}
randomList.Add(this.Parent.Worker);
if (!this.Parent.PushPrepareFoodInteraction(RandomUtil.GetRandomObjectFromList<Sim>(randomList), (string) null, quantity, destination))
return false;
this.mTimeLastDidCookingRelatedAction = SimClock.ElapsedTime(TimeUnit.Minutes);
return true;
}

private void ContinueCooking()
{
InteractionInstance currentInteraction = this.Parent.Worker.CurrentInteraction;
if (currentInteraction == null && this.Parent.Worker.InteractionQueue.Count > 0)
return;
if (currentInteraction is ICookingInteraction)
this.mTimeLastDidCookingRelatedAction = SimClock.ElapsedTime(TimeUnit.Minutes);
if (this.Parent.NumFoodOnLot(Quality.Neutral) >= this.mNumSimsToCookFor)
this.Parent.CompleteCooking();
float lastTime = this.mTimeLastDidCookingRelatedAction;
if ((double) SimClock.ElapsedTimeInMinutes(ref lastTime) < (double) Butler.TimeBeforeRestartCooking)
return;
this.BeginCooking();
}

Can Neutral be changed to something higher or better or kick it up a notch?

Then Because I made a change in Butler I have to make this change in ButlerSituation:
public override void SetMotivesAndCommodities()
{
this.Worker.Motives.MaxEverything();
this.Worker.WorkMotive = CommodityKind.BeButler;
this.Worker.Motives.CreateMotive(CommodityKind.LookAfterBabyOrToddler);
this.Worker.Motives.CreateMotive(CommodityKind.BeButler);
this.Worker.Motives.CreateMotive(CommodityKind.BeMaid);
this.Worker.Motives.CreateMotive(CommodityKind.LookAfterChild);
this.Worker.Motives.CreateMotive(CommodityKind.BabysitterClean);
this.Worker.Motives.CreateMotive(CommodityKind.BeBartender);
Field Researcher
#59 Old 4th Feb 2012 at 10:28 PM
Quote: Originally posted by Jbob
In Butler situation to make changes in cooking I am looking at this area:
this.mNumSimsToCookFor = randomList.Count;
Recipe.MealQuantity quantity = Recipe.MealQuantity.Single;
Recipe.MealDestination destination = Recipe.MealDestination.SurfaceOnly;
if (this.mNumSimsToCookFor > 1)<--is there a way to make it check for number of sims on lot as well as keep it default of (1)?
{
quantity = Recipe.MealQuantity.Group;
destination = Recipe.MealDestination.SurfaceAndCallToMeal;
}


Well, what this is telling you is that if there is more then 1 Sim to cook for then go ahead and set the quantity of the meal being prepared to a group meal and once it's done cooking to put it down on a available surface and call the household/lot to the meal. (">" means greater than, just like in math class while "<" meaning less than and "<=" is less than or equal to and ">=" is greater than or equal to and "==" just being equal to).


Your code is a bit difficult to read without you using the CODE tags. It's nice to read the code when it's aligned correctly .

I'm not really sure what your trying to ask me with the rest of the code that you posted.

You should try running your code ingame every once in a while (keeping a original saved .cs file before the build) to see if the game will run it correctly. If not, then you can go back to the original saved file and see what you messed up on. ScriptError is also a nice mod to have when doing this.
Lab Assistant
Original Poster
#60 Old 4th Feb 2012 at 11:03 PM
Code:
// Type: Sims3.Gameplay.Services.Butler
// Assembly: Sims3GameplaySystems, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Assembly location: Documents and Settings\Sims 3 Modding\Sims3GameplaySystems.dll
// Type: Sims3.Gameplay.Services.BartenderService
// Assembly: Sims3GameplaySystems, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// Assembly location: Documents and Settings\Sims 3 Modding\Sims3GameplaySystems.dll

using Sims3.Gameplay.Services;
using Sims3.Gameplay;
using Sims3.Gameplay.Actors;
using Sims3.Gameplay.ActorSystems;
using Sims3.Gameplay.Autonomy;
using Sims3.Gameplay.CAS;
using Sims3.Gameplay.Core;
using Sims3.Gameplay.Interfaces;
using Sims3.Gameplay.Objects;
using Sims3.Gameplay.Scenarios;
using Sims3.Gameplay.Skills;
using Sims3.Gameplay.Utilities;
using Sims3.SimIFace;
using System.Collections.Generic;

namespace JbobIntelligentButler
{
public class JbobIntelligentButler : Service, IAmCleaningService
{
private static readonly string sLocalizationKey = "Sims3.Gameplay.Services".Substring(6).Replace('.', '/') + "/Butler";
private static string kButlerBook = "HowToServeAndNotBeServed";
[Tunable]
private static Service.ServiceTuning kServiceTuning = new Service.ServiceTuning();
[TunableComment("If any of the CTYAE Sims get below this hunger value, Butler starts cooking")]
[Tunable]
private static float kMinHungerBeforeStartCooking = -20f;
[Tunable]
[TunableComment("How often the butler will cook in minutes. This prevents the butler from Autonomously cooking continuously. Only used when successfully cooked")]
private static float kTimeBetweenSuccessfulCookingSessions = 40f;
[TunableComment("When you interrupt a butler while he's cooking, he'll try to continue cooking. But, if he hasn't cooked anything after this time, he'll restart the meal from scratch.")]
[Tunable]
private static float kTimeBeforeRestartCooking = 20f;
[TunableComment("How old leftovers can be out in minutes before the butler will put it away")]
[Tunable]
private static float kTimeWaitBeforePutawayLeftovers = 60f;
[TunableComment("Multiplier for interactions in a room where a sim is sleeping")]
[Tunable]
private static float kUseObjectInSameRoomAsSleeperMultiplier = 0.1f;
[TunableComment("If Butler's relationship with any YAE falls below this level, he will quit")]
[Tunable]
private static float kRelationshipLevelForQuit = -50f;
[TunableComment("Butler can start cooking this many hours before the target sim wakes up. This allows the butler to have food ready when the sleeping sim wakes up")]
[Tunable]
private static float kTimeCanStartCookBeforeSimWakes = 1.8f;
[Tunable]
[TunableComment("Chance you get the good advice moodlet when asking for advice from the butler")]
private static float kChanceGetGoodAdviceMoodlet = 25f;
[TunableComment("Length of time (in hours) that the butler waits before routing to lot")]
[Tunable]
private static float kDelayBeforeArriving = 0.5f;
private static JbobIntelligentButler sButler = (JbobIntelligentButler)null;

protected override Service.ServiceTuning Tuning
{
get
{
return JbobIntelligentButler.kServiceTuning;
}
}

public static float MinHungerBeforeStartCooking
{
get
{
return JbobIntelligentButler.kMinHungerBeforeStartCooking;
}
}

public static float TimeBetweenSuccessfulCookingSessions
{
get
{
return JbobIntelligentButler.kTimeBetweenSuccessfulCookingSessions;
}
}

public static float TimeBeforeRestartCooking
{
get
{
return JbobIntelligentButler.kTimeBeforeRestartCooking;
}
}

public static float TimeWaitBeforePutawayLeftovers
{
get
{
return JbobIntelligentButler.kTimeWaitBeforePutawayLeftovers;
}
}

public static float UseObjectInSameRoomAsSleeperMultiplier
{
get
{
return JbobIntelligentButler.kUseObjectInSameRoomAsSleeperMultiplier;
}
}

public static float RelationshipLevelForQuit
{
get
{
return JbobIntelligentButler.kRelationshipLevelForQuit;
}
}

public static float TimeCanStartCookBeforeSimWakes
{
get
{
return JbobIntelligentButler.kTimeCanStartCookBeforeSimWakes;
}
}

public static float ChanceGetGoodAdviceMoodlet
{
get
{
return JbobIntelligentButler.kChanceGetGoodAdviceMoodlet;
}
}

public static float DelayBeforeArriving
{
get
{
return JbobIntelligentButler.kDelayBeforeArriving;
}
}

public static JbobIntelligentButler Instance
{
get
{
return JbobIntelligentButler.sButler;
}
}

public override ServiceType ServiceType
{
get
{
return ServiceType.Butler;
}
}

public override List<CommodityKind> ServiceMotives
{
get
{
return new List<CommodityKind>((IEnumerable<CommodityKind>) new CommodityKind[6]
{
CommodityKind.LookAfterBabyOrToddler,
CommodityKind.LookAfterChild,
CommodityKind.BabysitterClean,
CommodityKind.BeMaid,
CommodityKind.BeButler,
CommodityKind.BeBartender
});
}
}

public override bool IsPaidWeekly
{
get
{
return true;
}
}

static JbobIntelligentButler()
{
}

public JbobIntelligentButler()
{
if (!GameUtils.IsInstalled(ProductVersion.EP3))
JbobIntelligentButler.sButler = (JbobIntelligentButler)null;
else
JbobIntelligentButler.sButler = this;
}

private static string LocalizeString(string name, params object[] parameters)
{
return Localization.LocalizeString(JbobIntelligentButler.sLocalizationKey + ":" + name, parameters);
}

public static void Create()
{
if (ServiceNPCSpecifications.ValidForCurrentWorld(ServiceType.Butler))
{
if (JbobIntelligentButler.sButler == null)
{
JbobIntelligentButler butler = new JbobIntelligentButler();
}
else
JbobIntelligentButler.sButler.PostLoadFixup();
}
else
JbobIntelligentButler.DestroyButler();
}

public static void Destroy()
{
JbobIntelligentButler.DestroyButler();
}

private static void DestroyButler()
{
Service.Destroy((Service)JbobIntelligentButler.sButler);
JbobIntelligentButler.sButler = (JbobIntelligentButler)null;
}

public static void RemoveButlersFromLot(Lot lot)
{
Butler instance = Butler.Instance;
if (instance == null || !instance.IsServiceRequested(lot) && !instance.IsAnySimAssignedToLot(lot))
return;
foreach (Sim actor in instance.GetSimsAssignedToLot(lot))
{
ButlerSituation butlerSituation = ServiceSituation.FindServiceSituationInvolving(actor) as ButlerSituation;
if (butlerSituation != null)
butlerSituation.SetToLeave();
}
}

protected override bool NeedsAssignment(Lot lot)
{
if (this.IsServiceRequested(lot))
return !this.IsAnySimAssignedToLot(lot);
else
return false;
}

protected override ServiceSituation InternalCreateSituation(Lot assignedLot, Sim createdSim, int cost, ObjectGuid requestingSim)
{
if (assignedLot.MoveInScenario is Rodents)
{
ServiceSituation serviceSituation = assignedLot.MoveInScenario.SetupSituation((Service)this, createdSim);
assignedLot.MoveInScenario = (Scenario)null;
return serviceSituation;
}
else
{
createdSim.SimDescription.ShowSocialsOnSim = true;
createdSim.CanBeFired = true;
return (ServiceSituation)new ButlerSituation((Service)this, assignedLot, createdSim, cost);
}
}

public override void UpdateCreatedSim(Sim sim)
{
Skill skill1 = sim.SkillManager.AddElement(SkillNames.Handiness);
Skill skill2 = sim.SkillManager.AddElement(SkillNames.Cooking);
Skill skill3 = sim.SkillManager.AddElement(SkillNames.Bartending);
int maxSkillLevel = skill1.MaxSkillLevel;
for (int index = 0; index < maxSkillLevel; ++index)
{
skill3.ForceGainPointsForLevelUp();
skill2.ForceGainPointsForLevelUp();
skill1.ForceGainPointsForLevelUp();
}
Book book = (Book)BookGeneralData.GetBookGeneralByTitle(JbobIntelligentButler.kButlerBook);
Inventory inventory = sim.Inventory;
if (inventory == null)
return;
inventory.DestroyItems();
if (inventory.TryToAdd((IGameObject)book))
return;
book.Destroy();
}

protected override void SetServiceNPCProperties(SimDescription simDescription)
{
simDescription.CanBeKilledOnJob = true;
simDescription.Marryable = true;
simDescription.Contactable = true;
simDescription.ShowSocialsOnSim = true;
}

protected override void SetTraits(SimDescription simDescription)
{
TraitManager traitManager = simDescription.TraitManager;
traitManager.AddElement(TraitNames.Neat);
traitManager.AddElement(TraitNames.Brave);
traitManager.AddElement(TraitNames.FamilyOriented);
List<Trait> validTraits = AgingManager.GetValidTraits(simDescription, false, false, true);
for (int index = 0; index < 2; ++index)
{
if (validTraits.Count > 0)
{
Trait randomObjectFromList = RandomUtil.GetRandomObjectFromList<Trait>(validTraits);
traitManager.AddElement(randomObjectFromList.Guid);
validTraits.Remove(randomObjectFromList);
}
}
}

public override string GetServiceTopic(Sim serviceSim)
{
return "Butler Service";
}

public override bool CanRequestServiceFromPhone(Lot lot)
{
if (base.CanRequestServiceFromPhone(lot) && GameUtils.GetCurrentWorldType() != WorldType.Vacation)
return lot.CommercialLotSubType != CommercialLotSubType.kEP1_BaseCamp;
else
return false;
}

public static void AskToCook(Sim sim)
{
ButlerSituation butlerSituation = ServiceSituation.FindServiceSituationInvolving(sim) as ButlerSituation;
if (butlerSituation == null)
return;
butlerSituation.PrepareFood(false);
}
}
}

namespace JbobIntelligentButlerBartenderService
{
public class JbobIntelligentButlerBartenderService : Service
{
[PersistableStatic(false)]
public static ulong sFirstBartender = 0UL;
[PersistableStatic(false)]
public static int sNumAdditionalBartendersRequested = 0;
[PersistableStatic(false)]
public static int sNumAdditionalBartenders = 0;
[Tunable]
[TunableComment("Min Bartending Skil")]
private static int kMinBartendingSkill = 5;
[TunableComment("Max Handiness Skil")]
[Tunable]
private static int kMaxBartendingSkill = 10;
[Tunable]
[TunableComment("Max number of bartender NPCs on a lot.")]
private static int kMaxNumBartendersPerLot = 10;
[Tunable]
private static Service.ServiceTuning kServiceTuning = new Service.ServiceTuning();
[Tunable]
[TunableComment("Length of time (in hours) that bartender waits before routing to lot.")]
private static float kDelayBeforeArriving = 0.25f;
[TunableComment("Length of time (in hours) that bartender waits before leaving the lot, after his work is done.")]
[Tunable]
private static float kDelayBeforeLeaving = 0.3f;
[TunableComment("Number of Sim hours the bartender will work before seeing if the party is dead.")]
[Tunable]
private static float kShiftTime = 4f;
[TunableComment("Number of Sim hours the bartender will work after their shift time has expired, but guests are still on the lot. This will repeat until all guests that aren't staying over leave.")]
[Tunable]
private static float kExtendedShiftTime = 1f;
[Tunable]
[TunableComment("Extra time (in hours) to wait before leaving if the service NPC is socialized with")]
private static float kExtraWaitTimeAfterSocializing = 0.5f;
private static JbobIntelligentButlerBartenderService sBartenderService;

public static JbobIntelligentButlerBartenderService Instance
{
get
{
return JbobIntelligentButlerBartenderService.sBartenderService;
}
}

public override ServiceType ServiceType
{
get
{
return ServiceType.Bartender;
}
}

public override List<CommodityKind> ServiceMotives
{
get
{
return new List<CommodityKind>((IEnumerable<CommodityKind>)new CommodityKind[2]
{
CommodityKind.BeBartender,
CommodityKind.BeButler
});
}
}

public static int MaxNumBartendersPerLot
{
get
{
return JbobIntelligentButlerBartenderService.kMaxNumBartendersPerLot;
}
}

protected override Service.ServiceTuning Tuning
{
get
{
return JbobIntelligentButlerBartenderService.kServiceTuning;
}
}

public static Service.ServiceTuning GetServiceTuning
{
get
{
return JbobIntelligentButlerBartenderService.kServiceTuning;
}
}

public static float DelayBeforeArriving
{
get
{
return JbobIntelligentButlerBartenderService.kDelayBeforeArriving;
}
}

public static float DelayBeforeLeaving
{
get
{
return JbobIntelligentButlerBartenderService.kDelayBeforeLeaving;
}
}

public static float ShiftTime
{
get
{
return JbobIntelligentButlerBartenderService.kShiftTime;
}
}

public static float ExtendedShiftTime
{
get
{
return JbobIntelligentButlerBartenderService.kExtendedShiftTime;
}
}

public static float ExtraWaitTimeAfterSocializing
{
get
{
return JbobIntelligentButlerBartenderService.kExtraWaitTimeAfterSocializing;
}
}

static JbobIntelligentButlerBartenderService()
{
}

public JbobIntelligentButlerBartenderService()
{
if (!GameUtils.IsInstalled(ProductVersion.EP3))
JbobIntelligentButlerBartenderService.sBartenderService = (JbobIntelligentButlerBartenderService)null;
else
JbobIntelligentButlerBartenderService.sBartenderService = this;
}

public static void Create()
{
if (ServiceNPCSpecifications.ValidForCurrentWorld(ServiceType.Bartender))
{
if (JbobIntelligentButlerBartenderService.sBartenderService == null)
{
JbobIntelligentButlerBartenderService bartenderService = new JbobIntelligentButlerBartenderService();
}
else
JbobIntelligentButlerBartenderService.sBartenderService.PostLoadFixup();
}
else
JbobIntelligentButlerBartenderService.DestroyBartenderService();
}

public static void Destroy()
{
JbobIntelligentButlerBartenderService.DestroyBartenderService();
}

private static void DestroyBartenderService()
{
Service.Destroy((Service)JbobIntelligentButlerBartenderService.sBartenderService);
JbobIntelligentButlerBartenderService.sBartenderService = (JbobIntelligentButlerBartenderService)null;
}

protected override bool NeedsAssignment(Lot lot)
{
bool flag1 = this.IsServiceRequested(lot);
bool flag2 = this.IsAnySimAssignedToLot(lot);
if (flag1 && !flag2)
return true;
if (!flag1 && flag2)
return JbobIntelligentButlerBartenderService.sNumAdditionalBartenders < JbobIntelligentButlerBartenderService.sNumAdditionalBartendersRequested;
else
return false;
}

public override bool CanRequestServiceFromPhone(Lot lot)
{
if (!base.CanRequestServiceFromPhone(lot))
return false;
int num = 0;
foreach (Sim sim in lot.GetSims())
{
if (sim.Service is BartenderService)
++num;
}
return num < BartenderService.MaxNumBartendersPerLot;
}

protected override ServiceSituation InternalCreateSituation(Lot assignedLot, Sim createdSim, int cost, ObjectGuid requestingSim)
{
createdSim.CanBeFired = true;
return (ServiceSituation)new BartenderServiceSituation((Service)this, assignedLot, createdSim, cost);
}

public override void UpdateCreatedSim(Sim sim)
{
Skill skill = sim.SkillManager.AddElement(SkillNames.Bartending);
if (skill == null)
return;
int @int = RandomUtil.GetInt(JbobIntelligentButlerBartenderService.kMinBartendingSkill, JbobIntelligentButlerBartenderService.kMaxBartendingSkill);
skill.ForceSkillLevelUp(@int);
}

protected override void SetServiceNPCProperties(SimDescription simDescription)
{
simDescription.MotivesDontDecay = true;
simDescription.CanBeKilledOnJob = true;
simDescription.Marryable = true;
simDescription.CanStartFires = false;
simDescription.Contactable = true;
}

protected override void SetTraits(SimDescription simDescription)
{
List<TraitNames> randomList = new List<TraitNames>((IEnumerable<TraitNames>)new TraitNames[3]
{
TraitNames.Flirty,
TraitNames.Schmoozer,
TraitNames.Athletic
});
for (int index = 0; index < 2; ++index)
{
TraitNames randomObjectFromList = RandomUtil.GetRandomObjectFromList<TraitNames>(randomList);
simDescription.TraitManager.AddElement(randomObjectFromList);
randomList.Remove(randomObjectFromList);
}
}

public override string GetServiceTopic(Sim serviceSim)
{
return "Bartender Service";
}
}
} 
Lab Assistant
Original Poster
#61 Old 4th Feb 2012 at 11:04 PM
Sorry not sure if that is what you meant.
Lab Assistant
Original Poster
#62 Old 5th Feb 2012 at 9:00 AM Last edited by Jbob : 5th Feb 2012 at 9:23 AM.
I am confused on how to now make the package. I am following the Pure Scripting Modding but I get lost when it asks to :
Open a text editor and paste the following:

<?xml version="1.0" encoding="utf-8"?>
<base>
<Current_Tuning>
<kInstantiator value="True" />
</Current_Tuning>
</base>

Of course you have noticed the kInstantiator variable from the code. Save the file. You can close the text editor now as you won't need it again.

and

Click on Ok, and then just like for the .dll file click on Grid and this time import the XML text file you created. S3PE will show the content of the XML resource in its preview window. Make sure that the content begins with an angle bracket and not with some unintelligible characters. That is a common error.

I dont have an XML file I have me .CS file and my .dll and my .DLL is in Bin/debug NOT bin/release

So then I tried the steps in the XML Tuning Modding and when I got here:
With your resource selected, click on the "Editor" button next to External. This should open it in Notepad, and it will look basically the same as what you saw in the "Examine" step - but now you can edit it to your liking.

Make whatever changes you would like to the XML. This tutorial can't really walk you through this part, since the changes and what you will want to change will be different for everything. The best way to learn is by trying things out and seeing how it works. Just make sure to follow the same basic format as the original.

Note: If you are very comfortable editing XML already, you can choose just selected tags to override and delete the rest from your package. If you don't know how to do that or what that means, don't worry about it.

I couldn't see how that would work.
Field Researcher
#63 Old 5th Feb 2012 at 4:36 PM
If you don't have the XML file, then you create one

The kInstantiator value is only to make sure that the scripting mod loads up correctly. You should really follow the tutorial for the object scripting tutorial first, and then once you successfully make a object mod then try and do a pure scripting mod.

Also the directory of your .DLL doesn't matter. The only reason why your DLL is in Debug folder is because you didn't set the solution to compile in Release mode.
Inventor
#64 Old 5th Feb 2012 at 9:55 PM
@Odistant

agree.
Lab Assistant
Original Poster
#65 Old 6th Feb 2012 at 5:37 AM
I need this for the XML file? Just open notepad ++ and copy past that into it and save it as JbobIntelligentButler?

<?xml version="1.0" encoding="utf-8"?>
<base>
<Current_Tuning>
<kInstantiator value="True" />
</Current_Tuning>
</base>

When I enter this into my script for the butler:

namespace JbobIntelligentButler
{
public class JbobIntelligentButler : Service, IAmCleaningService
{
[Tunable]
protected static bool kInstantiator = false;

static JbobIntelligentButler();
}
private static readonly string sLocalizationKey = "Sims3.Gameplay.Services".Substring(6).Replace('.', '/') + "/Butler";
private static string kButlerBook = "HowToServeAndNotBeServed";
[Tunable]

I get 40 new errors

Identifier expected, Type or namespace definition, or end of file expected, expected class, delegate, enum, interface or struct,
Field Researcher
#66 Old 6th Feb 2012 at 11:53 AM
Well you're trying to just copy and paste big portions of code that you see in reflector and then just renaming stuff. Of course your going to get errors. Reflector doesn't always decompile the code correctly, and you really do need some basic knowledge on coding in c#.
Lab Assistant
Original Poster
#67 Old 30th May 2012 at 5:45 AM
Quote: Originally posted by Odistant
Well you're trying to just copy and paste big portions of code that you see in reflector and then just renaming stuff. Of course your going to get errors. Reflector doesn't always decompile the code correctly, and you really do need some basic knowledge on coding in c#.


Not dead, life just came up and has slowed down my absorption of C#. I welcome more pointers and suggestions or tips on C#.

I Really want to thank you all who gave time and voice to this idea of mine. Thank you very much!!
Page 3 of 3
Back to top