Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

[IDEA] Clothing Changes


DaMage
 Share

Recommended Posts

Okay Ive had this idea for a while, but the amount of repeditive code has meant that I wont get around to ever making it due to my other projects. The idea is you script clothing, and even armor, changes for NPCs in towns and so forth, to make it seem like they are changing clothing each day.

How this would work:

A quest script that casts a large area-of-effect spell each time the player enters a new cell, hitting all the NPCs in the area.

This script checks what they are currently wearing (slots; upperbody, lowerbody, shoes, hands and head) then using a random variable, choses out another clothing of that type (lowerclass for a lowerclass etc). The items are swapped, they could lose shirt and pants and gain an outfit clothing, or just have thier shirt and pants swapped, hell lower class people could even lose their shirts (like some of the pirate on the IC docks).

This really leaves it right open to whoever makes it, you could include things like having a chance for magic items, a small chance that the NPC will go 'up' or 'down' in class ranking (lower class merchant suddnly becomes middle class and changing cloths to suit this, exceptions would have to be made of course).

Now if anyone wanted to be super awesome, they could use arrays making it possible to add modded items based on value, just have three lists, lowerclass, middleclass, upperclass then you would just have to in the clothing ID in their for it to be added. The ideas are endless for this, but that would require someone who really knew OBSE scripting (Even I wouldnt be able to do that without help).

You of course would need to aviod swapping out in cases where what they have scripted, or quest items equipped. But that can be done with simple checks.

Things I havent worked out:

-How to make it effect an NPC that 'enters' the player's current cell after the player (hence not hit by the spell)

-We only want them to be hit once per day, so how would you stop them being hit again (like in towns) when the player crosses cells (though i think would just be an invisible token system that removes itself on the change of date)

Entire aim of this would be to add yet another aspect to create a living world in oblivion. To at least 'fake' NPCs changing as ime progresses.

So is anyone interested in taking this up? I can help with scripting and idea working out if needed :thumbup:

Link to comment
Share on other sites

I think that you wouldn't need any spell.

You could use OBSE's functions getnext ref, getwalkingref, and whatever and also the functions for equipped slots.

In Nine divines robes robe adding is done through that kind of quest script:

scn wwNineDivinesRobesQS

ref curcell ; the current cell
ref curref
short doOnce
float fQuestDelayTime
short TestMode

Begin Gamemode

If player.getparentcell == curcell
return ; this check runs once every 1 second (not much drain on memory) and only does the rest if the cell hasn't been checked
endif

set curref to getfirstref 69 ; actors

While (curref)
if curref.iscreature == 0 && curref.getisreference player == 0 && curref.getinfaction NineDivines == 1
if curref.getfactionrank NineDivines == 0
if curref.getitemcount ndroberank0 == 0 ; replace with real robe eid
curref.additem ndroberank0 1 ; replace with real robe eid
;curref.equipitem ndroberank0 ; ditto
endif
elseif curref.getfactionrank NineDivines == 1
if curref.getitemcount ndroberank1 == 0 ; replace with real robe eid
curref.additem ndroberank1 1 ; replace with real robe eid
;curref.equipitem ndroberank1 ; ditto
endif
elseif curref.getfactionrank NineDivines == 2
if curref.getitemcount ndroberank2 == 0 ; replace with real robe eid
curref.additem ndroberank2 1 ; replace with real robe eid
;curref.equipitem ndroberank2 ; ditto
endif
elseif curref.getfactionrank NineDivines == 3
if curref.getitemcount ndroberank3 == 0 ; replace with real robe eid
curref.additem ndroberank3 1 ; replace with real robe eid
;curref.equipitem ndroberank3 ; ditto
endif
elseif curref.getfactionrank NineDivines == 4
if curref.getitemcount ndroberank4 == 0 ; replace with real robe eid
curref.additem ndroberank4 1 ; replace with real robe eid
;curref.equipitem ndroberank4 ; ditto
endif
elseif curref.getfactionrank NineDivines == 5
if curref.getitemcount ndroberank5 == 0 ; replace with real robe eid
curref.additem ndroberank5 1 ; replace with real robe eid
;curref.equipitem ndroberank5 ; ditto
endif
elseif curref.getfactionrank NineDivines == 6
if curref.getitemcount ndroberank6 == 0 ; replace with real robe eid
curref.additem ndroberank6 1 ; replace with real robe eid
;curref.equipitem ndroberank6 ; ditto
endif
elseif curref.getfactionrank NineDivines == 7
if curref.getitemcount ndroberank7 == 0 ; replace with real robe eid
curref.additem ndroberank7 1 ; replace with real robe eid
;curref.equipitem ndroberank7 ; ditto
endif
elseif curref.getfactionrank NineDivines == 8
if curref.getitemcount ndroberank8 == 0 ; replace with real robe eid
curref.additem ndroberank8 1 ; replace with real robe eid
;curref.equipitem ndroberank8 ; ditto
endif
elseif curref.getfactionrank NineDivines == 9
if curref.getitemcount ndroberank9 == 0 ; replace with real robe eid
curref.additem ndroberank9 1 ; replace with real robe eid
;curref.equipitem ndroberank9 ; ditto
endif
endif
endif
set curref to getnextref
Loop

Set Curcell to player.getparentcell

if doonce == 0
set fQuestDelayTime to 1 ; could be less time (at 1 it this script will run once per second at 0.5 twice etc.
set doOnce to 1
endif

If testmode == 1
player.additem wwndunusedrobe 1
set testmode to 2
EndIf

End[/codebox]

Link to comment
Share on other sites

And then you can add a token to each NPC, so you don't keep removing and adding clothes repeatedly. Problem is that you need to remove the token after one day. The only way I can think of assigning a time-stamp to a token is to add a certain number of them to the NPC, depending on the current date. Hopefully NPCs receiving hundreds of invisible useless tokens won't cause a slow down, I don't see why it would... And when you go to remove and add clothing you can put a GetPCMiscStat 1 check to compare the date of the token and the current date. If not equal, then go ahead and swap clothing.

As for the adding of any mod-added clothing, that would be difficult, to say the least. The only way I can think of doing it would require a list of every piece of mod-added clothing, either a leveled list or a ini sort of external list.

I would try this out, but my hands are full as well, and you're right, it would require a lot of repetitive coding. :salute:

Link to comment
Share on other sites

I never even thought of using levelled lists, that is a good idea, especially with OBSE's functions to manipulate lists.

Though thinking about adding modded items to the list, how would that work when it is possible for mods to be removed or moved around in the person's list? Suddenly items could become lost, but will they still be in the list?

Link to comment
Share on other sites

well here are all the leveled list functions from OBSE, there is alot we can do with them.

Also, about using a spell versus using OBSe getnextref, spells only hit NPCs and creautes, where as getnext ref will have to go through and check every item in the cell, the spell seems more preformance kinder.

AddToLeveledList - adds an object to a leveled creature, spell, or item list.. Count defaults to 1 if unspecified.

(nothing) AddToLeveledList leveledList:ref object:ref level:short count:short

RemoveFromLeveledList - removes all occurences of an object from a leveled list and returns the number of occurences removed.

(numRemoved:short) RemoveFromLeveledList leveledList:ref object:ref

CalcLeveledItem - returns one item from a leveled item list, selected randomly for a character of the specified level. (randomItem:ref) CalcLeveledItem leveledList:ref level:short useChanceNone:bool levelDiff:short

CalcLevItemNR - does the same thing as CalcLeveledItem but will not recurse through nested leveled lists. This means that unlike CalcLeveledItem, CalcLevItemNR can return another leveled list rather than a real object.

(randomItem:ref CalcLevItemNR leveledList:ref level:short useChanceNone:bool levelDiff:short

GetCalcAllLevels - returns 1 if the "calculate for all levels <= PC level" flag is checked.

(calcAllLevels:bool) GetCalcAllLevels leveledList:ref

GetCalcEachInCount - returns 1 if the "calculate for each item in count" flag is checked.

(calcEach:bool) GetCalcEachInCount leveledList:ref

GetChanceNone - returns the chance from 0 to 100 that a leveled list returns no item.

(chanceNone:short) GetChanceNone leveledList:ref

GetNthLevItem - returns the Nth element in a leveled list, as ordered in the Construction Set.

(element:ref) GetNthLevItem index:short leveledList:ref

GetNthLevItemCount - returns the count of the Nth element of a leveled list.

(count:short) GetNthLevItemCount index:short leveledList:ref

GetNthLevItemLevel - returns the level of the Nth element of a leveled list.

(level:short) GetNthLevItemLevel index:short leveledList:ref

GetNumLevItems - returns the number of elements in a leveled list.

(numItems:short) GetNumLevitems leveledList:ref

GetLevItemByLevel - returns the first element of the specified level in the leveled list.

(element:ref) GetLevItemByLevel whichLevel:short leveledList:ref

RemoveLevItemByLevel - removes any elements of the specified level from a leveled list

(numRemoved:short) RemoveLevItemByLevel whichLevel:short leveledList:ref

ClearLeveledList - removes all elements from a leveled list.

(nothing) ClearLeveledList leveledList:ref

RemoveNthLevItem - removes the nth item from a leveled list.

(nothing) RemoveNthLevItem index:short leveledList:ref

GetLevItemIndexByLevel - returns the index of the first item of the specified level within a leveled list, or -1 if no item exists for that level.

(index:short) GetLevItemIndexByLevel level:short leveledList:ref

GetLevItemIndexByForm - returns the index of the first occurrence of the specified form in a leveled list, or -1 if the form is not found.

(index:short) GetLevItemIndexByForm leveledList:ref formToFind:ref

SetChanceNone - sets the chance that a leveled list generates no item.

(nothing) SetChanceNone chance:short levlist:ref

Link to comment
Share on other sites

Thinking about it, this is what I have come up with for getting this to work with minimal preformance hit, this is only vanilla items.

Have arrays that store the mesh paths for each generic clothing item (so one path refers to all enchanted versions of the clothing), I have such a script already set up for CMR, so its not hard to get that. The script that will check ll the NPCs compares thier item to each array till it gets a match, then will remove the item, and instert in the right levelled list to put int the new cllothing item.

Now about this token, how will it remove once the day ends? You cant have 100's of token all running gamemode scripts cant you?

Link to comment
Share on other sites

Thinking about it, this is what I have come up with for getting this to work with minimal preformance hit, this is only vanilla items.

Have arrays that store the mesh paths for each generic clothing item (so one path refers to all enchanted versions of the clothing), I have such a script already set up for CMR, so its not hard to get that. The script that will check ll the NPCs compares thier item to each array till it gets a match, then will remove the item, and instert in the right levelled list to put int the new cllothing item.

Now about this token, how will it remove once the day ends? You cant have 100's of token all running gamemode scripts cant you?

Use GetRef functions, they are much faster than using a spell. And I guess it is just me, but I've found that area spells with scripts only run the script on the last actor hit by the spell :salute: . GetRef functions are more efficient anyways.

Not sure about the model path thing. Not familiar enough with that.

The tokens themselves need no script. The tokens aren't removed after one day. This is what happens:

1. The first run through the cell, the getref functions find the first actor

2. Do the change clothing code here. The actor gets new clothing

3. Add a certain number of tokens depending on the GetPCMiscStat 1 value to the actor's inventory (these tokens are not scripted!)

4. If the actor is selected again during the same day by the getref functions, then a simple check of the current date and the number of tokens in the actors inventory will show that they are the same number. If they are the same then a change of clothing is not needed.

5. If however, the actor is selected another day from the previous clothing change (doesn't matter if it is a day later or a week later), then the current date and number of tokens will not match. If they don't match then the actor will need to change clothing.

Even though it doesn't work every single day (though it could), it doesn't need too because it will only update the NPC's clothing if the player enters the cell with them in it.

Like I said, I'm pretty sure adding hundreds of tokens to an actor wont make a performance hit. Most NPCs have hundreds of arrows and they give no performance hit, and plus these tokens are invisible and unplayable.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...