Story System

STORY SYSTEM for OpenBoR 2.1

No permission to download
playmusic(name, loop)

~Play a bor music.
~'name' is the path.
~'loop': 0 means dont loop, 1 means loop.

So it doesn't have support for offset loop. In fact, there is a way to do it in music for stages, but you need to calculate the offset + the file header, which is nowhere closer to be user friendly.
I would love to see OpenBOR support looping points in .ogg
 
O Ilusionista said:
playmusic(name, loop)

~Play a bor music.
~'name' is the path.
~'loop': 0 means dont loop, 1 means loop.

So it doesn't have support for offset loop. In fact, there is a way to do it in music for stages, but you need to calculate the offset + the file header, which is nowhere closer to be user friendly.
I would love to see OpenBOR support looping points in .ogg

Is that even dated? Cause I saw on the manual that it does support offsets:
Code:
playmusic(name, loop, offset)

    ~Pauses the music abruptly. technically, it toggles the variable 'sound_pause_music', commonly used for the pause menu to stop the music while the pause menu is present.
    ~name: pathname
    ~loop: toggle 1 or 0. 1 for loop music
    ~offset: start music offset
 
I found that there are different entries at manual about this, and some aren't updated with the offset. I will fix this, thanks.
Just remember to set the loop like uTunnels explained here http://www.chronocrash.com/forum/index.php?topic=610.msg4494#msg4494

 
Finally, I've managed to get along and made the text typewritten!

Damn, it's been a long time.

It was like 3 years since touching OpenBOR again. With so many things going on in my life, my career as a nurse and Nikki Shore, I've gotten touch with this project and started digging around the code. With some help from DC (thanks again!), I managed to find a way to make the text typewritten, like visual novels.

The code might my be hackish at best, but nevertheless it made things better. Static text is still available for people who still want that.

Link is here.

It's good to be back in the community and talk to some folks outside of chrono crash too.

Although sad to say, I'll be in and out. I'm still gonna come here and there, but with the duty having a pretty awful scheduling, I say I couldn't be as active as I used to be back then (I didn't have work and Nikki was then a game, not a novel). And thank goodness for Plombo and DC to carry over the code of OpenBOR to Github as well as carry over the Android port.

That's enough of that, now go ahead and check the new Story System out!
 
hey man nice to see you again.  I hope your contribution leads to more action RPG's.


Nikki Shore ?? have you had a kid ?
 
msmalik681 said:
Nikki Shore ?? have you had a kid ?

No, She's one of my original characters. I wrote a novel starring Nikki, Ghost Beneath The Ashes. It's on Wattpad, you can search for it. The very first syory starring her is called Pit Of Lies and you can find it on Wattpad as well

nsw25 contributed to the first story
 
Welcome back CRxTRDude!

Glad to have you back.

I try the new StorySystem 2.0 and have some problems.

Here the log:
Code:
Total Ram: 4294967295 Bytes
 Free Ram: 4294967295 Bytes
 Used Ram: 3223552 Bytes

debug:nativeWidth, nativeHeight, bpp, Hz  1360, 768, 24, 60
OpenBoR v3.0 Build , Compile Date: Jan 26 2017

Game Selected: ./Paks/bor.pak

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

Loading menu.txt.............	Done!
Loading fonts................	1 2 3 4 5 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': story_typing line 268, column 26

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

Can't compile script 'updated' 
Total Ram: 4294967295 Bytes
 Free Ram: 4294967295 Bytes
 Used Ram: 26718208 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 'updated'

Here my updated.c:
Code:
#include "data/scripts/anititle.c"
#include "data/scripts/story/story_define.h"
#include "data/scripts/story.c"
#include "data/scripts/gettick.c"
#include "data/scripts/playsound.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(){

   processRushCount();

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

void mainLoop(){
	void scene=openborvariant("current_scene");
	if(openborvariant("in_level"))
	{
		turnWhite();
		storySystem();
	}
	if(openborvariant("in_titlescreen")){
		if (scene!="data/scenes/intro.txt"){
			inTitleLoop(1);
		}
	}
	else {
		inTitleLoop(0);	
	}
                selectScreenEvent();  
}

void selectScreenEvent(){
	int was_in_selectscreen = getlocalvar("was_in_selectscreen");
	if(openborvariant("in_selectscreen")){
		if(was_in_selectscreen == NULL() || !was_in_selectscreen){
			playSound("data/sounds/choose.wav");
			setlocalvar("was_in_selectscreen", 1);
		}
	} else {
		if(was_in_selectscreen != NULL() && was_in_selectscreen != 0) setlocalvar("was_in_selectscreen", 0);
	}
}

void rushCountSound(int rush_count){
	if (rush_count == 3) {
	int iSnd = loadsample("data/sounds/hits3_triple.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 4){
	int iSnd = loadsample("data/sounds/hits4_super.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 5){
	int iSnd = loadsample("data/sounds/hits5_hyper.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 6){
	int iSnd = loadsample("data/sounds/hits6_brutal.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 7){
	int iSnd = loadsample("data/sounds/hits7_master.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 8){
	int iSnd = loadsample("data/sounds/hits8_awesome.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 9){
	int iSnd = loadsample("data/sounds/hits9_blaster.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 10){
	int iSnd = loadsample("data/sounds/hits10_monster.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 11){
	int iSnd = loadsample("data/sounds/hits11_king.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count >= 12 && rush_count <=20){
	int iSnd = loadsample("data/sounds/hits12_killer.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count >= 21 && rush_count <=30){
	int iSnd = loadsample("data/sounds/hits13_ultra.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
   else if (rush_count >= 31){
   int iSnd = loadsample("data/sounds/hitsx_ultimate.wav");
   playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
   }   		
	
	
}


void processRushCount(){
	void vEnt = getplayerproperty(0, "entity");
	if(vEnt != NULL()){
		int lastRushCount = getentityvar(vEnt, "last_rush_count");
		int rushCount = getentityproperty(vEnt, "rush_count");
		
		if(lastRushCount != NULL() && rushCount < lastRushCount){ // Combo ended, play sound
			rushCountSound(lastRushCount);
		}
		setentityvar(vEnt, "last_rush_count", rushCount);
		
	}
	
}
 
Did you modify your story_define.h? I think I included instructions to modify indexed vars to vacant slots, because I included new variables for the typewriting.

Specifically:

Code:
#define story_typing 43
#define story_charlength 44
#define story_text 45
#define story_state 46
#define story_timer 47
#define story_dialinit 48
#define story_speed 49
 
Thanks my friend!

Now finally works, but the default speed of the text work really slow in  my  mod. So I think something is wrong, because I see the Demo 2.0 and the text shows more fast.
I try changing the speed, but not work.

Here my story.c
Code:
//Story System for OpenBOR
//Original by Volcanic; Modifications by CRxTRDude

//story.c
//the main displaying logic for the story system.

#include "data/scripts/story/story_screen.c"
#include "data/scripts/common/commons.c"

//gcd function for aspect ratio. Thanks to 
//Jack at StackOverflow for this code.
//http://stackoverflow.com/questions/19738919/gcd-function-for-c
int gcd (int a, int b) {
    int temp;
    while (b != 0)
    {
        temp = a % b;

        a = b;
        b = temp;
    }
    return a;
}

//storySystem()
//main function to draw dialogs

void storySystem()
{
	//This only works if the story_switch indexed var is set to 1.
	//use the story_switch indexed var for detecting if the story
	//is applied.
	if(getindexedvar(story_switch))
	{
		//grabbed from the dialog script vars        
		void name	=	getindexedvar(story_msgName);
		void portrait	=	getindexedvar(story_msgPortrait);
		void dir	=	getindexedvar(story_dir);
		
		char msg	=	getindexedvar(story_msg1);
		char msgn	=	getindexedvar(story_msg2);
		char name	=	getindexedvar(story_msgName);		
		
		//grabbed from the scroll script vars
		void backf	=	getindexedvar(story_backfile);
		void backf2	=	getindexedvar(story_backfile2);
		void backf3	=	getindexedvar(story_backfile3);

		void back	=	getindexedvar(story_back);
		void back2	=	getindexedvar(story_back2);
		void back3	=	getindexedvar(story_back3);

		//Local Variables
		//for this script only.		
		void spr	=	getlocalvar("story."+portrait); // Single sprite
		void sprites = getlocalvar("story.array."+portrait); // Array of sprites
		
		void ctc	=	getlocalvar("story.ctc");
		void ctc1	=	getlocalvar("story.ctc1");
		void ctc_x = getlocalvar("story.ctc_x");
		void ctc_y = getlocalvar("story.ctc_y");
		
		void frame_x = getlocalvar("story.frame_x"); 
		void frame_y = getlocalvar("story.frame_y"); 
		void frame_w = getlocalvar("story.frame_w");
		void frame_h = getlocalvar("story.frame_h"); 
		void frame_color = getlocalvar("story.frame_color");

		//define how many sprites are in the sprite array.
		int numberOfSprites = sprites ? size(sprites) : 0;
		
		//The text object indexes. Since indexing in text objects is
		//dissimilar to indexed variables, you don't have to worry
		//about this.
		void txt_name = 0;
		void txt_msg1 = 1;
		void txt_msg2 = 2;
		
		//Variables to make the system resolution independent.		
		void ar_gcd = gcd(res_x, res_y);
		void ar_x	= res_x/ar_gcd;
		void ar_y = res_y/ar_gcd;
		
		void x		=	0;
		void y		= 0; 
		
		//Variables for the screens.
		void scr	=	getSpriteScreen();
		void dialogscr = getDialogScreen();
		void istextdisplayed = getindexedvar(story_isDisplayDialog);
		
		clearSpriteScreen();
		clearDialogScreen();
		
		if(name==NULL())return;

		//Initialize Vars*
		if(dir==NULL())dir=0;
		
		if (!sprites){
			sprites = array(1);
			log("Allocating sprite : " + portrait + "...\n");
			
			void filename;
			void fullStr = portrait;
			void resteStr = strinfirst(fullStr, ":"); //use colon as separator

			if(resteStr == NULL() || resteStr == "" || resteStr == -1){
			//Solo sprites
				if(!spr){
					spr=loadsprite("data/story/portrait/"+portrait);
					if (spr == NULL()) shutdown (1, "STORY: File not found '"+spr+"\n\n");
					setlocalvar("story."+portrait, spr);
				}
				set(sprites, numberOfSprites, spr);
				log("Sprite allocated : " + spr + "\n");
				
			}else {
			//Array of sprites
				while(resteStr != NULL() && resteStr != "" && resteStr != -1){
					int pos = strlength(fullStr) - strlength(resteStr);
					filename = strleft(fullStr, pos);
					spr = getlocalvar("story."+filename); //similar to story.portrait
					if (!spr){
						spr = loadsprite("data/story/portrait/"+filename);
						setlocalvar("story."+filename, spr);
					}
					set(sprites, numberOfSprites, spr);
					log("Sprite allocated : " + filename + "\n");
					fullStr = strright(resteStr, 1);
					resteStr = strinfirst(fullStr, ":");
					numberOfSprites++;
				}
			}
			setlocalvar("story.array."+portrait, sprites);
		}
		
		if (!ctc_y){
			//Define the frame
			//First determine if it's either 4:3 or not.
			//Else we use a more smaller version on
			//other aspect ratios.
			if ((ar_x == 4) && (ar_y == 3)){
				frame_x = res_x*0.02;
				frame_y = res_y*0.73;
				frame_w = res_x - ((frame_x*2)-1);
				frame_h = 60;
			}
			else{ 
				frame_x = res_x*0.1;
				frame_y = res_y*0.73;
				frame_w = res_x - ((frame_x*2)-1);
				frame_h = 60;
			}
			setlocalvar("story.frame_x",frame_x);
			setlocalvar("story.frame_y",frame_y);
			setlocalvar("story.frame_w",frame_w);
			setlocalvar("story.frame_h",frame_h);			
			
			//Define the click to continue sprite (the arrow icon
			//at the bottom of the text box).
			
			ctc=loadsprite("data/story/sprites/story_ctc");
			ctc1=loadsprite("data/story/sprites/story_ctc1");
			ctc_x = (frame_x + frame_w) - 20;
			ctc_y = (frame_y + frame_h) - 53;
			setlocalvar("story.ctc",ctc);
			setlocalvar("story.ctc1",ctc1);
			setlocalvar("story.ctc_x",ctc_x);
			setlocalvar("story.ctc_y",ctc_y);
		}
		if(!back){
			if (backf!=NULL()){
				back=loadsprite(backf);
				setindexedvar(story_back,back);
			}
			if (backf2!=NULL()){
				back2=loadsprite(backf2);
				setindexedvar(story_back2,back2);
			}
			if (backf3!=NULL()){
				back3=loadsprite(backf3);
				setindexedvar(story_back3,back3);
			}
		}
		
		if (dir){
			frame_color = rgbcolor(210,91,91);
			setlocalvar("story.frame_color",frame_color);
		}else{
			frame_color = rgbcolor(91,107,210);
			setlocalvar("story.frame_color",frame_color);
		}
		
//Start drawing here.		
		
		//Draw Alpha Background*
		drawbox(0,0,res_x,res_y,1000,0,6);
		
		//Draw Background*
		if(back2==NULL()){
			if(back)drawspritetoscreen(back,scr,0,0);
		}else{
			//drawboxtoscreen(scr,0,0,480,272,0);
			if(back)drawspritetoscreen(back,scr,0,0);
			setdrawmethod(NULL(),1,256,256,0,0,0,1);
			if(back)drawspritetoscreen(back2,scr,0,0);
			if(back)drawspritetoscreen(back3,scr,0,0);
			setdrawmethod(NULL(),0,256,256,0,0,0,0);
		}

		//Draw Sprite*
		
		//calculate the resolution before applying.
				
		if(dir) x=res_x*0.96;
		else 	x=res_x*0.03;
		
		changedrawmethod(NULL(), "channelg", 220);
		changedrawmethod(NULL(), "channelr", 220);
		changedrawmethod(NULL(), "channelb", 220);
		
		setdrawmethod(NULL(),1,256,256,dir,0,0,0,0);
							
		int yOffset;
		if(numberOfSprites == 0){
			// for solo sprites.
			if(spr){
				y = res_y - getgfxproperty(spr,"height");
				drawspritetoscreen(spr,scr,res_x,y);
			}
			
		} else {
			// for array of sprites
			int xOffset = 0;

			int i;
			for(i=numberOfSprites-1; i>=0; i--){
				spr = get(sprites, i);
				y = res_y - getgfxproperty(spr,"height");
				drawspritetoscreen(spr, scr, x+xOffset, y);
				
				//You can adjust the spacing of the chars when
				//displaying multiple sprites here. Default is
				//0.45, which is enough for two sprites on
				//the resolution of 320x240 on sprites with height no
				//less than 240 px high.
				
				if(dir) xOffset -= getgfxproperty(spr,"width")*0.4;
				else xOffset += getgfxproperty(spr,"width")*0.4;
			}
		}
		setdrawmethod(NULL(),0,256,256,0,0,0,0,0);
		
		drawSpriteScreen();
		
		//if(getlocalvar("story.array."+portrait)){
		//	free(getlocalvar("story.array."+portrait));
		//	setlocalvar("story.array."+portrait, NULL());
		//}

//Renders for the sprite ends here, proceeding to frame and text.		
		
		//Draw Frame here*
		drawbox(frame_x,frame_y,frame_w,frame_h,1200,frame_color,6);
		
		//Draw Click-to-Continue sprite*
		if(!getindexedvar(story_typing)){
	 		setdrawmethod(NULL(),1,256,256,0,0,0,6);
	
			if(openborvariant("elapsed_time")%120/60==1){
				drawspritetoscreen(ctc,dialogscr,ctc_x,ctc_y);
			}else{
				drawspritetoscreen(ctc1,dialogscr,ctc_x,ctc_y);
			}
			setdrawmethod(NULL(),0,256,256,0,0,0,0);
		}
		
		//Draw Text For Dialog *		
		if(!istextdisplayed){
			settextobj(txt_name,frame_x+5,frame_y+5,1,1300,name);		
			
			void typing = getindexedvar(story_typing);
			void fin;
			void char_length;
			float len;
			void charspeed = 120;
			void current_msg;
			void current_txtobj;
			void incr;
			void speed;
			
			if (getindexedvar(story_speed) != NULL()){
				speed = getindexedvar(story_speed); 
			}
			else{
				speed = 10;
			}
			      
			if(getindexedvar(story_typing))
			{
				if (!getindexedvar(story_dialinit)){
					incr = 0;
					cleartextobj(txt_msg1);
					cleartextobj(txt_msg2);
					setindexedvar(story_timer, 0);
					setindexedvar(story_dialinit,1);
				}
				//1 - set length appropriately
				if (getindexedvar(story_state)==0){
					current_msg = msg;
					current_txtobj = txt_msg1;
				}
				else if (getindexedvar(story_state)==1){
					current_msg = msgn;
					current_txtobj = txt_msg2;
				}
				len = strlength(current_msg);
				//2 - type off the appropriate line
				if (getindexedvar(story_charlength) < len){
					if (getindexedvar(story_timer)<speed)
					{
						incr = getindexedvar(story_timer)+1;
						if (setindexedvar(story_timer, incr)){
							incr = 0;
						}
						//log(getindexedvar(story_timer));
					}
					else if (getindexedvar(story_timer)>=speed)             
					{
						fin = getindexedvar(story_text) + getchar(current_msg,getindexedvar(story_charlength));
						if (getindexedvar(story_state)==0){
							settextobj(txt_msg1,frame_x+15,frame_y+22,0,1300,getindexedvar(story_text));
						}
						else if (getindexedvar(story_state)==1){
							settextobj(txt_msg2,frame_x+15,frame_y+40,0,1300,getindexedvar(story_text));
						}
						if(setindexedvar(story_text,fin)){
							fin = ""; 
						}
						char_length = (getindexedvar(story_charlength))+1;
						if (setindexedvar(story_charlength,char_length)){
							char_length = 0;
						}
						setindexedvar(story_timer, 0);       
					}  
				}
				//3 - switch the state once the line has been finished
				else if (getindexedvar(story_charlength) >= len){
					if (getindexedvar(story_state)==0){
						if (msgn!=NULL()){
							settextobj(txt_msg1,frame_x+15,frame_y+22,0,1300,msg);
							setindexedvar(story_text,"");
							setindexedvar(story_charlength,0);
							setindexedvar(story_state,1);
						}
						else{
							cleartextobj(txt_msg2);
							setindexedvar(story_state,2);
						}
					}
					else if (getindexedvar(story_state)==1){
						setindexedvar(story_state,2);
					}
					else{
						setindexedvar(story_text,"");
						setindexedvar(story_typing,0);
					}
				}
			}
			else{
					settextobj(txt_msg1,frame_x+15,frame_y+22,0,1300,msg);
					if (msgn!=NULL()){
						settextobj(txt_msg2,frame_x+15,frame_y+40,0,1300,msgn);
					}
					else{
						cleartextobj(txt_msg2);
					}
					istextdisplayed = 1;
					setindexedvar(story_isDisplayDialog, istextdisplayed);
			 }	
		}
		drawDialogScreen();
	}		
//Note that there's no cleartextobj commands in this
//script other than to detect if there is message2
//in a text file, this is because it is handled
//in the story_key.c which is the one that handles
//key capture.
}

//Transferred turnWhite into story.c to unclutter the
//updated.c as well as easing the installation process.

void turnWhite()
{
	void dir=getindexedvar(WHITE);
	
	if(!dir){return;}else{}

	void tick=get_tick();
	void w=getglobalvar("white.alpha");
	if(!w)
	{
		if(dir==1) w=0;
		else w=256;
	}
	
	if(dir==1) w+=tick*0.8;
	else w-=tick*0.8;

	if(dir==1)
	{
		if(w>255)w=255;
	}else{
		if(w<0)w=0;
	}
	setglobalvar("white.alpha",w);
	drawbox(0,0,res_x,res_y,900,rgbcolor(w,w,w),1);
}

Here my updated.c:
Code:
#include "data/scripts/anititle.c"
#include "data/scripts/story/story_define.h"
#include "data/scripts/story.c"
#include "data/scripts/gettick.c"
#include "data/scripts/playsound.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(){

   processRushCount();

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

void mainLoop(){
	void scene=openborvariant("current_scene");
	if(openborvariant("in_level"))
	{
		turnWhite();
		storySystem();
	}
	if(openborvariant("in_titlescreen")){
		if (scene!="data/scenes/intro.txt"){
			inTitleLoop(1);
		}
	}
	else {
		inTitleLoop(0);	
	}
                selectScreenEvent();  
}

void selectScreenEvent(){
	int was_in_selectscreen = getlocalvar("was_in_selectscreen");
	if(openborvariant("in_selectscreen")){
		if(was_in_selectscreen == NULL() || !was_in_selectscreen){
			playSound("data/sounds/choose.wav");
			setlocalvar("was_in_selectscreen", 1);
		}
	} else {
		if(was_in_selectscreen != NULL() && was_in_selectscreen != 0) setlocalvar("was_in_selectscreen", 0);
	}
}

void rushCountSound(int rush_count){
	if (rush_count == 3) {
	int iSnd = loadsample("data/sounds/hits3_triple.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 4){
	int iSnd = loadsample("data/sounds/hits4_super.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 5){
	int iSnd = loadsample("data/sounds/hits5_hyper.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 6){
	int iSnd = loadsample("data/sounds/hits6_brutal.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 7){
	int iSnd = loadsample("data/sounds/hits7_master.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 8){
	int iSnd = loadsample("data/sounds/hits8_awesome.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 9){
	int iSnd = loadsample("data/sounds/hits9_blaster.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 10){
	int iSnd = loadsample("data/sounds/hits10_monster.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 11){
	int iSnd = loadsample("data/sounds/hits11_king.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count >= 12 && rush_count <=20){
	int iSnd = loadsample("data/sounds/hits12_killer.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count >= 21 && rush_count <=30){
	int iSnd = loadsample("data/sounds/hits13_ultra.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
   else if (rush_count >= 31){
   int iSnd = loadsample("data/sounds/hitsx_ultimate.wav");
   playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
   }   		
	
	
}


void processRushCount(){
	void vEnt = getplayerproperty(0, "entity");
	if(vEnt != NULL()){
		int lastRushCount = getentityvar(vEnt, "last_rush_count");
		int rushCount = getentityproperty(vEnt, "rush_count");
		
		if(lastRushCount != NULL() && rushCount < lastRushCount){ // Combo ended, play sound
			rushCountSound(lastRushCount);
		}
		setentityvar(vEnt, "last_rush_count", rushCount);
		
	}
	
}
 
dantedevil said:
Thanks my friend!

Now finally works, but the default speed of the text work really slow in  my  mod. So I think something is wrong, because I see the Demo 2.0 and the text shows more fast.
I try changing the speed, but not work.

Here my story.c
Code:
//Story System for OpenBOR
//Original by Volcanic; Modifications by CRxTRDude

//story.c
//the main displaying logic for the story system.

#include "data/scripts/story/story_screen.c"
#include "data/scripts/common/commons.c"

//gcd function for aspect ratio. Thanks to 
//Jack at StackOverflow for this code.
//http://stackoverflow.com/questions/19738919/gcd-function-for-c
int gcd (int a, int b) {
    int temp;
    while (b != 0)
    {
        temp = a % b;

        a = b;
        b = temp;
    }
    return a;
}

//storySystem()
//main function to draw dialogs

void storySystem()
{
	//This only works if the story_switch indexed var is set to 1.
	//use the story_switch indexed var for detecting if the story
	//is applied.
	if(getindexedvar(story_switch))
	{
		//grabbed from the dialog script vars        
		void name	=	getindexedvar(story_msgName);
		void portrait	=	getindexedvar(story_msgPortrait);
		void dir	=	getindexedvar(story_dir);
		
		char msg	=	getindexedvar(story_msg1);
		char msgn	=	getindexedvar(story_msg2);
		char name	=	getindexedvar(story_msgName);		
		
		//grabbed from the scroll script vars
		void backf	=	getindexedvar(story_backfile);
		void backf2	=	getindexedvar(story_backfile2);
		void backf3	=	getindexedvar(story_backfile3);

		void back	=	getindexedvar(story_back);
		void back2	=	getindexedvar(story_back2);
		void back3	=	getindexedvar(story_back3);

		//Local Variables
		//for this script only.		
		void spr	=	getlocalvar("story."+portrait); // Single sprite
		void sprites = getlocalvar("story.array."+portrait); // Array of sprites
		
		void ctc	=	getlocalvar("story.ctc");
		void ctc1	=	getlocalvar("story.ctc1");
		void ctc_x = getlocalvar("story.ctc_x");
		void ctc_y = getlocalvar("story.ctc_y");
		
		void frame_x = getlocalvar("story.frame_x"); 
		void frame_y = getlocalvar("story.frame_y"); 
		void frame_w = getlocalvar("story.frame_w");
		void frame_h = getlocalvar("story.frame_h"); 
		void frame_color = getlocalvar("story.frame_color");

		//define how many sprites are in the sprite array.
		int numberOfSprites = sprites ? size(sprites) : 0;
		
		//The text object indexes. Since indexing in text objects is
		//dissimilar to indexed variables, you don't have to worry
		//about this.
		void txt_name = 0;
		void txt_msg1 = 1;
		void txt_msg2 = 2;
		
		//Variables to make the system resolution independent.		
		void ar_gcd = gcd(res_x, res_y);
		void ar_x	= res_x/ar_gcd;
		void ar_y = res_y/ar_gcd;
		
		void x		=	0;
		void y		= 0; 
		
		//Variables for the screens.
		void scr	=	getSpriteScreen();
		void dialogscr = getDialogScreen();
		void istextdisplayed = getindexedvar(story_isDisplayDialog);
		
		clearSpriteScreen();
		clearDialogScreen();
		
		if(name==NULL())return;

		//Initialize Vars*
		if(dir==NULL())dir=0;
		
		if (!sprites){
			sprites = array(1);
			log("Allocating sprite : " + portrait + "...\n");
			
			void filename;
			void fullStr = portrait;
			void resteStr = strinfirst(fullStr, ":"); //use colon as separator

			if(resteStr == NULL() || resteStr == "" || resteStr == -1){
			//Solo sprites
				if(!spr){
					spr=loadsprite("data/story/portrait/"+portrait);
					if (spr == NULL()) shutdown (1, "STORY: File not found '"+spr+"\n\n");
					setlocalvar("story."+portrait, spr);
				}
				set(sprites, numberOfSprites, spr);
				log("Sprite allocated : " + spr + "\n");
				
			}else {
			//Array of sprites
				while(resteStr != NULL() && resteStr != "" && resteStr != -1){
					int pos = strlength(fullStr) - strlength(resteStr);
					filename = strleft(fullStr, pos);
					spr = getlocalvar("story."+filename); //similar to story.portrait
					if (!spr){
						spr = loadsprite("data/story/portrait/"+filename);
						setlocalvar("story."+filename, spr);
					}
					set(sprites, numberOfSprites, spr);
					log("Sprite allocated : " + filename + "\n");
					fullStr = strright(resteStr, 1);
					resteStr = strinfirst(fullStr, ":");
					numberOfSprites++;
				}
			}
			setlocalvar("story.array."+portrait, sprites);
		}
		
		if (!ctc_y){
			//Define the frame
			//First determine if it's either 4:3 or not.
			//Else we use a more smaller version on
			//other aspect ratios.
			if ((ar_x == 4) && (ar_y == 3)){
				frame_x = res_x*0.02;
				frame_y = res_y*0.73;
				frame_w = res_x - ((frame_x*2)-1);
				frame_h = 60;
			}
			else{ 
				frame_x = res_x*0.1;
				frame_y = res_y*0.73;
				frame_w = res_x - ((frame_x*2)-1);
				frame_h = 60;
			}
			setlocalvar("story.frame_x",frame_x);
			setlocalvar("story.frame_y",frame_y);
			setlocalvar("story.frame_w",frame_w);
			setlocalvar("story.frame_h",frame_h);			
			
			//Define the click to continue sprite (the arrow icon
			//at the bottom of the text box).
			
			ctc=loadsprite("data/story/sprites/story_ctc");
			ctc1=loadsprite("data/story/sprites/story_ctc1");
			ctc_x = (frame_x + frame_w) - 20;
			ctc_y = (frame_y + frame_h) - 53;
			setlocalvar("story.ctc",ctc);
			setlocalvar("story.ctc1",ctc1);
			setlocalvar("story.ctc_x",ctc_x);
			setlocalvar("story.ctc_y",ctc_y);
		}
		if(!back){
			if (backf!=NULL()){
				back=loadsprite(backf);
				setindexedvar(story_back,back);
			}
			if (backf2!=NULL()){
				back2=loadsprite(backf2);
				setindexedvar(story_back2,back2);
			}
			if (backf3!=NULL()){
				back3=loadsprite(backf3);
				setindexedvar(story_back3,back3);
			}
		}
		
		if (dir){
			frame_color = rgbcolor(210,91,91);
			setlocalvar("story.frame_color",frame_color);
		}else{
			frame_color = rgbcolor(91,107,210);
			setlocalvar("story.frame_color",frame_color);
		}
		
//Start drawing here.		
		
		//Draw Alpha Background*
		drawbox(0,0,res_x,res_y,1000,0,6);
		
		//Draw Background*
		if(back2==NULL()){
			if(back)drawspritetoscreen(back,scr,0,0);
		}else{
			//drawboxtoscreen(scr,0,0,480,272,0);
			if(back)drawspritetoscreen(back,scr,0,0);
			setdrawmethod(NULL(),1,256,256,0,0,0,1);
			if(back)drawspritetoscreen(back2,scr,0,0);
			if(back)drawspritetoscreen(back3,scr,0,0);
			setdrawmethod(NULL(),0,256,256,0,0,0,0);
		}

		//Draw Sprite*
		
		//calculate the resolution before applying.
				
		if(dir) x=res_x*0.96;
		else 	x=res_x*0.03;
		
		changedrawmethod(NULL(), "channelg", 220);
		changedrawmethod(NULL(), "channelr", 220);
		changedrawmethod(NULL(), "channelb", 220);
		
		setdrawmethod(NULL(),1,256,256,dir,0,0,0,0);
							
		int yOffset;
		if(numberOfSprites == 0){
			// for solo sprites.
			if(spr){
				y = res_y - getgfxproperty(spr,"height");
				drawspritetoscreen(spr,scr,res_x,y);
			}
			
		} else {
			// for array of sprites
			int xOffset = 0;

			int i;
			for(i=numberOfSprites-1; i>=0; i--){
				spr = get(sprites, i);
				y = res_y - getgfxproperty(spr,"height");
				drawspritetoscreen(spr, scr, x+xOffset, y);
				
				//You can adjust the spacing of the chars when
				//displaying multiple sprites here. Default is
				//0.45, which is enough for two sprites on
				//the resolution of 320x240 on sprites with height no
				//less than 240 px high.
				
				if(dir) xOffset -= getgfxproperty(spr,"width")*0.4;
				else xOffset += getgfxproperty(spr,"width")*0.4;
			}
		}
		setdrawmethod(NULL(),0,256,256,0,0,0,0,0);
		
		drawSpriteScreen();
		
		//if(getlocalvar("story.array."+portrait)){
		//	free(getlocalvar("story.array."+portrait));
		//	setlocalvar("story.array."+portrait, NULL());
		//}

//Renders for the sprite ends here, proceeding to frame and text.		
		
		//Draw Frame here*
		drawbox(frame_x,frame_y,frame_w,frame_h,1200,frame_color,6);
		
		//Draw Click-to-Continue sprite*
		if(!getindexedvar(story_typing)){
	 		setdrawmethod(NULL(),1,256,256,0,0,0,6);
	
			if(openborvariant("elapsed_time")%120/60==1){
				drawspritetoscreen(ctc,dialogscr,ctc_x,ctc_y);
			}else{
				drawspritetoscreen(ctc1,dialogscr,ctc_x,ctc_y);
			}
			setdrawmethod(NULL(),0,256,256,0,0,0,0);
		}
		
		//Draw Text For Dialog *		
		if(!istextdisplayed){
			settextobj(txt_name,frame_x+5,frame_y+5,1,1300,name);		
			
			void typing = getindexedvar(story_typing);
			void fin;
			void char_length;
			float len;
			void charspeed = 120;
			void current_msg;
			void current_txtobj;
			void incr;
			void speed;
			
			if (getindexedvar(story_speed) != NULL()){
				speed = getindexedvar(story_speed); 
			}
			else{
				speed = 10;
			}
			      
			if(getindexedvar(story_typing))
			{
				if (!getindexedvar(story_dialinit)){
					incr = 0;
					cleartextobj(txt_msg1);
					cleartextobj(txt_msg2);
					setindexedvar(story_timer, 0);
					setindexedvar(story_dialinit,1);
				}
				//1 - set length appropriately
				if (getindexedvar(story_state)==0){
					current_msg = msg;
					current_txtobj = txt_msg1;
				}
				else if (getindexedvar(story_state)==1){
					current_msg = msgn;
					current_txtobj = txt_msg2;
				}
				len = strlength(current_msg);
				//2 - type off the appropriate line
				if (getindexedvar(story_charlength) < len){
					if (getindexedvar(story_timer)<speed)
					{
						incr = getindexedvar(story_timer)+1;
						if (setindexedvar(story_timer, incr)){
							incr = 0;
						}
						//log(getindexedvar(story_timer));
					}
					else if (getindexedvar(story_timer)>=speed)             
					{
						fin = getindexedvar(story_text) + getchar(current_msg,getindexedvar(story_charlength));
						if (getindexedvar(story_state)==0){
							settextobj(txt_msg1,frame_x+15,frame_y+22,0,1300,getindexedvar(story_text));
						}
						else if (getindexedvar(story_state)==1){
							settextobj(txt_msg2,frame_x+15,frame_y+40,0,1300,getindexedvar(story_text));
						}
						if(setindexedvar(story_text,fin)){
							fin = ""; 
						}
						char_length = (getindexedvar(story_charlength))+1;
						if (setindexedvar(story_charlength,char_length)){
							char_length = 0;
						}
						setindexedvar(story_timer, 0);       
					}  
				}
				//3 - switch the state once the line has been finished
				else if (getindexedvar(story_charlength) >= len){
					if (getindexedvar(story_state)==0){
						if (msgn!=NULL()){
							settextobj(txt_msg1,frame_x+15,frame_y+22,0,1300,msg);
							setindexedvar(story_text,"");
							setindexedvar(story_charlength,0);
							setindexedvar(story_state,1);
						}
						else{
							cleartextobj(txt_msg2);
							setindexedvar(story_state,2);
						}
					}
					else if (getindexedvar(story_state)==1){
						setindexedvar(story_state,2);
					}
					else{
						setindexedvar(story_text,"");
						setindexedvar(story_typing,0);
					}
				}
			}
			else{
					settextobj(txt_msg1,frame_x+15,frame_y+22,0,1300,msg);
					if (msgn!=NULL()){
						settextobj(txt_msg2,frame_x+15,frame_y+40,0,1300,msgn);
					}
					else{
						cleartextobj(txt_msg2);
					}
					istextdisplayed = 1;
					setindexedvar(story_isDisplayDialog, istextdisplayed);
			 }	
		}
		drawDialogScreen();
	}		
//Note that there's no cleartextobj commands in this
//script other than to detect if there is message2
//in a text file, this is because it is handled
//in the story_key.c which is the one that handles
//key capture.
}

//Transferred turnWhite into story.c to unclutter the
//updated.c as well as easing the installation process.

void turnWhite()
{
	void dir=getindexedvar(WHITE);
	
	if(!dir){return;}else{}

	void tick=get_tick();
	void w=getglobalvar("white.alpha");
	if(!w)
	{
		if(dir==1) w=0;
		else w=256;
	}
	
	if(dir==1) w+=tick*0.8;
	else w-=tick*0.8;

	if(dir==1)
	{
		if(w>255)w=255;
	}else{
		if(w<0)w=0;
	}
	setglobalvar("white.alpha",w);
	drawbox(0,0,res_x,res_y,900,rgbcolor(w,w,w),1);
}

Here my updated.c:
Code:
#include "data/scripts/anititle.c"
#include "data/scripts/story/story_define.h"
#include "data/scripts/story.c"
#include "data/scripts/gettick.c"
#include "data/scripts/playsound.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(){

   processRushCount();

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

void mainLoop(){
	void scene=openborvariant("current_scene");
	if(openborvariant("in_level"))
	{
		turnWhite();
		storySystem();
	}
	if(openborvariant("in_titlescreen")){
		if (scene!="data/scenes/intro.txt"){
			inTitleLoop(1);
		}
	}
	else {
		inTitleLoop(0);	
	}
                selectScreenEvent();  
}

void selectScreenEvent(){
	int was_in_selectscreen = getlocalvar("was_in_selectscreen");
	if(openborvariant("in_selectscreen")){
		if(was_in_selectscreen == NULL() || !was_in_selectscreen){
			playSound("data/sounds/choose.wav");
			setlocalvar("was_in_selectscreen", 1);
		}
	} else {
		if(was_in_selectscreen != NULL() && was_in_selectscreen != 0) setlocalvar("was_in_selectscreen", 0);
	}
}

void rushCountSound(int rush_count){
	if (rush_count == 3) {
	int iSnd = loadsample("data/sounds/hits3_triple.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 4){
	int iSnd = loadsample("data/sounds/hits4_super.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 5){
	int iSnd = loadsample("data/sounds/hits5_hyper.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 6){
	int iSnd = loadsample("data/sounds/hits6_brutal.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 7){
	int iSnd = loadsample("data/sounds/hits7_master.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 8){
	int iSnd = loadsample("data/sounds/hits8_awesome.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 9){
	int iSnd = loadsample("data/sounds/hits9_blaster.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 10){
	int iSnd = loadsample("data/sounds/hits10_monster.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count == 11){
	int iSnd = loadsample("data/sounds/hits11_king.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count >= 12 && rush_count <=20){
	int iSnd = loadsample("data/sounds/hits12_killer.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
	else if (rush_count >= 21 && rush_count <=30){
	int iSnd = loadsample("data/sounds/hits13_ultra.wav");
	playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
	}
   else if (rush_count >= 31){
   int iSnd = loadsample("data/sounds/hitsx_ultimate.wav");
   playsample(iSnd, 0, openborvariant("effectvol"), openborvariant("effectvol"), 100, 0);
   }   		
	
	
}


void processRushCount(){
	void vEnt = getplayerproperty(0, "entity");
	if(vEnt != NULL()){
		int lastRushCount = getentityvar(vEnt, "last_rush_count");
		int rushCount = getentityproperty(vEnt, "rush_count");
		
		if(lastRushCount != NULL() && rushCount < lastRushCount){ // Combo ended, play sound
			rushCountSound(lastRushCount);
		}
		setentityvar(vEnt, "last_rush_count", rushCount);
		
	}
	
}


Well my friend, I try everything but still working really slow. I can't find the problem.
Here my steps:

1) Replace all the scripts in the "story" folder.

2)  Replace all the scripts in the "common" folder.

3) Put the script "gettick" in the scripts folder:

4) Here my endlevel.c, have some adds:
Code:
#include "data/scripts/story/story_clear.c"

void main()
{
   clearStory();
   setdrawmethod(NULL(),0,256,256,0,0,0,0,0,0,0,0,0,NULL());
}

4) Here my keyall.c:, have some adds:
Code:
#include "data/scripts/story/story_clear.c"

void main()
{
   clearStory();
   setdrawmethod(NULL(),0,256,256,0,0,0,0,0,0,0,0,0,NULL());
}

So this is all, i don't know where is the problem.
 
I try in my computer and try changing speed to a high value, but the speed not change.
So no doubt something is wrong.
 
I can confirm that the new Story System is pretty slow on Android. I was relying on the game updating every frame. What I did is basically add single variables. Probably this is slow on devices. I'll try to work that when I get the chance.

dantedevil said:
I try in my computer and try changing speed to a high value, but the speed not change.
So no doubt something is wrong.

You were using text objects or other things drawn on your game? Maybe disabling the other text objects or lessen what is drawn in the screen might help, I guess.
 
You were using text objects or other things drawn on your game? Maybe disabling the other text objects or lessen what is drawn in the screen might help, I guess.
You mean something like the shadowtrail script?

Code:
#define MAX_TRAILS 50

/*
Per pulire piano tutta la trail.
Impostare un flag ON come parametro nella func. Poi ad ogni aggiornamento dello sprite cancella la coda (localvar spr) 2 sprites per volta.
Quindi cancella 2 sprites e aggiorna di 1. Si cancellerà uno sprites per volta. Quando sono tutti cancellati pulisci la trail.
Se il flag è on e se tutta la coda è pulita allora non chiamare più il metodo draw_trail.
In alternativa si puà usare updated.c ed eseguire il metodo fintanto che la coda è piena...
*/


int clear_shadowtrail(void ent) {
    int i;

        for( i = 0; i < MAX_TRAILS; ++i) {
            setlocalvar("xpos"+ent+"_"+i, NULL());
            setlocalvar("zpos"+ent+"_"+i, NULL());
            setlocalvar("apos"+ent+"_"+i, NULL());
            setlocalvar("facing"+ent+"_"+i, NULL());
            setlocalvar("spr"+ent+"_"+i, NULL());
            setlocalvar(ent+"_k",NULL());
        }

   return 0;
}

int get_oldest(void ent, int maxtrails) {
    if ( getlocalvar(ent+"_k") == NULL() ) return NULL();
    else {
        int k,i;

        if ( getlocalvar(ent+"_k") != NULL() ) k = getlocalvar(ent+"_k")-1; else k = 0;
        if (k < 0 ) k = maxtrails-1;

        for( i = k+1; i < maxtrails; ++i) { // dal k+1 c'è possibilità di trovare il k-vecchio
            if ( getlocalvar("spr"+ent+"_"+i) != NULL() ) return i;
        }
        for( i = 0; i <= k; ++i) { // ricominciamo dall'inizio fino a k compreso (evidentemente 1 solo sprite in tutto)
            if ( getlocalvar("spr"+ent+"_"+i) != NULL() ) return i;
        }

        return NULL();
    }
}

int draw_shadowtrail(void ent, int maxtrails, int refresh_frm, int min_transp, int max_transp, int swap_flag, int on_off_switch, int alpha, int color, int new_map) {
     int i = 0, k = 0, c = 0;
	 void spr = getentityproperty(ent, "sprite");
	 float x = getentityproperty(ent, "x");
     float z = getentityproperty(ent, "z");
     float a = getentityproperty(ent, "y");
	 int facing = getentityproperty(ent, "direction");
	 int colourmap = getentityproperty(ent, "colourmap");
     int elapsed_time = openborvariant("elapsed_time");
     float xpos, zpos, apos;

     if ( new_map != NULL() ) {
         int map = getentityproperty(ent, "map");

         changeentityproperty(ent,"map",new_map);
         colourmap = getentityproperty(ent, "colourmap");
         changeentityproperty(ent,"map",map);
     }

     if ( alpha == NULL() ) alpha = 6;

	 if ( facing == 1 ) facing = 0;
	 else facing = 1;

	 if ( maxtrails > MAX_TRAILS ) maxtrails = MAX_TRAILS;

     //drawstring( 10,200,0,"k:  "+getlocalvar(ent+"_k")+"  oldk:  "+get_oldest(ent, maxtrails));
     if ( elapsed_time%refresh_frm == 0 && openborvariant("in_level") ) { // memorizziamo sprites e posizioni nel tempo
            if ( getlocalvar(ent+"_k") != NULL() ) k = getlocalvar(ent+"_k"); else k = 0;

            // SPRITES SWAP
            if ( swap_flag && getlocalvar(ent+"_k") != NULL() ) {
                int tk = k;
                void tspr = NULL();

                for( i = 0; i < maxtrails; ++i) {
                    --tk;
                    if ( tk < 0 ) tk = maxtrails-1;
                    tspr = getlocalvar("spr"+ent+"_"+tk);
                    --tk;
                    if ( tk < 0 ) tk = maxtrails-1;
                    setlocalvar("spr"+ent+"_"+tk, tspr); // inseriamo lo sprite precedente nello slot ancora precedente
                }
            }
            // END SPRITES SWAP

            if ( on_off_switch && on_off_switch != NULL() ) {
                setlocalvar("xpos"+ent+"_"+k, x);
                setlocalvar("zpos"+ent+"_"+k, z);
                setlocalvar("apos"+ent+"_"+k, a);
                setlocalvar("facing"+ent+"_"+k, facing);
                setlocalvar("spr"+ent+"_"+k, spr);
                ++k;
                if ( k >= maxtrails ) k = 0;
                setlocalvar(ent+"_k", k); // Impostiamo il k recente
            } else {
                int old_k = get_oldest(ent, maxtrails);

                if ( getlocalvar(ent+"_k") != NULL() ) k = getlocalvar(ent+"_k")-1; else k = 0;
                if (k < 0 ) k = maxtrails-1;

                if ( old_k != NULL() ) setlocalvar("spr"+ent+"_"+old_k, NULL()); // cancelliamo lo sprite più vecchio

                if ( old_k != NULL() && old_k == k ) {
                        clear_shadowtrail(ent); // se abbiamo cancellato anche l'ultimo sprite, puliamo tutto!!
                        return 0;
                }
            } // fine on/off switch
     }

	 if ( openborvariant("in_level") ) { // draw trails

		 for( i = 0; i < maxtrails; ++i) {
                int transp, gradient;
                int layer = getentityproperty(ent, "setlayer");

                if ( getlocalvar("spr"+ent+"_"+i) != NULL() ) {
                     x = getlocalvar("xpos"+ent+"_"+i);
                     z = getlocalvar("zpos"+ent+"_"+i);
                     a = getlocalvar("apos"+ent+"_"+i);
                     facing = getlocalvar("facing"+ent+"_"+i);
                     spr = getlocalvar("spr"+ent+"_"+i);

                     // naturalmente il più recente deve essere il meno trasparente, ecco perchè usiamo k e non i!!
                     if ( getlocalvar(ent+"_k") != NULL() ) k = getlocalvar(ent+"_k")-1; else k = 0;
                     if (k < 0 ) k = maxtrails-1;
                     // Presa la k più recente impostiamo la k corrispondente alla i dalla più recente alla meno recente
                     // Dobbiamo sottrarre quindi maxtrails-i a k
                     /*for ( c = 0; c < i; ++c ) {
                        --k;
                        if ( k < 0 ) k = maxtrails-1;
                     }
                     gradient = maxtrails-1;
                     for ( c = 0; c < k; ++c ) {
                        --gradient;
                        if ( gradient < 0 ) gradient = maxtrails-1;
                     }*/

                     c = maxtrails-1-k;
                     gradient = (i+c)%maxtrails;

                     changedrawmethod(NULL(), "enabled", 1);
                     changedrawmethod(NULL(), "reset", 1);
                     //changedrawmethod(NULL(), "flag", 1);

                     changedrawmethod(NULL(), "alpha", alpha);
                     if ( color != NULL() ) {
                         changedrawmethod(NULL(), "tintmode", alpha);
                         changedrawmethod(NULL(), "tintcolor", color); // rgbcolor(0x00,0x00,0xFF)
                     }

                     transp = ( (max_transp-min_transp)*(gradient+1)/maxtrails )+min_transp;
                     changedrawmethod(NULL(), "channelg", transp);
                     changedrawmethod(NULL(), "channelr", transp);
                     changedrawmethod(NULL(), "channelb", transp);

                     // (entity, int flag, int scalex, int scaley, int flipx, int flipy, int shiftx, int alpha, int remap, int fillcolor, int rotate, int fliprotate, int transparencybg, void* colourmap, int centerx, int centery);
                     setdrawmethod(NULL(), 1, 256, 256, facing, 0, 0, alpha, 1, 0, 0, 0, 0, colourmap); // map: -1 = Use entity's colormap.

                     if ( x != NULL() ) drawsprite(spr, x-openborvariant("xpos"), z-a-openborvariant("ypos")-4, z-(maxtrails-1-gradient), layer);
                     changedrawmethod(NULL(), "enabled", 0);
                     changedrawmethod(NULL(), "reset", 1);
                     setdrawmethod(NULL(), 0);
                } // fine if spr != NULL()

		 } // fine for
	 } // if in_level

    return 1;
}

int check_shadow_trail(void player) {
    if ( get_shad_trail_flag(player) != NULL() && get_shad_trail_flag(player) != 0 ) {
        if ( draw_shadowtrail(player, 5, 15, 20, 160, 0, get_shad_trail_flag(player),6,NULL(),1) == 0 ) set_shad_trail_flag(player,NULL());
    }
}

int get_shad_trail_flag(void player) {
    return getentityvar(player, "shadowtrail");
}

int set_shad_trail_flag(void player, int value) {
    setentityvar(player, "shadowtrail", value);
}

I do not think I have any other text objects.

Apart from all the files I've shown you, you need something else to confirm where the error may be?
 
Hey guys!

I wonder why in the version 1.3 the system to play musics doesn't work (tested with two PC) but in the version 2.1, yes. Does anyone have the answer ?
 
Would it be possible for the Story System to support up to 3 lines of dialogue?
Example:
s5ZoCZc.png
 
I am sure if you can modify the code you could add another line my story system supports 3 line I hope to release my last demo by soon.
 
Back
Top Bottom