D
doranikofu
Guest
Rocket Viper has a story script that allows saving all the dialogs in txt file. This saves a lot of resources if the game has lots of storylines. The most impressive thing is that it supports Chinese characters (set through level difficulty level at beginning of game, 0=english 1=chinese).
I was looking at the project(RV2 v2.4) but still cannot understand how it fully works.
> Lines written in txt file, starting with character name and words to display. Script loads the name and avatar (based on name)
sample dialog "xiang1.txt"
> spawn a entity named story in the stage, alias specifies the filename of the dialog txt to load. For example, the dialog above would be
the story entity is defined with empty image
> the script file I could not understand how it works. I can get how the script it loading the player name, avatar facing direction, lines, and playing effects from txt file. But I can't track down to find the script to actually display all the contents (like dialog box, etc) Are some of the commands build-in? I could not find much from the referenced script files in the #include
I think it would be cool if there is a template project with only the essential things to make this work. This will give a lot of versatility for different language support in game. I tried to load those files into my project but I definitely missed something. Whenever the story entity spawns the level freezes (text entity, character not moving but can pause game with start button and exit, no error in log).
I was looking at the project(RV2 v2.4) but still cannot understand how it fully works.
> Lines written in txt file, starting with character name and words to display. Script loads the name and avatar (based on name)
sample dialog "xiang1.txt"
Code:
Girl 1 You_villain!! I_won't_let_you_get_away!
Kim 0 V_._._._villain? You're_talking_to_me?
Terry 0 She's_talking_to_you,Akuma.
Akuma 0 Humph!
end
> spawn a entity named story in the stage, alias specifies the filename of the dialog txt to load. For example, the dialog above would be
Code:
spawn story
alias xiang1
at 0
the story entity is defined with empty image
Code:
name story
type text
subtype noskip
shadow 0
health 1
animationscript data/scripts/story.c
anim idle
loop 1
delay 10
frame data/chars/misc/empty
@cmd talk
frame data/chars/misc/empty
anim freespecial
loop 1
delay 5
frame data/chars/misc/empty
delay 4000
@cmd sendMsg
frame data/chars/misc/empty
> the script file I could not understand how it works. I can get how the script it loading the player name, avatar facing direction, lines, and playing effects from txt file. But I can't track down to find the script to actually display all the contents (like dialog box, etc) Are some of the commands build-in? I could not find much from the referenced script files in the #include
Code:
#include "data/scripts/define.h"
#include "data/scripts/common/playsnd.c"
#include "data/scripts/common/iscn.c"
void getCname(void name)
{
void cname;
if (!isCN()) return name;
if(name=="Sarah"){
cname="莎拉";
}else if(name=="Shiki"){
cname="色";
}else if(name=="Ken"){
###------------omitted for brevity, for name conversion ------------------
}
return cname;
}
void sendMsg()
{
//name direction msg msg1 pro width
void self = getlocalvar("self");
void filenumber = getlocalvar("fh");
void name = getfilestreamargument(filenumber,0,"string");
void dir = getfilestreamargument(filenumber,1,"int");
void msg2 = getfilestreamargument(filenumber,2,"string");
void msg22 = getfilestreamargument(filenumber,3,"string");
void pro = getfilestreamargument(filenumber,4,"string");
void sound;
if(msg22==NULL())
msg22="_";
if (name=="end"){
endStory();
}else if(name=="_sound"){
playSound(msg2);
filestreamnextline(filenumber);
updateframe(self,0);
}else if(name=="_white"){
setindexedvar(WHITE,1);
filestreamnextline(filenumber);
updateframe(self,0);
}else if(name=="_normal"){
setindexedvar(WHITE,-1);
filestreamnextline(filenumber);
updateframe(self,0);
}else if(name=="_music"){
playmusic(msg2,1);
filestreamnextline(filenumber);
updateframe(self,0);
}else if(name=="_stopmusic"){
fademusic(1);
filestreamnextline(filenumber);
updateframe(self,0);
}else{
if (name=="_player"){
void vSelf = getplayerproperty(0, "entity");
if (vSelf==NULL()){vSelf=getplayerproperty(1, "entity");}
if (vSelf==NULL()){vSelf=getplayerproperty(2, "entity");}
name = getentityproperty(vSelf,"name");
}
if (pro=="" || pro==NULL() ||pro=="_"){pro=name;}
setglobalvar("story.msg1",msg2);
setglobalvar("story.msg2",msg22);
name=getCname(name);
setglobalvar("story.msgName",name);
setglobalvar("story.msgPro",pro);
setglobalvar("story.dir",dir);
filestreamnextline(filenumber);
setindexedvar(story_switch,1);
}
}
void talk()
{
void self = getlocalvar("self");
char folder=getentityproperty(self,"name");
setindexedvar(STORY_ENT,self);
setindexedvar(PAUSE,0);
if (folder!="story"){
setlocalvar("fh",openfilestream("data/story/"+getPath()+"/"+folder+".txt"));
changeentityproperty(self, "animation", openborconstant("ANI_FREESPECIAL"));
}
}
void playBgm(char bgm){
playmusic(bgm, 1);
}
void endStory()
{
//if there's no backfile then disable credit scroll screen
if(!getglobalvar("story.backfile"))
{
setindexedvar(PAUSE,0);
setindexedvar(story_switch,NULL());
}
//
setindexedvar(STORY_ENT,NULL());
killentity(getlocalvar("self"));
}
I think it would be cool if there is a template project with only the essential things to make this work. This will give a lot of versatility for different language support in game. I tried to load those files into my project but I definitely missed something. Whenever the story entity spawns the level freezes (text entity, character not moving but can pause game with start button and exit, no error in log).
