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

📄 monsterai.pas

📁 RO模拟器!!适合玩仙境传说的玩家们呦~
💻 PAS
📖 第 1 页 / 共 5 页
字号:
                  ts.HP := ts.HP + dmg[0];
                  if ts.HP > integer(ts.Data.HP) then ts.HP := ts.Data.HP;

                  WFIFOW( 0, $011a);
                  WFIFOW( 2, ts.MSKill);
                  WFIFOW( 4, dmg[0]);
                  WFIFOL( 6, ts.ID);
                  WFIFOL(10, ts.ID);
                  WFIFOB(14, 1);
                  SendBCmd(tm, ts.Point, 15);
                end;
          29: {Increase Agility}
            begin
              if ts.MLevel > 5 then begin
						    ts.speed := ts.speed - 45;
						  end else begin
						    ts.speed := ts.speed - 30;
						  end;

            end;

          51:     {Hide}
                begin
                        ProcessType := 1;
                end;


          114:    {Power Maximize}
                begin
                        ProcessType := 1;
                end;
          135:  {Cloaking}
            begin
                //When ProcessType = 1, cloaking will be handled
                xy.X := ts.Point.X;
                xy.Y := ts.Point.Y;

                if (ts.Cloaked) then begin
                    // Cloaked, so uncloak
                    ProcessType := 1;

                end else begin
                    for j1 := - 1 to 1 do begin
                        for i1 := -1 to 1 do begin
                            if ((j1 = 0) and (i1 = 0)) then continue;
                            j := tm.gat[xy.X + i1, xy.Y + j1];
                            if (j = 1) or (j = 5) then begin
                                ProcessType := 1;
                            end;
                        end
                    end;
                end;
                //if ProcessType = 0 then DebugOut.Lines.Add('Monster is too far from a wall');
            end;
          196:  {Summon Slave}
            begin
              // (ts.isLeader) and ( (MonsterMob) or ((ts.isSummon) and (SummonMonsterMob)) )then begin
                if ts.SlaveCount = 0 then begin
                  // (Random(1000) <= 10) then begin
                    WFIFOW( 0, $011a);
                    WFIFOW( 2, 196);
                    WFIFOW( 4, 1);
                    WFIFOL( 6, ID);
                    WFIFOL(10, ID);
                    WFIFOB(14, 1);
                    SendBCmd(tm, ts.Point, 15);
                    MobSpawn(tm,ts,Tick);
                  //end;
                end;
              //end;
            end;

          197:  {NPC Emotion}
                  begin
                    j := Random(31) + 1;

                    // Not sure on the exact emotion its supposed to do,
                    // So I just did it with a random emotion
                    WFIFOW(0, $00c0);
                    WFIFOL(2, ts.ID);
                    WFIFOB(6, j);
                    SendBCmd(tm, ts.Point, 7);
                  end;
          else //debugout.lines.add('[' + TimeToStr(Now) + '] ' + 'Skill ' + IntToStr(ts.MSkill) + ' Is not coded')
        end;

        case ProcessType of
                0:  //Skill Used on Oneself
                        begin
                                //Packet Process
                                WFIFOW( 0, $011a);
                                WFIFOW( 2, ts.MSKill);
                                WFIFOW( 4, dmg[0]);
                                WFIFOL( 6, ts.ID);
                                WFIFOL(10, ID);
                                WFIFOB(14, 1);
                                SendBCmd(tm, ts.Point, 15);
                        end;
                1:  //Skills Like Power Maximize
                        begin
                                WFIFOW( 0, $011a);
                                WFIFOW( 2, ts.MSKill);
                                WFIFOW( 4, ts.MLevel);
                                WFIFOL( 6, ts.ID);
                                WFIFOL(10, ts.ID);
                                WFIFOB(14, 1);
                                SendBCmd(tm, ts.Point, 15);

                                if (ts.MSKill = 51) or (ts.MSkill = 135) then begin
                                    if (ts.Hidden) or (ts.Cloaked) then begin
                                        ts.Hidden := false;
                                        ts.Cloaked := false;
                                        WFIFOW(0, $0119);
                                        WFIFOL(2, ts.ID);
                                        WFIFOW(6, 0);
                                        WFIFOW(8, 0);
    					                WFIFOW(10, 0);
    					                WFIFOB(12, 0);
    					                SendBCmd(tm, ts.Point, 13);
                                        //DebugOut.Lines.Add('Monster ' + ts.Name + ' uncloaks via Skill Cloaking!');

                                    end else begin
                                        if ts.MSkill = 135 then ts.Cloaked := true
                                        else ts.Hidden := true;
                                        WFIFOW(0, $0119);
    					                WFIFOL(2, ts.ID);
    					                WFIFOW(6, 0);
    					                WFIFOW(8, 0);
    					                WFIFOW(10, 6);
    					                WFIFOB(12, 0);
    					                SendBCmd(tm, ts.Point, 13);
                                        //DebugOut.Lines.Add('Monster ' + ts.Name + ' cloaks!');
                                    end;

                                end;
                                {
                                if (tc1.MSkill = 143) then begin
                                        if tc1.Sit = 1 then begin
						tc1.Sit := 3;
                                                SkillTick := tc1.Skill[MSkill].Tick;
                                                SkillTickID := MSkill;
                                                tc1.SP := tc1.SP + 5;
                                                if tc1.SP > tc1.MAXSP then tc1.SP := tc1.MAXSP;
                                                CalcStat(tc1, Tick);
                                        end else begin
                                                tc1.Sit := 1;
                                        end;
                                end;}

                                if (ts.MSKill = 114) then begin
                                        //debugout.lines.add('[' + TimeToStr(Now) + '] ' + 'Monster Casts Power Maximize');
                                        {if tc1.Option = 32 then begin
						//tc1.Option := tc1.Optionkeep;
                                                SkillTick := tc1.Skill[MSkill].Tick;
                                                SkillTickID := MSkill;
                                                //CalcMonsterStat(ts, Tick);
                                        end else begin
                                                tc1.Optionkeep := tc1.Option;
                                                tc1.Option := 32;
                                        end; }
                                end;

                        end;
                end;
        end;
end;

//------------------------------------------------------------------------------

procedure MobSkillDamageCalc(tm:TMap; tc:TChara; ts:TMob; Tick:cardinal);
        var
	i,j,k     :integer;
	miss      :boolean;
	crit      :boolean;
	avoid     :boolean; //姰慡夞旔
	i1,j1,k1  :integer;
	xy        :TPoint;
	ts1       :TMob;
	tn        :TNPC;
   //     tl        :TSkillDB;
begin
	if tc.TargetedTick <> Tick then begin
		if DisableFleeDown then begin
			tc.TargetedFix := 10;
			tc.TargetedTick := Tick;
		end else begin
			i := 0;
			xy := tc.Point;
			for j1 := xy.Y div 8 - 2 to xy.Y div 8 + 2 do begin
				for i1 := xy.X div 8 - 2 to xy.X div 8 + 2 do begin
					for k1 := 0 to tm.Block[i1][j1].Mob.Count - 1 do begin
            if (tm.Block[i1][j1].Mob.Objects[k1] is TMob) then begin
						ts1 := tm.Block[i1][j1].Mob.Objects[k1] as TMob;
						if (tc.ID = ts1.ATarget) and (abs(ts1.Point.X - tc.Point.X) <= ts1.Data.Range1) and
							 (abs(ts1.Point.Y - tc.Point.Y) <= ts1.Data.Range1) then Inc(i);
					end;
				end;
			end;
			end;
			//debugout.lines.add('[' + TimeToStr(Now) + '] ' + 'Targeted: ' + inttostr(i));
			if i > 12 then i := 12;
			if i < 2 then i := 2;
			tc.TargetedFix := 12 - i;
			tc.TargetedTick := Tick;
		end;
	end;

	with ts.Data do begin
                //MobSkillCalc(tm,ts,Tick);

		i := HIT - (tc.FLEE1 * tc.TargetedFix div 10) + 80;
		i := i - tc.FLEE2;
		if i < 5 then i := 5
		else if i > 95 then i := 95;

		dmg[6] := i;
		//crit := boolean((SkillPer = 0) and (Random(100) < Critical));
		crit := false;
		//avoid := boolean((SkillPer = 0) and (Random(100) < tc.Lucky));
		miss := boolean((Random(100) >= i) and (not crit));

                //Shield Reflect
                {if ((miss = False) and (tc.Skill[252].Tick > Tick)) then begin
                                tc.MSkill := 252;
                                dmg[0] := (dmg[0] * tc.Skill[252].Effect1) div 100;
                                WFIFOW( 0, $011a);
                                WFIFOW( 2, tc.MSkill);
                                WFIFOW( 4, tc.MUseLV);
                                WFIFOL( 6, tc.ID);
                                WFIFOL(10, tc.ID);
                                WFIFOB(14, 1);
                                SendBCmd(tm, tc.Point, 15);
                                WFIFOW( 0, $008a);
                                WFIFOL( 2, tc.ID);
                                WFIFOL( 6, ts.ID);
                                WFIFOL(10, timeGetTime());
                                WFIFOL(14, tc.aMotion);
                                WFIFOL(18, ts.Data.dMotion);
                                WFIFOW(22, dmg[0]); //僟儊乕僕
                                WFIFOW(24, 1); //暘妱悢
                                WFIFOB(26, 0); //0=扨峌寕 8=暋悢 10=僋儕僥傿僇儖
                                WFIFOW(27, 0); //媡庤
                                SendBCmd(tm, ts.Point, 29);
                                SendCSkillAtk1(tm, tc, ts, Tick, dmg[0], 1, 6);
                                if not DamageProcess1(tm, tc, ts, dmg[0], Tick) then
                                StatCalc1(tc, ts, Tick);
                                dmg[0] := 0;
                                dmg[5] := 11;
                end;

                if tc.AnolianReflect then begin
                      dmg[0] := (dmg[0] * 10) div 100;
                      if not DamageProcess1(tm, tc, ts, dmg[0], Tick) then
                      StatCalc1(tc, ts, Tick);
                      dmg[0] := 0;
                      dmg[5] := 11;
                end;

                //Poison React
                if ((miss = False) and (tc.Skill[139].Tick > Tick) and (ts.Data.Element = 25)) then begin
                                DamageCalc1(tm, tc, ts, Tick, 0, 0, 0, 20);
                                tc.MSkill := 139;
                                dmg[0] := (dmg[0] * tc.Skill[139].Effect1) div 100;
                                WFIFOW( 0, $011a);
                                WFIFOW( 2, tc.MSkill);
                                WFIFOW( 4, tc.MUseLV);
                                WFIFOL( 6, tc.ID);
                                WFIFOL(10, tc.ID);
                                WFIFOB(14, 1);
                                SendBCmd(tm, tc.Point, 15);
                                WFIFOW( 0, $008a);
                                WFIFOL( 2, tc.ID);
                                WFIFOL( 6, ts.ID);
                                WFIFOL(10, timeGetTime());
                                WFIFOL(14, tc.aMotion);
                                WFIFOL(18, ts.Data.dMotion);
                                WFIFOW(22, dmg[0]); //僟儊乕僕
                                WFIFOW(24, 1); //暘妱悢
                                WFIFOB(26, 0); //0=扨峌寕 8=暋悢 10=僋儕僥傿僇儖
                                WFIFOW(27, 0); //媡庤
                                SendBCmd(tm, ts.Point, 29);
                                SendCSkillAtk1(tm, tc, ts, Tick, dmg[0], 1, 6);
                                if not DamageProcess1(tm, tc, ts, dmg[0], Tick) then
                                StatCalc1(tc, ts, Tick);
                                dmg[0] := 0;
                                dmg[5] := 11;
                end; }

                //From mWeiss

		i1 := 0;
		while (i1 >= 0) and (i1 < tm.Block[tc.Point.X div 8][tc.Point.Y div 8].NPC.Count) do begin
			tn := tm.Block[tc.Point.X div 8][tc.Point.Y div 8].NPC.Objects[i1] as TNPC;
			if tn = nil then begin
				Inc(i1);
				continue;
			end;
			if (tc.Point.X = tn.Point.X) and (tc.Point.Y = tn.Point.Y) then begin
				case tn.JID of
				$7e: //僙僀僼僥傿僂僅乕儖
					begin
						miss := true;
						if not avoid then Dec(tn.Count);
						if tn.Count = 0 then begin
							DelSkillUnit(tm, tn, tc);
							Dec(i1);

⌨️ 快捷键说明

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