View Full Version : Generating an NPC on demand in a residential lot
18th Sep 2011, 03:28 AM
I have an object I am working on (currently it has end table semi-globals) and this object is designed to be used on Community or Residential lots.
The idea is a playable sim goes to the object - runs a little ask anim - buys a food - walks away - consumes it - and thats it. I have a working simple food, the cash transaction works nicely with some anims, but I am struggling to get an NPC to appear. I don't actually need the NPC to DO anything - just to be there (in a specific spot - container slot can be arranged) as it looks a bit absurd having a whole transaction going on with no-one on the other end of it. I COULD just take em out, but it's cute and suits the object.
My concern is that I do want it to be placeable on a residential lot (well, actually, I want it to arrive on the lot - a bit like the schoolbus) but right now I am just looking at the NPC and I was not sure whether I would end up with an angry desperate NPC trapped in an object - which was not the vibe I really wanted.......
I can post the object if it is needed, and I am hoping for some very clear BHAV tips (CODE!! :rolleyes: ) as I am not a proficient BHAV modder and helpful hints like check in the thingy for the wotsit just baffle me and I would like to finish this in the near future.
Thank you for any help.
18th Sep 2011, 05:35 AM
You have a couple of options. You can repurpose one of the existing template NPCs, spawn them into the slot, and push an interaction on them. That way, if you have more than one of these objects on a lot then you'll get a different NPC on each of the objects. Playable sims can also interact with them, make friends with them, all the standard stuff you can do with templated NPCs. Your interactions will have to be a bit more complex to handle a sim coming and going though. You can find an example of this style of NPC in the High Rollers project Craps Table - http://modthesims.info/download.php?p=2057850#post2057850 . The croupier is a repurposed maid, dressedin the businesswear career outfit.
The alternative is to have a unique, 'shell' NPC. You can customize how they look using bodyshop, but they'll look like clones of each other if you place multiples on the same lot. You can treat them pretty much exactly like obects, as their motives are static and therefore not an issue. They can also have custom Function - Main code, if you need it, which gives you pretty much complete control over them. If you want your sims to converse with them, that's harder, and it's pretty much impossible for playable sims to form relationships with them. You can see an example of this type of NPC in the Carnival set Performing Clowns - http://modthesims.info/d/213108
Both options will require about the same amount of code to ensure that when the NPC gets removed from the lot on exit (the residential lot NPC problem) they get re-created on game start. That code's already written and ready to borrow though, so don't stress over that. :)
Let me know which of the two options you fancy, and I should be able to come up with some specific code for your mod (although you'll need to post it for that part!).
19th Sep 2011, 09:23 PM
Hi Echo, I am struggling on with this (just so you know I saw your post and am acting on it :) ) Its the stack object bit - it always makes my brain hurt. Current status is that I THINK I should go with the clown option. So far no sign of the clown in my object though. Its very dispiriting.
I have added a slot - and that works as a slot, and I have added the Make Clown BHAV. But I cant get it to RUN.... I thought to first get a clown to appear then make a more apt NPC. I will package up the object and attach.
EDIT: added object attachment. Just to add that I do have the clown in my downloads folder - I have three of them on podiums on my test lot - which is looking more absurd by the hour, as it is covered in clowns, fences, bookcases and doors.... Poor test sims.
20th Sep 2011, 01:19 PM
The main thing here is that it's a multi-tile object. That'll be making a lot of things harder on you. I've made a couple of changes (attached), but I haven't tested any of them yet.
20th Sep 2011, 02:51 PM
I ran a test on the object, bad news I am afraid :( When I loaded a lot with a van on it took a long time to load, very choppy camera etc very slow. I exited and entered a new lot. All was ok until I started to place the object - attached is the error log - too many iterations is what it said on screen.
22nd Jan 2012, 10:26 AM
I'm reviving the dead for a very specific reason. I create dolls to replace NPCs and was suggested that to spawn an NPC is the right way to go. I'm not agreed. All NPCs are buggy, they are programmed to do specific tasks that most of the time they are not even able to carry out. They get trapped in lots, they cause errors that cannot be corrected. They clog the hood with absolutely unuseful characters. The game respawn characters and keep old ones totally unused in the NPC's family. Self EA don't give correct termination for their NPCs. For example, the Landlord, absolutely uneccessary because he simply replaces the maid, the butler and the servo, gets trapped everytime he throws a party on a lot he got friend with the residents. The game includes and attribute that classifies the Landlord as "NPC invited to stay" and there's no code lines either in the game self or in custom mods that corrects this attribute. The Landlord simply cannot leave the lot. I suppose I am the only one that has an object to release the Landlord, otherwise you have to get an object mod that can zap it. The maid gets trapped and die in some lots because she is not able to go back to her carpool. Christian-Lov created an "All-in-One-NPC" that get errors if she doesn't spawn to work and the controller traps whatever Visitor present in the lot. It is an error that can only be corrected with deleting the controller and replacing it. It then creates another NPC that later will cause the same problem.
Controllers are invisible objects that gets trapped in lots without your consent or knowledgements. The EP apartments have dozens of unsolved problems that makes the EP heavy and difficult. The processes run by the controllers use almost the whole capacity of the computer with the only objective of spawning NPCs. If any of you still don't know, the process of spawning NPCs is a permanent routine that runs in the background as soon as you place an object supposed to spawn one. The process will run independently if the NPC is necessary or not, and when you have several loop routines to check what is going on with an NPC it will use all your computer resources and make the game slow and laggy.
A doll doesn't run any process and will not use any resource. It will be a simple contact "Real" sim to effective object routine. It would be much more effective if there was some local animations available to dolls instead of spawing NPCs. No service people execute more than a couple of animations. The bus driver for example does only 2 functions: horn and hurt your ears and turn the head in the direction of passenger, otherwise he has no other function in the game once he is absolutely, well, a doll.
What I have against NPCs? First of all the initials mean "Non-playables", so it should not be in a game that by my understanding, was meant to be "Played".
22nd Jan 2012, 08:38 PM
xptl297, I am not so sure this thread is the best place for such a rant. I am a little uncertain if this is meant to be trolling, but I will respond anyway for the sake of others. :)
As I understand the way the game works, playable Sims actually benefit from controllers too. Controllers can do a lot more than simply manage NPCs. All social interactions are managed through such invisible objects, which work continuously in the background. To hate controllers with extreme prejudice is to hate a vital gear in the game mechanics. Can you imagine a Sims game where all Sims could not interact with objects or each other?
I am not sure what you mean by "doll." Are you suggesting you want to simply replace a NPC (such as the bus driver) with an animated statue? That is essentially what EA does, but they use a stripped down instance of a "Sim" object such that it would look and move like any other person in the neighborhood.
All objects inside the game run continuous processes and take up computer resources, whether they are NPCs or decorative. This includes playable Sims, NPCs, and furniture. The dining room table you gave your Sims several generations has been running an "idle" process ever since the instance of this object was spawned via the Buy catalog. I do not know what your computer specs are, but for most people this is usually not a problem. More objects will naturally mean more resources, whether they are a doll, controller, or a NPC.
You can still play a game with NPCs. The simple fact there are NPCs present does not mean that the game is not meant to be played. I do not understand why you think this.
Everyone plays with the Sims differently and I do not know what your style of playing is. But I (and likely many others) would be overwhelmed if I had to control every Sim in the entire neighborhood at the same time. Any time one of my Sims died, I would then have to manually direct the Grim Reaper (who I have also been controlling all this time apparently) to send the Sim to their grave. The game could not be easily played this way and I do not know anyone who would enjoy it. Even The Sims 3 does not make you control every Sim in the entire neighborhood at the same time.
Fortunately, the game does take control over Sims not in my control. Any Sim not currently in my control is, in effect, a NPC. They are non-playable because I am not playing them at that particular time. They may be playables when I am controlling their household, but I may not always want to control their household. So they need to be controlled as NPCs to make them seem alive when not under my control. It would be creepy if all Sims were static, lifeless dolls when I am focusing on another family. There would be no response from them; it would be like my Sims were talking to a brick wall. Without controllers and social objects, my playable Sims would not even be able to interact with these lifeless shells anyway.
Personally, any mod that I have ever made which spawns a custom NPC deletes the instance of said NPC when it is no longer needed. I have (and likely will continue in the future) even added a special interaction to delete all my custom NPCs from the lot that I have spawned if they were not deleted for whatever reason. All work I have done with custom NPCs (publicly shared or for personal use) has a means to delete the NPC and does not assume the NPC is constantly present. The object which spawned the NPC either was an object which could be grabbed onto to then be deleted in Buy Mode or was a social object, which I have already explained works continuously in the background anyway.
Please, do not hate controllers or NPCs. They really do love you and are heartbroken to hear how you really feel about them. :)
vBulletin v3.0.14, Copyright ©2000-2013, Jelsoft Enterprises Ltd.