//Spawns a random villager at the nearest waypoint to the PC. (Which should be inside the house the PC just entered.) //50% of the time a mid a level 7 villager is spawned //35% a level 5 villager //and 15% a level 10 villager void main() { int randomnum = d20(1); object o_pc = GetEnteringObject(); int do_once = GetLocalInt(GetArea(o_pc), "i_spawnonce"); location l_pc = GetLocation(o_pc); object o_spawnat = GetNearestObjectToLocation(OBJECT_TYPE_WAYPOINT, l_pc); location l_spawnat = GetLocation(o_spawnat); if (do_once != 1) { if (randomnum < 11) { CreateObject(OBJECT_TYPE_CREATURE, "aylatownsman_mid", l_spawnat, FALSE); SetLocalInt(GetArea(o_pc), "i_spawnonce", 1); } else { if (randomnum <18) { CreateObject(OBJECT_TYPE_CREATURE, "aylatownsman_low", l_spawnat, FALSE); SetLocalInt(GetArea(o_pc), "i_spawnonce", 1); } else { CreateObject(OBJECT_TYPE_CREATURE, "aylatownsman_hi", l_spawnat, FALSE); SetLocalInt(GetArea(o_pc), "i_spawnonce", 1); } } } }