'*****************************************************************'*****************************************************************'XX This script has been created by Ilnair, aka Dinand Mentink XX'XX Please do not give it out saying you made it, or distribute XX'XX it anywhere outside the Eclipse forums! Also, please always XX'XX distribute these credits along with the script! XX'XX www.nishansu.tk ©Dinand Mentink (aka Ilnair)XX'*****************************************************************'*****************************************************************'START MAPGEN!'*****************************************************************'*****************************************************************Sub GenerateMap(index, map, patern)On Error Resume NextDim xDim yDim tilesetDim tilexDim tileyDim paternnameDim likelyDim likelyminDim likelymaxDim likelycurrentDim patchDim solidDim solidmaxDim patchmaxDim randomDim objectDim objectmaxDim widthDim heightDim objectxsetDim objectysetDim objectxDim objectyDim ystartDim xstartDim objectylocDim objectxlocDim loopvarDim objecttilesDim objecttileDim layerDim controllobjectpaternname = GetVar("mapgenerator.ini", "paternnames", patern & "")If paternname = "none" Then Call PlayerMsg(index, "No patern specified for this number!", 12) Exit SubEnd IfCall PlayerMsg(index, "Building a " & paternname & " at map " & map & " using predefined values and random variables.", 15)Call PlayerMsg(index, "Building Ground...", 15)tileset = GetVar("mapgenerator.ini", paternname & "Ground", "groundset")tilex = GetVar("mapgenerator.ini", paternname & "Ground", "groundx")tiley = GetVar("mapgenerator.ini", paternname & "Ground", "groundy")x = 0y = 0Do While y < 15 Do While x < 20 Call SetTile(map, x, y, tilex, tiley, tileset, 0) x = x + 1 Loopy = y + 1x = 0LoopCall PlayerMsg(index, "Finished Ground, building Patches...", 15)patch = 1patchmax = GetVar("mapgenerator.ini", paternname & "Ground", "patches") + 1Do While patch < patchmaxx = 0y = 0tileset = GetVar("mapgenerator.ini", paternname & "Ground", "patch" & patch & "set")tilex = GetVar("mapgenerator.ini", paternname & "Ground", "patch" & patch & "x")tiley = GetVar("mapgenerator.ini", paternname & "Ground", "patch" & patch & "y")likely = GetVar("mapgenerator.ini", paternname & "Ground", "patch" & patch & "likely")likelymin = Int(likely - 2)likelymax = Int(likely + 2)likely = Int((likelymax - likelymin + 1)*Rnd) + likelyminlikelycurrent = 1 Do While likelycurrent < likely x = Int((19 - 0 + 1)*Rnd)+0 y = Int((14 - 0 + 1)*Rnd)+0 Call SetTile(map, x, y, tilex, tiley, tileset, 1) likelycurrent = likelycurrent + 1 Looppatch = patch + 1LoopCall PlayerMsg(index, "Finished Patches, building Solids...", 15)solid = 1solidmax = GetVar("mapgenerator.ini", paternname & "Ground", "solids") + 1Do While solid < solidmaxx = 0y = 0tileset = GetVar("mapgenerator.ini", paternname & "Ground", "solid" & solid & "set")tilex = GetVar("mapgenerator.ini", paternname & "Ground", "solid" & solid & "x")tiley = GetVar("mapgenerator.ini", paternname & "Ground", "solid" & solid & "y")likely = GetVar("mapgenerator.ini", paternname & "Ground", "solid" & solid & "likely")likelymin = Int(likely - 2)likelymax = Int(likely + 2)likely = Int((likelymax - likelymin + 1)*Rnd) + likelyminlikelycurrent = 1 Do While likelycurrent < likely x = Int((18 - 1 + 1)*Rnd)+1 y = Int((13 - 1 + 1)*Rnd)+1 Call SetTile(map, x, y, tilex, tiley, tileset, 1) Call SetBlock(map, x, y) likelycurrent = likelycurrent + 1 Loopsolid = solid + 1LoopCall PlayerMsg(index, "Finished Solids, building Objects...", 15)object = 1objectmax = GetVar("mapgenerator.ini", paternname & "Ground", "objects") + 0layer = GetVar("mapgenerator.ini", paternname & "Ground", "objectlayer") + 0Do While object <= objectmax likelycurrent = 1 likely = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "likely") likelymin = Int(likely - 2) likelymax = Int(likely + 2) likely = Int((likelymax - likelymin + 1)*Rnd) + likelymin Do While likelycurrent <= likely width = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "width") height = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "height") tileset = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "set") x = Int((19 - 0 + 1)*Rnd) + 0 y = Int(((13 - height) - 0 + 1)*Rnd) + 0 xstart = x ystart = y objecttiles = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "tiles") + 0 objecttile = 1objectcontroll = 0Do While y < ystart + height Do While x < xstart + width If GetTileX(map, x, y, layer) > 0 Then objectcontroll = 1 End If If GetTileY(map, x, y, layer) > 0 Then objectcontroll = 1 End if x = x + 1 Loopx = xstarty = y + 1Loopy = ystartx = xstartloopvar = 1Do While objectcontroll = 1objectcontroll = 0 x = Int((19 - 0 + 1)*Rnd) + 0 y = Int(((13 - height) - 0 + 1)*Rnd) + 0 xstart = x ystart = yDo While y < ystart + height Do While x < xstart + width If GetTileX(map, x, y, layer) > 0 Then objectcontroll = 1 End If If GetTileY(map, x, y, layer) > 0 Then objectcontroll = 1 End if x = x + 1 Loopx = xstarty = y + 1Looploopvar = loopvar + 1If loopvar = 5000 Then Call PlayerMsg(index, "Map full. Aborting Current Object!", 12) objecttile = objecttiles + 1 likelycurrent = likely objectcontroll = 0End IfLoop Do While objecttile <= objecttiles objectx = xstart + GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "tile" & objecttile & "x") objecty = ystart + GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "tile" & objecttile & "y") objectxset = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "tile" & objecttile & "setx") objectyset = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "tile" & objecttile & "sety") blocked = GetVar("mapgenerator.ini", paternname & "Ground", "object" & object & "tile" & objecttile & "blocked") If blocked = 1 Then Call SetBlock(map, objectx, objecty) End If Call SetTile(map, objectx, objecty, objectxset, objectyset, tileset, layer) objecttile = objecttile + 1 Loop likelycurrent = likelycurrent + 1 Loopobject = object + 1LoopCall PlayerMsg(index, "Finished Objects, placing 2nd layer objects...", 15)object = 1objectmax = GetVar("mapgenerator.ini", paternname & "Ground", "objectsb") + 0layer = GetVar("mapgenerator.ini", paternname & "Ground", "object2layer") + 0Do While object <= objectmax likelycurrent = 1 likely = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "likely") likelymin = Int(likely - 2) likelymax = Int(likely + 2) likely = Int((likelymax - likelymin + 1)*Rnd) + likelymin Do While likelycurrent <= likely width = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "width") height = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "height") tileset = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "set") x = Int((19 - 0 + 1)*Rnd) + 0 y = Int(((13 - heigth) - 0 + 1)*Rnd) + 0 xstart = x ystart = y objecttiles = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "tiles") + 0 objecttile = 1objectcontroll = 0Do While y < ystart + height Do While x < xstart + width If GetTileX(map, x, y, layer) > 0 Then objectcontroll = 1 End If If GetTileY(map, x, y, layer) > 0 Then objectcontroll = 1 End if x = x + 1 Loopx = xstarty = y + 1Loopy = ystartx = xstartloopvar = 1Do While objectcontroll = 1objectcontroll = 0 x = Int((19 - 0 + 1)*Rnd) + 0 y = Int(((13 - height) - 0 + 1)*Rnd) + 0 xstart = x ystart = yDo While y < ystart + height Do While x < xstart + width If GetTileX(map, x, y, layer) > 0 Then objectcontroll = 1 End If If GetTileY(map, x, y, layer) > 0 Then objectcontroll = 1 End if x = x + 1 Loopx = xstarty = y + 1Looploopvar = loopvar + 1 If loopvar = 5000 Then Call PlayerMsg(index, "Map full. Aborting Current Object!", 12) objecttile = objecttiles + 1 likelycurrent = likely objectcontroll = 0End IfLoop Do While objecttile <= objecttiles objectx = xstart + GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "tile" & objecttile & "x") objecty = ystart + GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "tile" & objecttile & "y") objectxset = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "tile" & objecttile & "setx") objectyset = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "tile" & objecttile & "sety") blocked = GetVar("mapgenerator.ini", paternname & "Ground", "objectb" & object & "tile" & objecttile & "blocked") If blocked = 1 Then Call SetBlock(map, objectx, objecty) End If Call SetTile(map, objectx, objecty, objectxset, objectyset, tileset, layer) objecttile = objecttile + 1 Loop likelycurrent = likelycurrent + 1 Loopobject = object + 1LoopCall PlayerMsg(index, "Finished 2nd layer Objects!", 15)Call PlayerMsg(index, "Succesfully Generated a " & paternname & " at map " & map & ".", 15)End Sub
'Map save/load/generate commands'Hieronder: TextSay, 1, lengte commando (dus /x is 2, /xxxxx is 6)If LCase(Mid(TextSay, 1, 4)) = "/map" Then 'Als commando alleen voor GM's is, kun je hier Exit Sub doen 'Hieronder vorige getal + 1 (2x) If GetPlayerAccess(index) = 0 ThenExit SubEnd If If Len(TextSay) > 5 Then TextSay = Mid(TextSay, 5) 'Dit gebeurt er als er een commando op is gegeven, TextSay is het commando Select Case LCase(Trim(TextSay)) Case "clear" x = 0 y = 0 map = GetPlayerMap(index) Call PlayerMsg(index, "Clearing the map. Please wait...", 15) layer = 0 Do While layer < 9 Do While y < 15 Do While x < 20 Call SetTile(map, x, y, 0, 0, 0, layer) x = x + 1 Loop x = 0 y = y + 1 Loop x = 0 y = 0 layer = layer + 1 Loop x = 0 y = 0 Do While y < 15 Do While x < 20 Call SetAttribute(map,X,Y,0,0,0,0,"","","") x = x + 1 Loop x = 0 y = y + 1 Loop Call PlayerMsg(index, "Map cleared!", 15) Exit Sub Case "list paterns" n = 1 Do While n < 10 name = GetVar("mapgenerator.ini", "paternnames", n & "") Call PlayerMsg(index, n & ": " & name, 15) n = n + 1 Loop Exit Sub Case "save" Call SaveMap(index, GetPlayerMap(index)) Exit Sub Case "load" Call LoadMap(index, GetPlayerMap(index)) Exit Sub Case "help" Call PlayerMsg(index, "COMMAND REFERENCE for /map:", 15) Call PlayerMsg(index, "Admin mapping commands.", 15) Call PlayerMsg(index, "save: Will save the current map to a .ini file.", 15) Call PlayerMsg(index, "load: loads the saved map from the .ini file to the current map.", 15) Call PlayerMsg(index, "clear: completely clears the current map.", 15) Call PlayerMsg(index, "gen <map> <pattern number>: generate a map based on predevined values and random variables. Use /map gen help for more info!", 15) Call PlayerMsg(index, "putvars <pattern number>: will use the 2 first rows to put vars for the solids and patches. Row 1 being patches, row 2 being solids. Use the MASK layer!", 15) Call PlayerMsg(index, "putobject <pattern number> <object number> <width> <height>: saves an object made in MASK layer as an object to the mapgenerator.ini file!", 15) Call PlayerMsg(index, "put2object <pattern number> <object number> <width> <height>: saves an object made in MASK layer as an 2nd layer object to the mapgenerator.ini file!", 15) 'Call PlayerMsg(index, "", 15) Exit Sub End Select'Hieronder TestSay, 1, lengte subcommando If Mid(TextSay, 2, 7) = "putvars" Then x = 1 name = Int(Mid(TextSay, 10, 10)) name = GetVar("mapgenerator.ini", "paternnames", name & "") Do While x < 20 Call PutVar("mapgenerator.ini", name & "Ground", "patch" & X & "set", GetTileSet(GetPlayerMap(index), x, 0, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "patch" & X & "x", GetTileX(GetPlayerMap(index), x, 0, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "patch" & X & "y", GetTileY(GetPlayerMap(index), x, 0, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "patch" & X & "likely", "3") x = x + 1 Loop x = 1 Do While x < 20 If GetTileX(GetPlayerMap(index), x, 1, 1) > 0 or GetTileY(GetPlayerMap(index), x, 1, 1) > 0 Then Call PutVar("mapgenerator.ini", name & "Ground", "solid" & X & "set", GetTileSet(GetPlayerMap(index), x, 1, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "solid" & X & "x", GetTileX(GetPlayerMap(index), x, 1, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "solid" & X & "y", GetTileY(GetPlayerMap(index), x, 1, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "solid" & X & "likely", "1") Else x = 20 End If x = x + 1 Loop Call PutVar("mapgenerator.ini", name & "Ground", "groundset", GetTileSet(GetPlayerMap(index), 0, 0, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "groundx", GetTileX(GetPlayerMap(index), 0, 0, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "groundy", GetTileY(GetPlayerMap(index), 0, 0, 1) & "") Call PlayerMsg(index, "Saved solid, patches and ground tiles for the " & name & " pattern.", 15) Exit Sub End If If Mid(TextSay, 2, 9) = "putobject" Then objectnumber = Mid(TextSay, 14, 1) name = Mid(TextSay, 12, 1) width = Int(Mid(TextSay, 16, 1)) height = Int(Mid(TextSay, 18, 1)) name = GetVar("mapgenerator.ini", "paternnames", name & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "width", width & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "height", height & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "tiles", height * width & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "likely", "1") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "set", GetTileSet(GetPlayerMap(index), width - 1, height - 1, 1) & "") x = 0 y = 0 n = 1 Do While y < height Do while x < width Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "tile" & n & "x", x & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "tile" & n & "y", y & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "tile" & n & "setx", GetTileX(GetPlayerMap(index), x, y, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "tile" & n & "sety", GetTileY(GetPlayerMap(index), X, Y, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "tile" & n & "blocked", "0") If GetAttribute(GetPlayerMap(index), x, y) = 1 Then Call PutVar("mapgenerator.ini", name & "Ground", "object" & objectnumber & "tile" & n & "blocked", "1") End If n = n + 1 x = x + 1 Loop x = 0 y = y + 1 Loop Call PlayerMsg(index, "Saved as object " & objectnumber & " on the " & name & " pattern!", 15) Exit Sub End If If Mid(TextSay, 2, 10) = "put2object" Then objectnumber = Mid(TextSay, 15, 1) name = Mid(TextSay, 13, 1) width = Int(Mid(TextSay, 17, 1)) height = Int(Mid(TextSay, 19, 1)) name = GetVar("mapgenerator.ini", "paternnames", name & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "width", width & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "height", height & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "tiles", height * width & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "likely", "1") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "set", GetTileSet(GetPlayerMap(index), width, height, 1) & "") x = 0 y = 0 n = 1 Do While y < height Do while x < width Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "tile" & n & "x", x & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "tile" & n & "y", y & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "tile" & n & "setx", GetTileX(GetPlayerMap(index), x, y, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "tile" & n & "sety", GetTileY(GetPlayerMap(index), X, Y, 1) & "") Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "tile" & n & "blocked", "0") If GetAttribute(GetPlayerMap(index), x, y) = 1 Then Call PutVar("mapgenerator.ini", name & "Ground", "objectb" & objectnumber & "tile" & n & "blocked", "1") End If n = n + 1 x = x + 1 Loop x = 0 y = y + 1 Loop Call PlayerMsg(index, "Saved object as 2nd layer object " & objectnumber & " on the " & name & " pattern!", 15) Exit Sub End If If Mid(TextSay, 2, 3) = "gen" then map = Mid(TextSay, 6, 3) patern = Int(Mid(TextSay, 10, 1)) If map = "loc" Then map = GetPlayerMap(index) End If Call GenerateMap(index, map, patern) Exit Sub End If Call PlayerMsg(index, "This command does not exist. Please enter /map help for all commands.", 12) Else 'Dit gebeurt er als je niets invult achter het commando Call PlayerMsg(index, "You need to enter a subcommand. Please enter /map help for all commands.", 12) End If Exit SubEnd If
[paternnames]1=Patername12=Patername23=Patername34=Patername45=Patername56=Patername67=Patername78=Patername89=Patername9
[paternname1ground]groundset=0groundx=7groundy=3
patches=2solids=2
patch1set=0patch1x=8patch1y=3patch1likely=3patch2set=0patch2x=9patch2y=3patch2likely=3
solid1set=0solid1x=5solid1y=209solid1likely=3solid2set=0solid2x=6solid2y=209solid2likely=3
objects=0objectsb=2objectlayer=5object2layer=7
objectb1likely=2object1likely=2
'*****************************************************************'*****************************************************************'XX This script has been created by Ilnair, aka Dinand Mentink XX'XX Please do not give it out saying you made it, or distribute XX'XX it anywhere outside the Eclipse forums! Also, please always XX'XX distribute these credits along with the script! XX'XX www.nishansu.tk ©Dinand Mentink (aka Ilnair)XX'*****************************************************************'*****************************************************************
Ok, now you installed the script. Now the fun is about to start .
map = Mid(TextSay, 6, 3)
map = Mid(TextSay, 6, 1)
This thing rocks... just ermm.. a few notes for people trying to use this script:1. either change Quote map = Mid(TextSay, 6, 3) to Quote map = Mid(TextSay, 6, 1) or alway be on the map you want to generate and type /map gen loc <pattern #>~~~~~~2.~~forgot xD I hate it when that happens.. anyways great script! but I guess you just "pooned" use mappers too, cause now we're outta a job
'Dit gebeurt er als je niets invult achter het commandolol goew gedaan hoor sad to see you leaving :'(
ok, looking forward to some results .