Spells and Abilities for Fantasy RPG Using Harlowe,and making combat coding easier

+1 vote
asked Jul 14 by Lucario (220 points)

Hey there! I'm currently working on a fantasy rpg using Harlowe, and while I already have a basic combat system coded, I'm hoping there's something I could do to make this simpler. My current set up looks like this:

(if: (random: 1,20) is >$AC)[  
The monster bites you! 
(set: $player's "HP" to $player's "HP" - (random: 1,3))  
(if: $player's "HP" < 1)[ You are [[dead]]! ]  
(else:)[ Your health is (print: $player's "HP"). 
[[Fight|fight1]]]  
 ]
 
(else:)[ You hit the monster!  
(set:$zombie_hp = $zombie_hp - ($weapon's damage))
(if: $zombie_hp < 1)[ The [[zombie is dead]]! ]  
(else:)[    
Its health is $zombie_hp.
[[Fight|fight1]]] 
      
 ]

This combat system feels very basic, and I'm hoping to build onto it by adding spells, abilities and consumable items. The problem is that I am doing this by hand for every instance of combat that occurrs, and it's extremely time consuming. I was hoping that someone more experienced might be able to recommend an easier way to go about populating this information, and I was figuring that it would most likely involve the use of datamaps and arrays, and my knowledge in those areas is rudimentary at best. I could be way off the mark here, so any advice would be wizard!

 

~Lucario

1 Answer

+1 vote
answered Jul 15 by kungfuspacebarbarian (540 points)
selected Jul 16 by Lucario
 
Best answer
This combat post from reddit may help. It'll require some work on your part because this version is really simple and sets the stats at the beginning of combat, but you could mix your code in with this to create a combat this way.

At least you wouldn't need to code every fight option by hand: https://www.reddit.com/r/twinegames/comments/3mq2rs/combat_system_in_harlowe_my_twine_2_guide_3/
commented Jul 16 by Lucario (220 points)
Honestly this is so much closer to what I wanted to do, but I wasn't even sure how to go about it. It'll take a little extra work to set up for sure, but in the long run, this will definitely make my life a little easier. Plus it's more elegant that my solution to combat anyway. A marraige of my set-up with this will definitely add the spice that my combat system was lacking before now. Thanks for the tip man!

~Lucario
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.
...