De DigiWiki.
// Bot Generator v1.1 fixed by djphil
// Bot Generator v1.0 by skidz
// Channel for command
// Say /32 HELP
integer mychannel = 32;
// Options for the random paths
integer randomPathMaxDistanceFromBase = 16;
integer randomPathNumberOfLocations = 10;
float RandomPathGroundHeight = 21.5;
integer RandomPathFlyOnly = TRUE;
integer RandomPathFinishWithHover = TRUE;
integer RandomPathLoop = TRUE;
// Bot Follow Options
float minDistance = 3.0;
float maxDistance = 6.0;
// bot random name and appearance
// replace the keys with users in your grid
// Add or remove names if you like
list whoToLookLike = ["da7e3fbe-72bf-40a7-8a26-db752ff2c41d", "4c7a7aa8-359d-43ce-82d6-55ee9ff02aba",
"0b14870b-35d0-4238-8839-11d7fee7d74c", "7ad595ca-19ca-4c78-9500-38f5f082eefd"];
list BotFirstName = ["Bobby", "Mike", "Lester", "Mark", "Jeff", "Rob", "Shawn", "Steve",
"Tom", "Ricky", "Sammy", "Edward", "Jason", "Mathew", "Fred", "Deejay"];
list BotLastName = ["Franklin", "Smith", "Johnson", "Spencer", "Carver", "Shepard",
"Bot", "Carter", "Oller", "Flowers", "Neil", "Obama"];
// don't change these
list BotNameCache = [];
list botID = [];
integer listener;
list map = [];
list mapTravel = [];
integer currentBot = 0;
Display()
{
integer botcount = llGetListLength(botID);
if (llGetListLength(botID) == 0)
llSetText("No Bots", <1.0,1.0,1.0>, 1.0);
else
llSetText("Bot " + (string)(currentBot + 1) + " of " + (string)botcount + "\n" + GetCurrentBotName(), <1.0,1.0,1.0>, 1.0);
}
DoubleCheckPos()
{
integer botcount = llGetListLength(botID);
if (botcount == 0) currentBot = 0;
else if (currentBot >= botcount) currentBot = 0;
else if (currentBot <= -1) currentBot = botcount - 1;
Display();
}
string MakeRandomBot()
{
integer firstN = randIntBetween(0, llGetListLength(BotFirstName) - 1);
integer lastN = randIntBetween(0, llGetListLength(BotLastName) - 1);
string fn = llList2String(BotFirstName,firstN);
string ln = llList2String(BotLastName,lastN);
if (llListFindList(BotNameCache, [firstN,lastN,"-"]) >= 0)
ln += (string)llGetListLength(botID);
BotNameCache += [firstN,lastN,"-"];
botID += [botCreateBot(fn, ln, llList2String(whoToLookLike, randIntBetween(0, llGetListLength(whoToLookLike) - 1)), llGetPos() + <1,0,0>)];
currentBot = llGetListLength(botID) - 1;
return fn + " " + ln;
}
string GetCurrentBotName()
{
return llList2String(BotFirstName, llList2Integer(BotNameCache, currentBot * 3)) + " " + llList2String(BotLastName, llList2Integer(BotNameCache, (currentBot * 3) + 1));
}
GenerateRandomPath()
{
map = [];
mapTravel = [];
vector mypos = llGetPos();
vector spot = mypos;
integer looper = 0;
for(; looper <= randomPathNumberOfLocations - 1; looper++)
{
spot = mypos;
spot.x += randIntBetween(randomPathMaxDistanceFromBase * -1, randomPathMaxDistanceFromBase);
spot.y += randIntBetween(randomPathMaxDistanceFromBase * -1, randomPathMaxDistanceFromBase);
spot.z = RandomPathGroundHeight;
if (spot.x <= 2.0) spot.x = 2.0;
else if (spot.x >= 254.0) spot.x = 254.0;
if (spot.y <= 2.0) spot.y = 2.0;
else if (spot.y >= 254.0) spot.y = 254.0;
if ((!RandomPathFlyOnly) && (randIntBetween(1, 4) >= 2))
{
spot.z = randIntBetween((integer)RandomPathGroundHeight, randomPathMaxDistanceFromBase + (integer)RandomPathGroundHeight);
mapTravel += [BOT_FOLLOW_FLY];
}
else if (RandomPathFlyOnly)
{
spot.z = randIntBetween((integer)RandomPathGroundHeight + 6, randomPathMaxDistanceFromBase + (integer)RandomPathGroundHeight);
mapTravel += [BOT_FOLLOW_FLY];
}
else mapTravel += [BOT_FOLLOW_WALK];
map += [spot];
}
if (RandomPathFinishWithHover)
{
mapTravel += [BOT_FOLLOW_FLY];
spot.z = RandomPathGroundHeight + 3;
map += [spot];
}
botSetMap(llList2String(botID,currentBot), map, mapTravel, RandomPathLoop);
map = [];
mapTravel = [];
}
KillBot(integer location)
{
DoubleCheckPos();
llSay(0,"Killing bot " + GetCurrentBotName());
botRemoveBot(llList2String(botID,location));
botID = llListReplaceList(botID, [], location, location);
BotNameCache = llListReplaceList(BotNameCache, [], location * 3, (location * 3) + 2);
DoubleCheckPos();
}
integer randInt(integer n)
{
return (integer)llFrand(n + 1);
}
integer randIntBetween(integer min, integer max)
{
return min + randInt(max - min);
}
default
{
state_entry()
{
Display();
listener = llListen(mychannel, "", "", "");
}
touch_start(integer a)
{
currentBot++;
DoubleCheckPos();
}
listen( integer channel, string name, key id, string message )
{
if (message == "BOTMAKE")
{
llSay(0, "Generating Bot");
MakeRandomBot();
Display();
}
else if (message == "BOTRANDOMMOVE")
{
llSay(0,"Generating random path for current for " + GetCurrentBotName());
GenerateRandomPath();
}
else if (message == "BOTKILL")
{
KillBot(currentBot);
}
else if (message == "BOTKILLALL")
{
integer looper = 0;
integer botcount = llGetListLength(botID);
for(; looper <= botcount; looper++)
{
KillBot(0);
}
}
else if (llGetSubString(message, 0, 8) == "BOTFOLLOW")
{
DoubleCheckPos();
string nameOf = llGetSubString(message, 10, -1);
llSay(0,"Bot " + GetCurrentBotName() + " will now follow " + nameOf);
botFollowAvatar(llList2String(botID,currentBot), nameOf, maxDistance, minDistance);
}
else if (message == "BOTSTOPFOLLOW")
{
DoubleCheckPos();
llSay(0,"Bot " + GetCurrentBotName() + " will stop following");
botStopFollowAvatar(llList2String(botID,currentBot));
}
else if (message == "MAPSPOTWALK")
{
llSay(0, "Recording spot to walk to");
map += [(vector)llList2String(llGetObjectDetails(id, [OBJECT_POS]), 0)];
mapTravel += [BOT_FOLLOW_WALK];
}
else if (message == "MAPSPOTFLY")
{
llSay(0, "Recording spot to walk fly to");
map += [(vector)llList2String(llGetObjectDetails(id, [OBJECT_POS]), 0)];
mapTravel += [BOT_FOLLOW_FLY];
}
else if (message == "MAPSPOTTELEPORT")
{
llSay(0, "Recording spot to walk teleport to");
map += [(vector)llList2String(llGetObjectDetails(id, [OBJECT_POS]), 0)];
mapTravel += [BOT_FOLLOW_TELEPORT];
}
else if (message == "MAPCLEAR")
{
llSay(0, "Clearing map");
map = [];
mapTravel = [];
}
else if (message == "MAPAPPLY")
{
llSay(0,"Setting Map to current Bot. With " + (string)llGetListLength(map) + " positions.");
botSetMap(llList2String(botID,currentBot), map, mapTravel, 0);
}
else if (message == "HELP")
{
llSay(0,"---------------------------------------------");
llSay(0,"Touch to move between bots");
llSay(0,"Commands are:");
llSay(0,"/" + (string)mychannel + " BOTMAKE - Generates a random bot");
llSay(0,"/" + (string)mychannel + " BOTKILL - Kills the current bot");
llSay(0,"/" + (string)mychannel + " BOTKILLALL - Kills all currents bots");
llSay(0,"/" + (string)mychannel + " BOTFOLLOW USERNAME - Follows the username");
llSay(0,"/" + (string)mychannel + " BOTSTOPFOLLOW - Stops following");
llSay(0,"/" + (string)mychannel + " BOTRANDOMMOVE - Generates a random path to walk around");
llSay(0,"---------------------------------------------");
llSay(0, "You can map out where the bot should go.");
llSay(0,"The following are map commands:");
llSay(0,"/" + (string)mychannel + " MAPSPOTWALK - Marks your current location on the map to walk to");
llSay(0,"/" + (string)mychannel + " MAPSPOTFLY - Marks your current location on the map to fly to");
llSay(0,"/" + (string)mychannel + " MAPSPOTTELEPORT - Marks your current location on the map to teleport to");
llSay(0,"/" + (string)mychannel + " MAPCLEAR - Clears the map");
llSay(0,"/" + (string)mychannel + " MAPAPPLY - Applys the map to the current bot");
llSay(0,"/" + (string)mychannel + " HELP - Displays help");
llSay(0,"---------------------------------------------");
llSay(0,"/" + (string)mychannel + " ANY MESSAGE AND THE CURRENT BOT WILL SAY IT");
}
else botSendChatMessage(llList2String(botID,currentBot), message, 0, 0);
}
}