Jump to content

Spawning a random set of armor


WalkerOfWoods

Recommended Posts

Is it possible to use a leveled list to randomly spawn a set of armor, rather than individual armor pieces? For instance, Claude Maric, always spawns with a set of the best Light Armor available at your level. What if I want him to spawn with a set of either the best Light Armor or the best Heavy Armor available?

 

I suspect that this would take a script (or even a scripted leveled list, if that were possible), but it seems to me that that would unnecessarily complicate something that ought to be possible with just leveled lists.

Link to comment
Share on other sites

This topic has like 120 views and no responses, so I would say that there is no easy way to do this using the vanilla Oblivion spawning engine. I think what you need is a Begin GameMode object script placed on Claude Maric. You could randomly have heavy or light armor selected with a line of code using GetRandomPercent or else key what he wears to something like day of week or hour of day. You would have to have a lot of lines concerning removing old armor whatever it happens to be when the new armor is added when you level up, unless it is okay for him to be carrying several suits of armor around in his inventory. I am thinking such a script would lightly fill two or three computer screens but would not be technically very difficult.

 

I may be off base, because I have heard that some overhauls have systems to make an NPC spawn a matching set of armor such as all steel or all iron.

Link to comment
Share on other sites

David Brasher: Claude Maric was merely an example. Using scripting in this way would become very tedious if I want to modify many characters in this way.

 

TodaY: To my knowledge, a leveled list can at most produce one type of item, not multiple items of various kinds. That is, I don't think it's possible to have a single list produce a full set of armor, only an individual armor piece.

Link to comment
Share on other sites

I thought of one (crappy) solution: use a script to do the following:

 

  • Generate a random number
  • If needed, get the day of week, level or some other value
  • Remove all old armor pieces (if possible, by using a function or two)
  • Add each new armor piece for a set identified by the generated number

 

One annoying problem is, as David Brasher said, in removing the old armor pieces. It might be best to spawn NPCs with this script attached without any armor, and to just add the set immediately after spawning. The result would probably be a 30-ish line script.

Link to comment
Share on other sites

Probably not what you're after, but you could use GetFirstRef 35 2 with GetNextRef to walk through the npc's in the player's area and then Foreach myitem <- actor to walk through the items in their inventory and do whatever you want with them (remove+add new or modify).
Link to comment
Share on other sites

You could simply make a leveled list with 100 % chance and a full set of armor, and do that for every armor, and add those lists to the actual leveled list.
TodaY: To my knowledge, a leveled list can at most produce one type of item, not multiple items of various kinds. That is, I don't think it's possible to have a single list produce a full set of armor, only an individual armor piece.

In my current WIP I have done just what TodaY suggested, most of the time it generates 3 or 4 pieces of the full set that match.

I have also tried to make 6 (with shield) different leveled lists, each with a single piece of the full set, then nest those within one List.

The results were exactly the same either way...

 

It WILL actually give a full matching set, but less than a 5% chance at that.

 

-heavywaters

Link to comment
Share on other sites

How about using the leveled list to add a token item to the actor, which in turn is scripted to spawn the whole armor set associated with the token?

 

You would have one token for the light armor set and one token for the heavy armor set (and more tokens for other sets you want to spawn). The leveled lists chooses one (and only one!) of these tokens at random when the actor is (re)spawned.

 

Then the script on the token would add the actual armor items, equip them on the actor and finally remove itself again. A token is a “clothing” item, without biped model, set to go into the “tail” slot, with the “playable” checkbox unchecked (this will prevent actors from equipping it and the player from looting it by accident).

 

You would need one script (and one token) for each armor set. Here is a example for a script that adds and equips a whole set of steel armor. You would need other scripts (and tokens in the leveled list) for Fur, Glass, Elven, etc.

 

ScriptName SteelArmorTokenScript

Short done	;set to 1 once all armor items have been added
Ref actor	;reference to the actor we are equipping with armor

Begin GameMode
If (done)				;if all items have been added
	actor.EquipItem SteelBoots	;|equip them on the actor
	actor.EquipItem SteelCuirass	;|
	actor.EquipItem SteelGauntlets	;|
	actor.EquipItem SteelGreaves	;|
	actor.EquipItem SteelHelmet	;|
	actor.EquipItem SteelShield	;/
	RemoveMe			;remove this token (also stops the script)
EndIf
Set actor To GetContainer		;get reference to actor the token was added to
If (actor)				;if a reference was returned
	actor.AddItem SteelBoots 1	;|add a full steel armor set to the actor
	actor.AddItem SteelCuirass 1	;|
	actor.AddItem SteelGauntlets 1	;|
	actor.AddItem SteelGreaves 1	;|
	actor.AddItem SteelHelmet 1	;|
	actor.AddItem SteelShield 1	;/
	Set done To 1			;all items added, equip them next frame
EndIf
End

 

I am not sure if this is the most elegant way to do it, but I've tested it and it works. The script is running not on the base NPC, but on the spawned child. So there should be no danger of ending up with a NPC with all kinds of armor sets, once he respawned a couple of times (each new child starts with a empty inventory).

 

Maybe this helps you.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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