[MUD-Dev] Re: Random Resets

John Robert Arras johna at wam.umd.edu
Wed May 1 12:41:31 New Zealand Standard Time 2002


On Mon, 29 Apr 2002 "Kwon Ekstrom" <justice at softhome.net> wrote:

> Lets say you only have 5 places for the kobolds to stand, 4 types
> of kobolds, 3 skill sets per kobold type, and perhaps 3 or 4
> different tasks for the kobolds (standing still, sleeping, peeing
> in the fire, I don't know... heh)
 
> That'd generate roughly 240 possible scenarios.  Add another place
> for your kobolds to stand, and you've increased to 288 possible
> scenarios.
 
> I've done alot of thought on handling things similar to this
> (although not this exactly) with creating script and equipment
> templates for creatures.  You could create alot of diversity
> simply by allowing multiple templates to be applied to a creature
> when it's loaded.  That'd create alot of interesting diversity
> with a minimum of work for the builders.

This is something I've played with a lot, too. I've got two things
that that I've gotten a lot of mileage out of. I think I've
mentioned them before, but not in a really detailed manner.


The first thing is to be able to put resets on everything:
areas/rooms/objs/mobs. When things reset, they reset
recursively. So, a room loads a guard, and the guard loads a sack,
and some bread loads in the sack. When the reset is called on the
room, the guard gets created, then the sack gets created, then the
bread gets created, and the bread gets put into the sack, the sack
is given to the guard, and the guard gets put into the room.

Area resets are handled a little differently. If the start area in
the MUD is the thing being reset, it first picks a random area, then
a random room to reset the thing in. If it's another area, it picks
a random room to reset things in.

The rooms that can be selected are further checked against their
sector flags. I use sector flags for things like
water/forest/field/city instead of a single number type. If the
thing being reset has any of these flags on it (since all things can
have flags as well as resets), then only those rooms with common
flags can be picked as locations for the thing to reset. If the
thing being reset has no flags on it, then any room in the area
(that isn't a dangerous room such as lava or water or air) can be
the location of the reset. This lets me reset fish in water, and
squirrels in forests.

-=-=-=-=-=-=-=-=-

The second idea is what I call "randpops". Basically, these make it
possible to reset one out of a large number of choices, and it's
possible to put things into "tiers" so one reset can give out good
equipment to powerful creatures, and weak equipment to wimpy.

Randpop objects are things that store extra data on them: the vnum
where a block of things to be resets starts, the number of things in
a "tier" of those things, the number of tiers of things, and the
chance to pick from a better tier. The chance to pick from a better
tier can be either a random chance like 1/5 per tier, or it can be
based on the level of the thing being reset, so that more powerful
things can pick from better tiers of equipment.

Here's what randpops can do:

I have 10 cloth armor, 10 leather armor, 10 chain armor, 10 splint
armor, and 10 plate armor starting at item 700. I have a randpop
item that starts at object 700, has 10 items per tier and 5
tiers. When a creature has this randpop item reset on it, the tier
is chosen by checking if (random(1,150) < mob_level) If the check is
true, then the tier gets increased. What this means is that a level
150 creature will always repop plate armor, and a level 10 creature
has a (1/15)^4 chance of popping a piece of plate armor. It's easy
to give mobs "background equipment" just by putting a 5x reset of a
randpop armor item at 50-75 percent, so they get a few pieces of
armor. It doesn't check against loading two pairs of boots, but it
does pretty well for very little builder effort.


This is an example of how these two things work together:

Let's pretend that I'm really lazy and that I hate building. I want
to make lots of forests on my MUD and I don't want them to be
barren, but I also don't want to have to make 100 kinds of squirrels
and wolves for each area and then reset them to specific locations.

What I do is I set aside a block of vnums to make "forest mobs". I
might set aside 50 vnums for small creatures, 50 for medium, 50 for
large, and 50 for huge. I might not even fill up all 50 slots at the
start, since if the code tries to load a creature where no creature
exists at that vnum, it will just not load anything and move on.

I then create a randpop item that has a start_vnum equal to the vnum
of the first "small" creature. I set the number of elements in a
tier to 50, and I set the number of tiers to 4. I then set the
chance of picking something from a more advanced tier to 1/5.

I then go to my start area, and I put a reset of 2000 copies of the
forest mob randpop item at 50 percent.


When the start area resets, it checks how many creatures from vnum
(start_vnum) to vnum (start_vnum+50*4) exist in the world. If it's
less than 2000, say 2000-N, it attempts to load N new creatures.


It checks if the randpop item is a randpop item or not. If it's not,
it knows that it will reset the thing in question. If it is a
randpop item, it records that fact.

For each of the N tries,

  It checks if the 50percent chance roll is made, and if not,
  nothing gets reset.

  If it's not a randpop item, the thing being reset is the original
  thing. If it is a randpop item, the thing being reset has to be
  found. The randpop item is checked and a mob is chosen from the
  list. So, 4/5 of the time, a small creature will be picked, and
  (4/5)(1/5) of the time a medium, (4/5)(1/5)^2 a large, and
  (4/5)(1/5)^3 a huge will be picked. If it loops past huge, it goes
  back to loading a small. Then, one of the creatures of the
  appropriate size is picked (pick randomly from the 50
  available). If this doesn't exist, since there may not be 50
  things in that tier, do nothing this iteration.

  If the creature exists, we now find a random area, and a random
  room for that creature. If it has special sector flags on it, pick
  only from those rooms with the appropriate sector flags
  themselves. This part should probably be done more uniformly over
  all rooms in all areas (such as by keeping track of the number of
  forest rooms and water rooms overall), but right now it does the
  random area followed by random_room search. If the area has no
  rooms of the proper type, then nothing gets loaded this iteration.

  If the room is found, then the creature gets loaded into that
  room. And as before with the guard and the sack and the bread, if
  it's a wandering elf, it may load random armors, and it may load a
  sack that loads bread.

  
This is repeated this N times, and the net effect is that after
several resets, we reach the point where there are close to 2000
forest creatures in the world. If some of the forest creatures are
given a simple drive to find and eat other things, then we get a
nice little ecology set up. Over time, if players attack things near
their cities, then the mobs will appear to concentrate in unused
areas, simply because the random resets there never get killed.



John

_______________________________________________
MUD-Dev mailing list
MUD-Dev at kanga.nu
https://www.kanga.nu/lists/listinfo/mud-dev



More information about the MUD-Dev mailing list