Pre-Frame 1 Operations on Gameworld.

Pre-Frame 1 Operations on Gameworld.

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Pre-Frame 1 Operations on Gameworld.

Post by Argh »

Basically, the more I mess with LUA, the more concerned I'm getting about this issue. To set up any really fancy game stuff involving the world, I need to do some very heavy math, which may take up to several seconds, on slower computers.

I think that we need to have at least 30 frames of "sim" which run before Spring accepts any UI input from players, or starts sending network traffic.

Why frames? Well, Spring's already structured around this, and it's a very loose definition- a "frame" lasts as long as it does, period.

Moreover, a frame has a start and an end, allowing for operations to be performed without interfering with one another- say, a mod's code wants to do certain operations on the gameworld's state, then the map's code needs to also do stuff- they cannot "know" about each other, so therefore the logical solution is to give them different frames to operate.

Allowing for 30 "frames" to occur, say, while the countdown was being performed (and not allowing the countdown to complete until a network packet was received from the host, stating it was complete and that data from the outcome was being sent), and having the results of then displayed on the "official" frame 1 (from there on out, network traffic begins) would allow game designers and mappers to run very complex code on the gameworld, and would greatly facilitate game designs that require extensive modifications of the gameworld.

Yes, this mainly means P.U.R.E. + World Builder, at the moment. However, I suspect once World Builder's available, a lot of people will want to use it (or variant ideas) to mess with the gameworld before the game really "begins", and I'm rather concerned that this will lead to constant desyncs until some leeway is introduced, at the game engine level.

Does anybody else have any thoughts on this?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Pre-Frame 1 Operations on Gameworld.

Post by AF »

Allowing 30 seconds to pass by previous to the game starting and the untis spawning would make AIs brake utterly. AIs expect the starting units to be present when they first run, and what happens may be different depending on the AI.

If the AI is dependant on the frame, such as NTai then either itll reach frame ten look for commanders and find nothing and either crash or not do anything, that or it gets spawned when the game starts and never initializes itself because its too late and the check never executes and thus starts receiving unit events, uses uninitialized data, and crashes.


What you need is a callback function that executes when loading finishes but before the loading screen dissapears.
user
Posts: 452
Joined: 22 Jan 2008, 16:33

Re: Pre-Frame 1 Operations on Gameworld.

Post by user »

doesnt the call in initialize works for this?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Pre-Frame 1 Operations on Gameworld.

Post by AF »

hmm not sure if that applies to my comment on AIs or arghs lua widgets.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Pre-Frame 1 Operations on Gameworld.

Post by Argh »

What you need is a callback function that executes when loading finishes but before the loading screen dissapears.
Firstly, I hear you, about the AIs. Sorry for not thinking about that wrinkle in advance.

The only problem with what you're proposing is that it needs to allow for more than one iteration- there has to be some sort of timing condition. IOW, we need to be able to do stuff like this:

Game Code: DoSomeStuff.

Map Code / Other Code: DoSomeOtherStuff.

Game Code: DoYetMoreStuff.

That way, game code and map code can exist without conflicts. That's my main concern with this- there needs to be a mechanism that allows for them to work separately in time, execution-wise, so that they don't "fight" with one another, whilst modifying the gameworld.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Pre-Frame 1 Operations on Gameworld.

Post by lurker »

If it's signed then you could always start at frame -29 or so.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Pre-Frame 1 Operations on Gameworld.

Post by Argh »

I'll check, but I'm going to be extremely surprised if it's signed.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Pre-Frame 1 Operations on Gameworld.

Post by lurker »

GlobalStuff.h wrote: int frameNum;
What's so surprising? It makes sense to use a plain int to simplify things and avoid conversions unless you really need that extra bit of space.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Pre-Frame 1 Operations on Gameworld.

Post by Argh »

That's not what I meant, sorry, I was being very unclear. The issue is whether Gadget:GameFrame can operate before frame 0...
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Pre-Frame 1 Operations on Gameworld.

Post by lurker »

It works pretty well, actually. Changing the init frame from 0 to -9000 made the game start at -5:00. The coms didn't spawn until frame 0/1, only air units could actually move (ground units could just turn), and there were a lot of no response and delayed response messages, but pretty workable. I'll try to get those bugs fixed up.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Pre-Frame 1 Operations on Gameworld.

Post by Argh »

Wonderful! That'd solve the vast majority of problems associated with this stuff...
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Pre-Frame 1 Operations on Gameworld.

Post by lurker »

Okay, got the gameserver sorted out. Now for the movement code.

Edit: Woo! Everything works now. Probably still has a couple minor bugs related to unit actions, but that's only an issue if you plan to play the entire game in negative time. Which you can. That and the corner clock having a separate negative sign for the seconds...
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: Pre-Frame 1 Operations on Gameworld.

Post by Forboding Angel »

*ahem* Forgotten something? Hmmm?
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

Re: Pre-Frame 1 Operations on Gameworld.

Post by AF »

imo setting up negative frames like this is a kludge, it would be much much better to have a proper method such as a lua callout after loading has finished, especially since only one frame is needed, what would do we do with the other 29 negative frames?

What's more it isn't apparent how it should be done in the end user API. I shouldn't have to be told this sort of thing, I should be able to see something like a preload() callback.

Argh, have you considered for the time being queuing up requests to spawn things and then doing the work over several frames rather than all at once?
imbaczek
Posts: 3629
Joined: 22 Aug 2006, 16:19

Re: Pre-Frame 1 Operations on Gameworld.

Post by imbaczek »

well, it's not uncommon to delay some stuff on game start in other games; quakes e.g. spawn initial entities over several frames.
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Pre-Frame 1 Operations on Gameworld.

Post by lurker »

kludge or not, I'm playing an entire game in negative time later :P
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Pre-Frame 1 Operations on Gameworld.

Post by Argh »

Argh, have you considered for the time being queuing up requests to spawn things and then doing the work over several frames rather than all at once?
Yes, I considered that. It's not practical, however. I'd have to break up the actions so much that it would be severely deleterious to gameplay, imo.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Pre-Frame 1 Operations on Gameworld.

Post by Argh »

Any chance this will show up at some point? I'd really like to make use of this to do a few major speed-ups for players...
User avatar
lurker
Posts: 3842
Joined: 08 Jan 2007, 06:13

Re: Pre-Frame 1 Operations on Gameworld.

Post by lurker »

Probably not, why? Once the rng seeding is fixed you could do it pregame at the end of loading, the way THIS operates.
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

Re: Pre-Frame 1 Operations on Gameworld.

Post by Argh »

I'll have to take a look at THAT's source, and see if it'll work. Dunno, World Builder requires placement of Units, and has very heavy math requirements.
Post Reply

Return to “Lua Scripts”