admin 发表于 2019-3-4 22:40:30

千年服务端任务设计制作例子


   内容介绍

任务策划:
出入江湖,当然要证明自己的实力。什么??实力?还是先证明你的力量吧!
来到新手村杀牛,牛爆牛皮、牛肉、牛角(有点残忍)
收集这些材料交给屠夫,他会奖励你东西
这里,我们设计用牛皮换金币,牛肉换银币,牛角换牛俊弓服。

目的:
体会最基本的活动都是怎么设计的

知识点:
1、检测包裹里的物品
2、检测包裹空间
3、给与物品
4、没收物品//这部分先声明脚本的名字。如果脚本出错,tgs会做一个错误纪录,文件名就是我们声明的这个。
unit 屠夫;//下面的是通用的调用程序内建的函数。每个脚本都有的。
interface

functionGetToken (aStr, aToken, aSep : String) : String;
functionCompareStr (aStr1, aStr2 : String) : Boolean;
functioncallfunc (aText: string): string;
procedure print (aText: string);
functionRandom (aScope: integer): integer;
functionLength (aText: string): integer;
procedure Inc (aInt: integer);
procedure Dec (aInt: integer);
functionStrToInt (astr: string): integer;
functionIntToStr (aInt: integer): string;
procedure exit;//下面的就是针对本脚本的函数了。注意,用到什么就在这里声明什么

//第一句的意思是当反馈参数的时候响应,比如牛肉换东西,我们弄个参数niurou

//第二句的意思是当左键单击的时候响应,
procedure OnGetResult (aStr : String);
procedure OnLeftClick (aStr : String);//以上是脚本的头部,下面是脚本的主体部分
implementation //当左键单击时
procedure OnLeftClick (aStr : String);//声明变量的类型
var//Str变量为字符串型
Str : String;//Race变量为整型
Race : Integer;
begin//获取点击者的种族
   Str := callfunc ('getsenderrace');//将获取的值由字符串型转换成整型
   Race := StrToInt (Str);//如果种族为1,这里种族为1代表是玩家
   if Race = 1 then begin//那么调出Help文件夹下的对话框 注意,这里对话框的类型是1 也就是不带滚动条的那种
Str := 'showwindow .\help\屠夫.txt 1';
      print (Str);//小判断结束
exit;
   end;//一个语句段结束
end;//另一个语句段开始

//当从Help文件里反馈回命令参数时,做出响应
procedure OnGetResult (aStr : String);
var
   Str, Name : String;
begin//当反馈参数为close的时候就关闭对话框
if aStr = 'close' then begin
      exit;
   end;//当玩家选择niujiao 的命令时
   if aStr = 'niujiao' then begin//检测背包里是否有牛角
      Str := callfunc ('getsenderitemexistence 牛角:1');//如果反馈信息为假,也就是没有
      if Str = 'false' then begin//屠夫说话
Str := 'say 快弄牛角再说';
         print (Str);//检测结束
exit;
      end;//如果有的话就继续执行下面的
         if Str = 'true' then begin//检测背包是否还有空位置Str := callfunc ('checkenoughspace');//如果返回值为假,也就是没有 if Str = 'false' then begin//那么就提示物品兰已满print ('say 物品栏已满');//检测结束exit;
            end;//如果背包有空位置,那么继续

//没收牛角Str := 'getsenderitem 牛角:1';
            print (Str);//给牛俊弓服
Str := 'putsendermagicitem 牛俊弓服:1 @屠夫 4';
            print (Str);
            Str := 'say 收好了..俺最喜欢的衣服~';
            print (Str);
            exit;
         end;//判断结束语句
end;
      exit;
end;
end.
end;

页: [1]
查看完整版本: 千年服务端任务设计制作例子