Kingdom Wars 2: Battles

Kingdom Wars 2: Battles

KW2B Workshop - Levels, Scenario, Mods.
Welcome to Kingdom Wars 2: Battles scenario and mod workshop. Play singleplayer and multiplayer levels and scenarios created by our community.
Learn More
How To: Scenario Making
This meant as a discussion page used to inform everyone how to use the scenario editor
< >
Showing 1-2 of 2 comments
Johnny Russian 8 Jul, 2016 @ 1:19am 
General questions
- How do you code a scenario?
- How do you edit starting resources?
- How did the guys who posted content do it?
Bad Logic  [developer] 3 8 Jul, 2016 @ 4:56am 
How do you code a scenario?
Scenarios are coded using the Lua language, and most of the code goes into Trigger functions which loop and can be enabled and disabled.

To add Script to a scenario, click the Scripting icon (looks like a Cog), then in the Script window click the New Globals Page icon (looks like a page with a G), open the newly created page and add your script there.

Here is some example code that gives the player the objective to build 10 houses and has a counter showing their progress:
local housesToBuild = 10 Trigger.BuildHousesObjective=function() Wait(2) InterfaceSignal("AddObjective","Build "..housesToBuild.." Houses",1) Trigger.CountHouses=true DisableSelf() end Trigger.CountHouses=function() local houseCount = 0 for subType in {"A","B","C"} do houseCount += Player[1]:TypePopulation("Men-Buildings-House Village-"..subType) end if houseCount < housesToBuild then InterfaceSignal("AddObjective","House Count: "..houseCount.."/"..housesToBuild,2,nil,nil,true) else InterfaceSignal("RemoveObjective",1) InterfaceSignal("RemoveObjective",2,true) DisableSelf() end Wait(10) end Trigger.CountHouses=false

How do you edit starting resources?
The code below will give 1000 of each resource to player 1 to 4
for p=1,4 do Player

.Resource[ResourceType.Food]=1000
Player

.Resource[ResourceType.Wood]=1000
Player

.Resource[ResourceType.Gold]=1000
Player

.Resource[ResourceType.Stone]=1000
end[/code]

How did the guys who posted content do it?
Slightly ambiguous question, so I'll answer a couple of questions:

How did you make your scenario?
I'm part of the dev team, so I have a bit of an advantage.

I was able to assemble the map from existing maps, and I know a lot of the ins and outs of the code.

I'd recommend to anyone making their own scenario to open up the workshop scenarios in the Editor and taking a look at some of the coding. Dead of Winter includes some advanced coding for a scenario-only "new" building using existing models but with different props and producing new units.

I might make a guide or some simpler scenarios to give coding examples.

How do you post content?
In the game's root folder there is a file called "steamworks_manager.exe", run this, select <New Workshop Project> and fill out all the fields.

Note: Keep the preview image small (mine are 512x288), I had problems when I tried to use a large image file (1920x1080)

< >
Showing 1-2 of 2 comments
Per page: 1530 50