2012-11-22 30 views
1

我想在我的Inform7游戏中做一个功能:Inform7:如何在inform7的特定情况下创建随机机会事件?

当玩家决定通过北行去穿过人行横道时,第一次叙述者会向玩家表明玩家有机会将会死亡,如果玩家再次向北输入,那么该事件将会发生,并且在1比2成功的随机几率中,玩家将能够去花园。 像这样:

 Instead of going north in the road for the second time when a random chance of 1 in 2 succeeds: 
     say "Yay! You made it!"; 
     now the player is in the Garden. 

     otherwise: 
     say "The car crashed you instantly - without any hope, you lost your whole strength in your body…"; 
     end the game in death. 

是的,这个代码不工作..任何人都可以帮助我弄清楚如何使这项工作?

回答

4

有两个问题与此代码:

  1. 告知不允许for the second timewhen条款。 (你可以反过来写,就像“第二次成功时1次随机成功的次数”,但这意味着不同的东西:它会在第二次随机机会成功时触发规则,即是,第二次玩家幸存过马路。)

  2. otherwise必须是if声明的一部分;它不能与when子句一起使用。

修复代码,你可以移动“随机机会”条件为if语句,然后更改标点符号这样的两种选择都相同规则的一部分:

[I added these lines to make a complete example...] 
Road is a room. 

Garden is a room, north of Road. 

Instead of going north in the road for the first time: 
    say "The road looks dangerous. You hesitate a moment, unsure if you really want to take the risk." 

[And here's the fixed rule:] 
Instead of going north in the road for the second time: 
    if a random chance of 1 in 2 succeeds: 
     say "Yay! You made it!"; 
     now the player is in the Garden; 
    otherwise: 
     say "The car crashed you instantly - without any hope, you lost your whole strength in your body…"; 
     end the game in death.
相关问题