Jump to content
MakeWebGames

working on attack


spikereloaded

Recommended Posts

Hey guys

i'm working on changing the attack system on our game and have come across quite a few odd things in the attack.php file, but this one has got me a little confused.

 

	if($mydamage < -100000) {
		$mydamage=abs($mydamage); 
	}

	else if($mydamage < 1) {
		$mydamage=1; 
	}

 

can anyone give me some idea about what the point of these two bits are. i just find it confusing that the top one will convert it into a positive number if it is less than -100000 making -900 change to 900 but then the second one says that if it is less than 1 damage equals 1....

am i just being slow here?

Link to comment
Share on other sites

Hey guys

i'm working on changing the attack system on our game and have come across quite a few odd things in the attack.php file, but this one has got me a little confused.

 

	if($mydamage < -100000) {
		$mydamage=abs($mydamage); 
	}

	else if($mydamage < 1) {
		$mydamage=1; 
	}

 

can anyone give me some idea about what the point of these two bits are. i just find it confusing that the top one will convert it into a positive number if it is less than -100000 making -900 change to 900 but then the second one says that if it is less than 1 damage equals 1....

am i just being slow here?

While it's poor implementation, there is reason behind it.

The damage is calculated using INT.

Therefore, if the number goes above 2.1 billion (Whatever the exact cap is) it'll change to a negative.

So, a negative number doesn't always mean it's actually less than 0.

Better to just cast certain values as float.

At least, that's what I'm assuming it's about.

The number itself doesn't make much sense to me, as a negative 2 bil+ would not be higher than 10,000.

Link to comment
Share on other sites

i can't say i have much admiration for the work that the guys did on this engine. OK it's a good base to start from but i've found so many weird and wonderful (or not) coding techniques in the source. and absolutely no explanations...it's not the hardest thing to comment whilst coding.

Thanks Seker, i'll keep that in mind while i try to decrypt this attack page!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...