Bot Generator v1.1
Categories
Scripts | botFunctions
Compat
Langage
Bot Generator v1.1 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
// 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); } } |