chenjywz 发表于 2012-4-23 22:35

海岛大亨4资源上限修改方法

本帖最后由 chenjywz 于 2012-4-26 12:04 编辑

是论坛转帖的去除人口上限的帖子启发了我,经过对lua的反编译以及和Swixel的交流,最终发现在他的去除人口上限代码中的NoLimitsMod(0)的最后加入
g_Classes.LargeGoldMarker.Amount = 20000000,就可以在挑战中将单个金矿的数目修改为20,000,000,我相信足够了,而且经过测试,矿井的一次采集大概在200左右,这样不会导致卡车司机不足。同理可以加LargeIronMarker,LargeBauxiteMarker。
全部的代码如下,我这里的人口上限是5000,而且一次不会有那么多人移民进来。

local GameEntityCount = 200000
local MaxPopulation = 5000

-- Original mod code
function NoLimitsMod()
    -- Sets the entity count
    config.MaxGameObjectExCount = GameEntityCount
    config.MaxGameObjectCount = GameEntityCount

    -- Remove the road construction limitations
    road_construction.ReachedLimit =function(x)
      return false
    end

    -- Sets the population
    MigrationMaxCitizens = MaxPopulation

    ImmigrationRandomize = function(y)
      return MulDivRound(y, MaxPopulation - CitizenCount, 60)
    end


      g_Classes.LargeGoldMarker.Amount = 80000000
      g_Classes.LargeBauxiteMarker.Amount = 80000000
      g_Classes.SmallGoldMarker.Amount = 8000000
      g_Classes.LargeIronMarker.Amount = 20000000


end



-- Only fire once
local FiredOnce = false

-- UA Set Mode
OnMsg.UASetMode = function(actions,mode)

    -- Fire until fired once
    if not FiredOnce then
      -- If we boot, trip it ...
      if(mode == "Boot") then
            FiredOnce = true

            -- Run the thread to bypass it
            CreateRealTimeThread(function()

                -- Do mod loading code here.
                NoLimitsMod()

                -- Reconfigure/force the settings every map load.
                OnMsg.MapPermanentObjectsLoaded = function()
                  NoLimitsMod()
                end
            end)
      end
    end
end

-- Legacy load (what the original mod used)
OnMsg.ClassesPreprocess = function()
    NoLimitsMod()
end


页: [1]
查看完整版本: 海岛大亨4资源上限修改方法