float MaxHealthPotionForCharacter(ref chref, ref idx,float hlost) { float ftmp; bool isFinded = false; idx = -1; aref chritems; makearef(chritems, chref.items); int n; for(int i = 0; i < GetAttributesNum(chritems); i++) { if(sti(GetAttributeValue(GetAttributeN(chritems, i))) > 0) { n = GetItemIndex(GetAttributeName(GetAttributeN(chritems, i))); if(CheckAttribute(&Items[n],"potion")) { if(CheckAttribute(&Items[n],"potion.health")) { if(isFinded) { if( (ftmp < hlost)&&(stf(Items[n].potion.health)>ftmp)||(stf(Items[n].potion.health)hlost) ) { ftmp = stf(Items[n].potion.health); idx = n; } }else{ ftmp = stf(Items[n].potion.health); isFinded = true; idx = n; } } } } } if(!isFinded) return 0.0; return ftmp; }