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

📄 objmon3.pas

📁 传奇源代码的delphi版本
💻 PAS
📖 第 1 页 / 共 5 页
字号:

    if ((GetTickCount - m_dwSearchEnemyTick) > 8000) or
       (((GetTickCount - m_dwSearchEnemyTick) > 1000) and (m_TargetCret = nil)) then begin
      m_dwSearchEnemyTick:=GetTickCount();
      //SearchTarget();
    end;
  end;
  inherited;
end;

procedure TFrostTiger.FrostAttack();
var
Target:TBaseObject;
magpwr:Integer;
WAbil:pTAbility;
begin
  if m_TargetCret = nil then exit;
  Target:=m_TargetCret;
  SendRefMsg(RM_LIGHTING,1,m_nCurrX,m_nCurrY,Integer(Target),'');

 if IsProperTarget (Target) then begin
  if Random(50) >= Target.m_nAntiMagic then begin
      WAbil:=@m_WAbil;
      magpwr:=(Random(SmallInt(HiWord(WAbil.MC) - LoWord(WAbil.MC)) + 1) + LoWord(WAbil.MC));
      Target.SendDelayMsg (self, RM_MAGSTRUCK, 0, magpwr, 0, 0, '', 600);
      if (Random(15) <= 3) and (Random(Target.m_btAntiPoison) = 0) then begin
        Target.MakePosion(POISON_FREEZE,(2 * 3),0);
      end;

      if (Random(40) <= 3) and (Random(Target.m_btAntiPoison) = 0) then begin
        Target.MakePosion(POISON_SLOWDOWN,5,0);
        Target.MakePosion(POISON_STONE,5,0);
      end;
    end;
  end;
end;

{ TGreenMonster }

constructor TGreenMonster.Create; //004A9690
begin
  inherited;
  m_dwSearchTime:=Random(1500) + 1500;
end;

destructor TGreenMonster.Destroy;
begin

  inherited;
end;

procedure TGreenMonster.Run;//004A9720
begin
  if not bo554 and CanMove then begin
       if m_TargetCret <> nil then begin
      m_nTargetX:=m_TargetCret.m_nCurrX;
     m_nTargetY:=m_TargetCret.m_nCurrY;
  if (abs(m_nTargetX-m_nCurrX) = 1) and (abs(m_nTargety-m_nCurry)=1) then begin
  if (Random(m_TargetCret.m_btAntiPoison + 7) <= 6) and (m_TargetCret.m_wStatusTimeArr[POISON_DECHEALTH] = 0) then begin
   m_TargetCret.MakePosion(POISON_DECHEALTH,30,1);
 end;
  end;
  end;
    if ((GetTickCount - m_dwSearchEnemyTick) > 8000) or
       (((GetTickCount - m_dwSearchEnemyTick) > 1000) and (m_TargetCret = nil)) then begin
      m_dwSearchEnemyTick:=GetTickCount();
      SearchTarget();
    end;
  end;
  inherited;
end;

{ TRedMonster }

constructor TRedMonster.Create; //004A9690
begin
  inherited;
  m_dwSearchTime:=Random(1500) + 1500;
end;

destructor TRedMonster.Destroy;
begin

  inherited;
end;

procedure TRedMonster.Run;//004A9720
begin
  if not bo554 and CanMove then begin
  if m_TargetCret <> nil then begin
      m_nTargetX:=m_TargetCret.m_nCurrX;
     m_nTargetY:=m_TargetCret.m_nCurrY;
  if (abs(m_nTargetX-m_nCurrX) = 1) and (abs(m_nTargety-m_nCurry)=1) then begin
  if (Random(m_TargetCret.m_btAntiPoison + 7) <= 6) and (m_TargetCret.m_wStatusTimeArr[POISON_DECHEALTH] = 0) then begin
   m_TargetCret.MakePosion(POISON_DAMAGEARMOR,30,1);
 end;
  end;
  end;
    if ((GetTickCount - m_dwSearchEnemyTick) > 8000) or
       (((GetTickCount - m_dwSearchEnemyTick) > 1000) and (m_TargetCret = nil)) then begin
      m_dwSearchEnemyTick:=GetTickCount();
      SearchTarget();
    end;
  end;
  inherited;
end;

{ khazard }
constructor TKhazard.Create; //004A9690
begin
  inherited;
  m_dwThinkTick:=GetTickCount();
  m_dwSearchTime:=Random(1500) + 1500;
end;

destructor TKhazard.Destroy;
begin

  inherited;
end;

procedure TKhazard.Run;//004A9720
var
  time1 : integer;
begin
  if not m_boFixedHideMode and
     not m_boStoneMode and
     CanMove then begin
    time1:=random(2);
    if m_TargetCret <> nil then begin

    //attack code
      if IsProperTarget(m_TargetCret) then begin
        m_nTargetX:=m_TargetCret.m_nCurrX;
        m_nTargetY:=m_TargetCret.m_nCurrY;
        if (abs(m_nTargetX-m_nCurrX) = 2) or (abs(m_nTargety-m_nCurry)=2) then begin
          if (GetTickCount - m_dwThinkTick) > 1000 then begin //do drag back on random
            m_dwThinkTick:=GetTickCount();
            if time1 < 2 then
              drag();
          end else
            AttackTarget();
        end;
      end;
    end;
    if ((GetTickCount - m_dwSearchEnemyTick) > 8000) or
       (((GetTickCount - m_dwSearchEnemyTick) > 1000) and (m_TargetCret = nil)) then begin
      m_dwSearchEnemyTick:=GetTickCount();
      SearchTarget();
    end;
  end;
  inherited;
end;

procedure TKhazard.Drag();
var
  nx,ny: Integer;
  nAttackDir: Integer;
begin
  nAttackDir:=GetNextDirection(m_TargetCret.m_nCurrX,m_TargetCret.m_nCurrY,m_nCurrX,m_nCurrY); //technicaly this is the dir the target would be facing if he was hitting us
  GetFrontPosition(nx,ny);
  SendRefMsg(RM_LIGHTING,1,m_nCurrX,m_nCurrY,Integer(m_TargetCret),'');

  m_TargetCret.CharPushed(nAttackDir,1);
  if (Random(1) = 0) and (Random(m_TargetCret.m_btAntiPoison + 7) <= 6) then begin
    m_TargetCret.MakePosion(POISON_DECHEALTH,35,2);
    exit;
  end;
end;

function TKhazard.AttackTarget():Boolean; //004A8F34
var
  btDir:Byte;
begin
  Result:=False;
  if m_TargetCret <> nil then begin
    if GetAttackDir(m_TargetCret,btDir) then begin
      if GetCurrentTime - m_dwHitTick > GetHitSpeed then begin
        m_dwHitTick:=GetCurrentTime;
        m_dwTargetFocusTick:=GetTickCount();
        Attack(m_TargetCret,btDir);  //FFED
        if (Random(1) = 0) and (Random(m_TargetCret.m_btAntiPoison + 7) <= 6) then begin
            m_TargetCret.MakePosion(POISON_DECHEALTH,35,2);
            exit;
        end;
      end;
      Result:=True;
    end;
  end;
end;

{ end }

{ runaway }
constructor TRunAway.Create; //004A9690
begin
  inherited;
  m_dwSearchTime:=Random(1500) + 1500;
end;

destructor TRunAway.Destroy;
begin

  inherited;
end;

procedure TRunAway.Run;//004A9720
var
time1,nx,ny:integer;
borunaway:boolean;
begin
  if (not bo554) and CanMove then begin
if m_TargetCret <> nil then begin
      m_nTargetX:=m_TargetCret.m_nCurrX;
     m_nTargetY:=m_TargetCret.m_nCurrY;
 if (m_wabil.HP <= round(m_wabil.MaxHP div 2)) and (borunaway=false) then begin //if health less then 1/2
    GetFrontPosition(nx,ny);
       SendRefMsg(RM_SPACEMOVE_FIRE,0,0,0,0,'');
       SpaceMove(M_sMapName, nx - 2, ny - 2, 0);  //move backwards 3 spaces
    borunaway:=true;
    end else begin
 if m_wabil.HP >= round(m_wabil.MaxHP div 2) then begin
    borunaway:=false;
 end;
 end;
  if borunaway then begin
     if Integer(GetTickCount - time1) > 5000 then begin
  if (abs(m_nTargetX-m_ncurrx)=1) and (abs(m_nTargety-m_ncurry)=1) then begin
     walkto(random(4),true);
  end else begin
     walkto(random(7),true);
  end;
     end else begin
       time1:=GetTickCount();
     end;
     end;
     end;
    if ((GetTickCount - m_dwSearchEnemyTick) > 8000) or
       (((GetTickCount - m_dwSearchEnemyTick) > 1000) and (m_TargetCret = nil)) then begin
      m_dwSearchEnemyTick:=GetTickCount();
      SearchTarget();
    end;
  end;
  inherited;
end;
{ end }

{ Tele mob }
constructor TTeleMonster.Create; //004A9690
begin
  inherited;
  m_dwSearchTime:=Random(1500) + 1500;
end;

destructor TTeleMonster.Destroy;
begin

  inherited;
end;

procedure TTeleMonster.Run;//004A9720
begin
  if (not bo554) and CanMove then begin
  //if it finds a target tele to him!
  if m_TargetCret <> nil then begin
    if  (abs(m_nCurrX-m_nTargetX) > 5) or
             (abs(m_nCurrY-m_nTargetY) > 5) then begin
           // if 5 spaces away teleport to the enemy!
            SendRefMsg(RM_SPACEMOVE_FIRE,0,0,0,0,'');
          SpaceMove(m_TargetCret.M_sMapName, m_TargetCret.m_nCurrX, m_TargetCret.m_nCurrY, 0);
          end;
  end;
  //end
    if ((GetTickCount - m_dwSearchEnemyTick) > 8000) or
       (((GetTickCount - m_dwSearchEnemyTick) > 1000) and (m_TargetCret = nil)) then begin
      m_dwSearchEnemyTick:=GetTickCount();
      SearchTarget();
    end;
  end;
  inherited;
end;
{ end }

{ Defend Monster }
constructor TDefendMonster.Create; //004A9690
begin
  inherited;
  m_dwSearchTime:=Random(1500) + 1500;
end;

destructor TDefendMonster.Destroy;
begin

  inherited;
end;

procedure TDefendMonster.Run;//004A9720
begin
  {if (not bo554) and CanMove then begin
  //if it finds a target 15 spaces away start sequence
  if (m_TargetCret <> nil) and (callguardrun=false) then begin

           // call guards!
           mainoutmessage('CALL GUARD' + inttostr(m_nCurrX) + ' ' + inttostr(m_nCurrY));
           callguard(m_sMapName,m_nCurrX,m_nCurrY);
          end;

    if ((GetTickCount - m_dwSearchEnemyTick) > 8000) or
       (((GetTickCount - m_dwSearchEnemyTick) > 1000) and (m_TargetCret = nil)) then begin
      m_dwSearchEnemyTick:=GetTickCount();
      SearchTarget();
    end;
  end;   }
  inherited;
end;
{
procedure TDefendMonster.callguard(mapmap:string; xx,yy:integer);
var
  I: Integer;
  nC:Integer;
  nx,ny:Integer;
  sMonName:array[0..3] of String;
  BaseObject:TBaseObject;
begin
  nC:=7; //how many areas around the boss
 // GetFrontPosition(nx,ny);
  sMonName[0]:='Hen';
 // sMonName[1]:=sZuma2;
 // sMonName[2]:=sZuma3;
 // sMonName[3]:=sZuma4;
    nx:=xx;
    ny:=yy;

  for I := 0 to nC do begin
  { case i of
    0: begin
    Dec(nY);
    end;
    1: begin
       Inc(nX);
       Dec(nY);
      end;
    2: begin
     Inc(nX)
     end;
    3: begin
    Inc(nX);
       Inc(nY);
       end;
    4: begin
     Inc(nY);
     end;
    5: begin
             Dec(nX);
       Inc(nY);
       end;
    6: begin
     Dec(nX);
     end;
    7: begin
             Dec(nX);
        Dec(nY);
        end;
    end;}
   // if m_GuardObjects.Count >= 5 then break;
   {
    BaseObject:=UserEngine.RegenMonsterByName(mapmap,nx,ny,sMonName[0]);
    if BaseObject <> nil then begin
      m_GuardObjects.Add(BaseObject);
    end;
  end;    // for
  callguardrun:=true;//tell it its already been run!
end;

}


constructor TClone.Create;//004AA4B4
begin
  inherited;
  m_dwSearchTime:=Random(1500) + 1500;
  m_dwMpLossTick:= GetTickCount();
  m_boNOITEM:=TRUE;
  m_boNoTame:=TRUE;
end;

procedure TClone.Die;
begin
  SendRefMsg(RM_10205,0,m_nCurrX,m_nCurrY,3{type},'');
  SendDelayMsg(self, RM_DISAPPEAR, 0, 0, 0, 0, '', 600);
  m_boObMode:=True;//hopefully switching to observer also makes us invisible to others when we die :p;
  inherited;
end;


destructor TClone.Destroy;
begin
  inherited;
end;


procedure TClone.StruckDamage(nDamage:integer);
begin
  if m_Master <> nil then begin
    if (m_Master.m_WAbil.MaxHP < nDamage) or (m_Master.m_WAbil.MP < nDamage) then begin
      m_WAbil.HP := 0;
      exit;
    end;
    m_Master.DamageSpell(nDamage);
    m_Master.HealthSpellChanged();
  end;
end;

procedure TClone.SetMpLoss(nMpReduction:Integer);
begin
  nMpLoss:=nMpReduction;
end;

procedure TClone.Run;
var
  nx,ny: Integer;
begin
  if not m_boFixedHideMode and
     not m_boStoneMode and
     CanMove then begin

     if m_Master <> nil then begin
      if (GetTickCount - m_dwMpLossTick) > 3000 then begin //drain our masters mp
        m_dwMpLossTick:=GetTickCount();
        m_Master.DamageSpell(nMpLoss);
        m_Master.HealthSpellChanged();
      end;
      if m_Master.m_WAbil.MP < (m_Master.m_WAbil.MaxMP div 10) then begin  //if our master has to little mp die :p
        m_WAbil.HP:=0;
        inherited;
        exit;
      end;
     end;

     if (GetTickCount - m_dwThinkTick) > 1000 then begin
      m_dwThinkTick:=GetTickCount();
      FindTarget();
     end;

      //some 'mobs' get locked after x steps i guess we could leave this part in :p
    if m_boWalkWaitLocked then begin    //this unlocks the 'walkwaitlock' after it's been locked

⌨️ 快捷键说明

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