📄 script.pas
字号:
WFIFOW(2, w);
WFIFOS(4, str, w - 4);
if (l mod 10 = 0) then begin
//僇儗儞僩MAP偺僉儍儔偵憲怣
tm := Map.Objects[Map.IndexOf(tn.Map)] as TMap;
for i := 0 to tm.CList.Count - 1 do begin
tc1 := tm.CList.Objects[i] as TChara;
if tc1.Login = 2 then tc1.Socket.SendBuf(buf, w);
end;
end else begin
//慡儚乕儖僪偺僉儍儔偵憲怣
for i := 0 to CharaName.Count - 1 do begin
tc1 := CharaName.Objects[i] as TChara;
if tc1.Login = 2 then tc1.Socket.SendBuf(buf, w);
end;
end;
Inc(tc.ScriptStep);
end;
35: //npctimer
begin
i := tn.Script[tc.ScriptStep].Data3[0];
j := tm.TimerAct.IndexOf(tn.ID);
if (i = 0) then begin
//僞僀儅乕OFF
if (j <> -1) then begin
//debugout.lines.add('[' + TimeToStr(Now) + '] ' + Format('NPC Timer(%d) was deleted / Remaining Timer(%d)', [tn.ID,tm.TimerAct.Count-1]));
tm.TimerAct.Delete(tm.TimerAct.IndexOf(tn.ID));
end;
end else if (i = 1) then begin
//僞僀儅乕ON
if (j = -1) then begin
//怴婯僗僞乕僩
j := tm.TimerDef.IndexOf(tn.ID);
if (j <> -1) then begin
tr := tm.TimerDef.Objects[j] as NTimer;
tr.Tick := timeGetTime();
for k := 0 to tr.Cnt - 1 do begin
tr.Done[k] := 0;
end;
tm.TimerAct.AddObject(tn.ID, tr);
//debugout.lines.add('[' + TimeToStr(Now) + '] ' + Format('NPC Timer(%d) was started / Starting Timer(%d)', [tn.ID,tm.TimerAct.Count]));
end;
end else begin
//嵞僗僞乕僩
tr := tm.TimerAct.Objects[j] as NTimer;
tr.Tick := timeGetTime();
for k := 0 to tr.Cnt - 1 do begin
tr.Done[k] := 0;
end;
//debugout.lines.add('[' + TimeToStr(Now) + '] ' + Format('NPC Timer(%d) was re-started / Starting Timer(%d)', [tn.ID,tm.TimerAct.Count]));
end;
end;
Inc(tc.ScriptStep);
end;
36: //addnpctimer
begin
i := -1;
for k := 0 to tm.NPC.Count - 1 do begin
tn1 := tm.NPC.Objects[k] as TNPC;
if (tn1.Name = tn.Script[tc.ScriptStep].Data1[0]) then begin
i := 0;
break;
end;
end;
if (i <> -1) then begin
i := tn.Script[tc.ScriptStep].Data3[0];
j := tm.TimerAct.IndexOf(tn1.ID);
if (j <> -1) then begin
tr := tm.TimerAct.Objects[j] as NTimer;
if (i > 0) then tr.Tick := tr.Tick - cardinal(i)
else tr.Tick := tr.Tick + cardinal(abs(i));
if (tr.Tick > Tick) then tr.Tick := Tick;
for k := 0 to tr.Cnt - 1 do begin
if (i < 0) and (tr.Tick + cardinal(tr.Idx[k]) > Tick) then begin
//夁嫀偺僀儀儞僩傪枹幚峴偵偡傞
tr.Done[k] := 0;
end else if (i > 0) and (tr.Tick + cardinal(tr.Idx[k]) < Tick) then begin
//枹棃偺僀儀儞僩傪幚峴嵪偵偡傞
tr.Done[k] := 1;
end;
end;
//debugout.lines.add('[' + TimeToStr(Now) + '] ' + Format('NPC Timer(%d) was added (%d)ms', [tn.ID,i]));
end;
end;
Inc(tc.ScriptStep);
end;
37: //return
begin
tc.ScriptStep := $FFFF;
break;
end;
38: //warpallpc
begin
if (tn.Script[tc.ScriptStep].Data3[2] = 0) then begin
//僇儗儞僩MAP偺僉儍儔傪揮憲
tm := Map.Objects[Map.IndexOf(tn.Map)] as TMap;
while (tm.CList.Count > 0) do begin
tc1 := tm.CList.Objects[0] as TChara;
if tc1.Login = 2 then begin
SendCLeave(tc1, 2);
tc1.tmpMap := tn.Script[tc.ScriptStep].Data1[0];
tc1.Point := Point(tn.Script[tc.ScriptStep].Data3[0],tn.Script[tc.ScriptStep].Data3[1]);
MapMove(tc1.Socket, tc1.tmpMap, tc1.Point);
end;
end;
end else if (tn.Script[tc.ScriptStep].Data3[2] = 1) then begin
//慡儚乕儖僪偺僉儍儔傪揮憲
for j := 0 to CharaName.Count - 1 do begin
tc1 := CharaName.Objects[j] as TChara;
if tc1.Login = 2 then begin
SendCLeave(tc1, 2);
tc1.tmpMap := tn.Script[tc.ScriptStep].Data1[0];
tc1.Point := Point(tn.Script[tc.ScriptStep].Data3[0],tn.Script[tc.ScriptStep].Data3[1]);
MapMove(tc1.Socket, tc1.tmpMap, tc1.Point);
end;
end;
end else begin
//NPC僠儍僢僩儖乕儉撪偺僉儍儔傪揮憲
if (tn.ChatRoomID <> 0) then begin
i := ChatRoomList.IndexOf(tn.ChatRoomID);
tcr := ChatRoomList.Objects[i] as TChatRoom;
if (tcr.Users < 2) then continue;
while (tcr.Users > 1) do begin
tc1 := CharaPID.IndexOfObject(tcr.MemberID[1]) as TChara;
if tc1.Login = 2 then begin
SendCLeave(tc1, 2);
tc1.tmpMap := tn.Script[tc.ScriptStep].Data1[0];
tc1.Point := Point(tn.Script[tc.ScriptStep].Data3[0],tn.Script[tc.ScriptStep].Data3[1]);
MapMove(tc1.Socket, tc1.tmpMap, tc1.Point);
end;
end;
end;
end;
Inc(tc.ScriptStep);
end;
39: //waitingroom
begin
if (tn.ChatRoomID = 0) then begin
tcr := TChatRoom.Create;
tcr.Title := tn.Script[tc.ScriptStep].Data1[0];
tcr.Limit := tn.Script[tc.ScriptStep].Data3[0];
tcr.Pub := 1;
tcr.MemberID[0] := tn.ID; //僆乕僫乕:0
tcr.MemberCID[0] := tn.JID;
tcr.MemberName[0] := tn.Name;
ChatMaxID := ChatMaxID + 1;
tcr.ID := ChatMaxID;
tcr.Users := 1;
tcr.NPCowner := 1;
tn.ChatRoomID := tcr.ID;
ChatRoomList.AddObject(tcr.ID, tcr);
//debugout.lines.add('[' + TimeToStr(Now) + '] ' + Format('ChatRoomTitle = %s : OwnerID = %d : OwnerName = %s', [tcr.Title, tcr.MemberID[0], tcr.MemberName[0]]));
//廃曈偵僷働憲怣
w := Length(tcr.Title);
WFIFOW(0, $00d7);
WFIFOW(2, w + 17);
WFIFOL(4, tcr.MemberID[0]);
WFIFOL(8, tcr.ID);
WFIFOW(12, tcr.Limit);
WFIFOW(14, tcr.Users);
WFIFOB(16, tcr.Pub);
WFIFOS(17, tcr.Title, w);
SendBCmd(tm, tn.Point, w + 17, nil);
end;
break;
end;
40: //enablenpc
begin
if Map.IndexOf(tn.Script[tc.ScriptStep].Data1[0]) = -1 then
MapLoad(tn.Script[tc.ScriptStep].Data1[0]);
tm1 := Map.Objects[Map.IndexOf(tn.Script[tc.ScriptStep].Data1[0])] as TMap;
if (tn.Script[tc.ScriptStep].Data3[0] = 1) then begin
//enable
i := -1;
for k := 0 to tm1.NPC.Count - 1 do begin
tn1 := tm1.NPC.Objects[k] as TNPC;
if (tn1.Name = tn.Script[tc.ScriptStep].Data1[1]) then begin
i := 0;
break;
end;
end;
if (tn1.ScriptInitS <> -1) then begin
//OnInit儔儀儖傪幚峴
//debugout.lines.add('[' + TimeToStr(Now) + '] ' + Format('OnInit Event(%d)', [tn1.ID]));
tc1 := TChara.Create;
tc1.TalkNPCID := tn1.ID;
tc1.ScriptStep := tn1.ScriptInitS;
tc1.AMode := 3;
tc1.AData := tn1;
tc1.Login := 0;
NPCScript(tc1,0,1);
tn.ScriptInitD := true;
tc1.Free;
end;
if (i = 0) and (tn1.Enable = false) then begin
tn1.Enable := true;
for j := tn1.Point.Y div 8 - 2 to tn1.Point.Y div 8 + 2 do begin
for i := tn1.Point.X div 8 - 2 to tn1.Point.X div 8 + 2 do begin
for k := 0 to tm1.Block[i][j].CList.Count - 1 do begin
tc1 := tm1.Block[i][j].Clist.Objects[k] as TChara;
if (abs(tc1.Point.X - tn1.Point.X) < 16) and (abs(tc1.Point.Y - tn1.Point.Y) < 16) then begin
SendNData(tc1.Socket, tn1, tc1.ver2);
end;
end;
end;
end;
end;
end else begin
//disable
i := -1;
for k := 0 to tm1.NPC.Count - 1 do begin
tn1 := tm1.NPC.Objects[k] as TNPC;
if (tn1.Name = tn.Script[tc.ScriptStep].Data1[1]) then begin
i := 0;
break;
end;
end;
if (i = 0) and (tn1.Enable = true) then begin
tn1.Enable := false;
l := tm.TimerAct.IndexOf(tn1.ID);
if (l <> -1) then begin
//debugout.lines.add('[' + TimeToStr(Now) + '] ' + Format('NPC Timer(%d) was deleted / Remaining Timer(%d)', [tn.ID,tm.TimerAct.Count-1]));
tm.TimerAct.Delete(tm.TimerAct.IndexOf(tn1.ID));
end;
for j := tn1.Point.Y div 8 - 2 to tn1.Point.Y div 8 + 2 do begin
for i := tn1.Point.X div 8 - 2 to tn1.Point.X div 8 + 2 do begin
for k := 0 to tm1.Block[i][j].CList.Count - 1 do begin
tc1 := tm1.Block[i][j].Clist.Objects[k] as TChara;
if (abs(tc1.Point.X - tn1.Point.X) < 16) and (abs(tc1.Point.Y - tn1.Point.Y) < 16) then begin
WFIFOW(0, $0080);
WFIFOL(2, tn1.ID);
WFIFOB(6, 0);
tc1.Socket.SendBuf(buf, 7);
end;
end;
end;
end;
end;
end;
Inc(tc.ScriptStep);
end;
41: //resetmymob
begin
if Map.IndexOf(tn.Script[tc.ScriptStep].Data1[0]) <> -1 then begin
tm1 := Map.Objects[Map.IndexOf(tn.Script[tc.ScriptStep].Data1[0])] as TMap;
for i := tm1.Mob.Count -1 downto 0 do begin
ts := tm1.Mob.Objects[i] as TMob;
if (ts.isSummon = true) then begin
if (tm1.CList.Count > 0) then begin
WFIFOW( 0, $0080);
WFIFOL( 2, ts.ID);
WFIFOB( 6, 1);
SendBCmd(tm1, ts.Point, 7);
end;
j := tm1.Block[ts.Point.X div 8][ts.Point.Y div 8].Mob.IndexOf(ts.ID);
if (j <> -1) then tm1.Block[ts.Point.X div 8][ts.Point.Y div 8].Mob.Delete(j);
j := tm1.Mob.IndexOf(ts.ID);
if (j <> -1) then tm1.Mob.Delete(j);
end;
end;
end;
Inc(tc.ScriptStep);
end;
42: //getmapusers
begin
if Map.IndexOf(tn.Script[tc.ScriptStep].Data1[0]) <> -1 then begin
tm1 := Map.Objects[Map.IndexOf(tn.Script[tc.ScriptStep].Data1[0])] as TMap;
if (Copy(tn.Script[tc.ScriptStep].Data1[1], 1, 1) <> '\') then begin
tc.Flag.Values[tn.Script[tc.ScriptStep].Data1[1]] := IntToStr(tm1.CList.Count);
end else begin
ServerFlag.Values[tn.Script[tc.ScriptStep].Data1[1]] := IntToStr(tm1.CList.Count);
end;
end;
Inc(tc.ScriptStep);
end;
43: //setstr
begin
j := tn.Script[tc.ScriptStep].Data3[0];
str := '';
//塃曈僼儔僌僠僃僢僋
if (Copy(tn.Script[tc.ScriptStep].Data1[1], 1, 1) = '\') then begin
//僒乕僶嫟桳僼儔僌
str := ServerFlag.Values[tn.Script[tc.ScriptStep].Data1[1]];
end else begin
i := -1;
if (tc.Login = 2) then begin
i := tc.Flag.IndexOfName(tn.Script[tc.ScriptStep].Data1[1]);
end;
if (i <> -1) then begin
//僉儍儔僋僞乕僼儔僌
str := tc.Flag.Values[tn.Script[tc.ScriptStep].Data1[1]];
end else begin
//暥帤楍
str := tn.Script[tc.ScriptStep].Data1[1];
end;
end;
//嵍曈僼儔僌僠僃僢僋
if (Copy(tn.Script[tc.ScriptStep].Data1[0], 1, 1) = '\') then begin
//僒乕僶嫟桳僼儔僌
if (j = 0) then begin
ServerFlag.Values[tn.Script[tc.ScriptStep].Data1[0]] := str;
end else begin
ServerFlag.Values[tn.Script[tc.ScriptStep].Data1[0]] := ServerFlag.Values[tn.Script[tc.ScriptStep].Data1[0]] + str;
end;
end else if (tc.Login = 2) then begin
//僉儍儔僋僞乕僼儔僌
if (j = 0) then begin
tc.Flag.Values[tn.Script[tc.ScriptStep].Data1[0]] := str;
end else begin
tc.Flag.Values[tn.Script[tc.ScriptStep].Data1[0]] := tc.Flag.Values[tn.Script[tc.ScriptStep].Data1[0]] + str;
end;
end;
Inc(tc.ScriptStep);
end;
45: //resetstat
begin
for i := 0 to 5 do begin
tc.ParamBase[i] := 1;
end;
tc.StatusPoint := 48;
for i := 1 to tc.BaseLV - 1 do begin
tc.StatusPoint := tc.StatusPoint + i div 5 + 3;
end;
CalcStat(tc);
SendCStat(tc);
SendCStat1(tc, 0, $0009, tc.StatusPoint);
Inc(tc.ScriptStep);
end;
57: //resetbonusstat
begin
for i := 0 to 5 do begin
tc.ParamBase[i] := 1;
end;
tc.StatusPoint := 48;
for i := 1 to tc.BaseLV + tc.BaseLV div 2 - 1 do begin
tc.StatusPoint := tc.StatusPoint + i div 5 + 3;
end;
CalcStat(tc);
SendCStat(tc);
SendCStat1(tc, 0, $0009, tc.StatusPoint);
Inc(tc.ScriptStep);
end;
46: //resetskill
begin
j := 0;
for i := 2 to MAX_SKILL_NUMBER do begin
j := j + tc.Skill[i].Lv;
if not tc.Skill[i].Card then
tc.Skill[i].Lv := 0;
end;
if tc.JID = 0 then begin
end
else begin
tc.skillpoint := j;
end;
SendCSkillList(tc);
CalcStat(tc);
SendCStat(tc);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -