function generateNPCWeapon($UserID, $HighestAttribute) { //get a weapon base matching the highest attribute $db = DB::GetConn(); $attribute_con = $db->quoteInto("damageattribute = ?", $HighestAttribute); $npc_con = $db->quoteInto("npcweapon = ?", 1); $getQuery = "SELECT * FROM `weaponbase` WHERE {$attribute_con} AND {$npc_con} limit 1;"; $res = $db->query($getQuery); $obj = $res->fetchObject(); $rw = Weapon::generateWeapon($UserID, $obj->ID); $rw->DamageOffset = (rand(1, 3) + rand(1, 3) + rand(1, 3) + rand(1, 3) + rand(1, 3) + rand(1, 3)) / 2 - 6; //6d3/2 - 6 return $rw; }