← Back to context

Comment by Nition

2 hours ago

That exact sort of magic numbering is rife in games from what I've seen over the years, especially in stuff like an old RPG from 1994. Maybe you've seen better game code on average than me. But you don't even really need the "random numbers" - I'd expect a mistake like:

    GetItemChange(curVal, percentBoost) { return curVal * PERCENT_BOOST; }
    
    eqipVal = val + GetItemChange(val, percentBoost);
    // ... later...
    unequipVal = val - GetItemChange(val, percentBoost);

Edit: I see there's Realmz source code on GitHub.[1] Although I can't see anything that'd cause the specific bug PlunderBunny mentions (they did say 'early versions' so maybe it was fixed), this is the kind of thing I mean re old games and "random numbers". This is part of the Wear method for equipping items:

    if ((item.sp1 > 59) && (item.sp1 < 100))
      c[character].condition[item.sp2] = 0; /**** neutralize condition ***/
    if (item.sp1 == 122) /******** item adds attacks **********/
    {
      c[character].attackbonus += item.sp2;
    }

    if ((item.sp1 > 19) && (item.sp1 < 60)) /******* adds condition *****/
    {
      if (c[character].condition[item.sp1 - 20] > -1)
        c[character].condition[item.sp1 - 20] = 0;
      c[character].condition[item.sp1 - 20] += item.sp2; /**** make condition[sp1-20] = sp2 ***/
    }

    if (item.sp3) /******* adds special ability *****/
    {
      if (item.sp3 < 0)
        c[character].special[abs(item.sp3) - 1] += item.sp5;
      else if ((item.sp3 < 16) && (item.sp3 > 0))
        c[character].spec[item.sp3 - 1] += item.sp5;
      else
        partycondition[item.sp3 - 30] -= abs(item.sp5);
    }

    if (item.sp4) {
      if (item.sp4 < 0)
        c[character].special[abs(item.sp4) - 1] += item.sp5;
      else if ((item.sp4 < 16) && (item.sp4 > 0))
        c[character].spec[item.sp4 - 1] += item.sp5;
      else
        partycondition[item.sp4 - 30] -= abs(item.sp5);
    }
  }

[1] https://github.com/Realmz-Castle/realmz