spikereloaded Posted December 14, 2013 Share Posted December 14, 2013 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? Quote Link to comment Share on other sites More sharing options...
Seker Posted December 14, 2013 Share Posted December 14, 2013 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. Quote Link to comment Share on other sites More sharing options...
spikereloaded Posted December 14, 2013 Author Share Posted December 14, 2013 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.