Advertisement
Guest User

Untitled

a guest
Oct 11th, 2019
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.54 KB | None | 0 0
  1. ----------------------------------------------------------------------------------
  2. -- Basic LUA-Script for all maps in Siedler 2 - Return to the Roots         --
  3. -- https://www.siedler25.org                                                    --
  4. -- Author: etother (v0.1)                           --
  5. -- special thanks to CrazyL, who made the files I learned from (v0.4)       --
  6. -- Also special thanks to the RttR Team, who made this possible         -- 
  7.                                  
  8. ------------------------General Informations - code below-------------------------
  9.  
  10. -------------------------------- Lua Version used -------------------------------
  11. function getRequiredLuaVersion()
  12.     return 1
  13. end
  14.  
  15. -------------------------------- general settings -------------------------------
  16.  
  17. function getAllowedChanges()    -- change this for enable or disable the checkboxes in settings menu
  18.    
  19.     return {general=true, addonsAll=true, addonsSome=false, swapping=true, playerState = not isSinglePlayer, ownNation = true, ownColor=true, ownTeam=true, aiNation=true, aiColor=true, aiTeam=true}
  20. end
  21.  
  22.  
  23. function onSettingsReady()
  24.  
  25. rttr:SetGameSettings({                     
  26.         ["fow"] = EXP_DISABLED,
  27.         ["startWares"] = SWR_ALOT })
  28. rttr:GetPlayer(1):SetAI(3)
  29.  
  30. end
  31.  
  32.  
  33. -------------------- set resources - CURRENTLY FOR PLAYER 2 ONLY-----------------
  34.  
  35. function onStart(isFirstStart)     
  36.     for i = 0, (rttr:GetPlayerCount() - 1) do   -- This is a call for player 1 to player n, Depends on how many players are playing. They will do the code below. "rttr:GetPlayerCount() - 1" could changed by the concrete number of players.
  37.         AddPlayerBld(i, not isFirstStart)   -- They do the "function" with the name "AddPlayerBld" also at the start of the game. This is a new defined function, no RttR Standard, need to be written correctly
  38.         AddPlayerRes(i, not isFirstStart)   -- They do the "function" with the name "AddPlayerRes" also at the start of the game. This is a new defined function, no RttR Standard, need to be written correctly
  39.        
  40.     end
  41.    
  42.     rttr:GetWorld():AddStaticObject(17,101, 502, 0xFFFF, 1)
  43.     rttr:GetWorld():AddStaticObject(17,102, 502, 0xFFFF, 1)
  44.     rttr:GetWorld():AddStaticObject(16,102, 502, 0xFFFF, 1)
  45.     rttr:GetWorld():AddStaticObject(15,101, 502, 0xFFFF, 1)
  46.     rttr:GetWorld():AddStaticObject(17,100, 502, 0xFFFF, 1)
  47.    
  48. end
  49.  
  50. function AddPlayerBld(p, onLoad)            -- The "function" with the name "AddPlayerBld" is done on Loading the game for player p. p is defined by next code
  51.  
  52.     if(p == 1) then                 -- Does the code for Player 2
  53.     rttr:GetPlayer(p):SetRestrictedArea(
  54.             nil, nil,
  55.             0,127,
  56.             31,127,
  57.             31,0,
  58.             0,0,
  59.             nil,nil,            -- Anmerkung: die gesetzten Koordinaten sind kein Bestandteil des "Sperrgebiets"
  60.             11,43,
  61.             20,43,
  62.             21,44,
  63.             12,44,
  64.             11,43)
  65.     end
  66. end
  67.  
  68. function AddPlayerRes(p, onLoad)            -- The "function" with the name "AddPlayerRes" is done on Loading the game for player p. p is defined by next code
  69.     if onLoad then return               -- It stops at Loading the Map, Just works at start of game
  70.     end
  71.  
  72.     if(p == 0) then                 -- Does the code for Player 1
  73.     rttr:GetPlayer(p):AddWares({       
  74.         [GD_BEER      ] =  0,      
  75.         [GD_TONGS     ] =  0,      
  76.         [GD_HAMMER    ] =  0,      
  77.         [GD_AXE       ] =  0,
  78.         [GD_SAW       ] =  0,
  79.         [GD_PICKAXE   ] =  0,
  80.         [GD_SHOVEL    ] =  0,
  81.         [GD_CRUCIBLE  ] =  0,
  82.         [GD_RODANDLINE] =  0,
  83.         [GD_SCYTHE    ] =  0,
  84.         [GD_WATER     ] =  0,
  85.         [GD_CLEAVER   ] =  0,
  86.         [GD_ROLLINGPIN] =  0,
  87.         [GD_BOW       ] =  0,
  88.         [GD_BOAT      ] =  0,
  89.         [GD_SWORD     ] =  0,
  90.         [GD_IRON      ] =  0,
  91.         [GD_FLOUR     ] =  0,
  92.         [GD_FISH      ] =  0,
  93.         [GD_BREAD     ] =  0,
  94.         [GD_SHIELD    ] =  0,
  95.         [GD_WOOD      ] =  0,
  96.         [GD_BOARDS    ] =  0,
  97.         [GD_STONES    ] =  0,
  98.         [GD_GRAIN     ] =  0,
  99.         [GD_COINS     ] =  0,
  100.         [GD_GOLD      ] =  0,
  101.         [GD_IRONORE   ] =  0,
  102.         [GD_COAL      ] =  0,
  103.         [GD_MEAT      ] =  0,
  104.         [GD_HAM       ] =  0
  105.         })
  106.  
  107.     rttr:GetPlayer(p):AddPeople({
  108.         [JOB_HELPER     ] =  0,
  109.         [JOB_WOODCUTTER     ] =  0,
  110.         [JOB_FISHER     ] =  0,
  111.         [JOB_FORESTER       ] =  0,
  112.         [JOB_CARPENTER      ] =  0,
  113.         [JOB_STONEMASON     ] =  0,
  114.         [JOB_HUNTER     ] =  0,
  115.         [JOB_FARMER     ] =  0,
  116.         [JOB_MILLER     ] =  0,
  117.         [JOB_BAKER      ] =  0,
  118.         [JOB_BUTCHER            ] =  0,
  119.         [JOB_MINER      ] =  0,
  120.         [JOB_BREWER     ] =  0,
  121.         [JOB_PIGBREEDER         ] =  0,
  122.         [JOB_DONKEYBREEDER      ] =  0,
  123.         [JOB_IRONFOUNDER        ] =  0,
  124.         [JOB_MINTER     ] =  0,
  125.         [JOB_METALWORKER        ] =  0,
  126.         [JOB_ARMORER            ] =  0,
  127.         [JOB_BUILDER            ] =  0,
  128.         [JOB_PLANER     ] =  0,
  129.         [JOB_GEOLOGIST          ] =  0,
  130.         [JOB_PRIVATE            ] =  0,
  131.         [JOB_PRIVATEFIRSTCLASS  ] =  0,
  132.         [JOB_SERGEANT           ] =  0,
  133.         [JOB_OFFICER            ] =  0,
  134.         [JOB_GENERAL            ] =  0,
  135.         [JOB_SCOUT      ] =  0,
  136.         [JOB_SHIPWRIGHT         ] =  0,
  137.         [JOB_PACKDONKEY         ] =  0,
  138.         [JOB_CHARBURNER         ] =  0
  139.         })
  140.     end
  141.  
  142.     if not(p == 0) then             -- Do the Code for all other players than Player 1
  143.     rttr:GetPlayer(p):AddWares({       
  144.         [GD_BEER      ] =  0,      
  145.         [GD_TONGS     ] =  0,      
  146.         [GD_HAMMER    ] =  0,      
  147.         [GD_AXE       ] =  0,
  148.         [GD_SAW       ] =  0,
  149.         [GD_PICKAXE   ] =  0,
  150.         [GD_SHOVEL    ] =  0,
  151.         [GD_CRUCIBLE  ] =  0,
  152.         [GD_RODANDLINE] =  0,
  153.         [GD_SCYTHE    ] =  0,
  154.         [GD_WATER     ] =  0,
  155.         [GD_CLEAVER   ] =  0,
  156.         [GD_ROLLINGPIN] =  0,
  157.         [GD_BOW       ] =  0,
  158.         [GD_BOAT      ] =  0,
  159.         [GD_SWORD     ] =  0,
  160.         [GD_IRON      ] =  0,
  161.         [GD_FLOUR     ] =  0,
  162.         [GD_FISH      ] =  0,
  163.         [GD_BREAD     ] =  0,
  164.         [GD_SHIELD    ] =  0,
  165.         [GD_WOOD      ] =  0,
  166.         [GD_BOARDS    ] =  0,
  167.         [GD_STONES    ] =  0,
  168.         [GD_GRAIN     ] =  0,
  169.         [GD_COINS     ] =  0,
  170.         [GD_GOLD      ] =  0,
  171.         [GD_IRONORE   ] =  0,
  172.         [GD_COAL      ] =  0,
  173.         [GD_MEAT      ] =  0,
  174.         [GD_HAM       ] =  0
  175.         })
  176.  
  177.     rttr:GetPlayer(p):AddPeople({
  178.         [JOB_HELPER     ] =  0,
  179.         [JOB_WOODCUTTER     ] =  0,
  180.         [JOB_FISHER     ] =  0,
  181.         [JOB_FORESTER       ] =  0,
  182.         [JOB_CARPENTER      ] =  0,
  183.         [JOB_STONEMASON     ] =  0,
  184.         [JOB_HUNTER     ] =  0,
  185.         [JOB_FARMER     ] =  0,
  186.         [JOB_MILLER     ] =  0,
  187.         [JOB_BAKER      ] =  0,
  188.         [JOB_BUTCHER            ] =  0,
  189.         [JOB_MINER      ] =  0,
  190.         [JOB_BREWER     ] =  0,
  191.         [JOB_PIGBREEDER         ] =  0,
  192.         [JOB_DONKEYBREEDER      ] =  0,
  193.         [JOB_IRONFOUNDER        ] =  0,
  194.         [JOB_MINTER     ] =  0,
  195.         [JOB_METALWORKER        ] =  0,
  196.         [JOB_ARMORER            ] =  0,
  197.         [JOB_BUILDER            ] =  0,
  198.         [JOB_PLANER     ] =  0,
  199.         [JOB_GEOLOGIST          ] =  0,
  200.         [JOB_PRIVATE            ] =  0,
  201.         [JOB_PRIVATEFIRSTCLASS  ] =  0,
  202.         [JOB_SERGEANT           ] =  0,
  203.         [JOB_OFFICER            ] =  0,
  204.         [JOB_GENERAL            ] =  0,
  205.         [JOB_SCOUT      ] =  0,
  206.         [JOB_SHIPWRIGHT         ] =  0,
  207.         [JOB_PACKDONKEY         ] =  0,
  208.         [JOB_CHARBURNER         ] =  0
  209.         })
  210.     end
  211. end
  212.  
  213. function onGameFrame(gf)
  214.     if(gf % 100 ~= 0) then return end
  215.    
  216.     if(gf == 200) then
  217.         rttr:GetWorld():AddStaticObject(17,101, 502, 0xFFFF, 0)
  218.         rttr:GetWorld():AddStaticObject(17,102, 502, 0xFFFF, 0)
  219.         rttr:GetWorld():AddStaticObject(16,102, 502, 0xFFFF, 0)
  220.         rttr:GetWorld():AddStaticObject(15,101, 502, 0xFFFF, 0)
  221.         rttr:GetWorld():AddStaticObject(17,100, 502, 0xFFFF, 0)
  222.     end
  223. end
  224.  
  225.  
  226.  
  227. function onOccupied(p, x, y)
  228.    
  229.     if( (p == 1) and (x == 14) and (y == 55) ) then     -- At Game Start the Restricted Area was defined with "nil, nil", which defines an impassable polygon for the AI. Its still possible for the AI to occupy military buildings. After the Area is occupied by the AI the LUA will set a new Restricted Area. In This Case the AreaRestriction is set to the whole Map
  230.  
  231. rttr:GetPlayer(1):SetRestrictedArea(                -- Area Restriction is set to the whole Map. For the moment there is no way to undo the Area Restriction from GameStart and GameLoad.
  232. 0,0,
  233. 31,0,
  234. 31,127,
  235. 127,0,
  236. 0,0)
  237. end
  238.  
  239. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement