Min1ons Posted April 20, 2011 Share Posted April 20, 2011 Ok, heres the problem, I am making a MOD that allows you to spawn things (NPC's) and after you spawn to many, it starts to lag or they get in your way.So what I want to do is make a choice that says "delete all NPC's"if anyone can help by showing me how to delete things using scripts, i could use it. :wallbash: Link to comment Share on other sites More sharing options...
devinpatterson Posted April 20, 2011 Share Posted April 20, 2011 (edited) Ok, heres the problem, I am making a MOD that allows you to spawn things (NPC's) and after you spawn to many, it starts to lag or they get in your way.So what I want to do is make a choice that says "delete all NPC's"if anyone can help by showing me how to delete things using scripts, i could use it. :wallbash: Wouldn't that be disable? For instance you have npcX, npcY and npcZ. They start getting in your way so your script would have a choice that says "delete all NPC's" then the script would be npcX.disablenpcY.disablenpcZ.disable Edited April 20, 2011 by devinpatterson Link to comment Share on other sites More sharing options...
agoon12 Posted April 20, 2011 Share Posted April 20, 2011 (edited) Wouldn't that be disable? For instance you have npcX' date=' npcY and npcZ. They start getting in your way so your script would have a choice that says "delete all NPC's" then the script would be npcX.disablenpcY.disablenpcZ.disable [/color'] This would work perfectly, if you had a limited quantity of NPCs of which you just decide which ones to be active and which ones not to be active.As far as I understood, you are "spawning" NPCs, so you're using the .placeatme command. If that is so, then you should not only disable you NPCs but also mark them for delete, this helps keeping your savegames small in size and is the more elegant way of disposing NPCs. (Well, actually it's the only way of really disposing them!) So, I would suggest:npcY.disablenpcY.markfordeletenpcX.disablenpcX.markfordeleteand so on. This actually is quite important on terms of performance...Check this out, too: http://geck.bethsoft...p/MarkForDelete Edited April 20, 2011 by agoon12 Link to comment Share on other sites More sharing options...
PaladinRider Posted April 20, 2011 Share Posted April 20, 2011 I apologize for threadjacking but I had a quick question regarding MarkForDelete. Suppose I have an Xmarker as a parent ref. I've got 5 NPC children to the xmarker parent. Obviously when you enable/disable the parent, the children will follow. If I disable AND markfordelete the Xmarker Parent ref, I know the children will be disabled, BUT will they also be marked for delete? This could also be useful for the OP if it works. If you are spawning groups of NPCs, it may be helpful to have them all enabled to a parent. Then instead of NPCX.disable NPCX.markfordelete NPCY.disable NPCY.markfordelete Etc for every NPC Could you instead do ParentRef.disable ParentRef.markfordelete Link to comment Share on other sites More sharing options...
Min1ons Posted April 20, 2011 Author Share Posted April 20, 2011 Ok, you guys say NPCx and NPCy. What does the X and Y mean or stand for? Link to comment Share on other sites More sharing options...
PaladinRider Posted April 20, 2011 Share Posted April 20, 2011 (edited) That's the reference names of the NPCs you want to be deleted. "NPCX" would be the reference name (with persistent reference checked!) of a single NPC. Like agoon12 mentioned, it's probably better if you're dealing with limited number of NPCs. Edited April 20, 2011 by PaladinRider Link to comment Share on other sites More sharing options...
agoon12 Posted April 20, 2011 Share Posted April 20, 2011 (edited) I'm not a hundred percent sure, but I doubt that this works. If you address a parent ref with anything else then .enable or .disable it does not immediately affect all the children. More precisely, with your setup, if I call .kill on the parent ref, the children won't be affected by this. So I guess .enable/.disable has a somewhat special status concerning parenting. I'll figure that out tomorrow. Quite an interesting question, though. But it reminds me of the reasons for NOT using ".placeatme"...The only occasions I use .placeatme is for fighting sequences, to spawn enemies... but then I just drop a tiny script on each of them, like this: begin ondeath disable markfordelete end Works fine for me! ;) Edit: Yeah, the "npcX" is just any name. Could be "StupidName102" or anything. (Except for names starting with numbers, the scripting engine doesn't really like those...) Edited April 20, 2011 by agoon12 Link to comment Share on other sites More sharing options...
Min1ons Posted April 20, 2011 Author Share Posted April 20, 2011 Ok you guys, I am using a terminal script, not an overall script.So what my goal is, is to make a button on the terminal that allows you to kill all placed NPC's, and delete them.I have already made some things that look like this... (NPC).Disable(NPC).MarkForDelete And nothing happens! But then I made one that looks like... (NPC).MarkForDelete And instead the terminal gets deleted!!! Does anyone understand this? Link to comment Share on other sites More sharing options...
agoon12 Posted April 20, 2011 Share Posted April 20, 2011 Well, how do you place the NPCs? Do you use .placeatme? And just as a side note: never use numbers or symbols at the beginning of reference names. The scripting engine hates 'em. Link to comment Share on other sites More sharing options...
Min1ons Posted April 20, 2011 Author Share Posted April 20, 2011 Yes, I use "placeatme" and as you did, I have given them to MarkForDelete upon death. But what im wanting is to have something that allows the player to choose when the NPC's are deleted. Link to comment Share on other sites More sharing options...
Recommended Posts