Jump to content

useful community scripts to start mods with


Guest Donkey

Recommended Posts

I think you don't need the remote container trick for that. It may make the problem more complicated, instead of making it simpler.

 

Just FYI, accessing remote container is very easy. You make a new cell (probably. actually it doesn't even need to be a new cell), place a container there. The point is putting it somewhere not normally seen. The container must be a persistent reference and must be given an usable EditorID. Then it's done. If you want to bring up the container menu for the player, it can be accessed by container_ref.Activate Player.

 

The problem is, each npc needs his own container. And there are over 1000 persistent npcs in vanilla game. So, it is not a viable option when dealing with many, anonymous npcs.. unless you got an idea to get around this problem.

(I don't think this is an entirely impossible idea, by the way. After all, you don't need to worry about all of them at the same time. But still I would not recommend it. There are more elegant ways.)

 

I had written a lengthy sample script on how to perform a while loop days ago, it used arrays and looping because they're effective and powerful. But it's neither the only way, nor the easiest way.

What I'm proposing here is ridiculously simple.

 

if npc_just_fell_asleep
    if (npc.GetItemCount Brassiere) == 0
        npc.AddItem Brassiere, 1
    endif
    if (npc.GetItemCount Panties) == 0
        npc.AddItem Panties, 1
    endif
    npc.EquipItem Brassiere
    npc.EquipItem Panties
elseif npc_just_woke_up
    restore_npc_clothings_somehow
    maybe_remove_underwears_too
endif
See, easy. Unless you have hundreds of different brassieres and panties that is.

Otherwise, if you really need to accurately restore the npc's previous clothings of potentially many npcs at the same time, you should become comfortable with arrays.

 

Let me show you a very useful code template that you will use thousands of times if you continue this scripting business. Let's say, this is a quest script. Quest script is good and easy to handle, because it just always run no matter what.

Let someone := GetFirstRef 35, 1
while someone
    if some_condition_is_true
        do_something_on_someone
    endif
    Let someone := GetNextRef
loop
What this does is, to cycle through all npc-type references near PC. This is almost essential when dealing with massive npcs. FYI, the 'old' AutoSetBody.esp from SetBody Reloaded (still downloadable) does this same thing. Its main quest script consists of effectively just one large "while" clause.

 

And this should prove useful for your purpose, too. You can replace the "some_condition_is_true" part with that GetSleeping thing. And it should let you perform the above additem/equipitem thing inside of this "if" clause.

Link to comment

Movomo-  Once again, thank you for your assistance.  Those templates will be handy.

 

And, yes, I have thought of a workaround.  Most NPCs won't need much work.  Armoured, random NPCs (bandits, marauders, etc.) can be solved just by removing/substituting clothing from their personal inventory and giving them a Sleep package.  Though a few already have one I think.  I recall in Dznot Cave that there's several NPCs that take naps at random; I sneak up and axe them when they do. :ph34r:   Same for guards, since they don't change until they go to sleep anyways.  Townsfolk can use the containers in their homes (your Vilja reference, BTW, I'm researching thouroughly, here.  Sexy Maid of Chorrol as well), which makes it fun for substitution.  It's just wandering NPCs that need the extra touch.  Mods like Roaming NPCs -from Nexus, and the like.  Plus unarmoured NPCs -necromancers, conjurers, etc.

 

The trick, I've found, is making it so that the NPC clears their clothing inventory no matter what it is.  Thus, if players use, say, inventory replacer mods, or just plain rob or switch the NPC's clothes, the script still works.  Also, I'm working on a mod where the NPC changes clothes for certain events/days/travels, etc.  Which can and will screw up without a general, all-encompassing script.

 

 

BTW, can creatures sleep?  I haven't seen any animation files for such, and their packages don't include anything like.

 

Totally irrelevant question, I know.  But I was having an idea regarding a quest that might use this, using Lovers Creatures.

Link to comment

Whoa! I wish I discovered this conversation much earlier.  I just spent an embarrassing number of hours (days/weeks), from reading the obse doc and cs wiki to trying and testing things, in order to cobble together a mod <plug>"Set Outfit"</>.  Then, Movomo, you just casually post a solution to a problem that I went round and round on.  I shutter at the thought of how quickly you would have made this thing I spent so long on; not mention, how much better or optimized it would be.  Now I have a strong feeling (and a little fear) you already have scripted something similar for simply testing your real mods.  :unsure:  *sigh*

 

Seriously, Movomo, I'm just really impressed, that's all. *bows*

 

edit: a word

Link to comment

That actually does cheer me up a bit.  :P
 
If you don't mind, I'd like to get your thoughts then.  My script unequips the NPC's items using the NoEquipFlag and equips new items with NoUnequipFlag. I was wondering what kind of problems you've seen or would expect to see with this method, especially with companions.  I've only used MCS, which works fine, but it's not as AI or script complex as others. 

 

Thanks.

Link to comment

Ah.

People don't praise other people for no reason. I see that now (grin)

 

I have to bite then. But it's tough to tell. I don't think your mod would screw too many other mods, but chances are that those other mods might screw up yours instead. Simply because they still can equip/unequip stuff anyway no matter the flags are set or not. Imo, you shouldn't expect that your npc would keep his chosen equipments forever. You must suspect and watch them.

 

Also, MCS does not rely on script commands for switching companions' armor/clothing state, but MPC does. Don't know about CSR or CM. I don't use them. And even if a companion mod doesn't normally perform scripted equip/unequip, it has to handle the tail slot, one way or another. Tail slot is most likely scripted.

 

If the author of some companion mod decided to implememt some sort of situation-specific equipment feature, that could be a problem too. Can't tell you what mod does it but it's very possible such mods are out there. Something like, Vilja perhaps? Or 'sleeping equipment for npcs' type mod, which was discussed just one page back.

 

Break Armor and Tamago Setbody may screw up. Both of them forcibly unequips random npcs. Sometimes simply by unequiping it, sometimes by destroying the inventory reference.

 

Other than that I have no idea.

Link to comment

It's the burden of the praiseworthy. ;) okay, I'll stop here with the hero-worship before it gets more uncomfortable and awkward

 

Screwing up my mod is the preference since the nature of it is just to have fun with it.  I try to be a minimalist when possible.  So I made an option to do a passive daily refresh of the outfit, but not anything actively keeping it equipped.  I did consider adding a sleep outfit option, but I wasn't ready for the leap into activators just yet.  Also, I don't know how resource heavy event handlers are, which goes back to the minimalist thing. 

 

For companions, I guess I'll just have to wait for people to give feedback.  What about the tail-thing though?  I don't really know much about the issues with it?  I've seen some posts about tails disappearing I think with cloaks or backpacks, but I'm not sure what/why special care needs to be done.  It didn't seem like anything I had to worry about, unless equipping playable clothing/armor on that slot is common (or not unusual).

 

I did see a rather odd thing when testing with Tamago Setbody.  I went to an inn, The Oak and Crosier in Chorrol, and set the same outfit on several NPCs, including one that was "with child."  I left the cell (or reloaded the game) and when I came back every NPC with that outfit was wearing maternity clothes even though FormID Finder reported them wearing the items in the outfit.  I get that Tamago Setbody does some forcing of things, but why it only affected that cell was the real mystery to me.  Other NPCs wearing that outfit that were outside the inn were fine.  That isn't a scenario I'm going to address, but leave up to the user to not redress pregnant NPCs.  Hmm, now I wonder if that also happens when an npc gets pregnant after being outfitted. Ugh!

Link to comment

NPCs don't normally wear tail slot items. Tail slot is not meant to be used as a clothing slot so they just ignore them. That's why companion mods manually equip tail slot using script commands. And, scripted equipping/unequipping may not be good for you because it ignores equippable flag.

 

The 'everyone go pregnant' issue with tamago setbody is a known bug and unfixable unless I switch to blockhead way. Right before you enter a cell that was not previously loaded, everyone except you is actually kind of naked. They wear their clothings when you enter. If one of them is actually pregnant, then tamago setbody swaps its global female mesh path. The changed mesh path is reverted back after 1 or so frames (varies). But it's already too late.. because everyone with the same outfit wore it when it looked like a preggo version.

Link to comment

NPCs don't normally wear tail slot items. Tail slot is not meant to be used as a clothing slot so they just ignore them. That's why companion mods manually equip tail slot using script commands. And, scripted equipping/unequipping may not be good for you because it ignores equippable flag.

 

The 'everyone go pregnant' issue with tamago setbody is a known bug and unfixable unless I switch to blockhead way. Right before you enter a cell that was not previously loaded, everyone except you is actually kind of naked. They wear their clothings when you enter. If one of them is actually pregnant, then tamago setbody swaps its global female mesh path. The changed mesh path is reverted back after 1 or so frames (varies). But it's already too late.. because everyone with the same outfit wore it when it looked like a preggo version.

Blockhead still won't fix that unfortunately as the mesh path is still changed globally for a second.

Link to comment

Back with another question.

 

What would be a good script to attach to a topic that would cause two NPCs to go off somewhere and have sex?  No packages.  Just a script attachment to a silent (if I can't find useful voice files)topic.

 

For example, two stable hands who wander around doing chores but speak to each other every so often, suddenly go off into one of the stalls for a quick one.  Or a prostitute who occasionally services a client while doing her rounds, going to a discreet spot each time to do so.  I want to activate both types with a conversation topic script and a random percentage generator.

 

I was digging around in both Gweden Brothel and Lovers Situations, and I noticed that SItuations uses a discussed script for initiating sex, and read the discussion in the supporting thread:

 

 set xLoversQuest.Offense to Player

 set xLoversQuest.Defense to GetSelf

 Player.Call xLoversCBStartSEXonBedR N

 

What I need is to figure out how to get this to work between two NPCs -Can it be done generally, or does it need to be tailored specifically to each NPC's ID?- and to cause the instigator to walk to the location while the other follows.  Setting a marker for the instigator to go to is simple, but the scripts I've tried either just teleport the couple there or just the instigator.  AI packages are also getting in the way and I don't want to change them if I don't have to.

 

 

"Two dragons walk into a tavern.  The first dragon says: 'Hot in here, isn't it?'  The second dragon turns to him and says: 'You shut your mouth!'"

-Bandalo the Fool

 

Link to comment

It is possible to initiate sex with a topic's result script. But you can't get away from the packages if you want to get an npc walk by an inch.

The implementation may vary depending on whether your npcs are anonymous or just some pre-defined ones. Anonymouse npcs always make things more complicated. But it can be done... probably. You can find some example scripts in the lovers adult play plus for SSP plugin. It gives a scripted token to the npcs, and the token forcibly applies a follow package so he will follow you around  after/before sex and initiate conversation with you.

Link to comment

Thanks Movomo.  I was hoping tokens wouldn't be necessary, since I was told in another forum that the more tokens and containers you use, the more bloat in the savegame; plus apparently the more and more tokens used the less and less stable the game becomes.  Not something I want to push.  Which is why I'm rethinking the container thing we talked about in an earlier post.  :s

 

On top of that is the fact of filling up the inventory with tokens.  I could use additem/removeitem, but I'm told that causes bloat and instability too.

 

Also, I've noted that changing AI packages makes it a pain for changing anything else about an NPC later, like faces.  I found this as I was going through Lovers Situations -a great mod, but it works badly with mods like Gweden Brothel, since it uses some of the same NPCs and by changing the AI packages causes a conflict, and consequently a CTD no matter the load order. Plus LoversSituations immediately wiped out my face replacer mod, which caused quite a shock when Rohssan suddenly went back to vanilla looks when I loaded up a savegame that had her facing me in the buff. 

 

I sleep with the light on now. But my therapist says after a few more sessions we should be able to stop the spontaneous bouts of screaming.  :blink:

 

The face thing can be dodged with a bash patch, or TES4Edit I'm told (though I haven't found out how to do that yet), but I thought that a resetting quest script might remove the need to add or change packages or tokens.  Topic result scripts worked fine in testing, except for that annoying teleporting problem (Test 3 zapped them straight across the whole of the IC Waterfront from the lighthouse, for example.  I haven't seen anyone move that far and fast for sex since high school.  :huh:) 

 

I thought I was missing something with MoveTo or such.

 

 

 

"How many Redguards does it take to change a candle? 

One, but only after he's fought the other nineteen to the death for the glory and honour of it."

 

-Bandalo the Fool

 

 

 

Link to comment

What's save game bloat... should any slightest increase in the save file size be called bloat, yes tokens and containers are save-bloaters. But then pretty much anything causes save game bloat. Even simply playing the game for a minute or two bloats your save file. You should not go out and explore the world because generated bandit references will bloat your save game...

When they are a neccessary change to get your mod working and can be removed easily, it's not bloat. The real bloat happens when you spammed cloned objects / string variables / etc, AND forgot to destroy them afterwards. You CAN spam thousand clone objects and ten thousands of strings as long as you remove them at some point. Besides, tokens aren't even cloned objects. As soon as you remove the mod from your load order they disappear as if nothing happend.

 

With tokens you can bypass that npc face issue because you won't make any changes on the npc reference itself. The reason why token is necessary is because you somehow must watch the npc, constantly.

Ability spells work similarly, but it becomes unreliable once the npc is in a different cell than yours. Quest script can be used too, but it might be a too much hassle to get a quest script to manage 100 npcs. So we use tokens. It's a kind of fire and forget way.

Link to comment
  • 3 weeks later...

Is it possible to create new custom traps in Oblivion? I wanted to add ambushes like loverscrime but triggered by trap instead (sort of like furogenerator, but that uses oblivion's mines iirc).

 

Say the trap moves a monster from a holding cell to the player and then back home after the monster's assaulted the pc. I can only get the trap to fire once and then it doesn't work anymore, anywhere.

Link to comment

Is it possible to create new custom traps in Oblivion? I wanted to add ambushes like loverscrime but triggered by trap instead (sort of like furogenerator, but that uses oblivion's mines iirc).

 

Say the trap moves a monster from a holding cell to the player and then back home after the monster's assaulted the pc. I can only get the trap to fire once and then it doesn't work anymore, anywhere.

 

The Lost Spires lets you have a working portable bear trap. Perhaps you could examine how it's done. I don't see anything really special there compared to the vanilla traps, though.

 

If you want to rearm the traps, you should reset it somehow, one way or another.

 

Your idea sounds like it doesn't really need to be a normal "trap" because you're not going to do damage or anything. It just needs the onTriggerMob block to catch the moment when someone enters a certain area. You could just reset all variables once the ambush attack is done, or maybe after a couple of days? Normally it should be automatically reset when the cell resets though. I'm not sure why it's not resetting itself.

Link to comment

I'm back with more clothes changing questions.

 

I'm looking into changing Hiyoko clothes as early as possibly after birth.  Is this right way to setup the eventhandler (assume there is a precheck that the mod is loaded) :

Call a4hccSetEventHandler "OnBirth" myfunction

I was wondering how cautious I should be using an "OnBirth" eventhandler since there are a lot of other mods that hook into this.  It hurts my brain thinking how this could work and not screw up the hiyokogenerator.

Do I have to do any cleanup after that? Like an "OnDeath"?

If there's too much conflict potential should I just run a quest script periodically to check for new Hiyoko?

Sorry for the barrage of questions.

 

Edit:

@Comrade Flenyx

In general, there aren't hard one-size-fits-all rules.  IMO, breaking up code mostly serves to make it easier on the programmer (and those who try to decipher it later). Separating code makes it more readable, easier to test, and allows reuse like in a function call.  That last one is probably the most important, especially when the scripts allow others to call those functions as well.  I have the (bad) tendency to write just one long script.  I eventually will come back to blocks of code that clearly perform isolated tasks and put them in functions.  It does make tracing bugs a bit easier (I guess), but it also lets me walk through the logic flow in my head more quickly.  I can think "this function call does this long calculation and this other one processes the result" and skip what each individual line of those functions does. 

 

Now here's big HOWEVER.  However, OBSE and CS have nuances that I have yet to wrap my head around. For instance, eventhandlers have to have a function to call, I think ( see how I have question(s) about them in this post).  So this is where it crosses from "in general" to what is necessary in specific cases.

 

TL;DR: Do whatever makes it easier for you

Link to comment

@Iamnoone

 

Yes you should be cautious. Not because of hiyoko generators though, but because of others. Hiyoko generators don't use OnBirth event.. there are special "generator" type events specific to hiyoko-spawning purpose.

 

As far as I can remember right now, (currently) hiyoko shooter and hiyoko futuredream are the listeners to the onBirth event. It's a very useful event, I see alot of reasons to use it, so it may be better to be prepared even for unknown or future listeners.

 

Hiyoko futuredream will be ok. I wrote it and I don't think I was messing with any equipment. But hiyoko shooter can be a problem. Or not.

You see, you can give them any equipment any time, but you don't want to actually 'equip' them during sex. Perhaps you could wait until sex animation (with mom) ends... in case hiyoko shooter becomes a problem.

Link to comment

@iamnoone - thanks, that helps clear up doubts I was having. My question was pertaining to a compilation combat mod I'm putting together. It includes SM EncAndFatigue, SMCombat Hide, SM Regional Bounty and Unequip Broken Armor. I've set them all to use the same ini, game start quest and associated script, and made sure to properly rename what needed to be changed. They all work as intended.

Link to comment

It is still IMO a best practice to comment your code and/or any INI files. I typically start with a description right under the header to the INI or code file. That is also where I maintain a version history and my LL ID. I then comment the snot out it; both INI and scripts. Helps me to remember exactly what I altered or added, especially in the case of reusing/re-engineering someone else's script or INI.

Link to comment

I did that. The scripts had nice headers and comments in them, and the inis had nice descriptions as to what the variables do, so I left it all in. Copied it all over and renamed a few things, all in the proper areas. Still adding and tweaking a few things. No horse riding or dual weild though. Makes it more compatible with OR for those that use the same options. It will have throwing though.

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use