Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How to create real time rpg battles in harlowe 2.0

its relatively easy to create rpg battles but the problems lies in you having to press fight over and over again that's boring, so I'm trying to make it so it automatically keeps pressing fight but I don't even have the slightest idea to this here's a copy of a simple rpg battle (mine is way too complex to work on):
(if: (either: 0, 1) is 0)[  
  The monster bites you! 
  (set: $hp to $hp - (either: 1,2,3))  
  (if: $hp < 1)[ You are [[dead]]! ]  
  (else:)[ Your health is $hp. 
    [[fight]] 
    [[flee|main]] ]  
]
(else:)[ You hit the monster!  
  (set:$monster_hp = $monster_hp - 1)  
  (if: $monster_hp < 1)[ The [[monster is dead]]! ]  
  (else:)[    
    Its health is $monster_hp.
    [[fight]] 
    [[flee|main]] ]  
]
say I want it to keep pressing fight automatically every 1s interval showing me you hit the monster/the monster bites you, I know I probably need to use setInterval I just don't know to properly implement it in twine

Comments

  • You could use the live macro to automatically fight again after a few seconds. Example: three seconds.
    (if: (either: 0, 1) is 0)[  
      The monster bites you! 
      (set: $hp to $hp - (either: 1,2,3))  
      (if: $hp < 1)[ You are [[dead]]! ]  
      (else:)[ Your health is $hp. 
        (live: 3s)[(goto: "fight")]
        [[flee|main]] ]  
    ]
    (else:)[ You hit the monster!  
      (set:$monster_hp = $monster_hp - 1)  
      (if: $monster_hp < 1)[ The [[monster is dead]]! ]  
      (else:)[    
        Its health is $monster_hp.
       (live: 3s)[(goto: "fight")]
        [[flee|main]] ]  
    ]
    

    So basically, after three seconds, it uses the goto macro to go to the passage called "fight" (without the double quote marks). If you can't see what I've done, I've replace where the fight link should be.
  • Deadshot wrote: »
    You could use the live macro to automatically fight again after a few seconds. Example: three seconds.
    (if: (either: 0, 1) is 0)[  
      The monster bites you! 
      (set: $hp to $hp - (either: 1,2,3))  
      (if: $hp < 1)[ You are [[dead]]! ]  
      (else:)[ Your health is $hp. 
        (live: 3s)[(goto: "fight")]
        [[flee|main]] ]  
    ]
    (else:)[ You hit the monster!  
      (set:$monster_hp = $monster_hp - 1)  
      (if: $monster_hp < 1)[ The [[monster is dead]]! ]  
      (else:)[    
        Its health is $monster_hp.
       (live: 3s)[(goto: "fight")]
        [[flee|main]] ]  
    ]
    

    So basically, after three seconds, it uses the goto macro to go to the passage called "fight" (without the double quote marks). If you can't see what I've done, I've replace where the fight link should be.
    thanks it works as well

Sign In or Register to comment.