OK論壇

 找回密碼
 註冊
12
返回列表 發新帖
樓主: 樂奇

問題1:交換物品時..有機率得到不同物品 // 問題2 裝備物品限制

 關閉 [複製鏈接]
  • TA的每日心情
    開心
    2024-9-22 07:14 PM
  • 簽到天數: 238 天

    連續簽到: 1 天

    [LV.7]常住居民III

    發表於 2009-8-7 12:38:27 | 顯示全部樓層
    爬文區找幾次了

    你說的script_commands.txt
    真的一點都看不懂=_=

    希望有人可以給我看到例子
    多謝指點
    樂奇 發表於 2009-8-7 03:47 AM

    看例子就是在幫你寫了
    回復 支持 反對

    使用道具 舉報

  • TA的每日心情
    開心
    2010-9-5 08:41 PM
  • 簽到天數: 1 天

    連續簽到: 0 天

    [LV.1]初來乍到

    發表於 2009-8-7 12:56:45 | 顯示全部樓層
    *rand(<number>{,<number>});
    This function returns a number, randomly positioned between 0 and the number you
    specify (if you only specify one) and the two numbers you specify if you give it
    two.

    rand(10) would result in 0,1,2,3,4,5,6,7,8 or 9

    rand(2,10) would result in 2,3,4,5,6,7,8,9 or 10
    *set <variable>,<expression>;
    This command will set a variable to the value that the expression results in.
    This is the only way to set a variable directly.

    This is the most basic script command and is used a lot whenever you try to do anything more advanced than just printing text into a messagebox.

        set @x,100;
       
    will make @x equal 100.

        set @x,1+5/8+9;
       
    will compute 1+5/8+9 (which is, surprisingly, 10 - remember, all numbers are integer in this language) and make @x equal it.

    Returns the variable reference (since trunk r12870).
    *if (<condition>) <statement>;
    This is the basic conditional statement command, and just about the only one available in this scripting language.

    The condition can be any expression. All expressions resulting in a non-zero value will be considered True, including negative values. All expressions resulting in a zero are false.

    If the expression results in True, the statement will be executed. If it isn't true, nothing happens and we move on to the next line of the script.

        if (1)  mes "This will always print.";
        if (0)  mes "And this will never print.";
        if (5)  mes "This will also always print.";
        if (-1) mes "Funny as it is, this will also print just fine.";

    For more information on conditional operators see the operators section above.
    Anything that is returned by a function can be used in a condition check without bothering to store it in a specific variable:

        if (strcharinfo(0)=="Daniel Jackson") mes "It is true, you are Daniel!";

    More examples of using the 'if' command in the real world:

    Example 1:

            set @var1,1;
            input @var2;
            if(@var1==@var2) goto L_Same;
            mes "Sorry that is wrong";
            close;
        L_Same:
            close;

    Example 2:
       
        set @var1,1;
        input @var2;
        if(@var1!=@var2) mes "Sorry that is wrong";
        close;

    (Notice examples 1 and 2 have the same effect.)

    Example 3:

        set @var1,@var1+1;
        mes "[Forgetfull Man]";
        if (@var==1) mes "This is the first time you have talked to me";
        if (@var==2) mes "This is the second time you have talked to me";
        if (@var==3) mes "This is the third time you have talked to me";
        if (@var==4) mes "This is the forth time you have talked to me, but I think I am getting amnesia, I have forgoten about you";
        if (@var==4) set @var,0;
        close;

    Example 4:

            mes "[Quest Person]";
            if(countitem(512)>=1) goto L_GiveApple;
            // The number 512 was found from item_db, it is the item number for the Apple.
            mes "Can you please bring me an apple?";
            close;
        L_GiveApple:
            mes "Oh an apple, I didnt want it, I just wanted to see one";
            close;

    Example 5:

            mes "[Person Checker]";
            if($name$!=null) goto L_Check;
            mes "Please tell me someones name";
            next;
            input $name$;
            set $name2$,strcharinfo(0);
            mes "[Person Checker]";
            mes "Thank you";
        L_Check:
            if($name$==strcharinfo(0) ) goto L_SameName;
            mes "[Person Checker]";
            mes "You are not the person that " +$name2$+ " mentioned";
        L_End:
            set $name$,null;
            set $name2$,null;
            close;
        L_SameName:
            mes "[Person Checker]";
            mes "You are the person that " +$name2$+ " just mentioned";
            mes "nice to meet you";
            goto L_End;

    See 'strcharinfo' for explanation of what this function does.

    Example 6: Using complex conditions.

            mes "[Multi Checker]";
            if( (@queststarted==1) && (countitem(512)>=5) ) goto L_MultiCheck;
            // Only if the quest has been started AND You have 5 apples will it goto "L_MultiCheck"
            mes "Please get me 5 apples";
            set @queststarted,1;
            close;
        L_MultiCheck:
            mes "[Multi Checker]";
            mes "Well done you have started the quest of got me 5 apples";
            mes "Thank you";
            set @queststarted,0;
            delitem 512,5;
            close;

    With the Advanced scripting engine, we got nested if's. That is:

    if (<condition>)
            dothis;
    else
            dothat;
           
    If the condition doesn't meet, it'll do the action following the else.
    We can also group several actions depending on a condition, the following way:

    if (<condition)
    {
            dothis1;
            dothis2;
            dothis3;
    } else {
            dothat1;
            dothat2;
            dothat3;
            dothat4;
    }

    Remember that if you plan to do several actions upon the condition being false, and you forget to use the curlies (the { } ), the second action will be executed regardless the output of the condition, unless of course, you stop the execution of the script if the condition is true (that is, in the first grouping using a return; , and end; or a close; )

    Also, you can have multiple conditions nested or chained, and don't worry about limits as to
    how many nested if you can have, there is no spoon ;)

    ...
    if (<condition 1>)
            dothis;
    else if (<condition 2>)
    {
            dotheother;
            do that;
            end;
    } else
            do this;
    ...
    1. set .@rand,rand(3);
    2. if(.@rand == 0) mes ".@rand變數等於0";
    3. else if(.@rand == 1) mes ".@rand變數等於1";
    4. else mes ".@rand變數等於2";
    5. close;
    複製代碼
    回復 支持 反對

    使用道具 舉報

  • TA的每日心情
    慵懶
    2013-7-11 12:09 AM
  • 簽到天數: 118 天

    連續簽到: 1 天

    [LV.6]常住居民II

    發表於 2009-8-7 13:24:07 | 顯示全部樓層
    你寫(@gi ==50)
    意思是:他從1~100個亂數中,當挑到50的時候才會獲得
    所以是=1%機率
    要寫>=,或者<=
    回復 支持 反對

    使用道具 舉報

    您需要登錄後才可以回帖 登錄 | 註冊

    本版積分規則

    Archiver|手機版|小黑屋|OK討論區

    GMT+8, 2025-6-30 07:27 PM , Processed in 0.189863 second(s), 16 queries , Gzip On.

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

    快速回復 返回頂部 返回列表