Critical bug in combat system [current 96 svn]

Open discussion forum. For topics that do not fit anywhere else.
Locked
Bracco
Adept Poster
Posts: 80
Joined: Thu Dec 28, 2006 11:52 am

Critical bug in combat system [current 96 svn]

Post 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
User avatar
tekproxy
Forum Regular
Posts: 352
Joined: Thu Apr 06, 2006 5:11 pm

Post by tekproxy »

Just for my own notes, this has been fixed (a long time ago).
Locked