新对话指令:
请仔细阅读说明,特别是红色粗体部分。
说明:
1、这是《小猪3-金庸水浒传》所使用的新对话指令,功能如下:
⑴可以显示各种颜色的字体,也就是说可以对于重点名词,可以突出表示,方便玩家;也可以用不同颜色表示不同内容
比如黄色是“心想”等。
⑵在对话框上面添加姓名框,由系统自动侦识,方便玩家认清说话对象,可以避免手动写姓名到对话的麻烦,且提高对话通用性。
⑶系统自动侦识主角姓名,添加到对话相应位置,以后不必因为对话无法详细显示而剥夺大家起名的权利。
⑷支持延时播放,这个功能很多目前主流rpg都有,如今我们完美的把它引入到金群的对话系统当中。
⑸支持等待击键,同上,在重点的地方等待敲击后播放,提醒大家认真看,同时作为升级到对话自动发展,不需要反复敲击。
⑹防止方向键刷版,以后因为这个错过剧情,甚至产生bug的烦恼将彻底根除。
⑺自动侦测主角头像
⑻支持改变对话框颜色
2、使用方法:调用函数 NewTalk(headnum, talknum, namenum, place, showhead, color, frame)。
具体参数意义:
headnum:头像编号,若为0则读取主角头像;
talknum:对话编号,对话不需要加*换行;
namenum:姓名控制,这里有三种取值方式:-2,即读取R*中第一个使用head为头像的人的名字
0或-1,即不显示姓名
其他数值N,即读取N号对话作为姓名
place:对话位置,0左头右对话;1右头左对话
showhead:头像开关,0显示,1隐藏
color:对话文字颜色,高8位为背景色,低8位为前景色(与50指令的显示字符串的颜色设置一样)
frame:对话框颜色,为该颜色在调色板的索引号
控制字符:控制字符是指在对话中插入的有特殊意义的字符,如原版的*,C语言的\n等。
**:换行
&&:显示主角姓名
##:延时500毫秒
@@:等待击键
^1——^5:把颜色换成1-5号颜色 0白,1黄,2红,3蓝,4绿,5橙
^^:把颜色换回ctrl预设
$$:显示姓
能自动检测(南宫,西门,东方,令狐,慕容,司马,诸葛,司空,太史,公孙,欧阳,耶律,司徒,完颜,轩辕,宇文,拓跋)等复姓(并未判断日本姓)
%%:显示名
4、如有问题,请与本人联系
5、另有50指令版本:http://www.txdx.net/thread-400898-1-1.html
procedure NewTalk(headnum, talknum, namenum, place, showhead, color, frame: integer);
var
k, alen, newcolor, color1, color2, nh, nw, ch, c1, r1, n, namelen, i, t1, grp, idx, offset, len, i1, i2, face, c, nx, ny, hx, hy, hw, hh, x, y, w, h, cell, row: integer;
np3, np, np1, np2, tp, p1, ap: pchar;
actorarray, talkarray, namearray, name1, name2: array of byte;
pword: array[0..1] of Uint16;
begin
pword[1] := 0;
//预设颜色值
case color of
0: color := 28515;
1: color := 28421;
2: color := 28435;
3: color := 28563;
4: color := 28466;
5: color := 28450;
end;
color1 := color and $FF;
color2 := (color shr 8) and $FF;
x := 68;//对话框位置X
y := 320;//对话框位置Y
w := 511;//对话框宽
h := 109;//对话框高
nw := 86;//姓名框宽
nh := 28;//姓名框高
hx := 68;//头像框位置X
hy := 244;//头像框位置Y
hw := 57;//头像框宽
hh := 72;//头像框高
nx := 129;//姓名框位置X
ny := 288;//姓名框位置Y
if showhead = 1 then nx := x;//根据是否显示头像设定姓名框位置
row := 5;
cell := 25;
if place = 1 then//根据显示位置设置头像框及姓名框位置
begin
hx := 522;
nx := 431;
if showhead = 1 then nx := x + w - nw;
end;
//read talk
//读取对话
idx := fileopen('resource\talk.idx', fmopenread);
grp := fileopen('resource\talk.grp', fmopenread);
if talknum = 0 then
begin
offset := 0;
fileread(idx, len, 4);
end
else
begin
fileseek(idx, (talknum - 1) * 4, 0);
fileread(idx, offset, 4);
fileread(idx, len, 4);
end;
len := (len - offset);
setlength(talkarray, len + 1);
fileseek(grp, offset, 0);
fileread(grp, talkarray[0], len);
fileclose(idx);
fileclose(grp);
for i := 0 to len - 1 do
begin
talkarray[ i] := talkarray xor $FF;
if talkarray[ i] = 255 then talkarray := 0;
end;
talkarray[ i] := 0;
tp := @talkarray[0];
//read name
//读取姓名
if namenum > 0 then
begin
idx := fileopen('resource\talk.idx', fmopenread);
grp := fileopen('resource\talk.grp', fmopenread);
fileseek(idx, (namenum - 1) * 4, 0);
fileread(idx, offset, 4);
fileread(idx, namelen, 4);
namelen := (namelen - offset);
setlength(namearray, namelen + 1);
fileseek(grp, offset, 0);
fileread(grp, namearray[0], namelen);
fileclose(idx);
fileclose(grp);
for i := 0 to namelen - 2 do
begin
namearray[ i] := namearray xor $FF;
if namearray[ i] = 255 then namearray := 0;
end;
namearray[ i] := 0;
np := @namearray[0];
end
else if namenum = -2 then
begin
for i := 0 to length(rrole) - 1 do
begin
if Rrole[ i].HeadNum = headnum then
begin
p1 := @Rrole[ i].Name;
namelen := 10;
setlength(namearray, namelen);
np := @namearray[0];
for n := 0 to namelen - 1 do
begin
(np + n)^ := (p1 + n)^;
// if (p1 + n)^ = char(0) then break;
end;
(np + n)^ := char(0);
(np + n + 1)^ := char(0);
break;
end;
end;
end;
p1 := @Rrole[0].Name;
alen := length(p1) + 2;
setlength(actorarray, alen);
ap := @actorarray[0];
for n := 0 to alen - 1 do
begin
(ap + n)^ := (p1 + n)^;
if (p1 + n)^ = char(0) then break;
end;
(ap + n)^ := char($0);
(ap + n + 1)^ := char(0);
//以下为判断姓
if alen = 6 then
begin
setlength(name1, 4);
np1 := @name1[0];
np1^ := ap^;
(np1 + 1)^ := (ap + 1)^;
(np1 + 2)^ := char(0);
(np1 + 3)^ := char(0);
setlength(name2, 4);
np2 := @name2[0];
np2^ := ap^;
for i := 0 to length(name2) - 1 do
(np2 + i)^ := (ap + i + 2)^;
end
else if alen > 8 then
begin
setlength(name1, 6);
np1 := @name1[0];
np1^ := ap^;
(np1 + 1)^ := (ap + 1)^;
(np1 + 2)^ := (ap + 2)^;
(np1 + 3)^ := (ap + 3)^;
(np1 + 4)^ := char(0);
(np1 + 5)^ := char(0);
setlength(name2, 6);
np2 := @name2[0];
for i := 0 to length(name2) - 1 do
(np2 + i)^ := (ap + i + 4)^;
end
else if alen = 8 then
begin
if ((puint16(ap)^ = $6EAB) and ((puint16(ap + 2)^ = $63AE))) or
((puint16(ap)^ = $E8A6) and ((puint16(ap + 2)^ = $F9AA))) or
((puint16(ap)^ = $46AA) and ((puint16(ap + 2)^ = $E8A4))) or
((puint16(ap)^ = $4FA5) and ((puint16(ap + 2)^ = $B0AA))) or
((puint16(ap)^ = $7DBC) and ((puint16(ap + 2)^ = $65AE))) or
((puint16(ap)^ = $71A5) and ((puint16(ap + 2)^ = $A8B0))) or
((puint16(ap)^ = $D1BD) and ((puint16(ap + 2)^ = $AFB8))) or
((puint16(ap)^ = $71A5) and ((puint16(ap + 2)^ = $C5AA))) or
((puint16(ap)^ = $D3A4) and ((puint16(ap + 2)^ = $76A5))) or
((puint16(ap)^ = $BDA4) and ((puint16(ap + 2)^ = $5DAE))) or
((puint16(ap)^ = $DABC) and ((puint16(ap + 2)^ = $A7B6))) or
((puint16(ap)^ = $43AD) and ((puint16(ap + 2)^ = $DFAB))) or
((puint16(ap)^ = $71A5) and ((puint16(ap + 2)^ = $7BAE))) or
((puint16(ap)^ = $B9A7) and ((puint16(ap + 2)^ = $43C3))) or
((puint16(ap)^ = $61B0) and ((puint16(ap + 2)^ = $D5C1))) or
((puint16(ap)^ = $74A6) and ((puint16(ap + 2)^ = $E5A4))) or
((puint16(ap)^ = $DDA9) and ((puint16(ap + 2)^ = $5BB6))) then
begin
setlength(name1, 6);
np1 := @name1[0];
np1^ := ap^;
(np1 + 1)^ := (ap + 1)^;
(np1 + 2)^ := (ap + 2)^;
(np1 + 3)^ := (ap + 3)^;
(np1 + 4)^ := char(0);
(np1 + 5)^ := char(0);
setlength(name2, 4);
np2 := @name2[0];
for i := 0 to length(name2) - 1 do
(np2 + i)^ := (ap + i + 4)^;
end
else
begin
setlength(name1, 4);
np1 := @name1[0];
np1^ := ap^;
(np1 + 1)^ := (ap + 1)^;
(np1 + 2)^ := char(0);
(np1 + 3)^ := char(0);
setlength(name2, 6);
np2 := @name2[0];
for i := 0 to length(name2) - 1 do
(np2 + i)^ := (ap + i + 2)^;
end;
end;
ch := 0;
while ((puint16(tp + ch))^ shl 8 <> 0) and ((puint16(tp + ch))^ shr 8 <> 0) do
begin
redraw;
c1 := 0;
r1 := 0;
DrawRectangle(x, y, w, h, frame, colcolor($FF), 40);
if (showhead = 0) or (headnum < 0) then
begin
DrawRectangle(hx, hy, hw, hh, frame, colcolor($FF), 40);
if headnum = 0 then
begin
DrawHeadPic(RRole[0].HeadNum, hx, hy + 68);
end
else
begin
DrawHeadPic(headnum, hx, hy + 68);
end;
end;
if namenum <> 0 then
begin
DrawRectangle(nx, ny, nw, nh, frame, colcolor($FF), 40);
namelen := length(np);
DrawBig5ShadowText(np, nx + 20 - namelen * 9 div 2, ny + 4, colcolor($63), colcolor($70));
end;
while r1 < row do
begin
pword[0] := (puint16(tp + ch))^;
if (pword[0] shr 8 <> 0) and (pword[0] shl 8 <> 0) then
begin
ch := ch + 2;
if (pword[0] and $FF) = $5E then //^^改变文字颜色
begin
case smallint((pword[0] and $FF00) shr 8) - $30 of
0: newcolor := 28515;
1: newcolor := 28421;
2: newcolor := 28435;
3: newcolor := 28563;
4: newcolor := 28466;
5: newcolor := 28450;
64: newcolor := color;//^^改回预设颜色
else newcolor := color;
end;
color1 := newcolor and $FF;
color2 := (newcolor shr 8) and $FF;
end
else if pword[0] = $2323 then //## 延时
begin
sdl_delay(500);
end
else if pword[0] = $2A2A then //**换行
begin
if c1 > 0 then
inc(r1);
c1 := 0;
end
else if pword[0] = $4040 then //@@等待击键
begin
sdl_updaterect(screen, 0, 0, screen.w, screen.h);
k := waitanykey;
while (k = sdlk_right) or
(k = sdlk_left) or
(k = sdlk_up) or
(k = sdlk_down) do
begin
k := waitanykey;
end;
end
else if (pword[0] = $2626) or (pword[0] = $2525) or (pword[0] = $2424) then
begin
case pword[0] of
$2626: np3 := ap; //&&显示姓名
$2525: np3 := np2; //%%显示名
$2424: np3 := np1; //$$显示姓
end;
i := 0;
while (puint16(np3 + i)^ shr 8 <> 0) and (puint16(np3 + i)^ shl 8 <> 0) do
begin
pword[0] := puint16(np3 + i)^;
i := i + 2;
Drawbig5ShadowText(@pword[0], x - 14 + CHINESE_FONT_SIZE * c1, y + 4 + CHINESE_FONT_SIZE * r1, colcolor(color1), colcolor(color2));
inc(c1);
if c1 = cell then
begin
c1 := 0;
inc(r1);
if r1 = row then
begin
sdl_updaterect(screen, 0, 0, screen.w, screen.h);
k := waitanykey;
while (k = sdlk_right) or
(k = sdlk_left) or
(k = sdlk_up) or
(k = sdlk_down) do
begin
k := waitanykey;
end;
c1 := 0;
r1 := 0;
redraw;
DrawRectangle(x, y, w, h, frame, colcolor($FF), 40);
if (showhead = 0) or (headnum < 0) then
begin
DrawRectangle(hx, hy, hw, hh, frame, colcolor($FF), 40);
if headnum = 0 then
begin
DrawHeadPic(RRole[0].HeadNum, hx, hy + 68);
end
else
begin
DrawHeadPic(headnum, hx, hy + 68);
end;
end;
if namenum <> 0 then
begin
DrawRectangle(nx, ny, nw, nh, frame, colcolor($FF), 40);
namelen := length(np);
DrawBig5ShadowText(np, nx + 20 - namelen * 9 div 2, ny + 4, colcolor($63), colcolor($70));
end;
end;
end;
end;
end
else //显示文字
begin
DrawBig5ShadowText(@pword, x - 14 + CHINESE_FONT_SIZE * c1, y + 4 + CHINESE_FONT_SIZE * r1, colcolor(color1), colcolor(color2));
inc(c1);
if c1 = cell then
begin
c1 := 0;
inc(r1);
end;
end;
end
else break;
end;
sdl_updaterect(screen, 0, 0, screen.w, screen.h);
k := waitanykey;
while (k = sdlk_right) or
(k = sdlk_left) or
(k = sdlk_up) or
(k = sdlk_down) do
begin
k := waitanykey;
end;
if (pword[0] and $FF = 0) or (pword[0] and $FF00 = 0) then break;
end;
redraw;
end;
以下为“大家好,我是&&,我姓$$,大家叫我%%哥哥就可以了。”的效果
[ 本帖最后由 KG 于 2010-1-5 13:38 编辑 ] |