Full Version : How do I - Spawn items with a random stack size
xmlspawner >>XMLSpawner - How do I? >>How do I - Spawn items with a random stack size


<< Prev | Next >>

tekproxy- 03-25-2009
Title says it all. I've been digging through forums and google all day. I have no trouble spawning items, but I am having trouble finding anything like a MaxStackSize or MinStackSize property. Any ideas?

[edit]
I take pride in the fact that most forum posts I make are not answered. Don't feel guilty.
[/edit]

Lichtblitz- 03-30-2009
gold/amount/RND,100,200

Spawns a stack of gold with a random amount between 100 and 200

gold/amount/RNDLIST,250,300,350

Spawns a stack of gold with a random amount of either 250, 300 or 350

Oh, btw.: answers in this forum take time since it is more or less deserted. You shouldn't be in a big hurry.

tekproxy- 04-01-2009
Thank you kindly, sir. Thanks for the tip.

Now I just need to take a look see at the code and see if I can do that from within a script. I feel more confident spending time on it now that I know it's doable.

Lichtblitz- 04-01-2009
From within a script it should be as simple as setting the amount property.

e.g.: (mobile being the mobile you want to give the gold to)

Gold goldstack = new Gold();
goldstack.Amount = Utility.RandomFromTo(500, 1000);
mobile.AddToBackpack(goldstack);


I know there is a shorter way here but this example is more general. For any further questions you might want to try RunUO forums. I'm sure you'll find all you need there :-)

tekproxy- 04-10-2009
Thanks. What I'm trying to do is generate spawners that create wilderness reagents. I already wrote code that does everything fine, except for the amounts of the stacks are not randomly random. It's always 1. I don't want to randomly decide all stacks are to be 1-4 or something.

I want each spawn each time to be random. I'll keep looking at the XmlSpawner class until I figure it out and then I'll post it here, just in case someone else wants to know.

[edit]
Oo, that was easy. I just set the name.

CODE
spawnRegs[i] = new XmlSpawner.SpawnObject(string.Format("{0}/amount/RNDLIST,1,1,1,2,2,3", m_Reagents[i]), 6);