Story System

STORY SYSTEM for OpenBoR 2.1

No permission to download
msmalik681 said:
How did u fix random skips on text object

If you meant the credits, well, I already answered that:

CRxTRDude said:
Fixed the scrolling text, adding linecount and spacing parameters, since I rewritten some of the logic for drawing and adding text lines.

The old logic was doing skipping, it's a tricky thing actually, since I needed to tune down the numbers just right as to not make them either skip too much or too little, that's why I added the linecount and spacing parameters for scrolling text, which allows you to adjust the spacing depending on the font size of the game.

The linecount though is placed there, since I still don't know how to check how many lines in the text file. This is needed, because I use the line count to determine the number of times the code will spew out text.

I think that's how it happened. If your game had problems with such, just update your story system to the new version to fix it. You might need to change your story() to storySystem() in updated to make it work. You will also need to add the line count and spacing parameters in scrollText, which replaces the {a} parameter. Check the documentation in the storysystem zip file for additional details on how to apply it.
 
I've come up with new features that might benefit the story system and placed them here so that anyone can see as well as I would just browse through anytime.

  • More cleaner and less convoluted code
  • Support for SFA3/KOFXIII style dialogs
  • Have a delay timer which can stop a line of scrolling text to be displayed in the center for a temporary while. Useful for start and end parts.
  • A story.txt in data\ which can be used to tweak some of the variables for the Story System, making it flexible.

That's all I have for a while. I'm working on the story.txt bit and will be going over the new dialog style after cleaning the code, since I'll just have to borrow from the video dialog code anyway.

Here's how I would implement the new dialog style:
  • A new portrait folder to hold the sprites and they need to be in exact height, probably I'll put that over later.
  • Putting the index of the text objects farther back to the 47-50 range, so that if you use text objects, there are still 46 more available starting from 1, effectively making 47-50 as system indexes.

Any response and questions guys?
 
Why not code the story system itself to check which indexes are in use elsewhere and only take up the free ones? A quick for loop should do it nicely.

DC
 
How would I go over a for loop with this? Is it okay if you would care to help with that? Also, how efficient it would be?
 
so cool, just saw this. saves me a lot of time to figure out :)
I was stuck in getting a dialog box background transparent. Will check this one out
 
Thank you for this great creation!
It is certainly very useful for everyone.
I find it hard to understand exactly how it works, but worth the effort.
 
I can help with implementing them, but you can do that yourself too.

Firstly, just study the demo game, it's not pak-ed so you can just check out how it works.

Then, to implement that on your own, just unzip the contents of storysystem.zip to your data folder. Don't worry about overwriting, there would be nothing to be overwritten (unless you're using something an intro and credits level similar to the structure. It's wise to just back up your mod first before putting this.) After that, follow the instructions.txt provided. That explains what scripts to use and how to set up the system.

The readme for the demo is the main documentation where it explains the dialog and scroll creations.

If you guys have problems implementing, just go ahead and post here, I can be able to help if I'm available.
 
Thanks CRxTRDude!

I will follow your advice and check them step by step.
Any doubt, I tell you.
I appreciate your work and your help.
I hope to implement this in my mod, MORTAL KOMBAT - The Chosen One.
Thanks.
 
Well, I've begun implementing story system in my mod, but I also have problems.
Te problem is in this part:
UPDATED.C:

Then, go to your updated.c and include the following:

#include "data/scripts/story/story_define.h"
#include "data/scripts/story.c"
#include "data/scripts/gettick.c"

To display the story system, make a 'in level' loop void that is executed when
the player is in the level (openborvariant("in_level")), place the following:

turnWhite();
storySystem();

Save and close your updated.c.
This is the original updated.c of my mod:
Code:
void zoom()
{
   void vscreen = openborvariant("vscreen");
   int maxz=openborvariant("PLAYER_MAX_Z")+1000;
   int zoom_value=getglobalvar("zoomvalue");
   int zoom_x=getglobalvar("zoomx");
   int zoom_y=getglobalvar("zoomy");
   void ent=getglobalvar("zoomentity");
   int px=getentityproperty(ent,"x") +  zoom_x - openborvariant("xpos");
   int py=getentityproperty(ent,"z") + zoom_y - openborvariant("ypos") - getentityproperty(ent,"a");
   void zoom_scr = getglobalvar("zoomscreen");
   if(!zoom_scr){
      zoom_scr = allocscreen(openborvariant("hResolution"),openborvariant("vResolution"));
      setglobalvar("zoomscreen",zoom_scr);
   }
   clearscreen(zoom_scr);

   //draw what we need 
   drawspriteq(zoom_scr,0,openborconstant("MIN_INT"),maxz,0,0);
   //setup drawMethod
   changedrawmethod(NULL(),"reset",1);
   changedrawmethod(NULL(),"enabled",1);
   changedrawmethod(NULL(),"scalex",zoom_value);
   changedrawmethod(NULL(),"scaley",zoom_value);
   changedrawmethod(NULL(),"centerx",px);
   changedrawmethod(NULL(),"centery",py);
   //Draw the resized customized screen to main screen.
   drawscreen(zoom_scr,px,py, maxz+1);
   changedrawmethod(NULL(),"enabled", 0);
   drawspriteq(vscreen, 0, maxz+1,maxz+1, 0, 0);
   drawspriteq(vscreen, 0, maxz+2,openborconstant("MAX_INT"), 0, 0);
   clearspriteq();
}


void main(){
   if(getglobalvar("zoomentity"))
   {
      zoom();        
   }
}
I do not understand exactly how to add what the instructions say.
I tried, but it always gives me error.
This was my last attempt:
Code:
#include "data/scripts/story/story_define.h"
#include "data/scripts/story.c"
#include "data/scripts/gettick.c"


void zoom()
{
   void vscreen = openborvariant("vscreen");
   int maxz=openborvariant("PLAYER_MAX_Z")+1000;
   int zoom_value=getglobalvar("zoomvalue");
   int zoom_x=getglobalvar("zoomx");
   int zoom_y=getglobalvar("zoomy");
   void ent=getglobalvar("zoomentity");
   int px=getentityproperty(ent,"x") +  zoom_x - openborvariant("xpos");
   int py=getentityproperty(ent,"z") + zoom_y - openborvariant("ypos") - getentityproperty(ent,"a");
   void zoom_scr = getglobalvar("zoomscreen");
   if(!zoom_scr){
      zoom_scr = allocscreen(openborvariant("hResolution"),openborvariant("vResolution"));
      setglobalvar("zoomscreen",zoom_scr);
   }
   clearscreen(zoom_scr);

   //draw what we need 
   drawspriteq(zoom_scr,0,openborconstant("MIN_INT"),maxz,0,0);
   //setup drawMethod
   changedrawmethod(NULL(),"reset",1);
   changedrawmethod(NULL(),"enabled",1);
   changedrawmethod(NULL(),"scalex",zoom_value);
   changedrawmethod(NULL(),"scaley",zoom_value);
   changedrawmethod(NULL(),"centerx",px);
   changedrawmethod(NULL(),"centery",py);
   //Draw the resized customized screen to main screen.
   drawscreen(zoom_scr,px,py, maxz+1);
   changedrawmethod(NULL(),"enabled", 0);
   drawspriteq(vscreen, 0, maxz+1,maxz+1, 0, 0);
   drawspriteq(vscreen, 0, maxz+2,openborconstant("MAX_INT"), 0, 0);
   clearspriteq();
}


void main(){
   if(getglobalvar("zoomentity"))
   {
      zoom();        
			}
		}
	}
	}
	mainLoop();
}

void mainLoop()
{
	if(SYS_INLEVEL)
	{
		inLevelLoop();
	}
	else if (SYS_SCENE != "intro.txt"){
		if(SYS_INMENU || SYS_INTITLE){
			drawstring(110,40,3,"Story System EdItIon");
			drawstring(124,212,0,"CRxTRDude 2014");
		}
	}
}

void inLevelLoop()
{
	turnWhite();
	storySystem();
}

Sorry, but I do not understand much about mixing different scripts.
Here the log:
Total Ram: 4294967295 Bytes
Free Ram: 4294967295 Bytes
Used Ram: 2875392 Bytes

debug:nativeWidth, nativeHeight, bpp  1360, 768, 32
OpenBoR v3.0 Build 3854, Compile Date: Mar  4 2013

Game Selected: ./Paks/bor.pak

FileCaching System Init...... Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video............. 480x272 (Mode: 1, Depth: 16 Bit)

Loading menu.txt............. Done!
Loading fonts................ 1 2 3 4 Done!
Timer init................... Done!
Initialize Sound.............. Done!
Loading sprites.............. Done!
Loading level order.......... Done!
Loading model constants...... Done!
Loading script settings...... Done!
Loading scripts..............

Script error: data/scripts/updated.c, line 47: Invalid external declaration '}' (in production 'external_decl')

}
    ^


********** An Error Occurred **********
*            Shutting Down            *

Failed to parse script file: 'data/scripts/updated.c'!
Total Ram: 4294967295 Bytes
Free Ram: 4294967295 Bytes
Used Ram: 37408768 Bytes

Release level data........... Done!
Release graphics data........ Done!
Release game data............


Release game data............ Done!
Release timer................ Done!
Release input hardware....... Done!
Release sound system......... Done!
Release FileCaching System... Done!

**************** Done *****************

Failed to parse script file: 'data/scripts/updated.c'!
 
I'm planning to make a tutorial video regarding the use of the Story System. I'm recording everything right now. I'll post it once finished.

BTW, @dantedevil:

There's a problem in your updated, that there's too much '}' and I assumed, you're copying from the story demo.

Code:
void main(){
   if(getglobalvar("zoomentity"))
   {
      zoom();        
   }
      mainLoop();
}

void mainLoop(){
   if(openborvariant(in_level))
   {
      turnWhite();
      storySystem();
   }
}

I designed the demo to use my constants.h, so it's not advised to copy paste depending on your situation. I've now revised the script for your situation now. You can try this one out.

Don't worry though, I'll make sure the video will be clear for you guys.
 
Not work.

Here my updated,c with your correction:

#include "data/scripts/story/story_define.h"
#include "data/scripts/story.c"
#include "data/scripts/gettick.c"


void zoom()
{
  void vscreen = openborvariant("vscreen");
  int maxz=openborvariant("PLAYER_MAX_Z")+1000;
  int zoom_value=getglobalvar("zoomvalue");
  int zoom_x=getglobalvar("zoomx");
  int zoom_y=getglobalvar("zoomy");
  void ent=getglobalvar("zoomentity");
  int px=getentityproperty(ent,"x") +  zoom_x - openborvariant("xpos");
  int py=getentityproperty(ent,"z") + zoom_y - openborvariant("ypos") - getentityproperty(ent,"a");
  void zoom_scr = getglobalvar("zoomscreen");
  if(!zoom_scr){
      zoom_scr = allocscreen(openborvariant("hResolution"),openborvariant("vResolution"));
      setglobalvar("zoomscreen",zoom_scr);
  }
  clearscreen(zoom_scr);

  //draw what we need
  drawspriteq(zoom_scr,0,openborconstant("MIN_INT"),maxz,0,0);
  //setup drawMethod
  changedrawmethod(NULL(),"reset",1);
  changedrawmethod(NULL(),"enabled",1);
  changedrawmethod(NULL(),"scalex",zoom_value);
  changedrawmethod(NULL(),"scaley",zoom_value);
  changedrawmethod(NULL(),"centerx",px);
  changedrawmethod(NULL(),"centery",py);
  //Draw the resized customized screen to main screen.
  drawscreen(zoom_scr,px,py, maxz+1);
  changedrawmethod(NULL(),"enabled", 0);
  drawspriteq(vscreen, 0, maxz+1,maxz+1, 0, 0);
  drawspriteq(vscreen, 0, maxz+2,openborconstant("MAX_INT"), 0, 0);
  clearspriteq();
}


void main(){
  if(getglobalvar("zoomentity"))
  {
      zoom();     
  }
      mainLoop();
}

void mainLoop(){
  if(openborvariant(in_level))
  {
      turnWhite();
      storySystem();
  }
}

And here the log:
Total Ram: 4294967295 Bytes
Free Ram: 4294967295 Bytes
Used Ram: 2867200 Bytes

debug:nativeWidth, nativeHeight, bpp  1360, 768, 32
OpenBoR v3.0 Build 3854, Compile Date: Mar  4 2013

Game Selected: ./Paks/bor.pak

FileCaching System Init...... Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video............. 480x272 (Mode: 1, Depth: 16 Bit)

Loading menu.txt............. Done!
Loading fonts................ 1 2 3 4 Done!
Timer init................... Done!
Initialize Sound.............. Done!
Loading sprites.............. Done!
Loading level order.......... Done!
Loading model constants...... Done!
Loading script settings...... Done!
Loading scripts..............
Script compile error in 'updated': in_level line 50, column 21

********** An Error Occurred **********
*            Shutting Down            *

Can't compile script!
Total Ram: 4294967295 Bytes
Free Ram: 4294967295 Bytes
Used Ram: 26927104 Bytes

Release level data........... Done!
Release graphics data........ Done!
Release game data............


Release game data............ Done!
Release timer................ Done!
Release input hardware....... Done!
Release sound system......... Done!
Release FileCaching System... Done!

**************** Done *****************

Can't compile script!
 
Sorry bout that, you need to put " in the in_level

Like so:
openborvariant("in_level")

I'm going to do the video tomorrow, I got family commitments that I need to do.
 
I'll fix that for you if you want. Just give me the recent copy you're working on so that I'll go work on it. The least I could do to save you the suffering.
 
Here you go guys:

https://www.youtube.com/watch?v=gQmr-jK9fPQ

BTW:

ADDENDUM:

I forgot what to place in Angel.c, here it is:

#include "data/scripts/story/story_spawn.c"

void main(){
spawnDialog("newdialogangel");
}

That's basically the function to spawn a story entity and play the dialog. You can also use this on animationscript too, just include story_spawn.c and use @ spawn_dialog "message"

Also, i prefer to turn on CC if  you guys don't understand what I'm saying. Thanks!
 
I have a problem to include the script of dialogue, in the character txt.

EX:

In thr demo the txt header of Kula is this:
Code:
name	Kula
health	100
speed	9
type	player
gfxshadow 1
globalmap 0
diesound data/sounds/eek.wav

icon	data/chars/kula/icon.png

remap	data/chars/kula/walk009.png data/chars/kula/alter.png

script data/chars/kula/kula.c

The last line is the script of story mode ok.

In my character the txt header already has several scripts, included
script data/.......
Here my player hrader:
Code:
name	THE_CHOSEN_ONE
health	100
speed	10
throw         2 3
type	player
risetime 30
grabdistance 45
shadow	0
gfxshadow  1
makeinv  1
#holdblock 1
bflash block
hmap 1 2
fmap 2
mp 100
mprate	2
dust		dust
risetime 100
projectilehit   player obstacle
falldie 2
blockback 1


icon	data/chars/chosen/icon.png

running		23 4 2 1 1

diesound  data/chars/chosen/death.wav


animationscript data/scripts/script.c 
script data/chars/chosen/trailer.c
onfallscript data/scripts/release.c
keyscript  data/scripts/ironkey.c

I have tried importing but nothing,
In all my heroes use the trailer.c for blue shadows.
And all I need to create dialogues.

How I can do to include this  script line in my heroes?
Ex:
script data/chars/chosen/chosen.c

 
dantedevil said:

Since this character is a player character, it's just best to use what nsw25 is doing, which is to spawn story each time before a wait.

Eg:
Code:
...

wait
at 1000

spawn story
alias dialog2
at 1000

...

Only use story spawn scripts on enemy characters that appear once, because if you use it on players, it will be a bit annoying.



Also, there is the video tutorial now online here
 
Ok, I'll try. While still do not really understand how it works.
I only managed to complete the steps for this all in place, but even I could create a single dialogue.
The tutorial will be of great help, no doubt.

Thanks.
 
Back
Top Bottom