⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uskills.pas

📁 千年源代码,只缺少控件,可以做二次开发用,好不容易得来的
💻 PAS
📖 第 1 页 / 共 5 页
字号:

   boSelfTarget := false;   
   TargetId := aTargetID;

   if aTargetID = 0 then begin
      TLifeObject (BasicObject).LifeObjectState := los_none;
      exit;
   end;
   TLifeObject (BasicObject).LifeObjectState := los_moveattack;
end;

procedure TAttackSkill.SetEscapeID (aEscapeID : Integer);
var
   i, xx, yy, mx, my, len: integer;
   bo : TBasicObject;
begin
   if aEscapeID = BasicObject.BasicData.id then exit;
   TargetId := aEscapeID;
   TLifeObject (BasicObject).LifeObjectState := los_escape;

   bo := TBasicObject (TLifeObject (BasicObject).GetViewObjectById (TargetId));
   if bo = nil then begin
      TLifeObject (BasicObject).LifeObjectState := los_none
   end else begin
      mx := BasicObject.BasicData.x;
      my := BasicObject.BasicData.y;
      len := 0;

      for i := 0 to 10-1 do begin
         xx := BasicObject.BasicData.X - 6 + Random (12);
         yy := BasicObject.BasicData.y - 6 + Random (12);

         if (len < GetLargeLength (bo.PosX, bo.PosY, xx, yy))
            and BasicObject.Maper.isMoveable (xx, yy) then  begin
            Len := GetLargeLength (bo.PosX, bo.PosY, xx, yy);
            mx := xx; my := yy;
         end;
      end;

      if (mx <> BasicObject.BasicData.x) or (my <> BasicObject.BasicData.y) then begin
         TargetX := mx;
         TargetY := my;
      end;
   end;
end;

procedure TAttackSkill.SetAttackMagic (aAttackMagic : TMagicData);
begin
   AttackMagic := aAttackMagic;

   if AttackMagic.rMagicType = MAGICTYPE_BOWING then begin
      BowCount := 5;
      BowAvailInterval := 500;
   end else begin
      BowCount := 5;
      BowAvailInterval := 300;
   end;
end;

procedure TAttackSkill.SetSelfTarget (boFlag : Boolean);
begin
   boSelfTarget := boFlag;
end;

procedure TAttackSkill.SetGroupSkill;
begin
   if GroupSkill = nil then begin
      boGroupSkill := true;
      GroupSkill := TGroupSkill.Create (BasicObject);
   end else begin
      boGroupSkill := true;
   end;
end;

procedure TAttackSkill.AddGroup (aBasicObject : TBasicObject);
begin
   if GroupSkill <> nil then begin
      GroupSkill.AddMember (aBasicObject);
   end;
end;

procedure TAttackSkill.ProcessNone (CurTick : Integer);
var
   nDis : Integer;
   SubData : TSubData;
begin
   if BasicObject.BasicData.Feature.rRace = RACE_NPC then begin
      if TargetPosTick + 3000 < CurTick then begin
         TargetPosTick := CurTick;
         TargetX := BasicObject.CreateX - TLifeObject (BasicObject).ActionWidth div 2 + Random (TLifeObject (BasicObject).ActionWidth);
         TargetY := BasicObject.CreateY - TLifeObject (BasicObject).ActionWidth div 2 + Random (TLifeObject (BasicObject).ActionWidth);
         exit;
      end;

      if TLifeObject (BasicObject).WalkTick + 200 < CurTick then begin
         TLifeObject (BasicObject).WalkTick := CurTick;
         {
         nDis := GetLargeLength (BasicObject.BasicData.X, BasicObject.BasicData.Y, TargetX, TargetY);
         if nDis > 10 then
            TLifeObject (BasicObject).GotoXyStandAI (TargetX, TargetY)
         else
         }
            TLifeObject (BasicObject).GotoXyStand (TargetX, TargetY);
      end;
   end else begin
      if boAttack = false then begin
         CurNearViewHumanId := 0;
         HateHumanId := 0;
      end;
      if boAutoAttack and (EscapeLife < TLifeObject (BasicObject).CurLife)
         and (CurNearViewHumanId <> 0) then begin
         SetTargetId (CurNearViewHumanId, true);
         CurNearViewHumanId := 0;
         exit;
      end;
      if (EscapeLife < TLifeObject (BasicObject).CurLife)
         and (HateHumanId <> 0) then begin
         SetTargetId (HateHumanId, true);
         HateHumanId := 0;
         exit;
      end;

      if (EscapeLife >= TLifeObject (BasicObject).CurLife)
         and (CurNearViewHumanId <> 0) then begin
         SetEscapeId (CurNearViewHumanId);
         CurNearViewHumanId := 0;
         exit;
      end;

      if (EscapeLife >= TLifeObject (BasicObject).CurLife)
         and (HateHumanId <> 0) then begin
         SetEscapeId (HateHumanId);
         HateHumanId := 0;
         exit;
      end;

      if TargetPosTick + 2000 < CurTick then begin
         TargetPosTick := CurTick;
         if Boss <> nil then begin
            TargetX := Boss.BasicData.x - 3 + Random (6);
            TargetY := Boss.BasicData.y - 3 + Random (6);
         end else begin
            TargetX := BasicObject.CreateX - 3 + Random (6);
            TargetY := BasicObject.CreateY - 3 + Random (6);
         end;
         if TLifeObject (BasicObject).SoundNormal.rWavNumber <> 0 then begin
            SetWordString (SubData.SayString, IntToStr (TLifeObject (BasicObject).SoundNormal.rWavNumber) + '.wav');
            TLifeObject (BasicObject).SendLocalMessage (NOTARGETPHONE, FM_SOUND, BasicObject.BasicData, SubData);
         end;
         exit;
      end;

      if TLifeObject (BasicObject).WalkTick + TLifeObject (BasicObject).WalkSpeed * 2 < CurTick then begin
         TLifeObject (BasicObject).WalkTick := CurTick;
         {
         nDis := GetLargeLength (BasicObject.BasicData.X, BasicObject.BasicData.Y, TargetX, TargetY);
         if nDis > 10 then
            TLifeObject (BasicObject).GotoXyStandAI (TargetX, TargetY)
         else
         }
            TLifeObject (BasicObject).GotoXyStand (TargetX, TargetY);
      end;
   end;
end;

procedure TAttackSkill.ProcessEscape (CurTick : Integer);
begin
   if BasicObject.BasicData.Feature.rrace = RACE_NPC then begin
   end else begin
      if TargetPosTick + 2000 < CurTick then begin
         TargetPosTick := CurTick;
         TLifeObject (BasicObject).LifeObjectState := los_none;
         exit;
      end;

      // if TLifeObject (BasicObject).WalkTick + TLifeObject (BasicObject).WalkSpeed div 2 < CurTick then begin
      if TLifeObject (BasicObject).WalkTick + TLifeObject (BasicObject).WalkSpeed < CurTick then begin
         TLifeObject (BasicObject).WalkTick := CurTick;
         TLifeObject (BasicObject).GotoXyStand (TargetX, TargetY);
         if (BasicObject.BasicData.x = TargetX) and (BasicObject.BasicData.y = TargetY) then
            TLifeObject (BasicObject).LifeObjectState := los_none;
      end;
   end;
end;

procedure TAttackSkill.ProcessFollow (CurTick : Integer);
begin

end;

function TAttackSkill.ProcessAttack (CurTick : Integer; aBasicObject : TBasicObject) : Boolean;
var
   bo : TBasicObject;
   key : word;
   boFlag : Boolean;
   nDis : Integer;
   tx, ty : Word;
   xx, yy : Integer;
begin
   Result := true;
   
   boFlag := false;

   try
      bo := TBasicObject (TLifeObject(BasicObject).GetViewObjectById (TargetId));
   except
      bo := nil;
   end;
   if bo = nil then begin
      boFlag := true;
   end else if bo.BasicData.Feature.rRace = RACE_HUMAN then begin
      if TUser(bo).GetLifeObjectState = los_die then boFlag := true;
   end else begin
      if TLifeObject(bo).LifeObjectState = los_die then boFlag := true;
   end;

   if (boflag = false) and (bo <> nil) then begin
      if bo.BasicData.Feature.rHideState = hs_0 then begin
         boFlag := true;
      end;
   end;

   if boFlag = true then begin
      if TLifeObject (aBasicObject).FboCopy = false then begin
         SetTargetID (0, true);
         Result := false;
      end;
      exit;
   end;

   if aBasicObject.BasicData.Feature.rRace = RACE_NPC then begin
      if GetLargeLength (aBasicObject.BasicData.X, aBasicObject.BasicData.Y, bo.PosX, bo.PosY) = 1 then begin
         key := GetNextDirection (aBasicObject.BasicData.X, aBasicObject.BasicData.Y, bo.PosX, bo.PosY);
         if key = DR_DONTMOVE then exit;   // 困率捞 0 老锭狼 版快牢单 困率捞 1烙..
         if key <> aBasicObject.BasicData.dir then begin
            TLifeObject(aBasicObject).CommandTurn (key);
         end;
         TLifeObject(aBasicObject).CommandHit (CurTick);
      end else begin
         if TLifeObject(aBasicObject).WalkTick + 50 < CurTick then begin
            TLifeObject(aBasicObject).Walktick := CurTick;
            TLifeObject(aBasicObject).GotoXyStand (bo.Posx, bo.Posy);
         end;
      end;
   end else begin
      if EscapeLife >= TLifeObject(aBasicObject).CurLife then begin
         SetEscapeID (TargetID);
         exit;
      end;

      nDis := GetLargeLength (aBasicObject.BasicData.X, aBasicObject.BasicData.Y, bo.PosX, bo.PosY);
      if ((AttackMagic.rMagicType = MAGICTYPE_ONLYBOWING) or (AttackMagic.rMagicType = MAGICTYPE_BOWING)) and (boBowAvail = true) then begin
         if (BowCount < 3) or ((nDis >= 3) and (nDis <= 5)) then begin
         // if (nDis >= 3) and (nDis <= 5) then begin
            key := GetNextDirection (aBasicObject.BasicData.X, aBasicObject.BasicData.Y, bo.PosX, bo.PosY);
            if key = DR_DONTMOVE then exit;   // 困率捞 0 老锭狼 版快牢单 困率捞 1烙..
            if key <> aBasicObject.BasicData.dir then begin
               TLifeObject (aBasicObject).CommandTurn (key);
               exit;
            end;

            if TLifeObject(aBasicObject).ShootMagic (AttackMagic, bo) = true then begin
               Dec (BowCount);
               if BowCount <= 0 then begin
                  boBowAvail := false;
                  Case AttackMagic.rMagicType of
                     MAGICTYPE_BOWING :
                        begin
                           BowCount := 5;
                           BowAvailTick := CurTick;
                        end;
                     MAGICTYPE_ONLYBOWING :
                        begin
                           BowCount := 5;
                           BowAvailTick := CurTick;
                        end;
                  end;
               end;
            end;
         end else if nDis < 3 then begin
            {
            key := GetViewDirection (aBasicObject.BasicData.X, aBasicObject.BasicData.Y, BO.PosX, BO.PosY);
            if key = DR_DONTMOVE then exit; // 困率捞 0 老锭狼 版快牢单 困率捞 1烙..
            if key <> aBasicObject.BasicData.dir then begin
               TLifeObject (aBasicObject).CommandTurn (key);
               exit;
            end;
            }
            GetOppositeDirection (aBasicObject.BasicData.X, aBasicObject.BasicData.Y, bo.PosX, bo.PosY, tx, ty);
            if not aBasicObject.Maper.isMoveable (tx, ty) then begin
               xx := tx; yy := ty;
               aBasicObject.Maper.GetNearXy (xx, yy);
               tx := xx; ty := yy;
            end;
            TLifeObject(aBasicObject).GotoXyStand (tx, ty);
         end else begin
            TLifeObject(aBasicObject).GotoXyStand (bo.PosX, bo.PosY);
         end;
      end else begin
         if AttackMagic.rMagicType <> MAGICTYPE_ONLYBOWING then begin
            if nDis = 1 then begin
               key := GetNextDirection (aBasicObject.BasicData.X, aBasicObject.BasicData.Y, bo.PosX, bo.PosY);
               if key = DR_DONTMOVE then exit;   // 困率捞 0 老锭狼 版快牢单 困率捞 1烙..
               if key <> aBasicObject.BasicData.dir then begin
                  TLifeObject (aBasicObject).CommandTurn (key);
               end else begin
                  TLifeObject (aBasicObject).CommandHit (CurTick);
               end;
            end else begin
               if TLifeObject(aBasicObject).WalkTick + TLifeObject(aBasicObject).WalkSpeed < CurTick then begin
                  TLifeObject(aBasicObject).WalkTick := CurTick;
                  TLifeObject(aBasicObject).GotoXyStand (bo.Posx, bo.Posy);
               end;
            end;
         end;
         if BowAvailTick + BowAvailInterval < CurTick then begin
            boBowAvail := true;
         end;
      end;
   end;
end;

procedure TAttackSkill.ProcessMoveAttack (Curtick : Integer);
var
   BO : TBasicObject;
begin
   bo := TBasicObject (TLifeObject(BasicObject).GetViewObjectById (TargetId));
   if bo <> nil then begin
      TLifeObject(BasicObject).LifeObjectState := los_attack;
      exit;
   end;
   if BasicObject.BasicData.Feature.rRace = RACE_NPC then begin
      if TLifeObject (BasicObject).WalkTick + 200 < CurTick then begin
         TLifeObject (BasicObject).WalkTick := CurTick;
         TLifeObject (BasicObject).GotoXyStand (TargetX, TargetY);
      end;
   end else begin
      if TLifeObject (BasicObject).WalkTick + TLifeObject (BasicObject).WalkSpeed * 2 < CurTick then begin
         TLifeObject (BasicObject).WalkTick := CurTick;
         TLifeObject (BasicObject).GotoXyStand (TargetX, TargetY);
      end;
   end;
end;

procedure TAttackSkill.ProcessDeadAttack (CurTick : Integer);
var
   pUser : TUser;
   key : word;
   boFlag : Boolean;
begin
   boFlag := false;

   pUser := UserList.GetUserPointer (DeadAttackName);
   if pUser = nil then begin
      boFlag := true;
   end else begin
      if pUser.GetLifeObjectState = los_die then boFlag := true;
      if pUser.ServerID <> BasicObject.ServerID then boFlag := true;
   end;

   if boFlag = true then begin
      DeadAttackName := '';
      // TLifeObject (BasicObject).LifeObjectState := los_none;
      TLifeObject (BasicObject).FboAllowDelete := true;
      exit;
   end;

   if GetLargeLength (BasicObject.BasicData.X, BasicObject.BasicData.Y, pUser.PosX, pUser.PosY) = 1 then begin
      key := GetNextDirection (BasicObject.BasicData.X, BasicObject.BasicData.Y, pUser.PosX, pUser.PosY);
      if key = DR_DONTMOVE then exit;
      if key <> BasicObject.BasicData.dir then begin
         TLifeObject(BasicObject).CommandTurn (key);
      end;
      TLifeObject(BasicObject).CommandHit (CurTick);
   end else begin
      if TLifeObject(BasicObject).WalkTick + 50 < CurTick then begin
         TLifeObject(BasicObject).WalkTick := CurTick;
         {
         if TLifeObject(BasicObject).MaxLife >= 5000 then begin
            TLifeObject(BasicObject).GotoXyStandAI (pUser.PosX, pUser.PosY);
         end else begin
         }
            TLifeObject(BasicObject).GotoXyStand (pUser.PosX, pUser.PosY);
         // end;
      end;
   end;
end;

procedure TAttackSkill.ProcessMoveWork (CurTick : Integer)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -