Jump to content

useful community scripts to start mods with


Guest Donkey

Recommended Posts

Hello all,

I've been working on a modification of a mod (which in itself was modified from the original by Aridale), available here: http://www.nexusmods.com/oblivion/mods/46133/?
The point is to change the speed of weapons based on weight and player speed stat,tthen agility for one-handed, strength for two-handed. As it is, the mod does this:

 

If the weapon meets the criteria for modification (is not bound weapon, hand to hand, or specially defined with the .00000012 at the end of the weight), then create a copy of the weapon with all its attributes (weapon health, weight, enchantments, etc). Go through the checks for speed and agility or speed and strength depending on weapon type, apply modifiers to weapon speed, make this the new weapon speed, then remove the original weapon and add the new modified weapon to the player's inventory and equip it.

 

I feel as though this is an inelegant way of going about the process, but I know very little about the workings of the Oblivion/Gamebryo engine. I just have my experience from going through others' scripts and editing them, and some Java/C++.

One person has tested my version of the mod and said it doesn't work for them, but they said they would get back to me with testing it on an unmodded installation. Aridale (original mod) and Offkorn's (one I edited) versions also don't work for them, so I wonder what it is that's causing that. :/

 

If anyone can direct me to how to do this properly, the help would be very appreciated! I've attached the two main scripts as text files. ANBDWSMainSct is the player one; MiscTokenSct is the NPC one. There is also an AOE spell that gives NPCs scripted tokens and applies the weapon speed effect to all NPCs around the player.

 

So far I've noticed a few potential pitfalls: one, that there's no uninstall function (though that can be added fairly easily I believe...should just be typing a console command to set an uninstall quest stage, whose script applies the inverse of the weapon speed script to all weapons that have been modified. Of course, the problem there is that it will only apply to those who are in the area/the current cell, I believe. Another problem is that I don't believe it will update if the player's stats change (although I haven't verified this).
My brother said that the weapon speed modifier could be set up as a scripted enchantment, but I believe that comes with its own problems.

 

Thanks

Razzy

ANBDWSMainSct.txt

ANBDWSMiscTokenSct.txt

Link to comment
  • 9 months later...

I'm trying alter or make improvements to a code snippet as follows:

 

 

 

 

If player.GetKnockedState == 0
   player.removespell aaMrPGetup
   If GetRandomPercent < 0.000000001
    If GetRandomPercent < 15
     player.addspellNS aaMrPFeint
    EndIf
   EndIf
  ElseIf Player.GetKnockedState == 1
   player.removespell aaMrPFeint
   player.addspellns aaMrPGetup
  EndIf

 

 

 

I think what I'm looking for is a timer or timed function, instead of the GetRandomPercent. The feinting is the functionality I'd like to further work with, but as it is structured currently is happens too quickly; you get this up and down action. What I want to produced is a longer or prolonged feint (GetKnockedState == 1) based on a set or variable number of seconds.

 

Any ideas?

Link to comment

I'm trying alter or make improvements to a code snippet as follows:

 

 

 

 

 

 

If player.GetKnockedState == 0
   player.removespell aaMrPGetup
   If GetRandomPercent < 0.000000001
    If GetRandomPercent < 15
     player.addspellNS aaMrPFeint
    EndIf
   EndIf
  ElseIf Player.GetKnockedState == 1
   player.removespell aaMrPFeint
   player.addspellns aaMrPGetup
  EndIf

 

 

I think what I'm looking for is a timer or timed function, instead of the GetRandomPercent. The feinting is the functionality I'd like to further work with, but as it is structured currently is happens too quickly; you get this up and down action. What I want to produced is a longer or prolonged feint (GetKnockedState == 1) based on a set or variable number of seconds.

 

Any ideas?

 

Try this:

 

 

float timer
begin gamemode
if player.GetKnockedState == 0
  if player.HasSpell aaMrPGetup
    player.removespellns aaMrPGetup
  endif
  set timer to timer + GetSecondsPassed
  If timer > 3.0 ;(or whatever)
    set timer to 0.00
    player.addspellNS aaMrPFeint
  EndIf
else
  if player.HasSpell aaMrPFeint
    player.removespellns aaMrPFeint
    player.addspellns aaMrPGetup
  endif
endif

 

Link to comment

@ Supierce - Thanks! That's now working close to what I intended; a prolonged feint. I think I just need to further adjust the two spells, aaMrPGetup & aaMrPFeint magnitudes a bit more. The original MOD author had them at 9999999 for Restore Fatigue & Damage Fatigue, resulting in Fatigue being in the +/- millions and counting up or down! I've lowered those to 999 each but I think I can go even lower yet.

 

Next question. Should I replace the Begin ScriptEffectStart and Begin ScriptEffectUpdate at the top of the script with a begin gamemode? I didn't include the begin gamemode in the code snippet as I usually only see those at the top or beginning of a script. Here's the entire script with the new edits. Note that the two commented out variables at the top I did in a previous edit, as they are not being used in the script and it was never compiled! I get the impression it was a 'work-in-progress'.

 

 

 

scn aaMrPSpaceCakeScript
short ths
short FOV
float timer
short MDoOnce
;short FeintVar
;float timer2
Begin ScriptEffectStart
If Weedstrain > 0
  set timer to 0
  Message "I'm not feeling anything yet, I need to wait"
EndIf
End
Begin ScriptEffectUpdate
set timer to timer + scripteffectelapsedseconds
If timer > 150 && timer <= 450 && SpaceCakeEaten == 1
  If Weedstrain == 1
   triggerhitshader 0.25
   con_setCameraFOV 110
   set ths to 0.25
   set FOV to 110
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 2
   triggerhitshader 0.35
   con_setCameraFOV 115
   set ths to 0.35
   set FOV to 115
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 3
   triggerhitshader 0.30
   con_setCameraFOV 110
   set ths to 0.30
   set FOV to 110
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 4
   triggerhitshader 0.35
   con_setCameraFOV 115
   set ths to 0.30
   set FOV to 100
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 5
   triggerhitshader 0.45
   con_setCameraFOV 90
   set ths to 0.4
   set FOV to 90
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 6
   triggerhitshader 0.4
   con_setCameraFOV 95
   set ths to 0.4
   set FOV to 95
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 7
   triggerhitshader 0.35
   con_setCameraFOV 120
   set ths to 0.35
   set FOV to 120
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 8
   triggerhitshader 0.45
   con_setCameraFOV 95
   set ths to 0.45
   set FOV to 95
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 9
   triggerhitshader 0.30
   con_setCameraFOV 115
   set ths to 0.25
   set FOV to 115
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 10
   triggerhitshader 0.17
   con_setCameraFOV 125
   set ths to 0.17
   set FOV to 125
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  EndIf
ElseIf Timer > 450 && Timer < 550
  If SpaceCakeEaten == 1
   set FOV to FOV - 10
   triggerhitshader (ths/2)
   con_setCameraFOV FOV
   If MDoOnce == 1
    Message "Hmm the effects are starting to wear off a little"
    set MDoOnce to 0
   EndIf
  EndIf
ElseIf Timer >= 550
  If SpaceCakeEaten == 1
   set FOV to FOV - 20
   triggerhitshader (ths/3)
   con_setCameraFOV FOV
   If MDoOnce == 0
    Message "Starting to get pretty clear again"
   EndIf
  EndIf
;Had too much spacecake
ElseIf timer > 150 && Timer <= 450 && SpaceCakeEaten > 1
  If MDoOnce == 0
   Message "I think I overate the spacecake..."
   set MDoOnce to 1
   player.addspellNS aaMrPSpaceCakeOverate
  EndIf
  If player.GetKnockedState == 0
   if player.HasSpell aaMrPGetup
        player.removespellns aaMrPGetup
    endif
     set timer to timer + GetSecondsPassed
    If timer > 3.0 ;(or whatever)
       set timer to 0.00
       player.addspellNS aaMrPFeint
    EndIf
else
    if player.HasSpell aaMrPFeint
       player.removespellns aaMrPFeint
       player.addspellns aaMrPGetup
    endif
endif
  If Weedstrain == 1
   triggerhitshader 0.15
   con_setCameraFOV 90
   set ths to 0.25
   set FOV to 110
  ElseIf WeedStrain == 2
   triggerhitshader 0.20
   con_setCameraFOV 90
   set ths to 0.35
   set FOV to 115
  ElseIf WeedStrain == 3
   triggerhitshader 0.20
   con_setCameraFOV 90
   set ths to 0.30
   set FOV to 110
  ElseIf WeedStrain == 4
   triggerhitshader 0.25
   con_setCameraFOV 95
   set ths to 0.30
   set FOV to 100
  ElseIf WeedStrain == 5
   triggerhitshader 0.30
   con_setCameraFOV 80
   set ths to 0.4
   set FOV to 90
  ElseIf WeedStrain == 6
   triggerhitshader 0.25
   con_setCameraFOV 85
   set ths to 0.4
   set FOV to 95
  ElseIf WeedStrain == 7
   triggerhitshader 0.25
   con_setCameraFOV 100
   set ths to 0.35
   set FOV to 120
  ElseIf WeedStrain == 8
   triggerhitshader 0.25
   con_setCameraFOV 85
   set ths to 0.45
   set FOV to 95
  ElseIf WeedStrain == 9
   triggerhitshader 0.15
   con_setCameraFOV 95
   set ths to 0.25
   set FOV to 115
  ElseIf WeedStrain == 10
   triggerhitshader 0.10
   con_setCameraFOV 110
   set ths to 0.17
   set FOV to 125
  EndIf
ElseIf Timer >= 599
  set Weedstrain to 0
  con_setCameraFOV 75
  player.removespell aaMrPSpaceCake
  player.removespell aaMrPSpaceCakeOverate
EndIf
End
Begin ScriptEffectFinish
set Weedstrain to 0
con_setCameraFOV 75
Player.RemoveSpell aaMrPSpaceCake
set SpaceCakeEaten to 0
MrPSpellcaster.MoveTo Player
MrPSpellcaster.cast aaMrPMunchiesSpell Player
MrPSpellcaster.MoveTo CookMuffinHome
End

 

 

 

The next goal will be to make my PC susceptible to H (due to player.GetKnockedState == 1, and both passive and/or aggressive H) via Lovers MODs, like WappyOne's RaperS  and others.

Link to comment

@ Supierce - Thanks! That's now working close to what I intended; a prolonged feint. I think I just need to further adjust the two spells, aaMrPGetup & aaMrPFeint magnitudes a bit more. The original MOD author had them at 9999999 for Restore Fatigue & Damage Fatigue, resulting in Fatigue being in the +/- millions and counting up or down! I've lowered those to 999 each but I think I can go even lower yet.

 

Next question. Should I replace the Begin ScriptEffectStart and Begin ScriptEffectUpdate at the top of the script with a begin gamemode? I didn't include the begin gamemode in the code snippet as I usually only see those at the top or beginning of a script. Here's the entire script with the new edits. Note that the two commented out variables at the top I did in a previous edit, as they are not being used in the script and it was never compiled! I get the impression it was a 'work-in-progress'.

 

 

 

scn aaMrPSpaceCakeScript
short ths
short FOV
float timer
short MDoOnce
;short FeintVar
;float timer2
Begin ScriptEffectStart
If Weedstrain > 0
  set timer to 0
  Message "I'm not feeling anything yet, I need to wait"
EndIf
End
Begin ScriptEffectUpdate
set timer to timer + scripteffectelapsedseconds
If timer > 150 && timer <= 450 && SpaceCakeEaten == 1
  If Weedstrain == 1
   triggerhitshader 0.25
   con_setCameraFOV 110
   set ths to 0.25
   set FOV to 110
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 2
   triggerhitshader 0.35
   con_setCameraFOV 115
   set ths to 0.35
   set FOV to 115
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 3
   triggerhitshader 0.30
   con_setCameraFOV 110
   set ths to 0.30
   set FOV to 110
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 4
   triggerhitshader 0.35
   con_setCameraFOV 115
   set ths to 0.30
   set FOV to 100
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 5
   triggerhitshader 0.45
   con_setCameraFOV 90
   set ths to 0.4
   set FOV to 90
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 6
   triggerhitshader 0.4
   con_setCameraFOV 95
   set ths to 0.4
   set FOV to 95
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 7
   triggerhitshader 0.35
   con_setCameraFOV 120
   set ths to 0.35
   set FOV to 120
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 8
   triggerhitshader 0.45
   con_setCameraFOV 95
   set ths to 0.45
   set FOV to 95
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 9
   triggerhitshader 0.30
   con_setCameraFOV 115
   set ths to 0.25
   set FOV to 115
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  ElseIf WeedStrain == 10
   triggerhitshader 0.17
   con_setCameraFOV 125
   set ths to 0.17
   set FOV to 125
   If MDoOnce == 0
    Message "Now I'm starting to feel something!"
    set MDoOnce to 1
    set SpaceCakeEaten to 0
   EndIf
  EndIf
ElseIf Timer > 450 && Timer < 550
  If SpaceCakeEaten == 1
   set FOV to FOV - 10
   triggerhitshader (ths/2)
   con_setCameraFOV FOV
   If MDoOnce == 1
    Message "Hmm the effects are starting to wear off a little"
    set MDoOnce to 0
   EndIf
  EndIf
ElseIf Timer >= 550
  If SpaceCakeEaten == 1
   set FOV to FOV - 20
   triggerhitshader (ths/3)
   con_setCameraFOV FOV
   If MDoOnce == 0
    Message "Starting to get pretty clear again"
   EndIf
  EndIf
;Had too much spacecake
ElseIf timer > 150 && Timer <= 450 && SpaceCakeEaten > 1
  If MDoOnce == 0
   Message "I think I overate the spacecake..."
   set MDoOnce to 1
   player.addspellNS aaMrPSpaceCakeOverate
  EndIf
  If player.GetKnockedState == 0
   if player.HasSpell aaMrPGetup
        player.removespellns aaMrPGetup
    endif
     set timer to timer + GetSecondsPassed
    If timer > 3.0 ;(or whatever)
       set timer to 0.00
       player.addspellNS aaMrPFeint
    EndIf
else
    if player.HasSpell aaMrPFeint
       player.removespellns aaMrPFeint
       player.addspellns aaMrPGetup
    endif
endif
  If Weedstrain == 1
   triggerhitshader 0.15
   con_setCameraFOV 90
   set ths to 0.25
   set FOV to 110
  ElseIf WeedStrain == 2
   triggerhitshader 0.20
   con_setCameraFOV 90
   set ths to 0.35
   set FOV to 115
  ElseIf WeedStrain == 3
   triggerhitshader 0.20
   con_setCameraFOV 90
   set ths to 0.30
   set FOV to 110
  ElseIf WeedStrain == 4
   triggerhitshader 0.25
   con_setCameraFOV 95
   set ths to 0.30
   set FOV to 100
  ElseIf WeedStrain == 5
   triggerhitshader 0.30
   con_setCameraFOV 80
   set ths to 0.4
   set FOV to 90
  ElseIf WeedStrain == 6
   triggerhitshader 0.25
   con_setCameraFOV 85
   set ths to 0.4
   set FOV to 95
  ElseIf WeedStrain == 7
   triggerhitshader 0.25
   con_setCameraFOV 100
   set ths to 0.35
   set FOV to 120
  ElseIf WeedStrain == 8
   triggerhitshader 0.25
   con_setCameraFOV 85
   set ths to 0.45
   set FOV to 95
  ElseIf WeedStrain == 9
   triggerhitshader 0.15
   con_setCameraFOV 95
   set ths to 0.25
   set FOV to 115
  ElseIf WeedStrain == 10
   triggerhitshader 0.10
   con_setCameraFOV 110
   set ths to 0.17
   set FOV to 125
  EndIf
ElseIf Timer >= 599
  set Weedstrain to 0
  con_setCameraFOV 75
  player.removespell aaMrPSpaceCake
  player.removespell aaMrPSpaceCakeOverate
EndIf
End
Begin ScriptEffectFinish
set Weedstrain to 0
con_setCameraFOV 75
Player.RemoveSpell aaMrPSpaceCake
set SpaceCakeEaten to 0
MrPSpellcaster.MoveTo Player
MrPSpellcaster.cast aaMrPMunchiesSpell Player
MrPSpellcaster.MoveTo CookMuffinHome
End

 

 

The next goal will be to make my PC susceptible to H (due to player.GetKnockedState == 1, and both passive and/or aggressive H) via Lovers MODs, like WappyOne's RaperS  and others.

 

Okay, I see what you're doing and have done something similar myself. Instead of a spell, I used a quest script where getting knocked, or forcing a knocked state, started incrementing a counter on each script run. Various things happened at specific counter values until the final counter value was reached and reset, and the player was fully recovered. I just like to monitor and control the situation externally.

Link to comment

I think I'm going to have inject one last check to remove player.addspellns aaMrPGetup, as that remained 'in inventory' post the end of the cycle, on my last test.

 

The magnitudes are still throwing me for a loop, as aaMrPFeint at now magnitude 99 can end up with a -Fatigue value around -25,000+ or so, while aaMrPGetup at 99 takes forever and a day to regain a 'normalized  fatigue level. I think I may need to rethink this a bit more, but it is beginning to function the way I want it to.

Link to comment

Just curious, is this a tweak that makes the marihuana mod so you get high, pass out and get raped?

 

That's sort of one of my current goals, but right now I'm working with the scripts for the weed muffins, which the original MOD author made as potions. Smoking weed could come later. (Have to be careful of that as I have NPCs currently smoking and it could end up as one big cluster fuck or orgy.) :P  

 

And susceptible to either rape or 'normal' H of nearby NPCs. I still need to figure out how to make calls to Lovers MODs I like WappyOne's RaperS for initiating rape scenarios, or alternately just initiating the Lovers H animations.

 

I'm also thinking of reusing WappyOne's hornyness or lust features (from LoversBitch), so lust goes up on your PC when you smoke or eat the muffins and becomes prone to looking for NPCs to have H with, to satisfy their cannabis induced randiness. 

 

The original MOD has some flaws or defects reported via CS/E that I cannot clean out; one invisible script reporting as not compiled, and a duplicate land mass or area, which has me totally baffled. So anything that I could/would release will just be script edits.

Link to comment

Can't believe I missed this page.

 

Sorry, folks.  I've been bugging people all over the forums with this problem.  Now, sadly, I've come here, hat in hand, to beg assistance.

 

Does anyone know of a script I can attach to a standard AI sleep package to get NPCs to remove or change clothing when they climb into bed, and put back on when the sleep is interrupted or the package ends?  A variation of the remove armour/weapons box in the AI screen, but for clothing.  To cover those NPCs without armour, or those who change out of armour long before going to bed, like Rohssan in IC Market.  No containers, please.

Link to comment

Ok, the land mass edits can be removed. It adds a chest full of stuff under the bridge near the IC. I have permissions to alter and upload the mod to the page on nexus. The WE versions I did, just a script change to allow hotkeyed items to grind/pack/smoke without needi g the menu.

I would really like to try your tweaks out once its all working how you want. Sounds fun.

Link to comment

Can't believe I missed this page.

 

Sorry, folks.  I've been bugging people all over the forums with this problem.  Now, sadly, I've come here, hat in hand, to beg assistance.

 

Does anyone know of a script I can attach to a standard AI sleep package to get NPCs to remove or change clothing when they climb into bed, and put back on when the sleep is interrupted or the package ends?  A variation of the remove armour/weapons box in the AI screen, but for clothing.  To cover those NPCs without armour, or those who change out of armour long before going to bed, like Rohssan in IC Market.  No containers, please.

GetSleeping is the script command you want, but you can't use it on the player.

 

http://cs.elderscrolls.com/index.php?title=GetSleeping

 

Here's an example:

	if SeedREF.GetSleeping > 0 && SeedREF.GetSleeping < 4 && SeedREF.GetEquipped leathergreaves > 0
		seedREF.unequipitem leathergreaves
	endif
	if SeedREF.GetSleeping == 0 && SeedREF.GetEquipped leathergreaves == 0
		seedREF.equipitemSilent leathergreaves
	endif
Let me know if you need more. :)
Link to comment

Ok, the land mass edits can be removed. It adds a chest full of stuff under the bridge near the IC. I have permissions to alter and upload the mod to the page on nexus. The WE versions I did, just a script change to allow hotkeyed items to grind/pack/smoke without needi g the menu.

I would really like to try your tweaks out once its all working how you want. Sounds fun.

 

Well, it may be slow going as I just purchased the Eidos Anthology from Steam this weekend. 34 games plus all DLCs, and then I went back and added the missing ones that were not in this discounted package.

 

We versions? I was able to remove the items under the bridge near the IC, even though it kept jumping to another area, till I used right-mouse click to select the item. Think I may have missed the chest.

 

Testing today with a Timber Wolf (aggressive) didn't go so well at first. I'll need to come up with a way to break from the script if H is in any way engaged. More testing on that later, more testing different scenarios no doubt.

 

Anyways, enough of a tangent here in this thread; supposed to be about useful scripts. As (and if) I make progress I'll start a new thread in the appropriate location.

Link to comment

@sleighrX

 

There are some useful things you may want to experiment with. obse can send you some interesting "event calls" such as OnPackageStart/End sort of thing. Or OnActivate perhaps, because npcs (probably) have to activate the bed object to sleep. You write a function with certain set arguments, register it to obse, and obse will call that function for you whenever such events happen. That way you can be notified whenever someone is about to sleep or wake, without having to constantly check their current state. Im on the phone so I can't verify or explain in much detail right now.

 

Once you know who are sleeping right now, you can (but don't have to) store them in a list and can do pretty much anything with it after that. Maybe ignore the ones that are too far from you, store their previous equipments, restore it once awake. you can consider doing this if you need more sophisticated equipment swap functionality than just update3D.

Link to comment

Movomo and Supierce

 

Both extremely helpful and areas I was just exploring.  Like minutes ago, really.

 

Is there a general UnequipItem function that emulates RemoveAllItems?  Or a code that covers general categories, not just single items?  e.g. Something that unequips all kinds of pants, not just specific references?  All clothing files are separated into a handful of categories: shirt, pants, shoes, etc.  despite being dresses, or robes or whatever.  Is there a reference that covers all of a category?

 

For example: player.Unequipitem AmuletofKings 1

would remove the Amulet of Kings and flag it unequippable by the player.  But it's specific to one item.  Is there a command that would make ALL amulets unequip when flagged?

 

e.g. player.UnequipItem [Amulets] 1

 

Plus, if attached to an AI package, will it stop working once that package ends?  Meaning the "no-equip" flag stops?

 

Supierce's script is great except for the fact that it's specific.  If I (or the Player -this is a mod I'm working on, BTW) switch the NPC's clothing, like you would with a companion or a slave, say, then Supierce's references no longer apply.  So the script dies when I remove the leather greaves from the NPCs inventory.

 

Well, the clothes come off in LAPF's sex animations don't they?  You can even choose which parts come off.  I've been scouring the LAPF scripts to see how that happens, but I'm still quite illiterate, I'm afraid.

Link to comment

I recommend reading through this very comprehensive series of tutorial articles on NVSE scripting, written by DoctaSax.
https://www.loverslab.com/topic/26749-tutorial-nvse4-part-1-syntax-and-expressions/

It's for the aspiring Fallout NV modders, but many (in fact almost all) of the FOSE/NVSE things can safely be applied to OBSE scripting as well.

Anyways, as to your questions...

First off, you can't attach a script to an AI package. You can't.

So you'll have to find an another way to detect who is sleeping. I'd recommend trying event handlers first, as I mentioned in my previous post. If that fails you'll find another ways.. such as running a quest script. Dunno. Perhaps Supierce could tell you more.

Begin GameMode
; This script is just an example; not to be used unmodified.

    if someone.GetSleeping
; will return true unless he is clearly not sleeping
; different return values mean different states of sleeping.
; 4 == getting ready to wake up: I don't know what exactly does this mean,
; you'll need to experiment with the return values.
        if (someone.GetItemCount been_checked_token) == 0
; The been_checked_token is an unplayable zero-weight clothing item
; We see if he has this token in his possession or not.
; If he has one, that means we've already checked this guy and don't need to
; care about. If not, we'll do the thing and give a token so we won't do the
; same thing over and over on the same guy.
            unequip_them
            someone.AddItem been_checked_token, 1
; There are many ways to do this same thing. Using token is just one of them.
; It's not very efficient but it's simple, and easy to understand.
        endif
    else
        if someone.GetItemCount been_checked_token
            reequip_them
            someone.RemoveItem been_checked_token, 1
        endif
    endif

End

For PC, you have to handle him a bit differently from npcs; PC is almost always special. You're SPECIAL.

; This time we set the slept flag as a boolian variable (True/False)
; The "short" var type can be used like bool vars in Oblivion scripting.
; Not a token, because there is only one and never two PCs in the game.
; You CAN use token instead, if you're already using tokens on npcs.
; Here I'm just assuming you don't care about the npcs, within this script,
; for the purpose of showing an example.
int has_slept

Begin MenuMode 1012
; MenuMode 1012 means sleep/wait menu.

    if IsTimePassing
; this ensures PC is *actually* sleeping or waiting.
; We'll soon see if he's sleeping or waiting.
        if IsPCSleeping
; PC is killing time by sleeping.
; This part returns true as long as the sleep menu stays open...
; even if you aren't actually sleeping. Which is why we needed IsTimePassing.
            if has_slept == 0
                unequip_them
; Set the slept flag on so that you won't be confused later.
; This also prevents your script from doing the same thing over and over.
                Let has_slept := 1
            endif
        else
; Ok, we're not interested here. PC is saving his master's time by wasting his.
            do_nothing
        endif
    endif
    
End

; We've set the slept flag on while sleeping.
; If the slept flag is set at True, and if it's GameMode,
; this means the PC has actually slept, already quit sleeping, and the player
; is already looking at their awoken PC.
Begin GameMode
; The MenuMode 1012 block won't work as soon as you close the sleepwait menu.
; That is why we need an additional GameMode block.
; We've undressed the PC, now we must redress them, but we can't do that in
; MenuMode, because once you're awake, you're already in GameMode.

    if has_slept
        reequip_them
        Let has_slept := 0
    endif

End

Now, you wanted to know how to mass-unequip an npc.
Let me show you one of the many ways.

int cur_index
; You will know what this does when it does.

ref cur_base
; This reference variable will hold the information on what kind of equipment
; it is.

array_var equipped_items
; First you must declare an array var, just like  any other variables you will
; use in any script.

Begin (event)
; Any event. Maybe GameMode, maybe Function. Maybe some other event.

    Let equipped_items := someone.GetEquippedItems
; The GetEquippedItems function returns the kinds of base objects that the
; calling npc reference is currently equiped with.
; We don't know what is what, yet, but it doesn't matter, because we'll see
; about that very soon.

; They are stored in an array variable: a list, or, a container of things.
; Arrays are powerful, and fun, because they can contain indefinite number of..
; "things". anything, in fact. Even another arrays.
; The items in an array are "indexed", so that you can locate them easily.
; In case of the "Array" type (there are other container-like types),
; the "index" always starts from 0. The first item is always indexed as the
; "0th" item. The next one is 1st item. 2nd, 3rd...
; You can retrive the actual item this way: some_array[index_number]
; So, equipped_items[0] means the first item that someone is equipped with.
; equipped_items[1] is the second item.

; One thing to be extra careful here. You can NOT retrive the item that the
; array does not have. If the equipped_items array has 4 items in total, its
; last index would be 3 (because it starts from zero), and this would cause
; an error: equipped_items[4], because it doesn't have the "4th" item (starting
; from "0th"). Do be careful.

; Also, the indexes must be "continuous". This means you can't have
; equipped_items[3] without having equipped_items[2] already. If you somehow
; manage to delte the [2] item, then [3] (as well as all the later entries) is
; automatically shifted down and becomes [2], [4] become [3], [5] becomes
; [4], ... and so ad infinitum. This is important, too.

; There are many more cautions to be taken, I'd recommend reading the OBSE doc
; carefully.

    Let cur_index := ar_Size equipped_items
; This fetches you the number of items stored in the equipped_items array.
; So the last index would be (cur_index -1), because it starts from zero.
; And this will be the starting point of the next part.
; Since we start from the last index, here we'll call this the reverse-loop.
; You can start from zero if you'd like, it doesn't matter in this case.
; It might matter whether you start from the first index to the last, or from
; the last index to the first, in other cases. Now's not.
    
    while cur_index
; The "while" keyword lets you repeatedly do the same thing over and over,
; as long as the condition statement (cur_index in this case) holds true.
; For integer type, any non-zero value is equal to True; and a zero is False.
        Let cur_index -= 1
; You remember that the initial value of the cur_index is actually 1 more than
; the actual last index. We start by substracting by 1 from it to avoid error.
        Let cur_base := equipped_items[cur_index]
; This is the base object of the item that the current entry of the
; equipped_items array is holding, accessed by the numeric key named
; cur_index. At the first loop, this is the very last entry.
        someone.UnequipItem cur_base
; Ok, we're done with the first loop. If the current cur_index value is more
; than 0 (thusly not False), the script will return to the top.
; If you take a look at the top part again, you will know that the very first
; thing it does is to substract 1 from the current cur_index value.
; If its result becomes 0, that means that loop will be the last loop.
; cur_index will never become -1 because this loop won't run if cur_index is
; False.
    loop

; That was quite a TLDR compared to the very short length of the actual code.

; One last thing though, you must "destroy" the array you've used.
; array_var and string_var are special, in that, once you have created them,
; you are also responsible for destroying them.
; You must do this unless you're going to use it again later.
; It's too long to explain it all here.
    Let equipped_items := ar_Null

End

Now you can mass-unequip someone with the above code. How to redress him?
Well, maybe update3D. But you might prefer doing it manually rather than leaving everything to Oblivion AI. (you don't want the certain types of equipments to be ignored at re-dressing time, for example)
Maybe you can reserve the equipped_items array, not destroying it immediately, for the later uses. If you loop through that array again, you can restore his equipments *exactly* as before going to bed. Or maybe you can do more sophisticated thing with other functions; such as GetItems or ... whatever.
Link to comment

Movomo-

 

Oh wow.  I didn't know you couldn't attach scripts to AI packages.  I thought they were part of the package.  I just never attempted to attach one until now, preferring to plan first then program.  Or I thought you wrote the scripts when you created the package, then assigned the package.  And I thought it also connected via the script window in the character screen in CS, and that coloured the conditions window in the AI screen, since there's function codes there (e.g. GetSleeping).

 

The way the character window in CS is set up it looks a lot like another editor I used to use.  Quite obviously it's nowhere near.

 

Looks like I've been sniffing along the wrong trail.  In fact, I'm so far off it I'm in the next country. 

 

This is obviously waaaaaay out of my league for the mo.  I understood maybe one sentence out of three in your post, Movomo.  :blink:

 

Sorry for wasting your time, folks.  Looks like I got a butt-load of reading to do before I even look at doing this again.  Scripting has obviously gone far, FAR, ahead of me since I did this before.   I'm tempted to pull out my old Duke Nukem 3D CD, or even Doom 2, and see if I can still figure that out!

 

Until then, I think I'll stick with what I DO know, like writing.  I've got a Bandalo short in the works.  Maybe I should go dust that off, after I crawl out the bottle of scotch I going to go buy right now.

 

 

 

"I've got a great drinking game for times like this.  You should try it.  It works like this: 

First, I take a drink.  Then, I take another.  Then, another.  Then...

What?  You already know this one?"

 

-Bandalo the Fool

 

 

 

Link to comment

That's too bad. If you ever change your mind though, do note that those sample scripts are very very short once you remove all the comments.

 

Scripts are there to fill up the places where other things can't help. You can set a specific Health value of an npc in the editor, by filling in the corresponding data field of that npc. Now you want to advance a certain quest's progress when that npc dies, you must write a script. That's where "OnDeath" script is used. Because, it's quite self-explanatory but, the OnDeath part of that npc's attached script will run when he dies. Then you maybe execute SetStage someQuest 10 there, for example.

 

If you have a feeling this is too much for you for the moment, try practicing with easier things. Like... write a scripted spell for you pc, an l33tMagickingSpell or something. I learned scripting the hard way, I'm sure it was the quickest way but can't tell it's the best way.

Link to comment

Well, for one thing I'm going to have to learn all these functions -some are easy to figure, like OnDeath, but some either I'm thinking wrong about, or don't know enough about them, like Array_var.  Plus, obviously I'm going to have to learn where you put scripts and when.

 

On the exploration front, I've been going over some mods to see if I can find hints.  See Your Sleep has a sleepwear option, but whether that works upon sleeping, or if it can be adapted for NPCs, I don't know.  It uses a token, I think.  But using it in a single AI package probably wouldn't work, huh?

 

Can the conditions section of the AI be used?  Or does that only work if something has already happened.  I mean, could I make a sleep package, then a UseItem package, using a token, that checks for sleep?  That would cover all packages in a set, wouldn't it?  It wouldn't work except during sleep times.  Except how to put the clothes back on...?

Link to comment

No need to "figure out" functions - their descriptions and examples of usage are all here:

 

http://cs.elderscrolls.com/index.php?title=Constwiki/index.php/Main_Page

 

AI Conditions are requirements for the AI package to run, so they need to already be present.

 

You still need to use OnPackageStart or GetSleeping to do stuff while the NPC is sleeping. And then the reverse to undo it.

 

I couldn't get OnPackageStart to work reliably, so I reverted to the GetSleeping block that I posted above. It works well to unequip something while sleeping and reequip it on waking, but you need to put it in a gamemode block and customize it for each NPC you want to change.

 

Movommo is the real expert with mass clothing changes and arrays, so I'll shut up now. :)

Link to comment

I couldn't get OnPackageStart to work reliably, so I reverted to the GetSleeping block that I posted above. It works well to unequip something while sleeping and reequip it on waking, but you need to put it in a gamemode block and customize it for each NPC you want to change.

Yikes. That's too bad.

..

Not too bad, actually. I have a feeling that it wasn't a very good approach from the beginning, now that I've actually coded some and tested them. (I got curious)

 

Going to a bed does fire PackageStart, but I also realized that it does NOT promise he is actually going into sleep very soon. My guinea pig started her sleep package, notified me with a console message, but could not find the bed for her. So she kept wandering near some occupied bed... for hours. I think this is the unreliability you were talking about.

 

Plus, simply way too many npcs trigger these package events. Even those live in shivering Isles. So, yes, I think running a quest is the way to go for SleighrX.

Link to comment

Okay.  Thanks folks!  I think I've exhausted all the lines of discussion on this topic.  Time to give someone else a chance.  Now to go experiment and see what happens and if it works.

 

 

 

Edit:  I know I said I was done, but as so often happens, I suddenly had one of those flashes of inspiration after a particular event - in this case changing my clothes and having all the contents of my pockets dump out all over the floor.  One of the items being my wallet.  Then *zing!* all kinds of freaky brain things happening inside my head. :wacko:

 

What if I put a zero-weight, unplayable container, say a bag ("wallet"), in the NPC's inventory.  Then make a script using GetSleeping to activate it with a RemoveAllItems -targeting the wallet.  When the NPC is not sleeping RemoveAllItems from the wallet back into the regular inventory.

 

Would this work?  Also, any suggestions how would I set it up for pickpocketing or death? 

 

 

 

 

Link to comment
There's no such thing as "container in inventory" in TES4 concept: mods what do something like "portable containers" use misc tokens just as activators, and then activate referenced hidden container by script. Also i'm fiercely afraid of "remove all items" thing - too often it ended with CTD for me (but m.b. i just was dumb?). As more complex approach example, mod Player Slave Encounters has a number (14, Carl!) of scripts dealing with forceful PC\NPC undressing. Strings looks like
------
set ItemRef to player.GetEquippedObject 18  ; it walks through 0..22 with some exclusions
if ItemRef != 0                                 ; possibly, SETBODY'parts should be specialy checked (and leaved)
        player.UnequipItemNS ItemRef
endif
---------

Or, maybe, those SetBody parts (appropriate for current character, just 4 slots) could be forcedly equipped on her\him to displace any of clothing\armor parts?

 

Link to comment

 

There's no such thing as "container in inventory" in TES4 concept

 

Really?  I thought for sure there were bags, even in vanilla, you could pick up and put in your inventory.  I got one off a dead bandit, I'm sure.  Maybe that was a different game...  :unsure:

 

Still, any item can be a token.  Give it a "bag" .nif and an icon in the inventory (a death item?) and a link to a remote container or actor (or "shadow" I believe it's called) and it would effectively be the same thing, though I'm not sure how you would go about making a shadow. 

 

Do containers have distance ranges?  They shouldn't.   They should be accessable anywhere using a reference ID. 

 

 

 

Also, I'm fiercely afraid of the "remove all items" thing - too often it ended with a CTD for me...

 

RemoveAllItems only removes playable objects from the inventory.  It won't remove unplayable items.  Which is the reason for the unplayable token object.  Otherwise it would put the bag in the bag!  And that would likely cause a CTD as physics and philosophy come smashing in like an ATF squad and the game spontaneously combusts in terminal existential uncertainty. :P

 

So Setbody parts should be fine as well, as they are unplayable clothing.  And I think Setbody Reloaded Blockhead Edition doesn't even do that.

 

Supierce mentioned containers before, but I couldn't see how they would work with roaming NPCs; companions made with Mad Companionship Spells, travel packages, etc.  That was before I read about remotes.

 

Speaking of which.  Does anyone have info on RemoteCont?  I saw a reference to RemoteCont.RemoveAllItems <actorID>   It was being used as an example on how to return removed items, but I can't find anything on how RemoteCont itself works.

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