Page 2 of 2

Re: Campaign.

Posted: 31 Jan 2008, 23:02
by KDR_11k
Don't make it so simple, TA was criticized for havbing a campaign that used pretty much these triggers. The initial goal might be something along those lines but these days people expect lots of events during a campaign mission, like unexpected enemy reinforcements, special weapons, commando missions, ambushes, etc.

Re: Campaign.

Posted: 01 Feb 2008, 01:46
by SinbadEV
Looks Like, if I understand this stuff correctly

http://spring.clan-sy.com/fisheye/brows ... txt?r=5148
http://spring.clan-sy.com/fisheye/brows ... txt?r=5148

The option isn't there... all we can manage would be to have a map with a LUA rules file that triggers the Scenario Script on-load as far as I can tell...

I still say... we need a working scenario before we bug people on getting it to run.

Re: Campaign.

Posted: 01 Feb 2008, 03:27
by SinbadEV
I have finished my rough-draft.

http://docs.google.com/Doc?id=df7qd3dg_9124xwgtg7

what you think?

Re: Campaign.

Posted: 02 Feb 2008, 17:56
by SinbadEV
Alright, I mashed the demo mission so it works again.

Code: Select all

-- Create a subclass of the native spring class Script
class 'SinbadEVsScriptTest' (Script)

-- Pass the script name to be displayed to the parent constructor
function SinbadEVsScriptTest:__init() super('LUA SinbadEVsScriptTest')
    self.state = 0

    -- Set to true to not have to press enter at start
    self.onlySinglePlayer = true
end

-- Return the mapname this script wants
function SinbadEVsScriptTest:GetMapName()
    return "SmallDivide.smf"
end

-- Return the modname this script wants
function SinbadEVsScriptTest:GetModName()
    return "XTA_Installer_Version.sdz"
end

-- This function is executed every simulated frame (30 times/sec)
function SinbadEVsScriptTest:Update()

    -- Perform initialization
    if self.state == 0 then
        self.state = 1
        self:Setup()

        print("A small ARM force has been trapped all alone. You must get " ..
              "them to the alien beacon quickly to call in reinforcements!")
    end

    -- Run SlowUpdate once every second
    if math.mod(gs.frameNum, 30) == 0 then
        self:SlowUpdate()
    end


    -- Do some stuff a bit later
    if gs.frameNum == 30*10 then
        self:SetupDelayed()
    end
end

-- Spring does not call this directly
function SinbadEVsScriptTest:SlowUpdate()

    if self.state == 1 then

        local num = units.GetNumAt(self.gatepos, 50)
        if num > 1 then
            print("Communication received. Reinforcements are on their way.")

            self.state = 2

            self.cmd:ChangeTeam(0, Unit.GIVEN)
            self.atlas:ChangeTeam(0, Unit.GIVEN)

            local c = Command()
            c.id = Command.UNLOAD_UNIT
            c:AddParam(3000)
            c:AddParam(80)
            c:AddParam(800)
            self.atlas:GiveCommand(c)
        end

    elseif self.state == 2 then
        if not self.cmd.transporter then
            print("The commander is here. Now destroy the CORE forces on " ..
                  "the other side of the pass.")
            self.state = 3
        end
    end

end

-- Create a bunch of units for this simple mission
function SinbadEVsScriptTest:Setup()
    units.Load("arm_maverick", float3(300, 80, 300), 0, false)
    units.Load("ARM_ZEUS", float3(400, 80, 300), 0, false)

    self.gatepos = float3(2832, 80, 776)
    -- I'm using the targeting facility as a placeholder for the Arm_Beacon (which isn't included in 0.74b3 version of XTA)
    self.gate = units.Load("ARM_targeting_facility", self.gatepos, 0, false)

    self.cmd = units.Load("arm_commander", float3(3800, 80, 1100), 1, false)
    self.atlas = units.Load("ARM_ATLAS", float3(3800, 80, 1200), 1, false)

    local c = Command()
    c.id = Command.LOAD_UNITS
    c:AddParam(self.cmd.id)
    self.atlas:GiveCommand(c)

    -- Enemy stuff

    local first = {
        units.Load("CORe_AK", float3(1200, 80, 200), 1, false),
        units.Load("CORe_AK", float3(1200, 80, 300), 1, false),
        units.Load("CORe_AK", float3(1200, 80, 400), 1, false),
        units.Load("CORe_AK", float3(1200, 80, 500), 1, false),
        units.Load("CORe_AK", float3(1000, 80, 200), 1, false),
        units.Load("CORe_AK", float3(1000, 80, 300), 1, false),
        units.Load("CORe_AK", float3(1000, 80, 400), 1, false),
        units.Load("CORe_AK", float3(1000, 80, 500), 1, false)
    }

    local c = Command()
    c.id = Command.PATROL
    c:AddParam(1100)
    c:AddParam(80)
    c:AddParam(1000)

    for i = 1, table.getn(first) do
        first[i]:GiveCommand(c)
    end

    -- And a pretty base (a bit small perhaps)

    units.Load("core_gaat_gun", float3(1759, 80, 2677), 1, false)
    units.Load("core_gaat_gun", float3(2413, 80, 2626), 1, false)
    units.Load("core_doomsday_machine", float3(2065, 80, 2609), 1, false)
    units.Load("core_cobra", float3(1623, 80, 2967), 1, false)

    units.Load("CORe_FUSion_power_plant", float3(1174, 80, 3271), 1, false)
    units.Load("core_doomsday_machine", float3(974, 80, 3271), 1, false)
    units.Load("core_doomsday_machine", float3(1374, 80, 3271), 1, false)
end

-- Move the commander out of the way
function SinbadEVsScriptTest:SetupDelayed()
    local c = Command()
    c.id = Command.MOVE
    c:AddParam(6000)
    c:AddParam(80)
    c:AddParam(1100)
    self.atlas:GiveCommand(c)
end

-- Instantiate the class so that it is registered and shown
sinbadEVsScriptTest = SinbadEVsScriptTest()
It looks like mod and map can be specified in the lua script so all we need now is a way to tell spring.exe what lua to load... for single player at least.

Re: Campaign.

Posted: 02 Feb 2008, 19:15
by jcnossen
Wouldn't it be less work to just make spring reload instead of building a new app around this problem?

Re: Campaign.

Posted: 02 Feb 2008, 21:09
by SinbadEV
Actually I was thinking about that as I was poking around in the code and being very confused... you can already load LUA scripts from the menu, why not a campaign.

Basically you would have a folder in the start-scripts folder (or some structure like this) that contain all the campaign missions and then each one would have a function like the get info GetInfo() we have for widgets that triggered some kind of summary screen and lists pre-requisites... hmmm... that part of the code seems simple enough.

somewhere between ScriptHandler.cpp and line 599 of PreGame.cpp is where the change would probably need to happen...

However we would like to be able to run LUA script multi-player scenarios from the lobby aswell so we still need a command line solution in the long run.

Re: Campaign.

Posted: 03 Feb 2008, 00:42
by SinbadEV
oddly enough there seems to be a valid "scriptname" variable in [game] of the start script.txt... any idea how to use it? I figured I'd just throw in my script but it keeps throwing "script not found"

edit: 2598 created by hughperkins on 13 November 2006, 20:41:07 +0100 (14 months ago) (patch)

Okay, looks like I can pass my script as "scriptname=LUA Scriptname;"
where Scriptname.lua is my lua start script... will keep poking but it looks positive... one problem is that the settings in the script.txt overrides the settings in the .lua for which map/mod to use.

Re: Campaign.

Posted: 03 Feb 2008, 03:38
by SinbadEV

Code: Select all

[game]
{
	mapname=Barren.smf;
	scriptname=LUA SinbadEVsScriptTest;
	startmetal=1000;
	startenergy=1000;
	maxunits=1000;
	startpostype=0;
	gamemode=0;
	gametype=XTA_Installer_Version.sdz;
	limitdgun=0;
	diminishingmms=0;
	ghostedbuildings=1;
	hostip=localhost;
	hostport=8452;
	myplayernum=0;
	numplayers=1;
	numteams=2;
	numallyteams=2;
	[player0]
	{
		name=SinbadEV;
		countrycode=ca;
		rank=0;
		spectator=0;
		team=0;
	}
	[team0]
	{
		teamleader=0;
		allyteam=0;
		rgbcolor=0.35294 0.35294 1.00000;
		side=Arm;
		handicap=0;
	}
	[team1]
	{
		teamleader=0;
		allyteam=1;
		rgbcolor=0.78431 0.00000 0.00000;
		side=Arm;
		handicap=0;
		aidll=AI/Bot-libs/TestGlobalAI.dll;
	}
	[allyteam0]
	{
		numallies=0;
	}
	[allyteam1]
	{
		numallies=0;
	}
	numrestrictions=0;
}
worked... as I understand it, if one were to impliment into the lobby the needed tag you could acctually have multiplayer scenarios with this.

Re: Campaign.

Posted: 03 Feb 2008, 04:46
by Nemo
SinbadEV wrote:
worked... as I understand it, if one were to impliment into the lobby the needed tag you could acctually have multiplayer scenarios with this.

you already can (just make the scenario be a mod LuaRule and nix the spawned commanders if you want them gone). the biggest issue is that you can't choose a script other than Commanders, but if they're removed on game start it doesn't matter much anyways.

Re: Campaign.

Posted: 03 Feb 2008, 04:57
by SinbadEV
Alright, maybe I'm missing something... how do I choose a LUARule set from the lobby or from the spring.exe or from the command line... I though LuaRules where MOD or Map specific LUA that controlled that executed if that MOD or MAP was loaded?

Re: Campaign.

Posted: 03 Feb 2008, 07:55
by jK
a mission should be map/mod dependend ..
also you can load local files in unsynced Lua's (even unsynced LuaRules) and then send the content with Spring.SendLua[Rules|Gaia]Msg() to all client (=synced code), so you can spawn units, restrict units etc.

Re: Campaign.

Posted: 03 Feb 2008, 16:49
by SinbadEV
jK wrote:a mission should be map/mod dependend
Yes, but as it stands right now you would have to release a new version of the MAP or MOD in order to support a LUARules based scenario... with a specific LUA mission script the script specifies the MAP and MOD necessary for mission/scenario... so it's still map/mod dependent you can just have multiple scenarios (or a campaigns) without having to release a new version of each map or mod used.

Re: Campaign.

Posted: 03 Feb 2008, 17:12
by AF
They're called mutators, variants, the same ones AA used for hovercraft commanders and deployment mutators.

Also,

Code: Select all

scriptname=LUA SinbadEVsScriptTest;
Aside from filibustering a single line inside an entire script file, you didn't describe the value itself, is this a file name with the .lua missing?

I'm sorry but you mission makers and the developers need to come together and clear this up once and for all and state definitively, how to make missions, how to start missions, and how it should all be done, because right now what your doing is filibustering and confusing the potential mission builders by touting two competing systems and using their terminology interchangeably while making highly ambiguous statements that could apply to both.

What I or any other developer needs:
  • How to start a mission
  • What extra information is needed about each mission before starting
  • Extra pieces of work to cater for campaigns such as needing to specify a map etc
Right now I have 3 methods of starting missions and no idea which si the correct method.
  • fnordias lua scripts
  • Lua Rules in a mod mutator
  • Lua Rules in a map
If we were going to use the luarule method I would recommend using the map method because a mission can only run on one map but a mod can have many missions.

Re: Campaign.

Posted: 03 Feb 2008, 17:25
by BrainDamage
don't forget to add stuff like return values of the mission itself, the system should be enough flexible to generate different mission paths according to what you did inside the game, (eg, you managed to destroy to kill a spy before it would escape a map, then enemy can't access to a particular tech in further missions, or you didn't kill the nuke silo before a timer reached 0 then the successive mission instead of being A (attacking enemy outpost) becomes on B (defending stronghold from enemy raids) )

this obviously implies also the necessity of a standardized format to save the mission data and the current mission progress, along to define a common format for mission chain nesting and trigger event modifiers, also stuff like briefing/media play could be done both inside the launcher interface(lobby) both inside the engine itself using lua scripts

Re: Campaign.

Posted: 04 Feb 2008, 00:07
by SinbadEV
AF wrote:Also,

Code: Select all

scriptname=LUA SinbadEVsScriptTest;
Aside from filibustering a single line inside an entire script file, you didn't describe the value itself, is this a file name with the .lua missing?
Yes, except for this problem.

If script is "script.lua", you include "scriptname=LUA script;"... But unfortunately it looks like there is a glitch in the parser that causes m/e storage to be 1000K when I try to test it.

Re: Campaign.

Posted: 07 Feb 2008, 16:31
by daan 79
Hallo,

I am reading this posts and i comeup with all different mind strings. Basicully this realised will bring a whole new site of spring alive and bring new ppl in who see the other sides of spring.

Basicully maybe not alll here have time to commit to lua, but i wanna give it a try. Not starting with this. But i can understand ther must be ppl around that if they knew what was told here ther could start stuff.

Some things would make it easier,

Seperate this isseu in three parts.

The making of a mission.
What commands do we use, where to put it, Exemples of working stuff. (or atleast untested stuff.) ideas about possible things in missions and ther workarounds. When stuff ready an easy download what an setain example would do in spring.

The implemantation of a mission.
Wether we use luarules mods/maps or the fnordia lua sripts the need to be discribed somewhere. Where does what file goes to. And what are the purposes of this. Does the txt file spring reads at start up effects what and how can we use this.

A wiki page or 2 treads that will work with those two problems. this tread could funtion as keeping this discussion alive, and maybe make two treads that deal with only the non philosofical side of this. Like a fact tread around a project. Like this i found out or this will do this instead of we need this and this.

greetz daan

Re: Campaign.

Posted: 18 Feb 2008, 15:37
by SeanHeron
Hey SindbadeV,
I haven't been round here for ages, but one of the last things (actually one of the only things) I was working on before not returning was a really, really newbies guide to spring (I had to smile when I saw your doc with the talk through, I had written up something very similiar, though far less detailed and deep). I even should have the start of a mission script knocking about somewhere (should be on UF, but I heard thats down), not anything that you couldn't write in half an hour, but something :D.
Anyway, what I wanted to say was I reckon we could put our heads together and try to get something going (I know I can always do with some external motivation). Hoping to hear from you soon, and regards,
Sean Heron.