Page 1 of 1

Critical bug in combat system [current 96 svn]

Posted: Sun Jan 14, 2007 1:33 pm
by Bracco
while i was looking at the distro attackhook i noticed a little, but critical bug that practically breaks the whole hook...

in this function

Code: Select all

function GetArmorHit(byref d_info)
	var hit_zone := CS_GetRandomArmorZone();
	var armor_hit := CS_GetEquipmentInArmorZone(d_info.mobile, hit_zone);

	if ( armor_hit.Size() < 1 )
		return 0;
	endif

	var best_armor := 0;
	foreach item in ( armor_hit )
		if ( item.ar > best_armor.ar )
			best_armor := item;
		endif
		SleepMS(2);
	endforeach

	return best_armor;
endfunction 
there is var best_armor := 0; and then if ( item.ar > best_armor.ar )

which is terribily wrong, and causes the function to return 0 nearly always, and with 0 armor you get huge damage...

so this is the fixed function:

Code: Select all

function GetArmorHit(byref d_info)
	var hit_zone := CS_GetRandomArmorZone();
	var armor_hit := CS_GetEquipmentInArmorZone(d_info.mobile, hit_zone);

	if ( armor_hit.Size() < 1 )
		return 0;
	endif

	var best_armor := armor_hit[1];
	foreach item in ( armor_hit )
		if ( item.ar > best_armor.ar )
			best_armor := item;
		endif
		SleepMS(2);
	endforeach

	return best_armor;
endfunction 
cheers

Posted: Thu Apr 26, 2007 7:39 pm
by tekproxy
Just for my own notes, this has been fixed (a long time ago).