夜游神 发表于 2022-12-31 21:09:07

元宝灵符掷骰子脚本-战神引擎


program mir2;


procedure removeAbil(strid : string);
var pName : string;
begin
        This_Player.sets(12,21, strtoint(strid));
        pName:=ReadIniSectionStr('骰王名单.txt','id', strid);
        if (pName <> '') and (This_Player.FindPlayer(pName) <> false) then
        begin
                This_Player.FindPlayerByName(pName).AddPlayerAbil(0, This_Player.MaxDC + 10, 0);
                This_Player.FindPlayerByName(pName).AddPlayerAbil(0, This_Player.MaxMC + 10, 0);
                This_Player.FindPlayerByName(pName).AddPlayerAbil(0, This_Player.MaxSC + 10, 0);
                This_Player.FindPlayerByName(pName).PlayerDialog('你的骰王已被玩家<'+This_Player.Name+'>占领!1.2倍属性消失');
                This_Player.FindPlayerByName(pName).sets(12,21, -1);
        end;       
        WriteIniSectionStr('骰王名单.txt','id', strid, This_Player.Name);
        This_Player.AddPlayerAbil(0, This_Player.MaxDC/100*12, 65535);
        This_Player.AddPlayerAbil(1, This_Player.MaxMC/100*12, 65535);
        This_Player.AddPlayerAbil(2, This_Player.MaxSC/100*12, 65535);
        This_Npc.NpcDialog(This_Player,
        '骰子的点数为:《豹子》 ' + inttostr(This_Player.GetS(12,5)) + ',' + inttostr(This_Player.GetS(12,6)) + ','+ inttostr(This_Player.GetS(12,7))+',\'
        +'获得了1.2倍攻魔道属性'
        );
end;

//先直接根据配平,给出三个骰子扔出的总和
function GetRandomDiceTotal() : Integer;
var temp1 : integer;
    temp2 : integer;   
begin
temp1 := random(500)+1;
Result := 0;
if temp1 = 500 then    //设置1/500的概率出现三个1或者三个6
begin
temp2 := random(2);
    if temp2 = 1 then
    begin
      Result := 3;
    end
    else
    begin
      Result := 18;
    end;
end
else if temp1 <= 40 then   //设置8%的概率结果为4、5、16、17
begin
    temp2 := random(4)+1;
    if temp2 = 1 then
    begin
      Result := 4;
    end
    else if temp2 = 2 then
    begin
      Result := 5;
    end
    else if temp2 = 3 then
    begin
      Result := 16;
    end
    else if temp2 = 4 then
    begin
      Result := 17;
    end;      
end
else if temp1 <= 155 then   //设置23%的概率结果为6、7、14、15
begin
    temp2 := random(4)+1;
    if temp2 = 1 then
    begin
      Result := 6;      
    end
    else if temp2 = 2 then
    begin
      Result := 7;      
    end
    else if temp2 = 3 then
    begin
      Result := 14;      
    end
    else if temp2 = 4 then
    begin
      Result := 15;      
    end;      
end
else                     //设置余下69%的概率结果为8--13
begin
    Result := 8 + random(6);      
end;
end;

procedure SetAllDice();
var
dice_num : Integer;
dice1 : integer;
dice2 : integer;
dice3 : integer;
temp1 : integer;         //临时记录后2个骰子的计算和
temp2 : integer;         //临时记录最后一个骰子的计算结果
begin
dice_num := GetRandomDiceTotal();       //取得三个骰子的和
dice1 := Random(6) + 1;
dice2 := Random(6) + 1;
temp1 := dice_num - dice1;
temp2 := temp1 - dice2;

//处理第一个骰子随机值出来后,用三个骰子的和减去该值,如后2个骰子之和小于2,则证明第一个骰子取值过大,自减一继续计算直到符合条件退出循环   
while (temp1 < 2) do      
begin
    dice1 := dice1 - 1;
    temp1 := dice_num - dice1;
    temp2 := temp1 - dice2;
end;
//处理第一个骰子随机值出来后,用三个骰子的和减去该值,如后2个骰子之和大于12,则证明第一个骰子取值过小,自加一继续计算直到符合条件退出循环
while (temp1 > 12) do
begin
    dice1 := dice1 + 1;
    temp1 := dice_num - dice1;
    temp2 := temp1 - dice2;
end;
//第一个骰子已决定,计算处理第二个骰子的值
//用三个骰子之和减去前两个骰子的值,判断第三个骰子的值是否在1至6中间
//该值小于1,则说明第二个骰子取值过大,需要自减1
//该值大于6,则说明第二个骰子取值过小,需要自加1
while (temp2 < 1) do
begin
    dice2 := dice2 - 1;
    temp2 := temp1 - dice2;
end;
while (temp2 > 6) do
begin
    dice2 := dice2 + 1;
    temp2 := temp1 - dice2;
end;
//循环退出,三个骰子值均计算得出,重新赋给骰子界面
//用11号活动的5、6、7变量分别记录1-3个骰子的结果
dice3 := temp2;         
This_Player.SetV(0,1,dice1);
This_Player.SetV(0,2,dice2);
This_Player.SetV(0,3,dice3);

This_Player.SetS(12,5,dice1);
This_Player.SetS(12,6,dice2);
This_Player.SetS(12,7,dice3);

end;

procedure _AfterPlayDice();
var dice1 : Integer;
    dice2 : Integer;
    dice3 : Integer;
    dice_num : Integer;
begin
if (CompareText(This_Player.MapName, 'em002~60') <> 0) or (This_Player.GetS(12, 2) < 60) then
   This_Npc.CloseDialog(This_Player);
   
dice1 := This_Player.GetS(12, 5);
dice2 := This_Player.GetS(12, 6);
dice3 := This_Player.GetS(12, 7);
dice_num := dice1 + dice2 + dice3;
if (dice1 > 0) and (dice2 > 0) and (dice3 > 0) then
begin
    //清空骰子的设值
    This_Player.SetV(0, 1, 0);
    This_Player.SetV(0, 2, 0);
    This_Player.SetV(0, 3, 0);   
    //显示骰子值给予奖励的过程
        if (This_Player.GetS(12,5) = 1) and (This_Player.GetS(12,6) = 1) and (This_Player.GetS(12,7) = 1) then       
        removeAbil(inttostr(This_Player.GetS(12,5)))       
        else
        if (This_Player.GetS(12,5) = 2) and (This_Player.GetS(12,6) = 2) and (This_Player.GetS(12,7) = 2) then       
        removeAbil(inttostr(This_Player.GetS(12,5)))
        else
        if (This_Player.GetS(12,5) = 3) and (This_Player.GetS(12,6) = 3) and (This_Player.GetS(12,7) = 3) then       
        removeAbil(inttostr(This_Player.GetS(12,5)))
        else
        if (This_Player.GetS(12,5) = 4) and (This_Player.GetS(12,6) = 4) and (This_Player.GetS(12,7) = 4) then       
        removeAbil(inttostr(This_Player.GetS(12,5)))
        else
        if (This_Player.GetS(12,5) = 5) and (This_Player.GetS(12,6) = 5) and (This_Player.GetS(12,7) = 5) then       
        removeAbil(inttostr(This_Player.GetS(12,5)))
        else
        if (This_Player.GetS(12,5) = 6) and (This_Player.GetS(12,6) = 6) and (This_Player.GetS(12,7) = 6) then       
        removeAbil(inttostr(This_Player.GetS(12,5)))       
        else
        This_Npc.NpcDialog(This_Player,
        '骰子的点数为: ' + inttostr(This_Player.GetS(12,5)) + ',' + inttostr(This_Player.GetS(12,6)) + ','+ inttostr(This_Player.GetS(12,7))+',\'
        +' 请继续努力!'
        );       
end;
This_Player.SetS(12,12,0);
This_Player.SetS(12,5,0);
This_Player.SetS(12,6,0);
This_Player.SetS(12,7,0);

end;

procedure _gotoDice;
begin
        if This_Player.YBNum < 100 then
        begin
        This_Npc.NpcDialog(This_Player, '你没有100元宝');
        exit;
        end;
        This_Player.ScriptRequestSubYBNum(100);
       
        This_Npc.CloseDialog(This_Player);
        This_Player.SetS(12,12, 1);
        SetAllDice();
        This_Npc.PlayDice(This_Player, 3,'@AfterPlayDice');
end;

procedure _setSuperVal;
var point : integer;
begin
        if This_Player.MyLFnum < 10 then
        begin
        This_Npc.NpcDialog(This_Player, '你没有10灵符');
        exit;
        end;
        This_Player.DecLF(0, 10, false);
       
        This_Npc.CloseDialog(This_Player);
        This_Player.SetS(12,12, 1);
        point := random(6) + 1;
       
        This_Player.SetV(0,1, point);
        This_Player.SetV(0,2, point);
        This_Player.SetV(0,3, point);

        This_Player.SetS(12,5, point);
        This_Player.SetS(12,6, point);
        This_Player.SetS(12,7, point);       
        This_Npc.PlayDice(This_Player, 3,'@AfterPlayDice');
end;

procedure domain;
var i : integer;
pName : arrayof string;
begin
        for i:=1 to 6 do
        begin
                pName:=ReadIniSectionStr('骰王名单.txt','id', inttostr(i));
                if pName <> '' then               
                else
                pName:='   暂无   ';
        end;       
       
        This_Npc.NpcDialog(This_Player,
        '骰王111 <1.2倍攻魔道> 当前骰王:【<'+pName+'/fcolor=250>】'+
        '|骰王222 <1.2倍攻魔道> 当前骰王:【<'+pName+'/fcolor=251>】'+
        '|骰王333 <1.2倍攻魔道> 当前骰王:【<'+pName+'/fcolor=252>】'+
        '|骰王444 <1.2倍攻魔道> 当前骰王:【<'+pName+'/fcolor=253>】'+
        '|骰王555 <1.2倍攻魔道> 当前骰王:【<'+pName+'/fcolor=254>】'+
        '|骰王666 <1.2倍攻魔道> 当前骰王:【<'+pName+'/fcolor=255>】'+       
        '|{cmd}<xxx元宝摇一次/@gotoDice>        <xxx灵符直接摇豹子/@setSuperVal>'
        )
end;

begin
    if This_Player.getS(12,12) > 0 then
        This_Npc.NpcDialog(This_Player, '你正在摇骰子,请稍候!')
        else
        domain;
end.

Chinese.Doll 发表于 2023-12-27 07:36:40

积分任务
页: [1]
查看完整版本: 元宝灵符掷骰子脚本-战神引擎