Howdy, Stranger!

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

Little help with my combat system (Harlowe)

edited February 2016 in Help! with 2.0
So, i'm trying to make a fight system for my story/game that's proving to be a little too deep for me to handle. I want to have body parts being damaged until one dies instead of HP bars; for that, i'm using a datamap containing the anatomy of the enemy (besides the one for the player, of course), and i need to refer to its contents through variables so i can use the same damage calculation passage for every enemy - at least that! Cause i'm already in need of a single passage for the construction of every specific enemy. That's a different issue, however.
I made this little test that illustrates my problem:

(set: $anatomy to (datamap: "skull", 0, "lEye", 0, "rEye", 0))
(set: $area to "skull")
(set: $area of $anatomy to 1)
(if: "skull" of $anatomy is 1)[It works!](else:)[Weird...]

(set: $bArmor to (datamap: "skull", 2, "lEye", 0, "rEye", 0))
(set: $block to 0)
(set: $block to it + $area of $bArmor)
$block

The first code is the problem itself. The second one works (i get a 2 for $block).
In the first one, i need to refer to the element "skull" of the datamap "$anatomy" but i can't say "skull" directly, because it could be the tail of a rat and some enemies won't have a tail; since in the actual project, the datamap associated with $anatomy is determined along with the enemy engaged, long before this passage.
Oddly enough, this line from the second code - which check for body parts that have armor and add that armor to $block - works perfectly:
(set: $block to it + $area of $bArmor)
That's almost the same thing i need to do here:
(set: $area of $anatomy to 1)
And can't, because it returns an error along with my "weird" message (indicating that he understood the "if" part of the first code).
I feel like it's only a syntax issue but can't figure which!
Thank you so much (:

Comments

  • Well, i think the "weird" thing don't means much really lol
  • As you found out the of operator/keyword does not work everywhere, in your case in a (set:) macro. I don't know if that is a bug or not but I suggest you create a new issue on the Harlowe project website about it.

    If you read the Array data section of the Harlowe manual you will see the $array's ($pos - 3) example showing that you can use variables to access the elements of an array, this technique also works with datamaps.
    (set: $anatomy to (datamap: "skull", 0, "lEye", 0, "rEye", 0))
    (set: $area to "skull")
    $area: (print: $anatomy's ($area))
    
    (set: $anatomy's ($area) to 1)
    $area: (print: $anatomy's ($area))
    
    (if: $anatomy's ($area) is 1)[It works!](else:)[Weird...]
    
  • This solves! Thank you very much, good sire :D
Sign In or Register to comment.