|
|
This thread is locked; no one can reply to it.
|
1
2
|
| Cutscene engine |
|
alethiophile
Member #9,349
December 2007
|
I am currently working on a cutscene engine for my Psychopyretic game. Does anyone have any idea how to do this? My current thought is to use functions that take a pointer to int and pass the "frames" variable that is incremented by your timer function to it. Does anyone have any better approaches, and are there any bad problems with that one? -- |
|
Schyfis
Member #9,752
May 2008
|
It depends entirely on what kind of cutscene you want. If your cutscene is a movie, just play the movie. ________________________________________________________________________________________________________ |
|
OnlineCop
Member #7,919
October 2006
|
If #2 (an in-game scene), others have set it up so the NPCs and players' characters can be controlled by script (move up, then left, then right...). There should be something like:
So now you can totally control all of the characters by simple scripts, waiting for one or more actions to finish, then doing other actions after it, etc. Is that what you had in mind?
|
|
alethiophile
Member #9,349
December 2007
|
That would be nice, but I'm not sure how it's supposed to work. What is map? -- |
|
bamccaig
Member #7,536
July 2006
|
I think it would actually work best if you could use a script to process the entire cutscene. Rather than executing short bursts in script and then hard coding the rest, it would be much easier I think if the talking, for example, was also handled by the script. This way, rather than having hundreds of little scripts, you could just have one script per cutscene with all the information it needs. I've never attempted anything like a cutscene or actually implemented a scripting engine before, but it should be possible and will probably make cutscenes really easy when done. -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|
OnlineCop
Member #7,919
October 2006
|
I know the KQ project did these kinds of cut scenes (this was more-or-less where I borrowed this suggestion from). They use LUA to implement the scripting, and all of their "move up 3 spaces, then right 2 spaces, then wait 50 clicks, then ..." could be applied to all the NPCs (and player's character) simultaneously if all of the IDs were specified in the "process_entities()" list. alethiophile said: That would be nice, but I'm not sure how it's supposed to work. What is map? NPCs had several states: WALK_RANDOM, WALK_SCRIPTED, WALK_STANDSTILL. When their state was "WALK_SCRIPTED", it took a string of inputs as cues to fulfill. The main Map would contain all of the NPCs positions, including "current_tile, target_tile, current_[xy]". So if you start an NPC moving in a certain direction, its current_tile may be (10,7) and its target_tile may be (10,8). Its current_x would be 160 (10 tiles * 16-pixel tile width) and current_y would be 112 (7*16), then 113 (7*16 + 1), then 114 (7*16 + 2), ... So "map" is just whatever map you're drawing to the screen. It's the main controller for all the NPCs contained in it. It's responsible for all the bounds-checking to ensure an NPC doesn't step on an invalid tile (or one occupied by another NPC).
|
|
Archon
Member #4,195
January 2004
|
If you're doing movie cutscenes, then take a look at APEG. There is lots of support available since it's made by one of the members in this forum |
|
Neil Black
Member #7,867
October 2006
|
How does someone go about making a movies that APEG can play?
|
|
Thomas Fjellstrom
Member #476
June 2000
|
Quote: How does someone go about making a movies that APEG can play? Record a video, and save it as an mpeg1 or ogg theora video. -- |
|
Neil Black
Member #7,867
October 2006
|
It's the recording a video part that I don't get. I know I can use CamStudio or the like to record a video, but how would I make a cutscene video?
|
|
Thomas Fjellstrom
Member #476
June 2000
|
Quote: but how would I make a cutscene video? A video is a video. All games with pre rendered cutscenes do is play back a video file. One way is to render it in a 3d app, and then encode that, or use a special higher quality scriptable version of your engine to render each frame, and encode that (if its not higher quality, or special in any way, you might as well just use in game scripted cutscenes). -- |
|
Neil Black
Member #7,867
October 2006
|
I guess my real question is how would I animate a video for a cutscene, but I think Ive hi-jacked this thread for long enough.
|
|
Thomas Fjellstrom
Member #476
June 2000
|
I do believe I gave two options -- |
|
Næssén
Member #5,025
September 2004
|
Me and my friend Per have implemented a really simple cut scene system for one of our games that yet hasn't been finished. It might give you some ideas. The cut scene is an entity in our engine just as an enemy or the player. You initialize the cut scene by pushing events to it and the events are carried out in the order they were pushed. Each entity has a logic function that is called each logic frame. The cut scene counts frames and draws itself accordingly. You can look at the code here (sorry for the formatting): If the player is to be animated, the player is simply disabled and replaced by an animation. When the cut scene is over the player is put back in place and enabled. _____________________ |
|
alethiophile
Member #9,349
December 2007
|
My current idea is to make a scriptable NPC framework, then run cutscenes by passing the right scripts to the NPCs. I can also use the scripts for simple AI actions. Some people have mentioned Lua as a scripting addition; is that a good idea, or should I use something different? I could probably make a scripting engine myself, but I would rather use an already-created one. -- |
|
Simon Parzer
Member #3,330
March 2003
|
For an action based system I would make two general types of actions: A blocking action blocks the action queue and unblocks it when it's finished. So you have one action queue (your cutscene), a list of actions "in progress" and a main thread like this (pseudo-code): do: if script.ready: Action nextAction = script.nextAction() currentActions.add(nextActions) if nextAction.blocking: script.ready = false foreach action in currentActions: action.advance() // Process 1 frame if action.finished: //Action has finished if action.blocking: script.ready = true currentActions.remove(action)
An action could be a simple command ("Move char A to (X,Y)") or even a sequence of actions, though this could be difficult to implement. Just an idea. On a second thought it is similar to Næssén's system. |
|
alethiophile
Member #9,349
December 2007
|
What I'm implementing currently is that all actions block, you call npc.update() in your main loop to update the current action, and you have to call npc.setscript() every time an action finishes and you want a new one. I may add a queue and non-blocking actions later, but that's all I need for now. -- |
|
OnlineCop
Member #7,919
October 2006
|
alethiophile said: I may add a queue and non-blocking actions later, but that's all I need for now. I would agree with Simon's approach of the list of non-blocked (followed by the blocked) action, because if you have three or four NPCs that you want to march out of a room, or fly away in a set formation, or whatever, you can't do that: you have to send one away, followed by the next, then the next. The queue would be a bit of a better approach as you wouldn't need to code in too much extra to implement it, and it would make program flow a lot easier...
|
|
alethiophile
Member #9,349
December 2007
|
No, there would just be one "currently executing" action for each NPC. I could call npc1.update(), npc2.update(), etc. in my main loop, and all execute at once. -- |
|
Matt Smith
Member #783
November 2000
|
Triggers are often more convenient than co-ordinating scripts manually. e.g. Set a trigger such that "When npc1 is at positon x, npc2.action = walkto y". The active triggers are kept in a list and each of their conditions is tested every frame, after the updates. Activating and deactivating the triggers is defined in the script, so a mixture of direct commands and triggers can be used in any script. |
|
alethiophile
Member #9,349
December 2007
|
That's probably a good idea, but right now I'm just trying to implement simple scripts. -- |
|
OnlineCop
Member #7,919
October 2006
|
I think a simple script would be a char[] array: To move in any four direction, specify "UDLR" (or if you want compass coordinates, "NEWS"), followed by the number of steps in that direction: char script_buffer[128]; // ... strncat(script_buffer, "U10", 3); // ... Then, step through each character of the array until you hit the '\0'-terminator. If the character is a letter, call the appropriate case __: statement to start collecting the important information afterward (usually, this just means to check the NEXT characters to see if they're numbers, and if so, parse the actual int value from them). It may be easiest to actually turn this into an expanded string once you have made all of the movement adjustments, such as turning "U4D3" into "UUUUDDD", if it makes the process loop easier for you.
|
|
monkeyCode
Member #7,140
April 2006
|
I'll assume that you're referring to acting out scenes within the game engine, ala Warcraft 3 cut-scenes. In the past I've been lazy a few times and implemented cut-scenes as scripts. Player.Perform(Move(19, 20)) Player.Perform(Attack(true)) This however, although very powerful and can provide lot of detail to your cut-scenes , is still coding. Which means it's very hard to write any intuitive tools to create and edit cut-scenes. So a better way could be to implement it in the same manner as you implement macro's in an application, as a sequence of commands/actions. |
|
Jonatan Hedborg
Member #4,886
July 2004
|
An XML (or whatever) based system might be nice;
Should be fairly easy to implement; You'd need an action factory and a condition factory, and some semi-clever logic to make it all work together
|
|
bamccaig
Member #7,536
July 2006
|
Rather than trying to implement an XML-based system, I think you'd probably be better off integrating with an existing scripting engine (i.e. Lua). -- acc.js | al4anim - Allegro 4 Animation library | Allegro 5 VS/NuGet Guide | Allegro.cc Mockup | Allegro.cc <code> Tag | Allegro 4 Timer Example (w/ Semaphores) | Allegro 5 "Winpkg" (MSVC readme) | Bambot | Blog | C++ STL Container Flowchart | Castopulence Software | Check Return Values | Derail? | Is This A Discussion? Flow Chart | Filesystem Hierarchy Standard | Clean Code Talks - Global State and Singletons | How To Use Header Files | GNU/Linux (Debian, Fedora, Gentoo) | rot (rot13, rot47, rotN) | Streaming |
|
|
1
2
|