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

📄 objmon.pas

📁 传世源码可编译的,功能齐全.是学习的好模版,会DELPHI的朋友们也可以自己修改,弄个自己的引擎.
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  if (GetTickCount - m_dwThinkTick) > 3 * 1000 then begin
    m_dwThinkTick:=GetTickCount();
    if m_PEnvir.GetXYObjCount(m_nCurrX,m_nCurrY) >= 2 then m_boDupMode:=True;
    if not IsProperTarget{FFFF4}(m_TargetCret) then m_TargetCret:=nil;
  end; //004A8ED2
  if m_boDupMode then begin     //人物重叠了
    nOldX:=m_nCurrX;
    nOldY:=m_nCurrY;
    WalkTo(Random(8),False);
    if (nOldX <> m_nCurrX) or (nOldY <> m_nCurrY) then begin
      m_boDupMode:=False;
      Result:=True;
    end;
  end;
end;

function TMonster.AttackTarget():Boolean; //004A8F34
var
  bt06:Byte;
  nX,nY:INTEGER;
begin
  Result:=False;
  if m_TargetCret <> nil then begin
    if GetAttackDir(m_TargetCret,bt06) then begin
      if Integer(GetTickCount - m_dwHitTick) > m_nNextHitTime  then begin
        m_dwHitTick:=GetTickCount();
        m_dwTargetFocusTick:=GetTickCount();
        Attack(m_TargetCret,bt06);  //FFED
         if m_btUsePoison>=0 then begin
           if random(5)<2 then  m_TargetCret.MakePosion(m_btUsePoison,_max(5,loword( m_WAbil.sC)),_max(5,loword( m_WAbil.mC))) ;
        end;
      {  if m_btusefire >=0 then begin
          GetFrontPosition(nX,nY);
          Makefire(nX,nY,BT06);

        end;
     }
        BreakHolySeizeMode();
      end;
      Result:=True;
    end else begin
      if m_TargetCret.m_PEnvir = m_PEnvir then begin
        SetTargetXY(m_TargetCret.m_nCurrX,m_TargetCret.m_nCurrY); {0FFF0h}
        //004A8FE3
      end else begin
        DelTargetCreat();{0FFF1h}
        //004A9009
      end;
    end;
  end;
end;
procedure TMonster.Run; //004A9020
var
  nX,nY,i,count:Integer;
//  VisibleMapItem:pTVisibleMapItem;

begin
  if not m_boGhost and
     not m_boDeath and
     not m_boFixedHideMode and
     not m_boStoneMode and
     (m_wStatusTimeArr[POISON_STONE{5 0x6A}] = 0) then begin
    if Think then begin
      inherited;
      exit;
    end;
    if m_boWalkWaitLocked then begin
      if (GetTickCount - m_dwWalkWaitTick) > m_dwWalkWait then begin
        m_boWalkWaitLocked:=False;
      end;
    end;
    if not m_boWalkWaitLocked and (Integer(GetTickCount - m_dwWalkTick) > m_nWalkSpeed) then begin
      m_dwWalkTick:=GetTickCount();
      Inc(m_nWalkCount);
      if m_nWalkCount > m_nWalkStep then begin
        m_nWalkCount:=0;
        m_boWalkWaitLocked:=True;
        m_dwWalkWaitTick:=GetTickCount();
      end; //004A9151
      if not m_boRunAwayMode then begin
        if not m_boNoAttackMode then begin
          if m_TargetCret <> nil then begin
            if AttackTarget{FFEB} then begin
              inherited;
              exit;
            end;
          end else begin
            m_nTargetX:=-1;
            if m_boMission then begin
              m_nTargetX:=m_nMissionX;
              m_nTargetY:=m_nMissionY;
            end; //004A91D3
          end;
        end; //004A91D3  if not bo2C0 then begin
        if m_Master <> nil then begin
          if m_TargetCret = nil then begin
            m_Master.GetBackPosition(nX,nY);
            if (abs(m_nTargetX - nX) > 1) or (abs(m_nTargetY - nY{nX}) > 1) then begin //004A922D
              m_nTargetX:=nX;
              m_nTargetY:=nY;
              if (abs(m_nCurrX - nX) <= 2) and (abs(m_nCurrY - nY) <= 2) then begin
                if m_PEnvir.GetMovingObject(nX,nY,True) <> nil then begin
                  m_nTargetX:=m_nCurrX;
                  m_nTargetY:=m_nCurrY;
                end //004A92A5
              end;
            end; //004A92A5
          end; //004A92A5 if m_TargetCret = nil then begin
          if (not m_Master.m_boSlaveRelax) and
             ((m_PEnvir <> m_Master.m_PEnvir) or
             (abs(m_nCurrX-m_Master.m_nCurrX) > 20) or
             (abs(m_nCurrY-m_Master.m_nCurrY) > 20)) and (not m_bohorserelax) then begin
            SpaceMove(m_Master.m_PEnvir.sMapName, m_nTargetX, m_nTargetY, 1);
          end; // 004A937E
        end;// 004A937E if m_Master <> nil then begin
      end else begin //004A9344
        if (m_dwRunAwayTime > 0) and ((GetTickCount - m_dwRunAwayStart) > m_dwRunAwayTime) then begin
          m_boRunAwayMode:=False;
          m_dwRunAwayTime:=0;
        end;
      end; //004A937E
      if ((m_Master <> nil) and m_Master.m_boSlaveRelax) or m_bohorserelax  then begin
        inherited ;
        exit;
      end;  //004A93A6


      ///如果会检物品的怪物
    { if m_canpickup then begin
       if m_Master<> nil then begin
         if m_Master.m_VisibleItems.Count=0 then curpos:=0;
         if m_Master.m_VisibleItems.Count >0 then begin
           if curpos<= m_Master.m_VisibleItems.Count-1 then   begin
             VisibleMapItem:=m_Master.m_VisibleItems[curpos];
             m_nTargetX:= VisibleMapItem.nX;
             m_nTargetY:= VisibleMapItem.nY;


            if ( m_nCurrX= VisibleMapItem.nX ) and  ( m_nCurrY= VisibleMapItem.nY )  THEN    begin
             if  Tplayobject(m_Master).ClientPickUpItemxy(m_nCurrX,m_nCurrY) then Tplayobject(m_Master).SearchViewRange
              else begin   //如果检起失败
               inc(curpos); //检下一个   如果超过 就不再检了。
              // if curpos> m_Master.m_VisibleItems.Count-1 then
              end;

             end; //     m_nCurrX= VisibleMapItem.nX
           end;  //  curpos<= m_Master.m_VisibleItems.Count-1

          end;
        end;
      end;
     }
    {  if m_canpickup then begin
       if m_Master<> nil then begin
         if (abs(m_nCurrX-m_Master.m_nCurrX) > 10) or (abs(m_nCurrY-m_Master.m_nCurrY) > 10) then
         begin
              curpos:=0;
              setpcount:=0;
              count:=m_Master.m_mobpicupItems.Count ;

             if count>0 then  begin
               m_Master.m_bocanaddpickupitem:=false;
              for i:=0 to  Count -1 do begin
                  VisibleMapItem:=m_Master.m_mobpicupItems.Items[i];
                //  m_Master.m_mobpicupItems.Delete(0);
                  Dispose(VisibleMapItem);
              end;//004B82E3
                m_Master.m_mobpicupItems.Clear;
               m_Master.m_bocanaddpickupitem:=true;
             end;
       //     MainOutMessage('清除检物品列表');
         end;
         if m_Master.m_mobpicupItems.Count >0 then begin
           if curpos<= m_Master.m_mobpicupItems.Count-1 then   begin
             VisibleMapItem:=m_Master.m_mobpicupItems[curpos];
             if m_PEnvir.CanWalk (VisibleMapItem.nX,VisibleMapItem.nY,False)  then begin  //如果这个物品可以走上去
              m_nTargetX:= VisibleMapItem.nX;
              m_nTargetY:= VisibleMapItem.nY;
         //     MainOutMessage(format('当前处理目标 %d/%d 为(%d/%d)',[curpos,m_Master.m_mobpicupItems.Count-1,m_nTargetX,m_nTargetY]));
             end else begin
                if ( m_nCurrX<>VisibleMapItem.nX ) and  ( m_nCurrY<>VisibleMapItem.nY )  then  begin
                
                inc(curpos); //如果不能走,且不是自己在物品上 就检下一个。
                
           //     MainOutMessage(format('如果不能走到有人在上面,检取下一个%d 为(%d/%d)',[curpos,VisibleMapItem.nX,VisibleMapItem.nY]));
                end;
                setpcount:=0;
             end;
            if ( m_nCurrX= VisibleMapItem.nX ) and  ( m_nCurrY= VisibleMapItem.nY )  THEN    begin
              if  Tplayobject(m_Master).ClientPickUpItemxy(m_nCurrX,m_nCurrY) then  begin
                   if curpos<= m_Master.m_mobpicupItems.Count-1 then begin
                   VisibleMapItem:=m_Master.m_mobpicupItems.Items[curpos];
                   m_Master.m_mobpicupItems.Delete(curpos);
                   Dispose(VisibleMapItem);
                   end;
                 setpcount:=0;
              end
              else begin   //如果检起失败
               inc(curpos); //检下一个   如果超过 就不再检了。
                setpcount:=0;
              // if curpos> m_Master.m_VisibleItems.Count-1 then
              end;

             end //     m_nCurrX= VisibleMapItem.nX
             else  begin           //如果走了10步还不能检取就检下一个
                 inc(setpcount);

                 if setpcount>10 then begin
                   if curpos< m_Master.m_mobpicupItems.Count then   begin
                     inc(curpos);
                 //    MainOutMessage(format('如果走了10步不能检取就检下一个%d 为(%d/%d)',[curpos,VisibleMapItem.nX,VisibleMapItem.nY]));
                     end;
                   setpcount:=0;
                 end;

              end;
           end;  //  curpos<= m_Master.m_VisibleItems.Count-1

          end;
        end;
      end;
     }

      ////
     if m_nTargetX <> -1 then begin
        GotoTargetXY(); //004A93B5 0FFEF
      end else begin
        if m_TargetCret = nil then Wondering();// FFEE   //Jacky
      end; //004A93D8
    end; //004A93D8  if not bo510 and ((GetTickCount - m_dwWalkTick) > n4FC) then begin
  end; //004A93D8
  



  inherited;

end;

{ TMonster 1}
constructor TMonster1.Create; //004A8B74
begin
  inherited;
  m_boDupMode:=False;
  bo554:=False;
  m_dwThinkTick:=GetTickCount();
  m_nViewRange:=5;
  m_nRunTime:=250;
  m_dwSearchTime:=3000 + Random(2000);
  m_dwSearchTick:=GetTickCount();
  m_btRaceServer:=80;
  curpos:=0;
  setpcount:=0;
  m_btUsePoison:=-1;
  m_btusefire:=-1;
end;

destructor TMonster1.Destroy; //004A8C24
begin
  inherited;
end;
function TMonster1.Makefire(nx,ny,btdir:integer):boolean;
 var
  FireBurnEvent:TFireBurnEvent;
  nHTime,nDamage,i,tx,ty:integer;
begin
  nHTime:=_max(3,loword( m_WAbil.sC));

  nDamage:=_max(5,loword( m_WAbil.mC));
  for i:=0 to 2 do begin
       m_PEnvir.GetNextPosition(nx,ny,btdir,i,tx,ty)  ;
       if m_PEnvir.GetEvent(tX,tY) = nil then begin
          FireBurnEvent:=TFireBurnEvent.Create(self,tx,ty,m_btusefire,nHTime * 1000 ,nDamage);
          g_EventManager.AddEvent(FireBurnEvent);
       end;

      
  end;
 {
  if m_PEnvir.GetEvent(nX,nY-1) = nil then begin
    FireBurnEvent:=TFireBurnEvent.Create(self,nX,nY-1,m_btusefire,nHTime * 1000 ,nDamage);
    g_EventManager.AddEvent(FireBurnEvent);
  end; //0492CFC   x
  if m_PEnvir.GetEvent(nX-1,nY) = nil then begin
    FireBurnEvent:=TFireBurnEvent.Create(self,nX-1,nY,m_btusefire,nHTime * 1000 ,nDamage);
    g_EventManager.AddEvent(FireBurnEvent);
  end; //0492D4D
  if  m_PEnvir.GetEvent(nX,nY) = nil then begin
    FireBurnEvent:=TFireBurnEvent.Create(self,nX,nY,m_btusefire,nHTime * 1000 ,nDamage);
    g_EventManager.AddEvent(FireBurnEvent);
  end; //00492D9C
  if  m_PEnvir.GetEvent(nX+1,nY) = nil then begin
    FireBurnEvent:=TFireBurnEvent.Create(self,nX+1,nY,m_btusefire,nHTime * 1000 ,nDamage);
    g_EventManager.AddEvent(FireBurnEvent);
  end; //00492DED
  if  m_PEnvir.GetEvent(nX,nY+1) = nil then begin
    FireBurnEvent:=TFireBurnEvent.Create(self,nX,nY+1,m_btusefire,nHTime * 1000 ,nDamage);
    g_EventManager.AddEvent(FireBurnEvent);
  end; //00492E3E }
  Result:=true;
end;


function TMonster1.MakeClone(sMonName: String;OldMon:TBaseObject): TBaseObject; //004A8C58
var
  ElfMon:TBaseObject;
begin
  Result:=nil;
  ElfMon:=UserEngine.RegenMonsterByName(m_PEnvir.sMapName,m_nCurrX,m_nCurrY,sMonName);
  if ElfMon <> nil then begin
    ElfMon.m_Master:=OldMon.m_Master;
    ElfMon.m_dwMasterRoyaltyTick:=OldMon.m_dwMasterRoyaltyTick;
    ElfMon.m_btSlaveMakeLevel:=OldMon.m_btSlaveMakeLevel;
    ElfMon.m_btSlaveExpLevel:=OldMon.m_btSlaveExpLevel;
    ElfMon.RecalcAbilitys;
    ElfMon.RefNameColor;
    if OldMon.m_Master <> nil then
      OldMon.m_Master.m_SlaveList.Add(ElfMon);
    ElfMon.m_WAbil:=OldMon.m_WAbil;
    ElfMon.m_wStatusTimeArr:=OldMon.m_wStatusTimeArr;
    ElfMon.m_TargetCret:=OldMon.m_TargetCret;
    ElfMon.m_dwTargetFocusTick:=OldMon.m_dwTargetFocusTick;
    ElfMon.m_LastHiter:=OldMon.m_LastHiter;
    ElfMon.m_LastHiterTick:=OldMon.m_LastHiterTick;
    ElfMon.m_btDirection:=OldMon.m_btDirection;
    Result:=ElfMon;
  end;
end;
function TMonster1.Operate(ProcessMsg: pTProcessMessage):Boolean;
begin
  Result:=inherited Operate(ProcessMsg);

end;
function TMonster1.Think():Boolean; //004A8E54
var
  nOldX,nOldY:integer;
begin
  Result:=False;
  if (GetTickCount - m_dwThinkTick) > 3 * 1000 then begin
    m_dwThinkTick:=GetTickCount();
    if m_PEnvir.GetXYObjCount(m_nCurrX,m_nCurrY) >= 2 then m_boDupMode:=True;
    if not IsProperTarget{FFFF4}(m_TargetCret) then m_TargetCret:=nil;
  end; //004A8ED2
  if m_boDupMode then begin     //人物重叠了
    nOldX:=m_nCurrX;
    nOldY:=m_nCurrY;
    WalkTo(Random(8),False);
    if (nOldX <> m_nCurrX) or (nOldY <> m_nCurrY) then begin
      m_boDupMode:=False;
      Result:=True;
    end;
  end;
end;

function TMonster1.AttackTarget():Boolean; //004A8F34
var
  bt06:Byte;
  nX,nY:INTEGER;
begin
  Result:=False;
  if m_TargetCret <> nil then begin
   if Integer(GetTickCount - m_dwHitTick) > m_nNextHitTime  then begin
     if GetAttackDirx(m_TargetCret,3,bt06) then begin

      //  m_dwHitTick:=GetTickCount();
      //  m_dwTargetFocusTick:=GetTickCount();
        m_btDirection:=GetNextDirection(m_nCurrX,m_nCurrY,m_TargetCret.m_nCurrX,m_TargetCret.m_nCurrY);
        if m_btusefire >=0 then begin
          GetFrontPosition(nX,nY);
          turnto(m_btDirection);
          Makefire(nX,nY,m_btDirection);

        end;

    end;   // GetAttackDirx
    if GetAttackDir(m_TargetCret,bt06) then begin
     // if Integer(GetTickCount - m_dwHitTick) > m_nNextHitTime  then begin
        m_dwHitTick:=GetTickCount();
        m_dwTargetFocusTick:=GetTickCount();
        Attack(m_TargetCret,bt06);  //FFED
        if m_btUsePoison>=0 then begin
           if random(5)<2 then  m_TargetCret.MakePosion(m_btUsePoison,_max(5,loword( m_WAbil.sC)),_max(5,loword( m_WAbil.mC))) ;
        end;


        BreakHolySeizeMode();
    //  end;
      Result:=True;
    end

    else begin
      if m_TargetCret.m_PEnvir = m_PEnvir then begin
        SetTargetXY(m_TargetCret.m_nCurrX,m_TargetCret.m_nCurrY); {0FFF0h}
        //004A8FE3
      end else begin
        DelTargetCreat();{0FFF1h}
        //004A9009
      end;
    end;
   end  // if Integer(GetTickCount - m_dwHitTick) > m_nNextHitTime
  end;  //if m_TargetCret <> nil 
end;
procedure TMonster1.Run; //004A9020
var
  nX,nY,i,count:Integer;
  VisibleMapItem:pTVisibleMapItem;

begin
  if not m_boGhost and
     not m_boDeath and
     not m_boFixedHideMode and
     not m_boStoneMode and
     (m_wStatusTimeArr[POISON_STONE{5 0x6A}] = 0) then begin
    if Think then begin
      inherited;
      exit;
    end;
    if m_boWalkWaitLocked then begin

⌨️ 快捷键说明

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