Jump to content

Search the Community

Showing results for tags 'in game map'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • News & Announcements
    • News
  • Project Zomboid
    • PZ Updates
    • General Discussions
    • Bug Reports
    • PZ Support
    • PZ Multiplayer
    • PZ Community & Creativity
    • PZ Suggestions
  • PZ Modding
    • Tutorials & Resources
    • Mods
    • Items
    • Mapping
    • Mod Ideas and Requests
  • General Games Development
    • Indie Scene
  • Other Discussions
    • General Discussion
    • Forum Games & Activities

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


AIM


MSN


Website URL


ICQ


Yahoo


Jabber


Skype


Twitter


Interests

Found 1 result

  1. First, create the following file structure (if you are adding the lootable map to your own map mod then create all folders within the media folder below in your map mods media folder instead): Spoiler MyLootableMapsMod >media >>lua >>>server >>>>Items >>>client >>>>ISUI >>>>>Maps >scripts >textures >>worldMap Next up create a .txt file in the scripts folder called something like "mylootablemap" (except make it more unique to avoid any possible compatability issues with other mods that might use the same names), it should include this code: Spoiler module Base { item MyLootableMap { DisplayCategory = Cartography, Type = Map, DisplayName = Your map name here, Icon = Map, Weight = 0.1, Map = MyLootableMap, WorldStaticModel = Map, } } The above code is adding a new item with the internal name "MyLootableMap" (so again make sure yours is something unique) into the vanilla pool of items, the above settings work for maps. The next file you need you will want to create in the "media\lua\server\Items" folder, call it something like MyLootableMapDistribution.lua but again make it's a unique name to avoid any possible mod imcompatability with other mods. It should contain the following code: Spoiler local function preDistributionMerge() table.insert(ProceduralDistributions.list.MagazineRackMaps.items, "MyLootableMap"); table.insert(ProceduralDistributions.list.MagazineRackMaps.items, 50); end Events.OnPreDistributionMerge.Add(preDistributionMerge); In the above code you can see that we are adding our new Item "MyLootableMap" into the "MagazineRackMaps" loot table inside of ProceduralDistributions.lua, this will affect any roomDef of any building that pulls from the MagazineRackMaps loot table. We are doing it this way as the definition we want to add to has the "procedural" tag in Distributions.lua and is therefore using the procedural loot tables. The number 50 is the "weight" of the item you are adding, higher number = more chance. To find the current room and container definitions, navigate to your "steamapps\common\ProjectZomboid\media\lua\server\Items" folder and open the Distributions.lua file. If the definition you want to add your item to is not procedural (does not have the "procedural = true" line) then you want to add this code instead of the above code: Spoiler local myMapdistributionTable = { all = { shelves = { rolls = 5, items = { "Magazine", 20, "Newspaper", 20, "Book", 20, "SheetPaper2", 20, "Notebook", 20, "BookTailoring1", 2, "BookTailoring2", 1, "BookTailoring3", 0.7, "BookTailoring4", 0.5, "BookTailoring5", 0.3, "BookCarpentry1", 2, "BookCarpentry2", 1, "BookCarpentry3", 0.7, "BookCarpentry4", 0.5, "BookCarpentry5", 0.3, "BookCooking1", 2, "BookCooking2", 1, "BookCooking3", 0.5, "BookCooking4", 0.3, "BookForaging1", 2, "BookForaging2", 1, "BookForaging3", 0.7, "BookForaging4", 0.5, "BookForaging5", 0.3, "BookFarming1", 2, "BookFarming2", 1, "BookFarming3", 0.7, "BookFarming4", 0.5, "BookFarming5", 0.3, "BookFishing1", 2, "BookFishing2", 1, "BookFishing3", 0.7, "BookFishing4", 0.5, "BookFishing5", 0.3, "BookTrapping1", 2, "BookTrapping2", 1, "BookTrapping3", 0.7, "BookTrapping4", 0.5, "BookTrapping5", 0.3, "BookFirstAid1", 2, "BookFirstAid2", 1, "BookFirstAid3", 0.7, "BookFirstAid4", 0.5, "BookFirstAid5", 0.3, "BookMetalWelding1", 2, "BookMetalWelding2", 1, "BookMetalWelding3", 0.7, "BookMetalWelding4", 0.5, "BookMetalWelding5", 0.3, "BookElectrician1", 2, "BookElectrician2", 1, "BookElectrician3", 0.7, "BookElectrician4", 0.5, "BookElectrician5", 0.3, "BookMechanic1", 2, "BookMechanic2", 1, "BookMechanic3", 0.7, "BookMechanic4", 0.5, "BookMechanic5", 0.3, "FishingMag1", 1, "FishingMag2", 1, "HuntingMag1", 1, "HuntingMag2", 1, "HuntingMag3", 1, "HerbalistMag", 1, "FarmingMag1", 1, "CookingMag1", 1, "CookingMag2", 1, "ElectronicsMag1", 1, "ElectronicsMag2", 1, "ElectronicsMag3", 1, "ElectronicsMag4", 1, "ElectronicsMag5", 1, "MechanicMag1", 1, "MechanicMag2", 1, "MechanicMag3", 1, "EngineerMagazine1", 1, "EngineerMagazine2", 1, "MetalworkMag1", 1, "MetalworkMag2", 1, "MetalworkMag3", 1, "MetalworkMag4", 1, "Journal", 2, "Radio.RadioBlack",2, "Radio.RadioRed",1, "MyLootableMap", 50, } }, } } table.insert(Distributions, 2, myMapdistributionTable); This would add your map to the existing "all>shelves" definitions, which would be every shelves container in the game world not inside a roomdef defined inside Distributions.lua, so for example your map would not spawn on shelves that are placed inside a "bookstore" room def as that room def already exists in Distributions.lua with a rule for shelves. You can also check this thread: for a more in-depth guide to working with the loot tables. Lastly, inside of your "media\lua\client\ISUI\Maps" folder create a new file called something like MyLootableMapDefinition.lua (make it unique to your mod instead of a generic name) and include the following code: Spoiler require "ISMapDefinitions" MapUtils = {} function MapUtils.initDirectoryMapData(mapUI, directory) local mapAPI = mapUI.javaObject:getAPIv1() local file = directory..'/worldmap-forest.xml' if fileExists(file) then mapAPI:addData(file) end file = directory..'/worldmap.xml' if fileExists(file) then mapAPI:addData(file) end -- This call indicates the end of XML data files for the directory. -- If map features exist for a particular cell in this directory, -- then no data added afterwards will be used for that same cell. mapAPI:endDirectoryData() mapAPI:addImages(directory) end function MapUtils.initDefaultMapData(mapUI) local mapAPI = mapUI.javaObject:getAPIv1() mapAPI:clearData() -- Add data from highest priority (mods) to lowest priority (vanilla) local dirs = getLotDirectories() for i=1,dirs:size() do MapUtils.initDirectoryMapData(mapUI, 'media/maps/'..dirs:get(i-1)) end end local MINZ = 0 local MAXZ = 24 local WATER_TEXTURE = false function MapUtils.initDefaultStyleV1(mapUI) local mapAPI = mapUI.javaObject:getAPIv1() local styleAPI = mapAPI:getStyleAPI() local r,g,b = 219/255, 215/255, 192/255 mapAPI:setBackgroundRGBA(r, g, b, 1.0) mapAPI:setUnvisitedRGBA(r * 0.915, g * 0.915, b * 0.915, 1.0) mapAPI:setUnvisitedGridRGBA(r * 0.777, g * 0.777, b * 0.777, 1.0) styleAPI:clear() local layer = styleAPI:newPolygonLayer("forest") layer:setMinZoom(13.5) layer:setFilter("natural", "forest") if true then layer:addFill(MINZ, 189, 197, 163, 0) layer:addFill(13.5, 189, 197, 163, 0) layer:addFill(14, 189, 197, 163, 255) layer:addFill(MAXZ, 189, 197, 163, 255) else layer:addFill(MINZ, 255, 255, 255, 255) layer:addFill(MAXZ, 255, 255, 255, 255) layer:addTexture(MINZ, "media/textures/worldMap/Grass.png") layer:addTexture(MAXZ, "media/textures/worldMap/Grass.png") layer:addScale(13.5, 4.0) layer:addScale(MAXZ, 4.0) end layer = styleAPI:newPolygonLayer("water") layer:setMinZoom(MINZ) layer:setFilter("water", "river") if not WATER_TEXTURE then layer:addFill(MINZ, 59, 141, 149, 255) layer:addFill(MAXZ, 59, 141, 149, 255) else layer:addFill(MINZ, 59, 141, 149, 255) layer:addFill(14.5, 59, 141, 149, 255) layer:addFill(14.5, 255, 255, 255, 255) layer:addTexture(MINZ, nil) layer:addTexture(14.5, nil) layer:addTexture(14.5, "media/textures/worldMap/Water.png") layer:addTexture(MAXZ, "media/textures/worldMap/Water.png") -- layer:addScale(MINZ, 4.0) -- layer:addScale(MAX, 4.0) end layer = styleAPI:newPolygonLayer("road-trail") layer:setMinZoom(12.0) layer:setFilter("highway", "trail") layer:addFill(12.25, 185, 122, 87, 0) layer:addFill(13, 185, 122, 87, 255) layer:addFill(MAXZ, 185, 122, 87, 255) layer = styleAPI:newPolygonLayer("road-tertiary") layer:setMinZoom(11.0) layer:setFilter("highway", "tertiary") layer:addFill(11.5, 171, 158, 143, 0) layer:addFill(13, 171, 158, 143, 255) layer:addFill(MAXZ, 171, 158, 143, 255) layer = styleAPI:newPolygonLayer("road-secondary") layer:setMinZoom(11.0) layer:setFilter("highway", "secondary") layer:addFill(MINZ, 134, 125, 113, 255) layer:addFill(MAXZ, 134, 125, 113, 255) layer = styleAPI:newPolygonLayer("road-primary") layer:setMinZoom(11.0) layer:setFilter("highway", "primary") layer:addFill(MINZ, 134, 125, 113, 255) layer:addFill(MAXZ, 134, 125, 113, 255) layer = styleAPI:newPolygonLayer("railway") layer:setMinZoom(14.0) layer:setFilter("railway", "*") layer:addFill(MINZ, 200, 191, 231, 255) layer:addFill(MAXZ, 200, 191, 231, 255) -- Default, same as building-Residential layer = styleAPI:newPolygonLayer("building") layer:setMinZoom(13.0) layer:setFilter("building", "yes") layer:addFill(13.0f, 210, 158, 105, 0) layer:addFill(13.5f, 210, 158, 105, 255) layer:addFill(MAXZ, 210, 158, 105, 255) layer = styleAPI:newPolygonLayer("building-Residential") layer:setMinZoom(13.0) layer:setFilter("building", "Residential") layer:addFill(13.0f, 210, 158, 105, 0) layer:addFill(13.5f, 210, 158, 105, 255) layer:addFill(MAXZ, 210, 158, 105, 255) layer = styleAPI:newPolygonLayer("building-CommunityServices") layer:setMinZoom(13.0) layer:setFilter("building", "CommunityServices") layer:addFill(13.0f, 139, 117, 235, 0) layer:addFill(13.5f, 139, 117, 235, 255) layer:addFill(MAXZ, 139, 117, 235, 255) layer = styleAPI:newPolygonLayer("building-Hospitality") layer:setMinZoom(13.0) layer:setFilter("building", "Hospitality") layer:addFill(13.0f, 127, 206, 225, 0) layer:addFill(13.5f, 127, 206, 225, 255) layer:addFill(MAXZ, 127, 206, 225, 255) layer = styleAPI:newPolygonLayer("building-Industrial") layer:setMinZoom(13.0) layer:setFilter("building", "Industrial") layer:addFill(13.0f, 56, 54, 53, 0) layer:addFill(13.5f, 56, 54, 53, 255) layer:addFill(MAXZ, 56, 54, 53, 255) layer = styleAPI:newPolygonLayer("building-Medical") layer:setMinZoom(13.0) layer:setFilter("building", "Medical") layer:addFill(13.0f, 229, 128, 151, 0) layer:addFill(13.5f, 229, 128, 151, 255) layer:addFill(MAXZ, 229, 128, 151, 255) layer = styleAPI:newPolygonLayer("building-RestaurantsAndEntertainment") layer:setMinZoom(13.0) layer:setFilter("building", "RestaurantsAndEntertainment") layer:addFill(13.0f, 245, 225, 60, 0) layer:addFill(13.5f, 245, 225, 60, 255) layer:addFill(MAXZ, 245, 225, 60, 255) layer = styleAPI:newPolygonLayer("building-RetailAndCommercial") layer:setMinZoom(13.0) layer:setFilter("building", "RetailAndCommercial") layer:addFill(13.0f, 184, 205, 84, 0) layer:addFill(13.5f, 184, 205, 84, 255) layer:addFill(MAXZ, 184, 205, 84, 255) end function MapUtils.overlayPaper(mapUI) local mapAPI = mapUI.javaObject:getAPIv1() local styleAPI = mapAPI:getStyleAPI() local layer = styleAPI:newTextureLayer("paper") layer:setMinZoom(0.00) local x1 = mapAPI:getMinXInSquares() local y1 = mapAPI:getMinYInSquares() local x2 = mapAPI:getMaxXInSquares() + 1 local y2 = mapAPI:getMaxYInSquares() + 1 layer:setBoundsInSquares(x1, y1, x2, y2) layer:setTile(true) layer:setUseWorldBounds(true) layer:addFill(14.00, 128, 128, 128, 0) layer:addFill(15.00, 128, 128, 128, 32) layer:addFill(15.00, 255, 255, 255, 32) layer:addTexture(0.00, "media/white.png") layer:addTexture(15.00, "media/white.png") layer:addTexture(15.00, "media/textures/worldMap/Paper.png") end function MapUtils.revealKnownArea(mapUI) local mapAPI = mapUI.javaObject:getAPIv1() local x1 = mapAPI:getMinXInSquares() local y1 = mapAPI:getMinYInSquares() local x2 = mapAPI:getMaxXInSquares() local y2 = mapAPI:getMaxYInSquares() WorldMapVisited.getInstance():setKnownInSquares(x1, y1, x2, y2) end ----- local function replaceWaterStyle(mapUI) if not WATER_TEXTURE then return end local mapAPI = mapUI.javaObject:getAPIv1() local styleAPI = mapAPI:getStyleAPI() local layer = styleAPI:getLayerByName("water") if not layer then return end layer:setMinZoom(MINZ) layer:setFilter("water", "river") layer:removeAllFill() layer:removeAllTexture() layer:addFill(MINZ, 59, 141, 149, 255) layer:addFill(MAXZ, 59, 141, 149, 255) end local function overlayPNG(mapUI, x, y, scale, layerName, tex, alpha) local texture = getTexture(tex) if not texture then return end local mapAPI = mapUI.javaObject:getAPIv1() local styleAPI = mapAPI:getStyleAPI() local layer = styleAPI:newTextureLayer(layerName) layer:setMinZoom(MINZ) layer:addFill(MINZ, 255, 255, 255, (alpha or 1.0) * 255) layer:addTexture(MINZ, tex) layer:setBoundsInSquares(x, y, x + texture:getWidth() * scale, y + texture:getHeight() * scale) end local function overlayPNG2(mapUI, x, y, scaleX, scaleY, tex) local mapAPI = mapUI.javaObject:getAPIv1() local styleAPI = mapAPI:getStyleAPI() local layer = styleAPI:newTextureLayer("lootMapPNG") layer:setMinZoom(MINZ) local texture = getTexture(tex) layer:addFill(MINZ, 255, 255, 255, 128) layer:addTexture(MINZ, tex) layer:setBoundsInSquares(x, y, x + texture:getWidth() * scaleX, y + texture:getHeight() * scaleY) end -- -- -- -- -- Now, after the last set of dashed lines you can add your lootable map definitions with the following code: Spoiler LootMaps.Init.MyLootableMap = function(mapUI) local mapAPI = mapUI.javaObject:getAPIv1() MapUtils.initDirectoryMapData(mapUI, 'media/maps/MyMapMod') -- 'media/maps/MyMapMod' - this should be where your maps worldmap.xml file is MapUtils.initDefaultStyleV1(mapUI) -- Specify the appearance of the map. replaceWaterStyle(mapUI) -- Use solid color for water instead of a texture. mapAPI:setBoundsInSquares(12900, 9900, 14399, 11399) -- (starting x, starting y, ending x, ending y) of the area you want to display and uncover, in World Co-ordinates. overlayPNG(mapUI, 14299, 9900, 0.666, "badge", "media/textures/worldMap/MyLootableMapBadge.png") -- Add your lootable maps banner PNG. overlayPNG(mapUI, 13000, 10000, 0.666, "legend", "media/textures/worldMap/Legend.png") -- Add the legend PNG. MapUtils.overlayPaper(mapUI) -- Draw a paper-like texture overtop the map. end Make sure that your "LootMaps.Init.MyLootableMap" on line 1 matches the name you specified on the "Maps = " line in your map item script you made earlier in this tutorial. The rest of the code is commented to describe what they do. The "textures\worldMap" folder that you created at the start should be used to store your maps name banner png if you have one and is referenced in the above code to make your lootable map look more official. As you can see, no external PNG's need to be created as the map is drawn from the data stored in the maps worldmap.xml file, which is what the "mapAPI:setBoundsInSquares" is using to draw a certain section of the overall world map. And that's it, copy your entire folder structure into your "C:\Users\YourUserNameHere\Zomboid\Mods" folder, load up the game, enable the mod (Your map mod if you made your lootable maps as part of a map mod) and start a new game, you now have your lootable map in game and waiting for you to find, and when you do it will uncover that area automatically on the main in game map. If you need a working example you can always subscribe to Bedford Falls on Steam and check it's workshop folder "steamapps\workshop\content\108600\522891356" . It's handy to verify your folder/file structure etc if you're having problems.
×
×
  • Create New...