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

📄 umonster.pas

📁 千年源代码,只缺少控件,可以做二次开发用,好不容易得来的
💻 PAS
📖 第 1 页 / 共 3 页
字号:
begin
   EndProcess;
   BasicData.x := x;
   BasicData.y := y;
   StartProcess;
end;

function  TMonster.FieldProc (hfu: Longint; Msg: word; var SenderInfo: TBasicData; var aSubData: TSubData): Integer;
var
   i, j, lifepercent : Integer;
   tx, ty, len, len2, key: word;
   Str : String;
   bo : TBasicObject;
   SubData : TSubData;
   ItemData : TItemData;
   MagicData : TMagicData;
   Monster : TMonster;
label abcde;

begin
   Result := PROC_FALSE;

   if isRangeMessage ( hfu, Msg, SenderInfo) = FALSE then exit;
   Result := inherited FieldProc (hfu, Msg, Senderinfo, aSubData);
   if Result = PROC_TRUE then exit;
   if FboAllowDelete = true then exit;

   if LifeObjectState = los_die then exit;

   case Msg of
      FM_IAMHERE, FM_HIT, FM_STRUCTED, FM_CHANGEFEATURE, FM_MOVE, FM_SHOW:
         begin
            if SenderInfo.id = BasicData.id then goto abcde;
            if SenderInfo.Feature.rrace <> RACE_HUMAN then goto abcde;        // 林籍捞搁 阁胶磐档 傍拜
            if SenderInfo.Feature.rHideState = hs_0 then goto abcde;

            if (SenderInfo.Feature.rFeatureState = wfs_die) then begin
               if SenderInfo.id = AttackSkill.CurNearViewHumanId then AttackSkill.CurNearViewHumanId := 0;
               if SenderInfo.id = AttackSkill.HateHumanId then AttackSkill.HateHumanId := 0;
               goto abcde;
            end;
            len := GetLargeLength (BasicData.x, BasicData.y, SenderInfo.x, SenderInfo.y);
            if AttackSkill.ViewWidth < len then exit;
            if AttackSkill.boViewHuman = FALSE then exit;
            bo := nil;
            if AttackSkill.CurNearViewHumanID <> 0 then
               bo := TBasicObject (GetViewObjectById (AttackSkill.CurNearViewHumanId));
            if bo <> nil then begin
               len2 := GetLargeLength (BasicData.x, BasicData.y, bo.Posx, bo.Posy);
               if len2 > len then AttackSkill.CurNearViewHumanId := SenderInfo.id;
            end else AttackSkill.CurNearViewHumanId := SenderInfo.id;
         end;
      FM_HIDE :
         begin
            if SenderInfo.id = BasicData.id then goto abcde;
            if SenderInfo.id = AttackSkill.CurNearViewHumanId then AttackSkill.CurNearViewHumanId := 0;
            if SenderInfo.id = AttackSkill.HateHumanId then AttackSkill.HateHumanId := 0;
         end;
   end;
abcde:

   case Msg of
      FM_IAMHERE :
         begin
            if SenderInfo.ID = BasicData.ID then exit;
            if SenderInfo.Feature.rRace = RACE_ITEM then begin
               if (LifeObjectState <> los_none) and (LifeObjectState <> los_attack) then exit;

               // 荐笼贱
               if not HaveMagicClass.isHavePickMagic then exit;
               if not HaveMagicClass.RunHavePickMagic (BasicData.LifePercent, StrPas (@SenderInfo.Name)) then exit;
               if HaveItemClass.HaveItemFreeCount > 0 then begin
                  AttackSkill.SetSaveIDandPos (SenderInfo.ID, SenderInfo.X, SenderInfo.Y, los_eat);
                  LifeObjectState := los_movework;
                  exit;
               end;
            end;
         end;
      FM_SHOW :
         begin
         end;
      FM_ADDITEM :
         begin
            if LifeObjectState = los_die then exit;
            if SenderInfo.Feature.rrace = RACE_ITEM then begin
               Str := StrPas (@aSubData.ItemData.rName);
               if HaveItemClass.AddHaveItem (Str, aSubData.ItemData.rCount, aSubData.ItemData.rColor) = true then begin
                  SetWordString (SubData.SayString, IntToStr (aSubData.ItemData.rSoundDrop.rWavNumber));
                  SendLocalMessage (NOTARGETPHONE, FM_SOUND, BasicData, SubData);
                  Result := PROC_TRUE;
               end;
            end;
         end;
      FM_CHANGEFEATURE:
         begin
            if SenderInfo.ID = BasicData.ID then exit;

            // if LifeObjectState = los_attack then exit;
            if SenderInfo.Feature.rRace <> RACE_HUMAN then exit;
            if SenderInfo.Feature.rfeaturestate <> wfs_die then exit;
            if HaveMagicClass.isHaveKillMagic then begin
               AttackSkill.SetSaveIDandPos (SenderInfo.ID, SenderInfo.X, SenderInfo.Y, los_kill);
               LifeObjectState := los_movework;
               exit;
            end;
         end;
      FM_GATHERVASSAL :
         begin
            if SenderInfo.id = BasicData.id then exit;
            if AttackSkill.boVassal and (LifeObjectState = los_none) and (aSubData.VassalCount > 0) then begin
               aSubData.VassalCount := aSubData.VassalCount - 1;
               AttackSkill.SetTargetId (aSubData.TargetId, false);
            end;
         end;
      FM_HIT,
      FM_MOVE :
         begin
            if SenderInfo.ID = BasicData.ID then exit;
            
            // 犁积贱
            if HaveMagicClass.isHaveHealMagic then begin
               if HaveMagicClass.RunHaveHealMagic (StrPas (@SenderInfo.Name), SenderInfo.LifePercent, SubData) then begin
                  key := GetNextDirection (BasicData.X, BasicData.Y, SenderInfo.X, SenderInfo.Y);
                  if (key <> DR_DONTMOVE) and (key <> BasicData.dir) then begin
                     CommandTurn (key);
                  end;
                  SubData.Motion := BasicData.Feature.rHitMotion;
                  SendLocalMessage (NOTARGETPHONE, FM_MOTION, BasicData, SubData);
                  ShowEffect (6, lek_follow);
                  SendLocalMessage (SenderInfo.ID, FM_HEAL, BasicData, SubData);
               end;
            end;
         end;
      FM_HEAL :
         begin
            ShowEffect (6, lek_follow);
            CurLife := CurLife + aSubData.HitData.ToHit;
            if CurLife > MaxLife then CurLife := MaxLife;

            if MaxLife <= 0 then BasicData.LifePercent := 0
            else BasicData.LifePercent := CurLife * 100 div MaxLife;
            SubData.Percent := BasicData.LifePercent;
            SendLocalMessage (NOTARGETPHONE, FM_LIFEPERCENT, BasicData, SubData);
         end;
      FM_STRUCTED :
         begin
            if SenderInfo.id = BasicData.id then begin
               if CurLife <= 0 then CurLife := 0;
               // 篮脚贱
               if HaveMagicClass.isHaveHideMagic then begin
                  if BasicData.Feature.rHideState = hs_100 then begin
                     if HaveMagicClass.RunHaveHideMagic (BasicData.LifePercent) then begin
                        SetHideState (hs_0);
                     end;
                  end;
               end;
               // 盒脚贱
               if HaveMagicClass.isHaveSameMagic then begin
                  if (FboCopy = false) and (LifeObjectState = los_attack) then begin
                     if HaveMagicClass.RunHaveSameMagic (BasicData.LifePercent, SubData) = true then begin
                        if CopiedList = nil then begin
                           CopiedList := TList.Create;
                        end;
                        CopiedList.Clear;
                        if BasicData.Feature.rrace = RACE_MONSTER then begin
                           for j := 0 to SubData.HitData.ToHit - 1 do begin
                              Monster := TMonsterList (Manager.MonsterList).CopyMonster (BasicData, AttackSkill);
                              if Monster <> nil then begin
                                 Monster.CopyBoss := Self;
                                 Monster.LifeObjectState := LifeObjectState;
                                 CopiedList.Add (Monster);
                              end;
                           end;
                        end;
                     end;
                  end;
               end;

               // 矫距贱
               if HaveMagicClass.isHaveEatMagic then begin
                  if HaveMagicClass.RunHaveEatMagic (BasicData.LifePercent, HaveItemClass, SubData) then begin
                     CurLife := CurLife + SubData.HitData.ToHit;
                     if CurLife > MaxLife then CurLife := MaxLife;

                     if MaxLife <= 0 then BasicData.LifePercent := 0
                     else BasicData.LifePercent := CurLife * 100 div MaxLife;
                     SubData.Percent := BasicData.LifePercent;
                     SendLocalMessage (NOTARGETPHONE, FM_LIFEPERCENT, BasicData, SubData);
                  end;
               end;

               if CurLife <= 0 then begin
                  AttackSkill.SetTargetId (0, true);
                  if HaveMagicClass.isHaveSwapMagic = false then begin
                     HaveItemClass.DropItemGround;
                  end;
                  exit;
               end;
               if AttackSkill.boAttack = false then exit;

               if AttackSkill.boChangeTarget then begin
                  Bo := GetViewObjectByID (AttackSkill.GetTargetID);
                  if Bo <> nil then begin
                     len := GetLargeLength (BasicData.x, BasicData.y, Bo.Posx, Bo.Posy);
                     if len > 1 then begin
                        AttackSkill.SetTargetId (aSubData.attacker, true);
                     end;
                  end;
               end;
               if isUserId (aSubData.attacker) then AttackSkill.HateHumanId := aSubData.attacker;
            end;
         end;
      FM_DEADHIT :
         begin
            if SenderInfo.id = BasicData.id then exit;
            if BasicData.Feature.rfeaturestate = wfs_die then begin Result := PROC_TRUE; exit; end;

            CurLife := 0;
            BasicData.LifePercent := 0;
            
            AttackSkill.SetTargetId (0, true);
            if HaveMagicClass.isHaveSwapMagic = false then begin
               HaveItemClass.DropItemGround;
            end;

            CommandChangeCharState (wfs_die);
         end;
      FM_SAY :
         begin
         end;
   end;
end;

procedure TMonster.Update (CurTick: integer);
var
   i : Integer;
   key : Word;
   boFlag : Boolean;
   SubData : TSubData;
   BO : TLifeObject;
   BasicObject : TBasicObject;
begin
//   inherited UpDate (CurTick);
   if (BasicData.Feature.rfeaturestate = wfs_die) and (LifeObjectState <> los_die) then begin
      LifeObjectState := los_die;
   end;
   
   case LifeObjectState of
      los_init :
         begin
            Start;
            exit;
         end;
      los_die :
         begin
            // 函脚贱
            if CurTick > DiedTick + 200 then begin
               if HaveMagicClass.isHaveSwapMagic then begin
                  if HaveMagicClass.RunHaveSwapMagic (BasicData.LifePercent, SubData) = true then begin
                     InitialEx (StrPas (@SubData.SubName));
                     SendLocalMessage (NOTARGETPHONE, FM_CHANGEFEATURE, BasicData, SubData);
                  end;
                  exit;
               end;
            end;
            if CurTick > DiedTick + 1600 then begin
               if Manager.RegenInterval = 0 then begin
                  if AttackSkill <> nil then begin
                     if AttackSkill.GetObjectBoss <> nil then begin
                        FboAllowDelete := true;
                     end;
                  end;
                  if FboAllowDelete = false then begin
                     Regen;
                  end;
                  exit;
               end;
            end;
            if CurTick > DiedTick + 800 then begin
               if Manager.RegenInterval > 0 then begin
                  FboAllowDelete := true;
                  exit;
               end;
            end;
         end;
      los_none:
         begin
            if AttackSkill <> nil then AttackSkill.ProcessNone (CurTick);
         end;
      los_escape:
         begin
            if AttackSkill <> nil then AttackSkill.ProcessEscape (CurTick);
         end;
      los_attack:
         begin
            if AttackSkill <> nil then begin
               boFlag := AttackSkill.ProcessAttack (CurTick, Self);
               if (boFlag = false) and (FboCopy = false) then begin
                  if CopiedList <> nil then begin
                     for i := 0 to CopiedList.Count - 1 do begin
                        BO := TLifeObject (CopiedList[i]);
                        BO.boAllowDelete := true;
                     end;
                  end;
               end;
            end;
         end;
      los_moveattack :
         begin
            if AttackSkill <> nil then AttackSkill.ProcessMoveAttack (CurTick);
         end;
      los_deadattack :
         begin
            if AttackSkill <> nil then AttackSkill.ProcessDeadAttack (CurTick);
         end;
      los_movework :
         begin
            if AttackSkill <> nil then AttackSkill.ProcessMoveWork (CurTick);
         end;
      los_eat :
         begin
            if AttackSkill = nil then begin
               LifeObjectState := los_none;
               exit;

⌨️ 快捷键说明

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