The Dink Network

Reply to Re: mathmod

If you don't have an account, just leave the password field blank.
Username:
Password:
Subject:
Antispam: Enter Dink Smallwood's last name (surname) below.
Formatting: :) :( ;( :P ;) :D >( : :s :O evil cat blood
Bold font Italic font hyperlink Code tags
Message:
 
 
January 27th 2006, 06:21 AM
custom_king.png
redink1
King He/Him United States bloop
A mother ducking wizard 
No.

First, you don't need those 'int' keywords, so...

if (&life == 0)
return;
&life = math_mod(&lifemax, 2);

math_mod returns the remainder of a division operation. If &lifemax is 8, 8 divided by 2 is 4 with no remainder, so it would return 0. If &lifemax was 27, 27 divided by 2 is 13 with a remainder of 1, so it would return 1. In fact, this use of math_mod will only return 0 or 1, which isn't what you're looking for.

You'd probably want to do something like this:

if (&life == 0)
return;

int &halflifemax = &lifemax;
&lifemax / 2;
&life += &halflifemax;
if (&life > &lifemax)
{
&life = &lifemax;
}