Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
cursed itr [Signed 32-bit 2^32-1]
#13
possible explanation for [regaining hp over the limit of 500]
tl;dr:
the dark and max hp values are stored as an unsigned ints, and when the character first dies, the dark and max hp values are "less" than the current hp value, and so is set to the hp value (but since it is an unsigned int, it is "more"). when the character revives, his hp continuously regens

Code:
Tag        | Hex            | Dec    |
--------------------------------|
HP        | 00 00 01 F4    | 500    |
Dark HP    | 00 00 01 F4    | 500    |
Max HP    | 00 00 01 F4    | 500    |

// perform first itr
injury ->    80 00 00 00    // -2147483648

// we perform the subtraction
      00 00 01 F4
    - 80 00 00 00
    = 80 00 01 F4    // -2147483148 (not the same as the itr value)

// logic: hp = hp - (unsigned int) injury; // implicit cast

>> insert crazy logic here
// hypothetical, max hp and hp must be stored as unsigned ints
if (dark hp < hp) {
    dark hp = hp;
}
if (max hp < hp) {
    max hp = hp;
}
>> done logic

HP        | 80 00 01 F4    |  -2147483148    |
Dark HP    | 00 00 01 F4    |  2147484148    |
Max HP    | 00 00 01 F4    |  2147484148    |

// perform second itr
injury ->    80 00 00 00    // -2147483648

// we perform the subtraction
      80 00 01 F4
    - 80 00 00 00
    = 00 00 01 F4

HP        | 00 00 01 F4    | 500    |    // back to normal
Dark HP    | 00 00 01 F4    | 2147484148    |
Max HP    | 00 00 01 F4    | 2147484148    |

// tada: "unlimited" hp regen

doesn't address the mp issues though, probably more crazy logic



Azriel~
Reply
Thanks given by: YinYin


Messages In This Thread
cursed itr [Signed 32-bit 2^32-1] - by YinYin - 02-23-2012, 05:13 PM
RE: cursed itr - by Gad - 02-23-2012, 06:04 PM
RE: cursed itr - by YinYin - 02-23-2012, 06:48 PM
RE: cursed itr - by Gad - 02-23-2012, 06:56 PM
RE: cursed itr - by YinYin - 02-23-2012, 07:08 PM
RE: cursed itr - by Gad - 02-23-2012, 07:23 PM
RE: cursed itr - by Madara Uchiha - 02-23-2012, 08:40 PM
RE: cursed itr - by Gad - 02-23-2012, 09:52 PM
RE: cursed itr - by Silverthorn - 02-23-2012, 10:27 PM
RE: cursed itr - by YinYin - 02-24-2012, 11:03 PM
RE: cursed itr - by TheNave - 02-25-2012, 12:38 AM
RE: cursed itr - by YinYin - 02-25-2012, 09:15 AM
RE: cursed itr - by Azriel - 02-25-2012, 12:52 PM
RE: cursed itr - by YinYin - 02-26-2012, 05:09 PM
RE: cursed itr - by Azriel - 02-27-2012, 07:54 AM
RE: cursed itr - by YinYin - 02-27-2012, 09:24 AM
RE: cursed itr - by mfc - 04-05-2012, 07:08 PM
RE: cursed itr - by Silverthorn - 04-05-2012, 07:53 PM
RE: cursed itr - by mfc - 03-19-2015, 02:39 PM



Users browsing this thread: 1 Guest(s)