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

📄 magic.pas

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

function TMagicManager.MagMakePrivateTransparent(BaseObject: TBaseObject; nHTime: Integer):Boolean; //004930E8
var
  I                :Integer;
  BaseObjectList   :TList;
  TargeTBaseObject :TBaseObject;
begin
  Result:=False;
  if BaseObject.m_wStatusTimeArr[STATE_TRANSPARENT{0x70}] > 0 then exit;   //4930FE
  BaseObjectList:=TList.Create;
  BaseObject.GetMapBaseObjects(BaseObject.m_PEnvir,BaseObject.m_nCurrX,BaseObject.m_nCurrY,9,BaseObjectList);
  for I := 0 to BaseObjectList.Count - 1 do begin
    TargeTBaseObject:=TBaseObject(BaseObjectList.Items[i]);
    if (TargeTBaseObject.m_btRaceServer >= RC_ANIMAL) and (TargeTBaseObject.m_TargetCret = BaseObject) then begin
      if (abs(TargeTBaseObject.m_nCurrX - BaseObject.m_nCurrX) > 1) or
         (abs(TargeTBaseObject.m_nCurrY - BaseObject.m_nCurrY) > 1) or
         (Random(2) = 0) then begin
        TargeTBaseObject.m_TargetCret:=nil;
      end;
    end;
  end;
  BaseObjectList.Free;
  BaseObject.m_wStatusTimeArr[STATE_TRANSPARENT{0x70}]:=nHTime; //004931D2
  BaseObject.m_nCharStatus:=BaseObject.GetCharStatus();
  BaseObject.StatusChanged();
  BaseObject.m_boHideMode:=True;
  BaseObject.m_boTransparent:=True;
  Result:=True;
end;

function TMagicManager.MagTamming(BaseObject, TargeTBaseObject: TBaseObject;
  nTargetX, nTargetY, nMagicLevel: Integer): Boolean; //00492368
var
  n14:Integer;
begin
  Result:=False;
  if (TargeTBaseObject.m_btRaceServer = MONSTER_CLONE) then exit;

  if (TargeTBaseObject.m_btRaceServer <> RC_PLAYOBJECT) and ((Random(4 - nMagicLevel) = 0)) then begin
    TargeTBaseObject.m_TargetCret:=nil;
    if TargeTBaseObject.m_Master = BaseObject then begin
      TargeTBaseObject.OpenHolySeizeMode((nMagicLevel * 5 + 10) * 1000);
      Result:=True;
    end else begin
      if Random(2) = 0 then begin
        if TargeTBaseObject.m_Abil.Level <= BaseObject.m_Abil.Level + 2 then begin
          if Random(3) = 0 then begin
            if Random((BaseObject.m_Abil.Level + 20) + (nMagicLevel * 5)) > (TargeTBaseObject.m_Abil.Level + g_Config.nMagTammingTargetLevel{10}) then begin
              if not(TargeTBaseObject.m_boNoTame) and
                 (TargeTBaseObject.m_btLifeAttrib <> LA_UNDEAD) and
                 (TargeTBaseObject.m_Abil.Level < g_Config.nMagTammingLevel{50}) and
                 (BaseObject.m_SlaveList.Count < g_Config.nMagTammingCount{(nMagicLevel + 2)}) then begin
                n14:=TargeTBaseObject.m_WAbil.MaxHP div g_Config.nMagTammingHPRate{100};
                if n14 <= 2 then n14:=2
                else Inc(n14,n14);
                if (TargeTBaseObject.m_Master <> BaseObject) and (Random(n14) = 0) then begin
                  TargeTBaseObject.BreakCrazyMode();
                  if TargeTBaseObject.m_Master <> nil then begin
                    TargeTBaseObject.m_WAbil.HP:=TargeTBaseObject.m_WAbil.HP div 10;
                  end;
                  TargeTBaseObject.m_Master:=BaseObject;
                  TargeTBaseObject.m_dwMasterRoyaltyTick:=LongWord((Random(BaseObject.m_Abil.Level * 2) + (nMagicLevel shl 2) * 5 + 20) * 60 * 1000) + GetTickCount;
                  TargeTBaseObject.m_btSlaveMakeLevel:=nMagicLevel;
                  if TargeTBaseObject.m_dwMasterTick = 0 then TargeTBaseObject.m_dwMasterTick:=GetTickCount();
                  TargeTBaseObject.BreakHolySeizeMode();
                  if LongWord(1500 - nMagicLevel * 200) < LongWord(TargeTBaseObject.m_nWalkSpeed) then begin
                    TargeTBaseObject.m_nWalkSpeed:=1500 - nMagicLevel * 200;
                  end;
                  if LongWord(2000 - nMagicLevel * 200) < LongWord(TargeTBaseObject.m_nNextHitTime) then begin
                    TargeTBaseObject.m_nNextHitTime:=2000 - nMagicLevel * 200;
                  end;
                  TargeTBaseObject.RefShowName();
                  BaseObject.m_SlaveList.Add(TargeTBaseObject);
                end else begin //004925F2
                  if Random(14) = 0 then TargeTBaseObject.m_WAbil.HP:=0;
                end;                  
              end else begin //00492615
                if (TargeTBaseObject.m_btLifeAttrib = LA_UNDEAD) and (Random(20) = 0) then
                  TargeTBaseObject.m_WAbil.HP:=0;
              end;
            end else begin //00492641
              if not (TargeTBaseObject.m_btLifeAttrib = LA_UNDEAD) and (Random(20) = 0) then
                TargeTBaseObject.OpenCrazyMode(Random(20) + 10);
            end;
          end else begin //00492674
            if not (TargeTBaseObject.m_btLifeAttrib = LA_UNDEAD) then
              TargeTBaseObject.OpenCrazyMode(Random(20) + 10); //变红
          end;
        end; //004926B0          
      end else begin //00492699
        TargeTBaseObject.OpenHolySeizeMode((nMagicLevel * 5 + 10) * 1000);
      end;
      Result:=True;
    end;
  end else begin
    if Random(2) = 0 then Result:=True;      
  end;
end;

function TMagicManager.MagTurnUndead(BaseObject, TargeTBaseObject: TBaseObject;
  nTargetX, nTargetY, nLevel: Integer): Boolean; //004926D4
var
  n14:Integer;
begin
  Result:=False;
  if TargeTBaseObject.m_boSuperMan or not (TargeTBaseObject.m_btLifeAttrib = LA_UNDEAD) then exit;
  TAnimalObject(TargeTBaseObject).Struck{FFEC}(BaseObject);
  if TargeTBaseObject.m_TargetCret = nil then begin
    TAnimalObject(TargeTBaseObject).m_boRunAwayMode:=True;
    TAnimalObject(TargeTBaseObject).m_dwRunAwayStart:=GetTickCount();
    TAnimalObject(TargeTBaseObject).m_dwRunAwayTime:=10 * 1000;
  end;
  BaseObject.SetTargetCreat(TargeTBaseObject);
  if (Random(2) + (BaseObject.m_Abil.Level - 1)) > TargeTBaseObject.m_Abil.Level then begin
    if TargeTBaseObject.m_Abil.Level < g_Config.nMagTurnUndeadLevel then begin
      n14:=BaseObject.m_Abil.Level - TargeTBaseObject.m_Abil.Level;
      if Random(100) < ((nLevel shl 3) - nLevel + 15 + n14) then begin
        TargeTBaseObject.SetLastHiter(BaseObject);
        TargeTBaseObject.m_WAbil.HP:=0;
        Result:=True;
      end
    end;
  end; //004927CB
end;

function TMagicManager.MagWindTebo(PlayObject: TPlayObject;
  UserMagic: pTUserMagic): Boolean;
var
  PoseBaseObject:TBaseObject;
begin
  Result:=False;
  PoseBaseObject:=PlayObject.GetPoseCreate;
  if (PoseBaseObject <> nil) and
     (PoseBaseObject <> PlayObject) and
     (not PoseBaseObject.m_boDeath) and
     (not PoseBaseObject.m_boGhost) and
     (PlayObject.IsProperTarget(PoseBaseObject)) and
     (not PoseBaseObject.m_boStickMode) then begin
    if (abs(PlayObject.m_nCurrX - PoseBaseObject.m_nCurrX) <= 1) and
       (abs(PlayObject.m_nCurrY - PoseBaseObject.m_nCurrY) <= 1) and
       (PlayObject.m_Abil.Level > PoseBaseObject.m_Abil.Level) then begin
      if Random(20) < UserMagic.btLevel * 6 + 6 + (PlayObject.m_Abil.Level - PoseBaseObject.m_Abil.Level) then begin
        PoseBaseObject.CharPushed(GetNextDirection(PlayObject.m_nCurrX,PlayObject.m_nCurrY,PoseBaseObject.m_nCurrX,PoseBaseObject.m_nCurrY),_MAX(0,UserMagic.btLevel -1) + 1);
        Result:=True;
      end;
    end;
  end;
end;

function TMagicManager.BladeAvalanche(PlayObject: TPlayObject;
  UserMagic: pTUserMagic;TargeTBaseObject: TBaseObject):Boolean;
const
OffsetXY:array[0..7,0..1] of Integer = ((-1,0),(-1,-1),(0,-1),(1,-1),
                                      (-1,0),(-1,-1),(0,-1),(1,-1));
var
BaseObject     :TBaseObject;
BaseObjectList:Tlist;

I:Integer;
NPower:integer;
PowAdd:integer;
Tx,Ty:Integer;//the 2nd xy coord infront of us
sx,sy,sxx,syy:Integer;//sx:sy=first coord infront of us, sxx:syy=third coord infront of us
begin
  Result:=FALSE;
  tx:=PlayObject.m_nCurrX;
  ty:=PlayObject.m_nCurrY;
  sx:=PlayObject.m_nCurrX + OffsetXY[PlayObject.m_btDirection,0];
  sy:=PlayObject.m_nCurrY + OffsetXY[PlayObject.m_btDirection,1];
  sxx:=PlayObject.m_nCurrX + ((-1) * + OffsetXY[PlayObject.m_btDirection,0]);
  syy:=PlayObject.m_nCurrY + ((-1) * + OffsetXY[PlayObject.m_btDirection,1]);

  BaseObjectList:=TList.Create;
  for I := 0 to PlayObject.m_VisibleActors.Count-1  do begin
    BaseObject:= TBaseObject (pTVisibleBaseObject(PlayObject.m_VisibleActors[i]).BaseObject);
    if BaseObject.m_boDeath or (BaseObject.m_boGhost) or (PlayObject = BaseObject) then Continue;
    if PlayObject.IsProperTarget (BaseObject) then begin
      PowAdd:=0;
      if InsameLine(tx,ty,PlayObject.m_btDirection,BaseObject.m_nCurrX, BaseObject.m_nCurrY,PlayObject) then
        PowAdd:=120;
      if InSameLine(sx,sy,PlayObject.m_btDirection,BaseObject.m_nCurrX, BaseObject.m_nCurrY,PlayObject) then
        PowAdd:=80;
      if InSameLine(sxx,syy,PlayObject.m_btDirection,BaseObject.m_nCurrX, BaseObject.m_nCurrY,PlayObject) then
        PowAdd:=80;
      if PowAdd > 0 then begin
        npower:=PlayObject.GetAttackPower(GetPower(MPow(UserMagic),UserMagic) + LoWord(PlayObject.m_WAbil.DC),
                            SmallInt(HiWord(PlayObject.m_WAbil.DC)-LoWord(PlayObject.m_WAbil.DC)) + 1);
        npower:= ((npower * PowAdd) div 100);
        PlayObject.SendDelayMsg(PlayObject,RM_DELAYMAGIC,nPower,MakeLong(BaseObject.m_nCurrX,BaseObject.m_nCurrY),1,Integer(BaseObject),'',200);
        PlayObject.SetTargetCreat(BaseObject);
        if baseobject.m_btRaceServer >= RC_ANIMAL then Result:=True;
      end;
    end;
  end;
end;


function TMagicManager.RedBlade(PlayObject: TPlayObject;
  UserMagic: pTUserMagic;TargeTBaseObject: TBaseObject):Boolean;
const
OffsetXY:array[0..7,0..1] of Integer = ((-1,0),(-1,-1),(0,-1),(1,-1),
                                      (-1,0),(-1,-1),(0,-1),(1,-1));
var
BaseObject     :TBaseObject;
BaseObjectList:Tlist;

I:Integer;
NPower:integer;
PowAdd:integer;
Tx,Ty:Integer;//the 2nd xy coord infront of us
sx,sy,sxx,syy:Integer;//sx:sy=first coord infront of us, sxx:syy=third coord infront of us
begin
  Result:=FALSE;
  tx:=PlayObject.m_nCurrX;
  ty:=PlayObject.m_nCurrY;
  sx:=PlayObject.m_nCurrX + OffsetXY[PlayObject.m_btDirection,0];
  sy:=PlayObject.m_nCurrY + OffsetXY[PlayObject.m_btDirection,1];
  sxx:=PlayObject.m_nCurrX + ((-1) * + OffsetXY[PlayObject.m_btDirection,0]);
  syy:=PlayObject.m_nCurrY + ((-1) * + OffsetXY[PlayObject.m_btDirection,1]);

  BaseObjectList:=TList.Create;
  for I := 0 to PlayObject.m_VisibleActors.Count-1  do begin
    BaseObject:= TBaseObject (pTVisibleBaseObject(PlayObject.m_VisibleActors[i]).BaseObject);
    if BaseObject.m_boDeath or (BaseObject.m_boGhost) or (PlayObject = BaseObject) then Continue;
    if PlayObject.IsProperTarget (BaseObject) then begin
      PowAdd:=0;
      if InsameLine(tx,ty,PlayObject.m_btDirection,BaseObject.m_nCurrX, BaseObject.m_nCurrY,PlayObject) then
        PowAdd:=120;
      if InSameLine(sx,sy,PlayObject.m_btDirection,BaseObject.m_nCurrX, BaseObject.m_nCurrY,PlayObject) then
        PowAdd:=80;
      if InSameLine(sxx,syy,PlayObject.m_btDirection,BaseObject.m_nCurrX, BaseObject.m_nCurrY,PlayObject) then
        PowAdd:=80;
      if PowAdd > 0 then begin
        npower:=PlayObject.GetAttackPower(GetPower(MPow(UserMagic),UserMagic) + LoWord(PlayObject.m_WAbil.DC),
                            SmallInt(HiWord(PlayObject.m_WAbil.DC)-LoWord(PlayObject.m_WAbil.DC)) + 1);
        npower:= ((npower * PowAdd) div 100);
        PlayObject.SendDelayMsg(PlayObject,RM_DELAYMAGIC,nPower,MakeLong(BaseObject.m_nCurrX,BaseObject.m_nCurrY),1,Integer(BaseObject),'',200);
        PlayObject.SetTargetCreat(BaseObject);
        if baseobject.m_btRaceServer >= RC_ANIMAL then Result:=True;
      end;
    end;
  end;
end;

{function  TBaseObject.WindStained (sx, sy, tx, ty, ndir, magpwr: integer; undeadattack: Boolean): integer;
var
   i, tcount: integer;
   BaseObject:TBaseObject;
begin
   tcount := 0;
   for i:=0 to 12 do begin
     BaseObject:=TBaseObject(m_PEnvir.GetMovingObject(sx,sy,True));
     if BaseObject <> nil then begin
       if IsProperTarget (BaseObject) then begin
         if Random(50) >= BaseObject.m_nAntiMagic then begin
           if undeadattack then
             magpwr := Round (magpwr * 1.5);

           BaseObject.SendDelayMsg (self, RM_MAGSTRUCK, 0, magpwr, 0, 0, '', 600);
           Inc (tcount);
         end;
       end;
     end;
     if not ((abs(sx-tx) <= 0) and (abs(sy-ty) <= 0)) then begin
       ndir := GetNextDirection (sx, sy, tx, ty);
       if not m_PEnvir.GetNextPosition (sx, sy, ndir, 1, sx, sy) then
         break;
     end else
       break;
   end;
   Result := tcount;

end;}


function TMagicManager.Insameline(nsx,nsy,nDir,tx,ty:Integer;PlayObject:TBaseObject): Boolean;
var
  sx,sy,sxx,syy,sxxx,syyy:Integer;
begin
  result:=FALSE;
  PlayObject.m_PEnvir.GetNextPosition(nsx,nsy,nDir, 1,sx,sy);
  PlayObject.m_PEnvir.GetNextPosition(nsx,nsy,nDir, 2,sxx,syy);
  PlayObject.m_PEnvir.GetNextPosition(nsx,nsy,nDir, 3,sxxx,syyy);
  if ((sx = tx) and (sy = ty)) or ((sxx = tx) and (syy = ty)) or ((sxxx = tx) and (syyy = ty)) then

⌨️ 快捷键说明

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