Magic

Magic

190k Downloads

Attributes giving arbitrary/irrational values

NightScythe1 opened this issue ยท 2 comments

commented

2023-03-03_02 42 07

tenet_oceanic:
  name: Oceanic Tenet
  description: Spend time in Water. Avoid leaving the water.
  triggers:
    - trigger: interval
      interval: 10000
  actions:
    cast:
    - class: CheckBlock
      allowed: water
      source_location: feet
      actions:
        - class: ModifyAttribute
          attribute: deity_favour
          bypass_undo: true
          value: "x+0.6"
      fail:
        - class: CheckRequirements
          requirements:
            - attributes:
              - attribute: deity_favour
                min: 1
          actions:
            - class: ModifyAttribute
              attribute: deity_favour
              bypass_undo: true
              value: "x-0.2"
  parameters:
    target: self

when using the above spell, the player should gain 0.6 attribute for every 10 seconds spent in water, and lose 0.2 attribute every 10 seconds out of water, but it seems that it's not adding/removing exactly 0.2 or 0.6 and over time it winds up with these strange values. The 0.6 and 0.2 are the only things able to change/alter this attribute right now

commented
commented

I've encountered these before when using operations that may result in irrational values like these, such as multiplication by decimals/floating point. But the part that's baffling me here is the only functions/operations/values are completely rational/normal numbers (I'm only incrementing by adding or subtracting 0.6 or 0.2 exactly) so I can't understand where the spell is gaining or losing these specific extra numbers. For example this triggers every 10 seconds, so it would be expected that after 10 seconds out of water the Attribute would decrease from 10.0 to 9.8 but instead it will fall to something like 9.79999999 or 9.80000001 etc. It's strange because there's no reason the function should need to round anything, if that's the error i'm encountering