📄 chapter.cpp
字号:
#include "ls.h"
int TWORLD::CHAPTER()
{ int done,error;
int cmd,cmd_len;
int data[20];
int i,j,k,r,a;
int chap=-1;
static char line[100];
if (CHAPTER_DELAY>0) {
CHAPTER_DELAY--;
return 0;
} else CHAPTER_DELAY=0;
if (looping!=1) return 0;
for (done=0,error=0;done==0&&error==0;)
{ cmd=chapter[ip];
cmd_len=0;
switch (cmd)
{ case 0 : cmd_len=1; break; // NULL
case 'R': done=1; cmd_len=1; break; // CALLBACK
case 'J': ip=chapter[ip+1]; cmd_len=0; break; // GOTO
case 'M': r=proc_loadmap(chapter[ip+1]); // LOADMAP
if (r) voc.regist_msg("[Error loadmap] IP=%d",ip);
if (r) error=-1;
cmd_len=2;
break; // CREATEACTOR
case 'C': r=proc_createactor(chapter[ip+1],chapter[ip+2],chapter[ip+3]);
if (r) voc.regist_msg("[Error createactor %d] IP=%d",chapter[ip+1],ip);
if (r) error=-2;
cmd_len=4;
break; // ACTOREVENT
case 'E': for (i=0;i<3;i++) data[i]=chapter[ip+2+i];
r=proc_actorevent(chapter[ip+1],data);
if (r) voc.regist_msg("[Error actorevent] IP=%d",ip);
if (r) error=-3;
cmd_len=5;
break;
case 'A': a=chapter[ip+1]; i=chapter[ip+2]; // ACTORMOVE
r=proc_actormove(a,&chapter[ip+3],i);
if (r) voc.regist_msg("[Error actormove %d] IP=%d",a,ip);
if (r) error=-4;
cmd_len=3+i;
break; // MAPEVENT
case 'V': proc_mapevent(chapter[ip+1],chapter[ip+2],chapter[ip+3],chapter[ip+4],
chapter[ip+5],chapter[ip+6]);
cmd_len=7;
break;
case 'I': r=proc_if(&chapter[ip+1]); // IF
if (r) ip=chapter[ip+8],cmd_len=0;
else cmd_len=9;
break;
case 'L': r=proc_set(&chapter[ip+1]); // SET
if (r) voc.regist_msg("[Error set] IP=%d",ip);
if (r) error=-5;
cmd_len=8;
break; // SAY
case 'S': r=proc_say(chapter[ip+1],chapter[ip+2],chapter[ip+3]);
if (r) voc.regist_msg("[Error say] IP=%d",ip);
if (r) error=-6;
cmd_len=4;
break;
case 'D': r=proc_delactor(chapter[ip+1]); // DELACTOR
if (r) voc.regist_msg("[Error delactor %d] IP=%d",chapter[ip+1],ip);
if (r) error=-7;
cmd_len=2;
break;
case 'N': chap=chapter[ip+1];
cmd_len=2;
done=2;
break;
case 'W': cmd_len=2;
break;
case 'G': looping=0;
done=1;
cmd_len=1;
break;
case 'U': if (chapter[ip+1]>=0) voc.playmidi(chapter[ip+1],1);
else voc.playdigi(-1-chapter[ip+1]);
cmd_len=2;
break;
case 'P': if (chapter[ip+1]==0) {
i=chapter[ip+2];
j=chapter[ip+3];
if (i>=0&&j>=0&&i<map.len&&j<map.wid) map_sx=i, map_sy=j;
if (i==-1) {
k=game_findactor(j);
if (j<0) j=0;
map_sx=actor[k].x-20;
map_sy=actor[k].y-15;
if (map_sx<0) map_sx=0;
if (map_sx>=map.len-40) map_sx=map.len-40;
if (map_sy<0) map_sy=0;
if (map_sy>=map.wid-30) map_sy=map.wid-30;
}
cmd_len=4;
} else if (chapter[ip+1]==1) {
i=map_sx+incx[chapter[ip+2]];
j=map_sy+incy[chapter[ip+2]];
if (i>=0&&j>=0&&i<map.len&&j<map.wid) map_sx=i, map_sy=j;
cmd_len=3;
} else error=-8;
break;
case 'B': i=game_findactor(chapter[ip+1]); // ACTOR SPEED
if (i>=0) actor[i].act_speed=chapter[ip+2];
cmd_len=3;
break; // CALLBACK n
case 'X': CHAPTER_DELAY=chapter[ip+1]-1;
cmd_len=2; done=1;
break;
case 'T': i=game_findactor(chapter[ip+1]);
if (i>=0) actor[i].do_command(ACTOR_MOVETO,chapter[ip+2],chapter[ip+3]);
cmd_len=4;
break;
case 'Y': cmd_len=2+chapter[ip+1];
switch (chapter[ip+2])
{ case 0: for (i=0;i<4;i++) {
j=game_findactor(i);
if (j>=0) {
LGAME.ac[j].hp=LGAME.ac[j].mhp;
LGAME.ac[j].mp=LGAME.ac[j].mmp;
}
}
break;
case 1: LGAME.MovieShip(); break;
case 2: LGAME.MovieEnd(); break;
}
break;
case 'Z': cmd_len=3;
i=chapter[ip+1];
if (event[i]) {
event[i]=0;
ip=chapter[ip+2];
cmd_len=0;
}
break;
case 'F': cmd_len=3;
proc_get_goods(chapter[ip+1],chapter[ip+2]);
break;
case 'H': cmd_len=2;
proc_get_money(chapter[ip+1]);
break;
case 'K': cmd_len=3+chapter[ip+2];
express.buy_sell(&chapter[ip+3],chapter[ip+1]);
break;
case 'O': cmd_len=2;
LGAME.FightStart(chapter[ip+1]);
break;
default: error=1;
cmd_len=0;
break;
}
ip+=cmd_len;
if (ip>=0x10000||ip<0) error=-0xff;
}
if (done==2)
{ express.scr_smooth(0);
game_reset_all(1,1,1,0);
dialog_clear(); ip=0;
if (NEW_CHAPTER(chap,1)) error=-8;
if (error) {
voc.regist_msg("CHAPTER %d ERROR LOADED",chap);
lActiveSurface(NULL);
lsetColor(c_dark);
lbar(0,0,320,240);
lsetPal(pal0);
sprintf(line,"#场境角本%2d错误读取。",chap);
express.out_say(0,1,line);
}
smooth=-1;
}
lsetColor(c_yellow);
layer.active(0);
if (error==1) {
lsetPal(pal0);
sprintf(line,"UNKNOW COMMAND %c (%d) IP=%d",chapter[ip],chapter[ip],ip);
louttextxy(0,40,line);
} else if (error<0) {
lsetPal(pal0);
sprintf(line,"ERROR CMD %d IP=%d",error,ip);
louttextxy(0,40,line);
}
return error;
}
int TWORLD::proc_get_money(int money)
{ char line[80];
LGAME.money+=money;
if (LGAME.money<0) LGAME.money=0;
return 0;
}
int TWORLD::proc_get_goods(int g,int mode)
{ int i;
char s[80];
if (LGAME.goods_add(g,mode)==-1) {
express.out_say(5,0,"#物品已满");
return -1;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -