View Single Post
  #4  
Old 10-25-2008, 02:25 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

You want to check the sanity of the rule setting, to stop a crash when accessing the array if someone sets it to an invalid value:

Code:
// figure out if they should lose exp
	float GetNum [] = {0.005f,0.015f,0.025f,0.035f,0.045f,0.055f,0.065f,0.075f,0.085f,0.095f };
	int Num = RuleI(Character, DeathExpLossMultiplier);
	if((Num < 0) || (Num > 9))
		Num = 0;
	float loss = GetNum[Num];
	exploss=(int)((float)GetEXP() * (loss)); //Angelox: lose % of total XP pending rule (choose 0-9)
I would also change GetNum & Num to more meaningful names.

Last edited by Derision; 10-25-2008 at 10:30 PM..
Reply With Quote