unit UnitArray;
inte**ce
uses SysUtils;
const
JobNames: array[0..4] of String=('战士', '法师', '道士', '刺客', '弓箭手'); //这是一个静态数组,运行期不需要改变,所以定义为const
var
Job_AddAbility: array of array of Integer; //这是动态数组
procedure Main(Npc: TNormNPC; Player: TPlayObject; Args: TArgs);
implementation
procedure Main(Npc: TNormNPC; Player: TPlayObject; Args: TArgs);
begin
Player.Say(IntToStr(Job_AddAbility[0][1])); //访问数组数据
end;
procedure InitArry;
var
I: Integer;
begin
//定义数组大小
SetLength(Job_AddAbility, 5);
for I := 0 to 4 do
SetLength(Job_AddAbility[I], 3);
//赋值
Job_AddAbility[0] := [12,13,14,15];
Job_AddAbility[1] := [10,6,10,4];
Job_AddAbility[2] := [10,12,20,8];
Job_AddAbility[3] := [10,18,30,12];
Job_AddAbility[4] := [10,30,50,20];
end;
procedure FinaArry;
begin
FillChar(Job_AddAbility, SizeOf(Job_AddAbility), #0);
end;
initialization
InitArry; //单元初始化的时候执行数组初始化(M2退出或重加载脚本)
finalization
FinaArry; //单元初始化的时候执行数组初始化(M2退出或重加载脚本)
end.
|
|