找回密码
 点一下
查看: 1272|回复: 4

一个随机触发问题````````

[复制链接]
发表于 2010-9-25 22:05:23 | 显示全部楼层 |阅读模式
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2010-9-25 22:53:54 | 显示全部楼层
[edit] 大家可以無視這個回复.......

    Events

        Timer - Elapsed time is 10.0 Game Time seconds
    Local Variables
    Conditions
    Actions
        General - Switch (Actions) depending on (Random integer between 1 and 3)
            Cases
                General - If (1)
                    Actions
                        Trigger - Run Untitled Trigger 001  (Check Conditions, Don't Wait until it finishes)
                        General - Wait 10.0 Game Time seconds
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                (Random integer between 1 and 2) == 1
                            Then
                                Trigger - Run Untitled Trigger 002  (Check Conditions, Don't Wait until it finishes)
                                General - Wait 10.0 Game Time seconds
                                Trigger - Run Untitled Trigger 003  (Check Conditions, Don't Wait until it finishes)
                            Else
                                Trigger - Run Untitled Trigger 003  (Check Conditions, Don't Wait until it finishes)
                                General - Wait 10.0 Game Time seconds
                                Trigger - Run Untitled Trigger 002  (Check Conditions, Don't Wait until it finishes)
                General - If (2)
                    Actions
                        Trigger - Run Untitled Trigger 002  (Check Conditions, Don't Wait until it finishes)
                        General - Wait 10.0 Game Time seconds
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                (Random integer between 1 and 2) == 1
                            Then
                                Trigger - Run Untitled Trigger 003  (Check Conditions, Don't Wait until it finishes)
                                General - Wait 10.0 Game Time seconds
                                Trigger - Run Untitled Trigger 001  (Check Conditions, Don't Wait until it finishes)
                            Else
                                Trigger - Run Untitled Trigger 001  (Check Conditions, Don't Wait until it finishes)
                                General - Wait 10.0 Game Time seconds
                                Trigger - Run Untitled Trigger 003  (Check Conditions, Don't Wait until it finishes)
                General - If (3)
                    Actions
                        Trigger - Run Untitled Trigger 003  (Check Conditions, Don't Wait until it finishes)
                        General - Wait 10.0 Game Time seconds
                        General - If (Conditions) then do (Actions) else do (Actions)
                            If
                                (Random integer between 1 and 2) == 1
                            Then
                                Trigger - Run Untitled Trigger 002  (Check Conditions, Don't Wait until it finishes)
                                General - Wait 10.0 Game Time seconds
                                Trigger - Run Untitled Trigger 001  (Check Conditions, Don't Wait until it finishes)
                            Else
                                Trigger - Run Untitled Trigger 002  (Check Conditions, Don't Wait until it finishes)
                                General - Wait 10.0 Game Time seconds
                                Trigger - Run Untitled Trigger 001  (Check Conditions, Don't Wait until it finishes)
            Default
回复

使用道具 举报

发表于 2010-9-26 01:27:16 | 显示全部楼层
你这样实在太长了。而且可读性比较糟糕。



下面这段代码就足够搞定。

[trigger]
Run
    Events
        Timer - Every 10.0 seconds of Game Time
    Local Variables
        Rnd = 0 <Integer>
    Conditions
        (Number of times (Current trigger) has been executed) < 3
    Actions
        General - Repeat (Actions) forever
            Actions
                Variable - Set Rnd = (Random integer between 1 and 3)
                General - If (Conditions) then do (Actions) else do (Actions)
                    If
                        Selected[Rnd] == false
                    Then
                        Variable - Set Selected[Rnd] = true
                        General - Break
                    Else
        Trigger - Run T[Rnd]  (Check Conditions, Don't Wait until it finishes)
[/trigger]

T是一个长度为4的Trigger型数组。T[1]到T[3]的值在地图初始化时设定。T1 T2 T3是要执行的触发器。
Variable - Set T[1] = T1
Variable - Set T[2] = T2
Variable - Set T[3] = T3

另外声明一个叫Selected的boolean型数组,长度为4.
回复

使用道具 举报

发表于 2010-9-26 09:05:39 | 显示全部楼层
雖然不會寫觸發~Renee的例子~很清晰的思路的說~
做一個數組→[隨機它的下標→Call各自的觸發器]每10S
回复

使用道具 举报

发表于 2010-9-26 10:52:58 | 显示全部楼层
sorry, 我上面的方法其實是因為懶, 所以省了不用任何 variable / array. 而且只是 copy & paste 幾次再改一改數字. 其實你留心看思路是很簡單直接的.

當然, 如果要造四五個以上的 random trigger 步驟, 頭目的方法會比較有效率.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-12-23 08:22 , Processed in 0.033357 second(s), 18 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表