Boolean Values != floating point

Post Reply
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Boolean Values != floating point

Post by perrinoia »

All of the following functions are written as if damage level is a Boolean value (true or false, 1 or 0).
Glitch wrote:function Repair(%targetPlayer, %sourcePlayer)

Code: Select all

	if(GameBase::getDamageLevel(%targetPlayer))
function SuperRepairBolt::checkDone(%this, %player)

Code: Select all

			if(GameBase::getDamageLevel(%player) == 0)
function RepairBolt::checkDone(%this, %player)

Code: Select all

			if(GameBase::getDamageLevel(%player) == 0) 
function RepairKit::onCollision(%this,%object)

Code: Select all

		if(GameBase::getDamageLevel(%object) != 0)
They should be checking if the damage level is less than or equal to 0 (GameBase::getDamageLevel(%targetPlayer) <= 0), or 0 is less than the damage level (0 < GameBase::getDamageLevel(%targetPlayer), because damage levels are actually floating point (positive or negative numbers with decimal values).
Fix wrote:function Repair(%targetPlayer, %sourcePlayer)

Code: Select all

	if(0 < GameBase::getDamageLevel(%targetPlayer))
function SuperRepairBolt::checkDone(%this, %player)

Code: Select all

			if(GameBase::getDamageLevel(%player) <= 0)
function RepairBolt::checkDone(%this, %player)

Code: Select all

			if(GameBase::getDamageLevel(%player) <= 0) 
function RepairKit::onCollision(%this,%object)

Code: Select all

		if(0 < GameBase::getDamageLevel(%object))
I believe this will fix the repair glitch, but I've never been able to successfully demonstrate the glitch myself, so I'm not 100% sure this is the solution. Either way, I am 100% sure this will not make it worse, as it is the proper way to write the code that was intended in the first place.
Image
User avatar
DaJ4ck3L
Crow{OZ}
Posts: 3375
Joined: Thu Jul 22, 2010 11:51 pm
Contact:

Re: Boolean Values != floating point

Post by DaJ4ck3L »

I'll test it out and see what it produces.
Image
Post Reply